001 package de.deepamehta.core; 002 003 import de.deepamehta.core.model.CompositeValueModel; 004 import de.deepamehta.core.model.DeepaMehtaObjectModel; 005 import de.deepamehta.core.model.SimpleValue; 006 import de.deepamehta.core.model.TopicModel; 007 import de.deepamehta.core.service.ClientState; 008 import de.deepamehta.core.service.Directives; 009 import de.deepamehta.core.service.ResultList; 010 011 import java.util.List; 012 013 014 015 public interface DeepaMehtaObject extends Identifiable, JSONEnabled { 016 017 018 019 // === Model === 020 021 // --- ID --- 022 023 long getId(); 024 025 // --- URI --- 026 027 String getUri(); 028 029 void setUri(String uri); 030 031 // --- Type URI --- 032 033 String getTypeUri(); 034 035 void setTypeUri(String typeUri); 036 037 // --- Simple Value --- 038 039 SimpleValue getSimpleValue(); 040 041 void setSimpleValue(String value); 042 void setSimpleValue(int value); 043 void setSimpleValue(long value); 044 void setSimpleValue(boolean value); 045 void setSimpleValue(SimpleValue value); 046 047 // --- Composite Value --- 048 049 CompositeValue getCompositeValue(); 050 051 void setCompositeValue(CompositeValueModel comp, ClientState clientState, Directives directives); 052 053 // --- 054 055 void loadChildTopics(String childTypeUri); 056 057 // --- 058 059 DeepaMehtaObjectModel getModel(); 060 061 062 063 // === Updating === 064 065 void update(DeepaMehtaObjectModel model, ClientState clientState, Directives directives); 066 067 // --- 068 069 void updateChildTopic(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, 070 Directives directives); 071 void updateChildTopics(List<? extends TopicModel> newChildTopics, AssociationDefinition assocDef, 072 ClientState clientState, 073 Directives directives); 074 075 076 077 // === Traversal === 078 079 // --- Topic Retrieval --- 080 081 /** 082 * Fetches and returns a related topic or <code>null</code> if no such topic extists. 083 * 084 * @param assocTypeUri may be null 085 * @param myRoleTypeUri may be null 086 * @param othersRoleTypeUri may be null 087 * @param othersTopicTypeUri may be null 088 */ 089 RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 090 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite); 091 092 ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, int maxResultSize); 093 094 /** 095 * @param assocTypeUri may be null 096 * @param myRoleTypeUri may be null 097 * @param othersRoleTypeUri may be null 098 * @param othersTopicTypeUri may be null 099 * @param fetchComposite 100 * @param fetchRelatingComposite 101 * @param maxResultSize Result size limit. Pass 0 for no limit. 102 */ 103 ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 104 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite, 105 int maxResultSize); 106 107 /** 108 * @param assocTypeUris may *not* be null 109 * @param myRoleTypeUri may be null 110 * @param othersRoleTypeUri may be null 111 * @param othersTopicTypeUri may be null 112 */ 113 ResultList<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri, 114 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite, 115 int maxResultSize); 116 117 // --- Association Retrieval --- 118 119 Association getAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 120 long othersTopicId); 121 122 List<Association> getAssociations(); 123 124 125 126 // === Deletion === 127 128 /** 129 * Deletes the DeepaMehta object in its entirety, that is 130 * - the object itself (the <i>parent</i>) 131 * - all child topics associated via "dm4.core.composition", recusively 132 * - all the remaining direct associations, e.g. "dm4.core.instantiation" 133 */ 134 void delete(Directives directives); 135 136 137 138 // === Properties === 139 140 Object getProperty(String propUri); 141 142 void setProperty(String propUri, Object propValue, boolean addToIndex); 143 144 boolean hasProperty(String propUri); 145 146 void removeProperty(String propUri); 147 }