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    /**
058     * Returns the type of this object.
059     * <p>
060     * No access control is performed as <i>Implicit READ permission</i> applies: if a user has READ access to an object
061     * she has READ access to its type as well.
062     * <p>
063     * Note: if the user would have no READ access to this object the DeepaMehta Core would not instantiate it in the
064     * first place, but throw an <code>AccessControlException</code>.
065     */
066    DeepaMehtaType getType();
067
068    DeepaMehtaObjectModel getModel();
069
070
071
072    // === Updating ===
073
074    void updateChildTopic(RelatedTopicModel newChildTopic, AssociationDefinition assocDef);
075    void updateChildTopics(List<? extends RelatedTopicModel> newChildTopics, AssociationDefinition assocDef);
076
077
078
079    // === Deletion ===
080
081    /**
082     * Deletes the DeepaMehta object in its entirety, that is
083     * - the object itself (the <i>parent</i>)
084     * - all child topics associated via "dm4.core.composition", recusively
085     * - all the remaining direct associations, e.g. "dm4.core.instantiation"
086     */
087    void delete();
088
089
090
091    // === Traversal ===
092
093    // --- Topic Retrieval ---
094
095    /**
096     * Fetches and returns a related topic or <code>null</code> if no such topic extists.
097     *
098     * @param   assocTypeUri        may be null
099     * @param   myRoleTypeUri       may be null
100     * @param   othersRoleTypeUri   may be null
101     * @param   othersTopicTypeUri  may be null
102     */
103    RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
104                                 String othersTopicTypeUri);
105
106    List<RelatedTopic> getRelatedTopics(String assocTypeUri);
107
108    /**
109     * @param   assocTypeUri        may be null
110     * @param   myRoleTypeUri       may be null
111     * @param   othersRoleTypeUri   may be null
112     * @param   othersTopicTypeUri  may be null
113     */
114    List<RelatedTopic> getRelatedTopics(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
115                                        String othersTopicTypeUri);
116
117    /**
118     * @param   assocTypeUris       may *not* be null
119     * @param   myRoleTypeUri       may be null
120     * @param   othersRoleTypeUri   may be null
121     * @param   othersTopicTypeUri  may be null
122     */
123    List<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri,
124                                        String othersTopicTypeUri);
125
126    // --- Association Retrieval ---
127
128    /**
129     * @param   assocTypeUri        may be null
130     * @param   myRoleTypeUri       may be null
131     * @param   othersRoleTypeUri   may be null
132     * @param   othersAssocTypeUri  may be null
133     */
134    RelatedAssociation getRelatedAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri,
135                                             String othersAssocTypeUri);
136
137    /**
138     * @param   assocTypeUri        may be null
139     * @param   myRoleTypeUri       may be null
140     * @param   othersRoleTypeUri   may be null
141     * @param   othersAssocTypeUri  may be null
142     */
143    List<RelatedAssociation> getRelatedAssociations(String assocTypeUri, String myRoleTypeUri,
144                                                    String othersRoleTypeUri, String othersAssocTypeUri);
145
146    // ---
147
148    Association getAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, long othersTopicId);
149
150    List<Association> getAssociations();
151
152
153
154    // === Properties ===
155
156    /**
157     * Returns this object's property value associated with the given property URI.
158     * If there's no property value associated with the property URI an exception is thrown.
159     */
160    Object getProperty(String propUri);
161
162    /**
163     * Checks whether for this object a property value is associated with a given property URI.
164     */
165    boolean hasProperty(String propUri);
166
167    void setProperty(String propUri, Object propValue, boolean addToIndex);
168
169    /**
170     * Removes this object's property associated with the given property URI.
171     * If there's no property value associated with the property URI nothing is performed.
172     */
173    void removeProperty(String propUri);
174
175
176
177    // === Misc ===
178
179    Object getDatabaseVendorObject();
180}