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 update(DeepaMehtaObjectModel model); 075 076 // --- 077 078 void updateChildTopic(RelatedTopicModel newChildTopic, AssociationDefinition assocDef); 079 void updateChildTopics(List<? extends RelatedTopicModel> newChildTopics, AssociationDefinition assocDef); 080 081 082 083 // === Deletion === 084 085 /** 086 * Deletes the DeepaMehta object in its entirety, that is 087 * - the object itself (the <i>parent</i>) 088 * - all child topics associated via "dm4.core.composition", recusively 089 * - all the remaining direct associations, e.g. "dm4.core.instantiation" 090 */ 091 void delete(); 092 093 094 095 // === Traversal === 096 097 // --- Topic Retrieval --- 098 099 /** 100 * Fetches and returns a related topic or <code>null</code> if no such topic extists. 101 * 102 * @param assocTypeUri may be null 103 * @param myRoleTypeUri may be null 104 * @param othersRoleTypeUri may be null 105 * @param othersTopicTypeUri may be null 106 */ 107 RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 108 String othersTopicTypeUri); 109 110 List<RelatedTopic> getRelatedTopics(String assocTypeUri); 111 112 /** 113 * @param assocTypeUri may 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(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 119 String othersTopicTypeUri); 120 121 /** 122 * @param assocTypeUris may *not* be null 123 * @param myRoleTypeUri may be null 124 * @param othersRoleTypeUri may be null 125 * @param othersTopicTypeUri may be null 126 */ 127 List<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri, 128 String othersTopicTypeUri); 129 130 // --- Association Retrieval --- 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 RelatedAssociation getRelatedAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 139 String othersAssocTypeUri); 140 141 /** 142 * @param assocTypeUri may be null 143 * @param myRoleTypeUri may be null 144 * @param othersRoleTypeUri may be null 145 * @param othersAssocTypeUri may be null 146 */ 147 List<RelatedAssociation> getRelatedAssociations(String assocTypeUri, String myRoleTypeUri, 148 String othersRoleTypeUri, String othersAssocTypeUri); 149 150 // --- 151 152 Association getAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, long othersTopicId); 153 154 List<Association> getAssociations(); 155 156 157 158 // === Properties === 159 160 /** 161 * Returns this object's property value associated with the given property URI. 162 * If there's no property value associated with the property URI an exception is thrown. 163 */ 164 Object getProperty(String propUri); 165 166 /** 167 * Checks whether for this object a property value is associated with a given property URI. 168 */ 169 boolean hasProperty(String propUri); 170 171 void setProperty(String propUri, Object propValue, boolean addToIndex); 172 173 /** 174 * Removes this object's property associated with the given property URI. 175 * If there's no property value associated with the property URI nothing is performed. 176 */ 177 void removeProperty(String propUri); 178 179 180 181 // === Misc === 182 183 Object getDatabaseVendorObject(); 184}