001package de.deepamehta.core;
002
003import de.deepamehta.core.model.ChildTopicsModel;
004import de.deepamehta.core.model.DeepaMehtaObjectModel;
005import de.deepamehta.core.model.RelatedTopicModel;
006import de.deepamehta.core.model.SimpleValue;
007
008import java.util.List;
009
010
011
012public interface DeepaMehtaObject extends Identifiable, JSONEnabled {
013
014
015
016    // === Model ===
017
018    // --- ID ---
019
020    long getId();
021
022    // --- URI ---
023
024    String getUri();
025
026    void setUri(String uri);
027
028    // --- Type URI ---
029
030    String getTypeUri();
031
032    void setTypeUri(String typeUri);
033
034    // --- Simple Value ---
035
036    SimpleValue getSimpleValue();
037
038    void setSimpleValue(String value);
039    void setSimpleValue(int value);
040    void setSimpleValue(long value);
041    void setSimpleValue(boolean value);
042    void setSimpleValue(SimpleValue value);
043
044    // --- Child Topics ---
045
046    ChildTopics getChildTopics();
047
048    void setChildTopics(ChildTopicsModel childTopics);
049
050    // ---
051
052    DeepaMehtaObject loadChildTopics();
053    DeepaMehtaObject loadChildTopics(String assocDefUri);
054
055    // ---
056
057    DeepaMehtaType getType();
058
059    DeepaMehtaObjectModel getModel();
060
061
062
063    // === Updating ===
064
065    void update(DeepaMehtaObjectModel model);
066
067    // ---
068
069    void updateChildTopic(RelatedTopicModel newChildTopic, AssociationDefinition assocDef);
070    void updateChildTopics(List<? extends RelatedTopicModel> newChildTopics, AssociationDefinition assocDef);
071
072
073
074    // === Deletion ===
075
076    /**
077     * Deletes the DeepaMehta object in its entirety, that is
078     * - the object itself (the <i>parent</i>)
079     * - all child topics associated via "dm4.core.composition", recusively
080     * - all the remaining direct associations, e.g. "dm4.core.instantiation"
081     */
082    void delete();
083
084
085
086    // === Traversal ===
087
088    // --- Topic Retrieval ---
089
090    /**
091     * Fetches and returns a related topic or <code>null</code> if no such topic extists.
092     *
093     * @param   assocTypeUri        may be null
094     * @param   myRoleTypeUri       may be null
095     * @param   othersRoleTypeUri   may be null
096     * @param   othersTopicTypeUri  may be null
097     */
098    RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
099                                 String othersTopicTypeUri);
100
101    List<RelatedTopic> getRelatedTopics(String assocTypeUri);
102
103    /**
104     * @param   assocTypeUri        may be null
105     * @param   myRoleTypeUri       may be null
106     * @param   othersRoleTypeUri   may be null
107     * @param   othersTopicTypeUri  may be null
108     */
109    List<RelatedTopic> getRelatedTopics(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
110                                        String othersTopicTypeUri);
111
112    /**
113     * @param   assocTypeUris       may *not* be null
114     * @param   myRoleTypeUri       may be null
115     * @param   othersRoleTypeUri   may be null
116     * @param   othersTopicTypeUri  may be null
117     */
118    List<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri,
119                                        String othersTopicTypeUri);
120
121    // --- Association Retrieval ---
122
123    /**
124     * @param   assocTypeUri        may be null
125     * @param   myRoleTypeUri       may be null
126     * @param   othersRoleTypeUri   may be null
127     * @param   othersAssocTypeUri  may be null
128     */
129    RelatedAssociation getRelatedAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
130                                             String othersAssocTypeUri);
131
132    /**
133     * @param   assocTypeUri        may be null
134     * @param   myRoleTypeUri       may be null
135     * @param   othersRoleTypeUri   may be null
136     * @param   othersAssocTypeUri  may be null
137     */
138    List<RelatedAssociation> getRelatedAssociations(String assocTypeUri, String myRoleTypeUri,
139                                                    String othersRoleTypeUri, String othersAssocTypeUri);
140
141    // ---
142
143    Association getAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, long othersTopicId);
144
145    List<Association> getAssociations();
146
147
148
149    // === Properties ===
150
151    /**
152     * Returns this object's property value associated with the given property URI.
153     * If there's no property value associated with the property URI an exception is thrown.
154     */
155    Object getProperty(String propUri);
156
157    /**
158     * Checks whether for this object a property value is associated with a given property URI.
159     */
160    boolean hasProperty(String propUri);
161
162    void setProperty(String propUri, Object propValue, boolean addToIndex);
163
164    /**
165     * Removes this object's property associated with the given property URI.
166     * If there's no property value associated with the property URI nothing is performed.
167     */
168    void removeProperty(String propUri);
169
170
171
172    // === Misc ===
173
174    Object getDatabaseVendorObject();
175}