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(); 056 void loadChildTopics(String childTypeUri); 057 058 // --- 059 060 DeepaMehtaObjectModel getModel(); 061 062 063 064 // === Updating === 065 066 void update(DeepaMehtaObjectModel model, ClientState clientState, Directives directives); 067 068 // --- 069 070 void updateChildTopic(TopicModel newChildTopic, AssociationDefinition assocDef, ClientState clientState, 071 Directives directives); 072 void updateChildTopics(List<? extends TopicModel> newChildTopics, AssociationDefinition assocDef, 073 ClientState clientState, 074 Directives directives); 075 076 077 078 // === Deletion === 079 080 /** 081 * Deletes the DeepaMehta object in its entirety, that is 082 * - the object itself (the <i>parent</i>) 083 * - all child topics associated via "dm4.core.composition", recusively 084 * - all the remaining direct associations, e.g. "dm4.core.instantiation" 085 */ 086 void delete(Directives directives); 087 088 089 090 // === Traversal === 091 092 // --- Topic Retrieval --- 093 094 /** 095 * Fetches and returns a related topic or <code>null</code> if no such topic extists. 096 * 097 * @param assocTypeUri may be null 098 * @param myRoleTypeUri may be null 099 * @param othersRoleTypeUri may be null 100 * @param othersTopicTypeUri may be null 101 */ 102 RelatedTopic getRelatedTopic(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 103 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite); 104 105 ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, int maxResultSize); 106 107 /** 108 * @param assocTypeUri may be null 109 * @param myRoleTypeUri may be null 110 * @param othersRoleTypeUri may be null 111 * @param othersTopicTypeUri may be null 112 * @param fetchComposite 113 * @param fetchRelatingComposite 114 * @param maxResultSize Result size limit. Pass 0 for no limit. 115 */ 116 ResultList<RelatedTopic> getRelatedTopics(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 117 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite, 118 int maxResultSize); 119 120 /** 121 * @param assocTypeUris may *not* be null 122 * @param myRoleTypeUri may be null 123 * @param othersRoleTypeUri may be null 124 * @param othersTopicTypeUri may be null 125 */ 126 ResultList<RelatedTopic> getRelatedTopics(List assocTypeUris, String myRoleTypeUri, String othersRoleTypeUri, 127 String othersTopicTypeUri, boolean fetchComposite, boolean fetchRelatingComposite, 128 int maxResultSize); 129 130 // --- Association Retrieval --- 131 132 Association getAssociation(String assocTypeUri, String myRoleTypeUri, String othersRoleTypeUri, 133 long othersTopicId); 134 135 List<Association> getAssociations(); 136 137 138 139 // === Properties === 140 141 Object getProperty(String propUri); 142 143 void setProperty(String propUri, Object propValue, boolean addToIndex); 144 145 boolean hasProperty(String propUri); 146 147 void removeProperty(String propUri); 148 }