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;
007import de.deepamehta.core.service.ResultList;
008
009import java.util.List;
010
011
012
013public interface DeepaMehtaObject extends Identifiable, JSONEnabled {
014
015
016
017    // === Model ===
018
019    // --- ID ---
020
021    long getId();
022
023    // --- URI ---
024
025    String getUri();
026
027    void setUri(String uri);
028
029    // --- Type URI ---
030
031    String getTypeUri();
032
033    void setTypeUri(String typeUri);
034
035    // --- Simple Value ---
036
037    SimpleValue getSimpleValue();
038
039    void setSimpleValue(String value);
040    void setSimpleValue(int value);
041    void setSimpleValue(long value);
042    void setSimpleValue(boolean value);
043    void setSimpleValue(SimpleValue value);
044
045    // --- Child Topics ---
046
047    ChildTopics getChildTopics();
048
049    void setChildTopics(ChildTopicsModel childTopics);
050
051    // ---
052
053    DeepaMehtaObject loadChildTopics();
054    DeepaMehtaObject loadChildTopics(String childTypeUri);
055
056    // ---
057
058    DeepaMehtaObjectModel getModel();
059
060
061
062    // === Updating ===
063
064    void update(DeepaMehtaObjectModel model);
065
066    // ---
067
068    void updateChildTopic(RelatedTopicModel newChildTopic, AssociationDefinition assocDef);
069    void updateChildTopics(List<RelatedTopicModel> newChildTopics, AssociationDefinition assocDef);
070
071
072
073    // === Deletion ===
074
075    /**
076     * Deletes the DeepaMehta object in its entirety, that is
077     * - the object itself (the <i>parent</i>)
078     * - all child topics associated via "dm4.core.composition", recusively
079     * - all the remaining direct associations, e.g. "dm4.core.instantiation"
080     */
081    void delete();
082
083
084
085    // === Traversal ===
086
087    // --- Topic Retrieval ---
088
089    /**
090     * Fetches and returns a related topic or <code>null</code> if no such topic extists.
091     *
092     * @param   assocTypeUri        may be null
093     * @param   myRoleTypeUri       may be null
094     * @param   othersRoleTypeUri   may be null
095     * @param   othersTopicTypeUri  may be null
096     */
097    RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
098                                 String othersTopicTypeUri);
099
100    ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, int maxResultSize);
101
102    /**
103     * @param   assocTypeUri        may be null
104     * @param   myRoleTypeUri       may be null
105     * @param   othersRoleTypeUri   may be null
106     * @param   othersTopicTypeUri  may be null
107     * @param   maxResultSize       Result size limit. Pass 0 for no limit.
108     */
109    ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
110                                              String othersTopicTypeUri, int maxResultSize);
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    ResultList<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri,
119                                              String othersTopicTypeUri, int maxResultSize);
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    ResultList<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}