001package systems.dmx.core.service;
002
003import systems.dmx.core.model.AssociationModel;
004import systems.dmx.core.model.AssociationDefinitionModel;
005import systems.dmx.core.model.AssociationRoleModel;
006import systems.dmx.core.model.AssociationTypeModel;
007import systems.dmx.core.model.ChildTopicsModel;
008import systems.dmx.core.model.DMXObjectModel;
009import systems.dmx.core.model.IndexMode;
010import systems.dmx.core.model.RelatedAssociationModel;
011import systems.dmx.core.model.RelatedTopicModel;
012import systems.dmx.core.model.RoleModel;
013import systems.dmx.core.model.SimpleValue;
014import systems.dmx.core.model.TopicModel;
015import systems.dmx.core.model.TopicDeletionModel;
016import systems.dmx.core.model.TopicReferenceModel;
017import systems.dmx.core.model.TopicRoleModel;
018import systems.dmx.core.model.TopicTypeModel;
019import systems.dmx.core.model.TypeModel;
020import systems.dmx.core.model.ViewConfigurationModel;
021import systems.dmx.core.model.facets.FacetValueModel;
022import systems.dmx.core.model.topicmaps.AssociationViewModel;
023import systems.dmx.core.model.topicmaps.TopicViewModel;
024import systems.dmx.core.model.topicmaps.ViewProperties;
025
026import org.codehaus.jettison.json.JSONArray;
027import org.codehaus.jettison.json.JSONException;
028import org.codehaus.jettison.json.JSONObject;
029
030import java.util.List;
031
032
033
034public interface ModelFactory {
035
036
037
038    // === TopicModel ===
039
040    TopicModel newTopicModel(long id, String uri, String typeUri, SimpleValue value, ChildTopicsModel childTopics);
041
042    // ### TODO: make internal?
043    TopicModel newTopicModel(ChildTopicsModel childTopics);
044
045    TopicModel newTopicModel(String typeUri);
046
047    TopicModel newTopicModel(String typeUri, SimpleValue value);
048
049    TopicModel newTopicModel(String typeUri, ChildTopicsModel childTopics);
050
051    TopicModel newTopicModel(String uri, String typeUri);
052
053    TopicModel newTopicModel(String uri, String typeUri, SimpleValue value);
054
055    TopicModel newTopicModel(String uri, String typeUri, ChildTopicsModel childTopics);
056
057    // ### TODO: make internal?
058    TopicModel newTopicModel(long id);
059
060    // ### TODO: make internal?
061    TopicModel newTopicModel(long id, ChildTopicsModel childTopics);
062
063    TopicModel newTopicModel(TopicModel topic);
064
065    TopicModel newTopicModel(JSONObject topic);
066
067
068
069    // === AssociationModel ===
070
071    AssociationModel newAssociationModel(long id, String uri, String typeUri, RoleModel roleModel1,
072                                         RoleModel roleModel2, SimpleValue value, ChildTopicsModel childTopics);
073
074    AssociationModel newAssociationModel(String typeUri, RoleModel roleModel1, RoleModel roleModel2);
075
076    AssociationModel newAssociationModel(String typeUri, RoleModel roleModel1, RoleModel roleModel2,
077                                                                               ChildTopicsModel childTopics);
078
079    // ### TODO: Refactoring needed. See comments in impl.
080    AssociationModel newAssociationModel();
081
082    // ### TODO: Refactoring needed. See comments in impl.
083    AssociationModel newAssociationModel(ChildTopicsModel childTopics);
084
085    // ### TODO: Refactoring needed. See comments in impl.
086    AssociationModel newAssociationModel(String typeUri, ChildTopicsModel childTopics);
087
088    AssociationModel newAssociationModel(long id, String uri, String typeUri, RoleModel roleModel1,
089                                                                              RoleModel roleModel2);
090
091    AssociationModel newAssociationModel(AssociationModel assoc);
092
093    AssociationModel newAssociationModel(JSONObject assoc);
094
095
096
097    // === ChildTopicsModel ===
098
099    ChildTopicsModel newChildTopicsModel();
100
101    ChildTopicsModel newChildTopicsModel(JSONObject values);
102
103    /**
104     * Utility.
105     */
106    String childTypeUri(String assocDefUri);
107
108
109
110    // === TopicRoleModel ===
111    
112    TopicRoleModel newTopicRoleModel(long topicId, String roleTypeUri);
113
114    TopicRoleModel newTopicRoleModel(String topicUri, String roleTypeUri);
115
116    TopicRoleModel newTopicRoleModel(JSONObject topicRoleModel);
117
118
119
120    // === AssociationRoleModel ===
121
122    AssociationRoleModel newAssociationRoleModel(long assocId, String roleTypeUri);
123
124    AssociationRoleModel newAssociationRoleModel(JSONObject assocRoleModel);
125
126
127
128    // === RelatedTopicModel ===
129
130    RelatedTopicModel newRelatedTopicModel(long topicId);
131
132    RelatedTopicModel newRelatedTopicModel(long topicId, AssociationModel relatingAssoc);
133
134    RelatedTopicModel newRelatedTopicModel(String topicUri);
135
136    RelatedTopicModel newRelatedTopicModel(String topicUri, AssociationModel relatingAssoc);
137
138    RelatedTopicModel newRelatedTopicModel(String topicTypeUri, SimpleValue value);
139
140    RelatedTopicModel newRelatedTopicModel(String topicTypeUri, ChildTopicsModel childTopics);
141
142    RelatedTopicModel newRelatedTopicModel(TopicModel topic);
143
144    RelatedTopicModel newRelatedTopicModel(TopicModel topic, AssociationModel relatingAssoc);
145
146
147
148    // === RelatedAssociationModel ===
149
150    RelatedAssociationModel newRelatedAssociationModel(AssociationModel assoc, AssociationModel relatingAssoc);
151
152
153
154    // === TopicReferenceModel ===
155
156    // TODO: make internal?
157
158    TopicReferenceModel newTopicReferenceModel(long topicId);
159
160    TopicReferenceModel newTopicReferenceModel(long topicId, AssociationModel relatingAssoc);
161
162    TopicReferenceModel newTopicReferenceModel(String topicUri);
163
164    TopicReferenceModel newTopicReferenceModel(String topicUri, AssociationModel relatingAssoc);
165
166    TopicReferenceModel newTopicReferenceModel(long topicId, ChildTopicsModel relatingAssocChildTopics);
167
168    TopicReferenceModel newTopicReferenceModel(String topicUri, ChildTopicsModel relatingAssocChildTopics);
169
170    TopicReferenceModel newTopicReferenceModel(Object topicIdOrUri);
171
172
173
174    // === TopicDeletionModel ===
175
176    // TODO: make internal?
177
178    TopicDeletionModel newTopicDeletionModel(long topicId);
179
180    TopicDeletionModel newTopicDeletionModel(String topicUri);
181
182
183
184    // === TopicTypeModel ===
185
186    TopicTypeModel newTopicTypeModel(TopicModel typeTopic, String dataTypeUri,
187                                     List<IndexMode> indexModes, List<AssociationDefinitionModel> assocDefs,
188                                     ViewConfigurationModel viewConfig);
189
190    TopicTypeModel newTopicTypeModel(String uri, String value, String dataTypeUri);
191
192    TopicTypeModel newTopicTypeModel(JSONObject topicType);
193
194
195
196    // === AssociationTypeModel ===
197
198    AssociationTypeModel newAssociationTypeModel(TopicModel typeTopic, String dataTypeUri,
199                                                 List<IndexMode> indexModes, List<AssociationDefinitionModel> assocDefs,
200                                                 ViewConfigurationModel viewConfig);
201
202    AssociationTypeModel newAssociationTypeModel(String uri, String value, String dataTypeUri);
203
204    AssociationTypeModel newAssociationTypeModel(JSONObject assocType);
205
206
207
208    // === AssociationDefinitionModel ===
209
210    AssociationDefinitionModel newAssociationDefinitionModel(String assocTypeUri,
211                                                             String parentTypeUri, String childTypeUri,
212                                                             String parentCardinalityUri, String childCardinalityUri);
213
214    AssociationDefinitionModel newAssociationDefinitionModel(String assocTypeUri,
215                                                             String parentTypeUri, String childTypeUri,
216                                                             String parentCardinalityUri, String childCardinalityUri,
217                                                             ViewConfigurationModel viewConfig);
218
219    AssociationDefinitionModel newAssociationDefinitionModel(String assocTypeUri,
220                                                             String customAssocTypeUri,
221                                                             boolean isIdentityAttr, boolean includeInLabel,
222                                                             String parentTypeUri, String childTypeUri,
223                                                             String parentCardinalityUri, String childCardinalityUri);
224
225    AssociationDefinitionModel newAssociationDefinitionModel(AssociationModel assoc,
226                                                             String parentCardinalityUri, String childCardinalityUri,
227                                                             ViewConfigurationModel viewConfig);
228
229    AssociationDefinitionModel newAssociationDefinitionModel(JSONObject assocDef);
230
231
232
233    // === ViewConfigurationModel ===
234
235    ViewConfigurationModel newViewConfigurationModel();
236
237    ViewConfigurationModel newViewConfigurationModel(Iterable<? extends TopicModel> configTopics);
238
239    ViewConfigurationModel newViewConfigurationModel(JSONArray configTopics);
240
241
242
243    // === Topicmaps ===
244
245    TopicViewModel newTopicViewModel(TopicModel topic, ViewProperties viewProps);
246
247    AssociationViewModel newAssociationViewModel(AssociationModel assoc, ViewProperties viewProps);
248
249
250
251    // === Facets ===
252
253    FacetValueModel newFacetValueModel(String childTypeUri);    // TODO: rename param to "assocDefUri"?
254
255    FacetValueModel newFacetValueModel(JSONObject facetValue);
256}