| 10 |
shop2020 |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.metamodel.definitions;
|
|
|
5 |
|
| 1050 |
rajveer |
6 |
import in.shop2020.metamodel.jaxb.comparison.CMPBucketDefinitionType;
|
|
|
7 |
import in.shop2020.metamodel.jaxb.comparison.CMPDefinitionType;
|
|
|
8 |
import in.shop2020.metamodel.jaxb.comparison.CMPRuleDefinitionType;
|
|
|
9 |
import in.shop2020.metamodel.jaxb.comparison.CMPSlideRuleDefinitionType;
|
|
|
10 |
import in.shop2020.metamodel.jaxb.core.BulletDefinitionType;
|
|
|
11 |
import in.shop2020.metamodel.jaxb.core.CategorySlideDefinitionType;
|
|
|
12 |
import in.shop2020.metamodel.jaxb.core.CategorySlideSequenceType;
|
|
|
13 |
import in.shop2020.metamodel.jaxb.core.CategoryType;
|
|
|
14 |
import in.shop2020.metamodel.jaxb.core.CompositeDefinitionType;
|
|
|
15 |
import in.shop2020.metamodel.jaxb.core.CompositePartDefinitionType;
|
|
|
16 |
import in.shop2020.metamodel.jaxb.core.DatatypeDefinitionType;
|
|
|
17 |
import in.shop2020.metamodel.jaxb.core.DefinitionType;
|
|
|
18 |
import in.shop2020.metamodel.jaxb.core.EditorialImportanceType;
|
|
|
19 |
import in.shop2020.metamodel.jaxb.core.EnumDefinitionType;
|
|
|
20 |
import in.shop2020.metamodel.jaxb.core.EnumValueType;
|
|
|
21 |
import in.shop2020.metamodel.jaxb.core.FeatureDefinitionType;
|
| 2170 |
rajveer |
22 |
import in.shop2020.metamodel.jaxb.core.HelpDocDefinitionType;
|
| 1050 |
rajveer |
23 |
import in.shop2020.metamodel.jaxb.core.SlideDefinitionType;
|
|
|
24 |
import in.shop2020.metamodel.jaxb.core.SlideFeatureDefinitionType;
|
|
|
25 |
import in.shop2020.metamodel.jaxb.core.UnitType;
|
|
|
26 |
import in.shop2020.metamodel.jaxb.facets.CategoryFacetDefinitionType;
|
|
|
27 |
import in.shop2020.metamodel.jaxb.facets.FacetDefinitionType;
|
| 1314 |
rajveer |
28 |
import in.shop2020.metamodel.jaxb.facets.FacetSlideDefinitionType;
|
| 1050 |
rajveer |
29 |
import in.shop2020.metamodel.jaxb.facets.IRDefinitionType;
|
|
|
30 |
import in.shop2020.metamodel.jaxb.facets.RuleDefinitionType;
|
| 70 |
naveen |
31 |
import in.shop2020.metamodel.util.ExpandedCMPSlideRuleDefinition;
|
| 45 |
naveen |
32 |
import in.shop2020.metamodel.util.ExpandedCategory;
|
| 62 |
naveen |
33 |
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
|
| 199 |
naveen |
34 |
import in.shop2020.metamodel.util.ExpandedSlideDefinition;
|
| 70 |
naveen |
35 |
import in.shop2020.util.Utils;
|
| 17 |
naveen |
36 |
|
| 457 |
rajveer |
37 |
import java.io.File;
|
| 1050 |
rajveer |
38 |
import java.io.FileInputStream;
|
| 10 |
shop2020 |
39 |
import java.io.Serializable;
|
| 18 |
naveen |
40 |
import java.util.ArrayList;
|
| 1050 |
rajveer |
41 |
import java.util.HashMap;
|
| 18 |
naveen |
42 |
import java.util.Iterator;
|
|
|
43 |
import java.util.List;
|
| 10 |
shop2020 |
44 |
import java.util.Map;
|
| 1050 |
rajveer |
45 |
import java.util.TreeMap;
|
| 10 |
shop2020 |
46 |
|
| 1050 |
rajveer |
47 |
import javax.xml.bind.JAXBContext;
|
|
|
48 |
import javax.xml.bind.JAXBElement;
|
|
|
49 |
import javax.xml.bind.Unmarshaller;
|
|
|
50 |
|
| 10 |
shop2020 |
51 |
/**
|
| 49 |
naveen |
52 |
* Single point of access to all definition objects
|
|
|
53 |
*
|
| 10 |
shop2020 |
54 |
* @author naveen
|
|
|
55 |
*
|
|
|
56 |
*/
|
|
|
57 |
public class DefinitionsContainer implements Serializable {
|
|
|
58 |
|
| 41 |
naveen |
59 |
/**
|
| 10 |
shop2020 |
60 |
*
|
|
|
61 |
*/
|
|
|
62 |
private static final long serialVersionUID = 1L;
|
| 49 |
naveen |
63 |
|
|
|
64 |
/**
|
|
|
65 |
* Hashtable of Category ID to Category object
|
|
|
66 |
*/
|
| 10 |
shop2020 |
67 |
private Map<Long, Category> categories;
|
| 49 |
naveen |
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Hashtable of Slide ID to SlideDefinition object
|
|
|
71 |
*/
|
| 10 |
shop2020 |
72 |
private Map<Long, SlideDefinition> slideDefinitions;
|
| 49 |
naveen |
73 |
|
|
|
74 |
/**
|
|
|
75 |
* Hashtable of Feature Definition ID to FeatureDefinition object
|
|
|
76 |
*/
|
| 10 |
shop2020 |
77 |
private Map<Long, FeatureDefinition> featureDefinitions;
|
| 49 |
naveen |
78 |
|
|
|
79 |
/**
|
|
|
80 |
* Hashtable of Datatype Definition ID to DatatypeDefinition object
|
|
|
81 |
*/
|
| 10 |
shop2020 |
82 |
private Map<Long, DatatypeDefinition> datatypeDefinitions;
|
| 49 |
naveen |
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Hashtable of Enum value ID to EnumValue object
|
|
|
86 |
*/
|
| 24 |
naveen |
87 |
private Map<Long, EnumValue> enumValues;
|
| 49 |
naveen |
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Hashtable of Unit ID to Unit object
|
|
|
91 |
*/
|
| 10 |
shop2020 |
92 |
private Map<Long, Unit> units;
|
|
|
93 |
|
|
|
94 |
/**
|
| 62 |
naveen |
95 |
* Hashtable of Facet Definition ID to FacetDefinition object
|
|
|
96 |
*/
|
|
|
97 |
private Map<Long, FacetDefinition> facetDefinitions;
|
|
|
98 |
|
| 1314 |
rajveer |
99 |
|
| 62 |
naveen |
100 |
/**
|
| 1314 |
rajveer |
101 |
* Hashtable of Slide Definition ID to FacetDefinition object
|
|
|
102 |
*/
|
|
|
103 |
private Map<Long, List<FacetDefinition>> slideFacetDefinitions;
|
|
|
104 |
|
|
|
105 |
/**
|
| 62 |
naveen |
106 |
* Hashtable of Category Facet Definition ID to CategoryFacetDefinition
|
|
|
107 |
* object
|
|
|
108 |
*/
|
|
|
109 |
private Map<Long, CategoryFacetDefinition> categoryFacetDefinitions;
|
|
|
110 |
|
|
|
111 |
/**
|
|
|
112 |
* Hashtable of IR Data Rule ID to RuleDefinition object
|
|
|
113 |
*/
|
|
|
114 |
private Map<Long, RuleDefinition> irDataRuleDefinitions;
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
* Hashtable of IR Meta Data Rule ID to RuleDefinition object
|
|
|
118 |
*/
|
|
|
119 |
private Map<Long, RuleDefinition> irMetaDataRuleDefinitions;
|
|
|
120 |
|
|
|
121 |
|
|
|
122 |
/**
|
| 70 |
naveen |
123 |
* Hashtable of Comparison Rule ID to CMPRuleDefinition object
|
|
|
124 |
*/
|
|
|
125 |
private Map<Long, CMPRuleDefinition> cmpRuleDefinitions;
|
|
|
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Hashtable of SlideDefinition ID to CMPSlideRuleDefinition object
|
|
|
129 |
*/
|
|
|
130 |
private Map<Long, CMPSlideRuleDefinition> cmpSlideRuleDefinitions;
|
|
|
131 |
|
|
|
132 |
/**
|
| 72 |
naveen |
133 |
* Hashtable of Category ID to list of CMPBucketDefinition object
|
|
|
134 |
*/
|
|
|
135 |
private Map<Long, List<CMPBucketDefinition>> cmpBucketDefinitions;
|
| 102 |
naveen |
136 |
|
|
|
137 |
/**
|
|
|
138 |
* Hashtable of feature definition ID to normalization rule definition ID
|
|
|
139 |
*/
|
|
|
140 |
private Map<Long, RuleDefinition> normalizationRuleDefinitions;
|
| 2170 |
rajveer |
141 |
|
|
|
142 |
/**
|
|
|
143 |
* Hashtable of help doc definition ID to help doc definition object
|
|
|
144 |
*/
|
|
|
145 |
private Map<Long, HelpDocDefinition> helpDocDefinitions;
|
| 199 |
naveen |
146 |
|
|
|
147 |
/**
|
|
|
148 |
* Hashtable of feature definition ID to normalization rule definition ID
|
|
|
149 |
*/
|
|
|
150 |
private Map<Long, List<Long>> categorySlideSequence;
|
| 72 |
naveen |
151 |
|
|
|
152 |
/**
|
| 473 |
rajveer |
153 |
* Database path. Just in case we want to override
|
|
|
154 |
*/
|
| 1050 |
rajveer |
155 |
private String xmlDefinitionsPath = Utils.CONTENT_DB_PATH + "definitions" + File.separator;
|
| 473 |
rajveer |
156 |
|
|
|
157 |
/**
|
| 49 |
naveen |
158 |
* Empty constructor. Data structures are initialised as needed
|
| 1050 |
rajveer |
159 |
* @throws Exception
|
| 10 |
shop2020 |
160 |
*/
|
| 1050 |
rajveer |
161 |
public DefinitionsContainer(){
|
|
|
162 |
try {
|
|
|
163 |
initialize();
|
|
|
164 |
} catch (Exception e) {
|
|
|
165 |
// TODO Auto-generated catch block
|
|
|
166 |
e.printStackTrace();
|
|
|
167 |
}
|
| 10 |
shop2020 |
168 |
}
|
|
|
169 |
|
|
|
170 |
/**
|
| 473 |
rajveer |
171 |
* Empty constructor. Just dbPath is initialised
|
| 1050 |
rajveer |
172 |
* @throws Exception
|
| 473 |
rajveer |
173 |
*/
|
| 1050 |
rajveer |
174 |
public DefinitionsContainer(String xmlDefinitionsPath) throws Exception {
|
|
|
175 |
this.xmlDefinitionsPath = xmlDefinitionsPath;
|
|
|
176 |
initialize();
|
| 473 |
rajveer |
177 |
}
|
| 1050 |
rajveer |
178 |
|
| 473 |
rajveer |
179 |
|
| 1050 |
rajveer |
180 |
private void initialize() throws Exception{
|
|
|
181 |
initializeCoreDefinitionObjects();
|
|
|
182 |
initializeFacetsDefinitionObjects();
|
|
|
183 |
initializeComparisonDefinitionObjects();
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
private void initializeCoreDefinitionObjects() throws Exception{
|
|
|
187 |
DefinitionType defType = null;
|
|
|
188 |
String srcFile;
|
|
|
189 |
Object oDefType = null;
|
|
|
190 |
|
|
|
191 |
// categoriy slide sequence
|
|
|
192 |
srcFile = xmlDefinitionsPath+ "categories.xml";
|
|
|
193 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
194 |
defType = (DefinitionType)oDefType;
|
|
|
195 |
//FIXME
|
|
|
196 |
categories = new HashMap<Long, Category>();
|
|
|
197 |
Category root = this.convertCategories(defType, categories, srcFile);
|
|
|
198 |
|
|
|
199 |
// category slide sequence
|
|
|
200 |
srcFile = xmlDefinitionsPath+ "categoryslidesequence.xml";
|
|
|
201 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
202 |
defType = (DefinitionType)oDefType;
|
|
|
203 |
this.categorySlideSequence = this.convertCategorySlideSequence(defType);
|
|
|
204 |
|
|
|
205 |
// units
|
|
|
206 |
srcFile = xmlDefinitionsPath+ "units.xml";
|
|
|
207 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
208 |
defType = (DefinitionType)oDefType;
|
|
|
209 |
this.units = this.convertUnits(defType);
|
|
|
210 |
|
|
|
211 |
//data type definitions
|
|
|
212 |
srcFile = xmlDefinitionsPath+ "datatypedefinitions.xml";
|
|
|
213 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
214 |
defType = (DefinitionType)oDefType;
|
|
|
215 |
this.datatypeDefinitions = this.convertDatatypeDefinition(defType);
|
|
|
216 |
|
|
|
217 |
//enum values
|
|
|
218 |
populateEnumValues();
|
|
|
219 |
|
|
|
220 |
//feature definitions
|
|
|
221 |
srcFile = xmlDefinitionsPath+ "featuredefinitions.xml";
|
|
|
222 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
223 |
defType = (DefinitionType)oDefType;
|
|
|
224 |
this.featureDefinitions = this.convertFeatureDefinitions(defType);
|
|
|
225 |
|
|
|
226 |
//slide definitions
|
|
|
227 |
srcFile = xmlDefinitionsPath+ "slidedefinitions.xml";
|
|
|
228 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
229 |
defType = (DefinitionType)oDefType;
|
|
|
230 |
this.slideDefinitions = this.convertSlideDefinitions(defType);
|
| 2170 |
rajveer |
231 |
|
|
|
232 |
//help doc definition
|
|
|
233 |
srcFile = xmlDefinitionsPath+ "helpdocdefinitions.xml";
|
|
|
234 |
oDefType = this.unmarshallSrcFile(srcFile, "core");
|
|
|
235 |
defType = (DefinitionType)oDefType;
|
|
|
236 |
this.helpDocDefinitions = this.convertHelpDocDefinitions(defType);
|
| 1050 |
rajveer |
237 |
|
|
|
238 |
}
|
|
|
239 |
|
|
|
240 |
private void initializeFacetsDefinitionObjects() throws Exception{
|
|
|
241 |
IRDefinitionType irDefType = null;
|
|
|
242 |
String srcFile;
|
|
|
243 |
Object oDefType = null;
|
|
|
244 |
|
|
|
245 |
//all facet definitions
|
|
|
246 |
srcFile = xmlDefinitionsPath+ "facetdefinitions.xml";
|
|
|
247 |
oDefType = this.unmarshallSrcFile(srcFile, "facets");
|
|
|
248 |
irDefType = (IRDefinitionType)oDefType;
|
|
|
249 |
this.facetDefinitions = this.convertFacetDefinitions(irDefType);
|
|
|
250 |
|
| 1314 |
rajveer |
251 |
//
|
|
|
252 |
this.populateSlideFacetDefinitions();
|
|
|
253 |
|
| 1050 |
rajveer |
254 |
//category facet definitions
|
|
|
255 |
srcFile = xmlDefinitionsPath+ "categoryfacetdefinitions.xml";
|
|
|
256 |
oDefType = this.unmarshallSrcFile(srcFile, "facets");
|
|
|
257 |
irDefType = (IRDefinitionType)oDefType;
|
|
|
258 |
this.categoryFacetDefinitions = this.convertCategoryFacetDefinitions(irDefType);
|
|
|
259 |
|
| 1314 |
rajveer |
260 |
|
| 1050 |
rajveer |
261 |
//ir data rules
|
|
|
262 |
srcFile = xmlDefinitionsPath+ "irdatarules.xml";
|
|
|
263 |
oDefType = this.unmarshallSrcFile(srcFile, "facets");
|
|
|
264 |
irDefType = (IRDefinitionType)oDefType;
|
|
|
265 |
irDataRuleDefinitions = this.convertRuleDefinitions(irDefType);
|
|
|
266 |
|
|
|
267 |
//ir meta data rules
|
|
|
268 |
srcFile = xmlDefinitionsPath+ "irmetadatarules.xml";
|
|
|
269 |
oDefType = this.unmarshallSrcFile(srcFile, "facets");
|
|
|
270 |
irDefType = (IRDefinitionType)oDefType;
|
| 1071 |
chandransh |
271 |
irMetaDataRuleDefinitions = this.convertRuleDefinitions(irDefType);
|
| 1050 |
rajveer |
272 |
|
|
|
273 |
//normalization rules
|
|
|
274 |
srcFile = xmlDefinitionsPath+ "normalizationrules.xml";
|
|
|
275 |
oDefType = this.unmarshallSrcFile(srcFile, "facets");
|
|
|
276 |
irDefType = (IRDefinitionType)oDefType;
|
|
|
277 |
normalizationRuleDefinitions = this.convertNormalizationRuleDefinitions(irDefType);
|
|
|
278 |
}
|
|
|
279 |
|
|
|
280 |
private void initializeComparisonDefinitionObjects() throws Exception{
|
|
|
281 |
CMPDefinitionType cmpDefType = null;
|
|
|
282 |
String srcFile;
|
|
|
283 |
Object oDefType = null;
|
|
|
284 |
|
|
|
285 |
//all facet definitions
|
|
|
286 |
srcFile = xmlDefinitionsPath+ "comparisonrules.xml";
|
|
|
287 |
oDefType = this.unmarshallSrcFile(srcFile, "comparison");
|
|
|
288 |
cmpDefType = (CMPDefinitionType)oDefType;
|
|
|
289 |
this.cmpRuleDefinitions = this.convertComparisonRuleDefinitions(cmpDefType);
|
|
|
290 |
|
|
|
291 |
|
|
|
292 |
//all f
|
|
|
293 |
srcFile = xmlDefinitionsPath+ "comparisondefinitions.xml";
|
|
|
294 |
oDefType = this.unmarshallSrcFile(srcFile, "comparison");
|
|
|
295 |
cmpDefType = (CMPDefinitionType)oDefType;
|
|
|
296 |
this.cmpSlideRuleDefinitions = this.convertComparisonDefinitions(cmpDefType);
|
|
|
297 |
|
|
|
298 |
//all facet definitions
|
|
|
299 |
srcFile = xmlDefinitionsPath+ "comparisonbuckets.xml";
|
|
|
300 |
oDefType = this.unmarshallSrcFile(srcFile, "comparison");
|
|
|
301 |
cmpDefType = (CMPDefinitionType)oDefType;
|
|
|
302 |
this.cmpBucketDefinitions = this.convertComparisonBuckets(cmpDefType);
|
|
|
303 |
|
|
|
304 |
}
|
|
|
305 |
|
|
|
306 |
|
| 473 |
rajveer |
307 |
/**
|
| 1050 |
rajveer |
308 |
*
|
|
|
309 |
* @param irDefType
|
|
|
310 |
* @return
|
|
|
311 |
*/
|
|
|
312 |
private Map<Long, RuleDefinition> convertNormalizationRuleDefinitions(
|
|
|
313 |
IRDefinitionType defType) {
|
|
|
314 |
|
|
|
315 |
Map<Long, RuleDefinition> idRuleDef =
|
|
|
316 |
new TreeMap<Long, RuleDefinition>();
|
|
|
317 |
|
|
|
318 |
List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
|
|
|
319 |
|
|
|
320 |
for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
|
|
|
321 |
long id = jaxbRuleDef.getID();
|
|
|
322 |
String script = jaxbRuleDef.getScript();
|
|
|
323 |
|
|
|
324 |
RuleDefinition ruleDef = new RuleDefinition(id, script);
|
|
|
325 |
ruleDef.setDescription(jaxbRuleDef.getDescription());
|
|
|
326 |
|
|
|
327 |
idRuleDef.put(new Long(id), ruleDef);
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
Utils.info("idRuleDef=" + idRuleDef);
|
|
|
331 |
|
|
|
332 |
return idRuleDef;
|
|
|
333 |
}
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
/**
|
|
|
338 |
*
|
|
|
339 |
* @param defType
|
|
|
340 |
* @return Map<Long, CMPRuleDefinition>
|
|
|
341 |
*/
|
|
|
342 |
private Map<Long, CMPRuleDefinition> convertComparisonRuleDefinitions(
|
|
|
343 |
CMPDefinitionType defType) {
|
|
|
344 |
Map<Long, CMPRuleDefinition> idRuleDef =
|
|
|
345 |
new TreeMap<Long, CMPRuleDefinition>();
|
|
|
346 |
|
|
|
347 |
List<CMPRuleDefinitionType> jaxbRuleDefs =
|
|
|
348 |
defType.getCMPRuleDefinition();
|
|
|
349 |
|
|
|
350 |
for(CMPRuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
|
|
|
351 |
long id = jaxbRuleDef.getID();
|
|
|
352 |
String script = jaxbRuleDef.getScript();
|
|
|
353 |
|
|
|
354 |
CMPRuleDefinition ruleDef = new CMPRuleDefinition(id, script);
|
|
|
355 |
ruleDef.setDescription(jaxbRuleDef.getDescription());
|
|
|
356 |
|
|
|
357 |
idRuleDef.put(new Long(id), ruleDef);
|
|
|
358 |
}
|
|
|
359 |
|
|
|
360 |
Utils.info("idRuleDef=" + idRuleDef);
|
|
|
361 |
return idRuleDef;
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
/**
|
|
|
365 |
*
|
|
|
366 |
* @param defType
|
|
|
367 |
* @return Map<Long, CMPSlideRuleDefinition>
|
|
|
368 |
*/
|
|
|
369 |
private Map<Long, CMPSlideRuleDefinition> convertComparisonDefinitions(
|
|
|
370 |
CMPDefinitionType defType) {
|
|
|
371 |
|
|
|
372 |
Map<Long, CMPSlideRuleDefinition> slideRuleDefs =
|
|
|
373 |
new TreeMap<Long, CMPSlideRuleDefinition>();
|
|
|
374 |
|
|
|
375 |
List<CMPSlideRuleDefinitionType> jaxbDefs =
|
|
|
376 |
defType.getCMPSlideRuleDefinition();
|
|
|
377 |
|
|
|
378 |
for(CMPSlideRuleDefinitionType jaxbDef : jaxbDefs) {
|
|
|
379 |
long ruleDefID = jaxbDef.getRuleDefinitionID();
|
|
|
380 |
long slideDefID = jaxbDef.getSlideDefinitionID();
|
|
|
381 |
|
|
|
382 |
CMPSlideRuleDefinition slideRuleDef =
|
|
|
383 |
new CMPSlideRuleDefinition(slideDefID, ruleDefID);
|
|
|
384 |
|
|
|
385 |
slideRuleDef.setDescription(jaxbDef.getDescription());
|
|
|
386 |
|
|
|
387 |
slideRuleDefs.put(new Long(slideDefID), slideRuleDef);
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
Utils.info("slideRuleDefs=" + slideRuleDefs);
|
|
|
391 |
return slideRuleDefs;
|
|
|
392 |
}
|
|
|
393 |
|
|
|
394 |
/**
|
|
|
395 |
*
|
|
|
396 |
* @param defType
|
|
|
397 |
* @return
|
|
|
398 |
*/
|
|
|
399 |
private Map<Long, List<CMPBucketDefinition>> convertComparisonBuckets(
|
|
|
400 |
CMPDefinitionType defType) {
|
|
|
401 |
|
|
|
402 |
Map<Long, List<CMPBucketDefinition>> cmpBuckets =
|
|
|
403 |
new HashMap<Long, List<CMPBucketDefinition>>();
|
|
|
404 |
|
|
|
405 |
List<CMPBucketDefinitionType> jaxbBuckets =
|
|
|
406 |
defType.getCMPBucketDefinition();
|
|
|
407 |
|
|
|
408 |
for(CMPBucketDefinitionType jaxbBucket : jaxbBuckets) {
|
|
|
409 |
String name = jaxbBucket.getName();
|
|
|
410 |
long categoryID = jaxbBucket.getCategoryID();
|
|
|
411 |
|
|
|
412 |
CMPBucketDefinition bucketDef =
|
|
|
413 |
new CMPBucketDefinition(name, categoryID);
|
|
|
414 |
|
|
|
415 |
bucketDef.setDescription(jaxbBucket.getDescription());
|
|
|
416 |
bucketDef.setDefaultWeight(
|
|
|
417 |
jaxbBucket.getDefaultWeight().intValue());
|
|
|
418 |
bucketDef.setSlideDefinitionIDs(jaxbBucket.getSlideDefinitionID());
|
|
|
419 |
|
|
|
420 |
List<CMPBucketDefinition> categoryBuckets =
|
|
|
421 |
cmpBuckets.get(new Long(categoryID));
|
|
|
422 |
|
|
|
423 |
if(categoryBuckets == null) {
|
|
|
424 |
categoryBuckets = new ArrayList<CMPBucketDefinition>();
|
|
|
425 |
cmpBuckets.put(new Long(categoryID), categoryBuckets);
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
categoryBuckets.add(bucketDef);
|
|
|
429 |
}
|
|
|
430 |
Utils.info("cmpBuckets=" + cmpBuckets);
|
|
|
431 |
|
|
|
432 |
return cmpBuckets;
|
|
|
433 |
}
|
|
|
434 |
|
|
|
435 |
|
|
|
436 |
/**
|
|
|
437 |
*
|
|
|
438 |
* @param defType
|
|
|
439 |
* @return
|
|
|
440 |
*/
|
|
|
441 |
private Map<Long, RuleDefinition> convertRuleDefinitions(
|
|
|
442 |
IRDefinitionType defType) {
|
|
|
443 |
Map<Long, RuleDefinition> idRuleDef =
|
|
|
444 |
new TreeMap<Long, RuleDefinition>();
|
|
|
445 |
|
|
|
446 |
List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
|
|
|
447 |
|
|
|
448 |
for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
|
|
|
449 |
long id = jaxbRuleDef.getID();
|
|
|
450 |
String script = jaxbRuleDef.getScript();
|
|
|
451 |
|
|
|
452 |
RuleDefinition ruleDef = new RuleDefinition(id, script);
|
|
|
453 |
ruleDef.setDescription(jaxbRuleDef.getDescription());
|
|
|
454 |
|
|
|
455 |
idRuleDef.put(new Long(id), ruleDef);
|
|
|
456 |
}
|
|
|
457 |
|
|
|
458 |
Utils.info("idRuleDef=" + idRuleDef);
|
|
|
459 |
return idRuleDef;
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
/**
|
|
|
464 |
*
|
|
|
465 |
* @param defType
|
|
|
466 |
* @return
|
|
|
467 |
*/
|
|
|
468 |
private Map<Long, FacetDefinition> convertFacetDefinitions(
|
|
|
469 |
IRDefinitionType defType) {
|
|
|
470 |
List<FacetDefinitionType> jaxbFacetDefs = defType.getFacetDefinition();
|
|
|
471 |
|
|
|
472 |
Map<Long, FacetDefinition> idFacetDefs =
|
|
|
473 |
new TreeMap<Long, FacetDefinition>();
|
|
|
474 |
|
|
|
475 |
for(FacetDefinitionType jaxbFacetDef : jaxbFacetDefs) {
|
|
|
476 |
long id = jaxbFacetDef.getID();
|
|
|
477 |
String target = jaxbFacetDef.getTarget();
|
|
|
478 |
|
|
|
479 |
FacetDefinition facetDef = new FacetDefinition(id, target);
|
|
|
480 |
|
| 1314 |
rajveer |
481 |
List<FacetSlideDefinition> facetSlideDefinitions = convertFacetSlideDefinitions(jaxbFacetDef);
|
| 1050 |
rajveer |
482 |
|
| 1314 |
rajveer |
483 |
facetDef.setFacetSlideDefinitions(facetSlideDefinitions);
|
| 1050 |
rajveer |
484 |
|
|
|
485 |
facetDef.setDescription(jaxbFacetDef.getDescription());
|
|
|
486 |
|
|
|
487 |
idFacetDefs.put(new Long(id), facetDef);
|
| 1314 |
rajveer |
488 |
|
| 1050 |
rajveer |
489 |
}
|
|
|
490 |
Utils.info("idFacetDefs=" + idFacetDefs);
|
|
|
491 |
return idFacetDefs;
|
|
|
492 |
}
|
|
|
493 |
|
| 1314 |
rajveer |
494 |
private void populateSlideFacetDefinitions() {
|
|
|
495 |
this.slideFacetDefinitions = new HashMap<Long, List<FacetDefinition>>();
|
|
|
496 |
for(FacetDefinition facetDef: facetDefinitions.values())
|
|
|
497 |
for(FacetSlideDefinition facetSlideDef: facetDef.getFacetSlideDefinitions()){
|
|
|
498 |
List<FacetDefinition> facetDefs = this.slideFacetDefinitions.get(facetSlideDef.getSlideDefinitionID());
|
|
|
499 |
if(facetDefs==null){
|
|
|
500 |
facetDefs = new ArrayList<FacetDefinition>();
|
|
|
501 |
}
|
|
|
502 |
facetDefs.add(facetDef);
|
|
|
503 |
this.slideFacetDefinitions.put(facetSlideDef.getSlideDefinitionID(), facetDefs);
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
|
|
|
507 |
private List<FacetSlideDefinition> convertFacetSlideDefinitions(
|
|
|
508 |
FacetDefinitionType jaxbFacetDef) {
|
|
|
509 |
|
|
|
510 |
List<FacetSlideDefinition> facetSlideDefinitions = new ArrayList<FacetSlideDefinition>();
|
|
|
511 |
|
|
|
512 |
for(FacetSlideDefinitionType jaxbFacetSlideDef : jaxbFacetDef.getFacetSlideDefinition()){
|
|
|
513 |
long irDataRuleID = jaxbFacetSlideDef.getIRDataRuleID();
|
|
|
514 |
long irMetaDataRuleID = jaxbFacetSlideDef.getIRMetaDataRuleID();
|
|
|
515 |
long slideDefinitionID = jaxbFacetSlideDef.getSlideDefinitionID();
|
|
|
516 |
FacetSlideDefinition facetSlideDefinition = new FacetSlideDefinition(slideDefinitionID, irMetaDataRuleID, irDataRuleID);
|
|
|
517 |
facetSlideDefinitions.add(facetSlideDefinition);
|
|
|
518 |
}
|
|
|
519 |
return facetSlideDefinitions;
|
|
|
520 |
}
|
|
|
521 |
|
| 1050 |
rajveer |
522 |
/**
|
|
|
523 |
*
|
|
|
524 |
* @param defType
|
|
|
525 |
* @return
|
|
|
526 |
* @throws Exception
|
|
|
527 |
*/
|
|
|
528 |
private Map<Long, CategoryFacetDefinition> convertCategoryFacetDefinitions(
|
|
|
529 |
IRDefinitionType defType) throws Exception {
|
| 1314 |
rajveer |
530 |
List<CategoryFacetDefinitionType> jaxbCategoryFacetDefs = defType.getCategoryFacetDefinition();
|
| 1050 |
rajveer |
531 |
|
|
|
532 |
Map<Long, CategoryFacetDefinition> idCategoryFacetDefs =
|
|
|
533 |
new TreeMap<Long, CategoryFacetDefinition>();
|
|
|
534 |
|
|
|
535 |
for(CategoryFacetDefinitionType jaxbCategoryFacetDef :
|
|
|
536 |
jaxbCategoryFacetDefs) {
|
| 1314 |
rajveer |
537 |
|
| 1050 |
rajveer |
538 |
long categoryID = jaxbCategoryFacetDef.getCategoryID();
|
|
|
539 |
|
|
|
540 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
541 |
new CategoryFacetDefinition(categoryID);
|
|
|
542 |
|
|
|
543 |
|
| 1314 |
rajveer |
544 |
List<Long> facetIDs = jaxbCategoryFacetDef.getFacetDefinitionID();
|
|
|
545 |
|
|
|
546 |
|
|
|
547 |
for(Long facetID : facetIDs) {
|
|
|
548 |
categoryFacetDef.addFacetDefinition(facetDefinitions.get(facetID));
|
| 1050 |
rajveer |
549 |
}
|
|
|
550 |
|
|
|
551 |
idCategoryFacetDefs.put(new Long(categoryID), categoryFacetDef);
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
// Append parent's facets
|
|
|
555 |
// Go only one level for now
|
|
|
556 |
// Categories need to be imported first
|
|
|
557 |
|
|
|
558 |
for(Long categoryID : idCategoryFacetDefs.keySet()) {
|
|
|
559 |
Category category = this.getCategory(categoryID.longValue());
|
|
|
560 |
Category parentCategory = category.getParentCategory();
|
|
|
561 |
|
|
|
562 |
if(parentCategory != null) {
|
|
|
563 |
long parentCategoryID = parentCategory.getID();
|
|
|
564 |
|
|
|
565 |
CategoryFacetDefinition parentCategoryFacetDef =
|
|
|
566 |
idCategoryFacetDefs.get(new Long(parentCategoryID));
|
|
|
567 |
|
|
|
568 |
if(parentCategoryFacetDef != null) {
|
| 1314 |
rajveer |
569 |
List<FacetDefinition> parentsFacetDefs =
|
|
|
570 |
parentCategoryFacetDef.getFacetDefinitions();
|
| 1050 |
rajveer |
571 |
|
| 1314 |
rajveer |
572 |
if(parentsFacetDefs != null) {
|
| 1050 |
rajveer |
573 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
574 |
idCategoryFacetDefs.get(categoryID);
|
|
|
575 |
|
| 1314 |
rajveer |
576 |
categoryFacetDef.appendFacetDefinitions(
|
|
|
577 |
parentsFacetDefs);
|
| 1050 |
rajveer |
578 |
}
|
|
|
579 |
}
|
|
|
580 |
}
|
|
|
581 |
}
|
|
|
582 |
|
|
|
583 |
Utils.info("idCategoryFacetDefs=" + idCategoryFacetDefs);
|
|
|
584 |
return idCategoryFacetDefs;
|
|
|
585 |
}
|
|
|
586 |
|
| 1314 |
rajveer |
587 |
private FacetDefinition convertFacetDefinition(
|
|
|
588 |
FacetDefinitionType jaxbFacetDef) {
|
|
|
589 |
long facetID = jaxbFacetDef.getID();
|
|
|
590 |
String target = jaxbFacetDef.getTarget();
|
|
|
591 |
FacetDefinition facetDefinition = new FacetDefinition(facetID, target);
|
|
|
592 |
facetDefinition.setDescription(jaxbFacetDef.getDescription());
|
|
|
593 |
facetDefinition.setFacetSlideDefinitions(convertFacetSlideDefinitions(jaxbFacetDef));
|
|
|
594 |
return facetDefinition;
|
|
|
595 |
}
|
|
|
596 |
|
|
|
597 |
|
| 1050 |
rajveer |
598 |
/**
|
|
|
599 |
*
|
|
|
600 |
* @param jaxbFacetRuleDef
|
|
|
601 |
* @return
|
|
|
602 |
*/
|
| 1314 |
rajveer |
603 |
/*
|
| 1050 |
rajveer |
604 |
private FacetRuleDefinition convertFacetRuleDefinition(
|
|
|
605 |
FacetRuleDefinitionType jaxbFacetRuleDef) {
|
|
|
606 |
long facetDefID = jaxbFacetRuleDef.getFacetDefinitionID();
|
|
|
607 |
long irDataRuleID = jaxbFacetRuleDef.getIRDataRuleID();
|
|
|
608 |
|
|
|
609 |
FacetRuleDefinition facetRuleDef = new FacetRuleDefinition(facetDefID,
|
|
|
610 |
irDataRuleID);
|
|
|
611 |
|
|
|
612 |
facetRuleDef.setDescription(jaxbFacetRuleDef.getDescription());
|
|
|
613 |
|
|
|
614 |
if(jaxbFacetRuleDef.getFeatureDefinitionID() != null) {
|
|
|
615 |
facetRuleDef.setFeatureDefinitionID(
|
|
|
616 |
jaxbFacetRuleDef.getFeatureDefinitionID().longValue());
|
|
|
617 |
}
|
|
|
618 |
|
|
|
619 |
if(jaxbFacetRuleDef.getSlideDefinitionID() != null) {
|
|
|
620 |
facetRuleDef.setSlideDefinitionID(
|
|
|
621 |
jaxbFacetRuleDef.getSlideDefinitionID().longValue());
|
|
|
622 |
}
|
|
|
623 |
|
|
|
624 |
return facetRuleDef;
|
|
|
625 |
}
|
| 1314 |
rajveer |
626 |
*/
|
| 1050 |
rajveer |
627 |
|
|
|
628 |
private void populateEnumValues(){
|
|
|
629 |
// RE-VISIT - May not be optimal
|
|
|
630 |
Map<Long, EnumValue> enumValuesMap = new TreeMap<Long, EnumValue>();
|
|
|
631 |
for(Long datatypeDefID : datatypeDefinitions.keySet()) {
|
|
|
632 |
DatatypeDefinition datatypeDef =
|
|
|
633 |
datatypeDefinitions.get(datatypeDefID);
|
|
|
634 |
|
|
|
635 |
if(datatypeDef instanceof EnumDefinition) {
|
|
|
636 |
List<EnumValue> enumValues =
|
|
|
637 |
((EnumDefinition) datatypeDef).getEnumValues();
|
|
|
638 |
|
|
|
639 |
for(EnumValue enumValue : enumValues) {
|
|
|
640 |
enumValuesMap.put(new Long(enumValue.getID()),
|
|
|
641 |
enumValue);
|
|
|
642 |
}
|
|
|
643 |
}
|
|
|
644 |
}
|
|
|
645 |
this.enumValues = enumValuesMap;
|
|
|
646 |
}
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
/**
|
| 199 |
naveen |
650 |
* Returns Slide sequence for a category in the database
|
|
|
651 |
*
|
|
|
652 |
* @return Map Null if Category-Slide definitions are not imported into
|
|
|
653 |
* definitions db
|
|
|
654 |
* (serialized java objects)
|
|
|
655 |
*
|
|
|
656 |
* @throws Exception
|
|
|
657 |
*/
|
|
|
658 |
public Map<Long, List<Long>> getCategorySlideSequence() throws Exception {
|
| 1050 |
rajveer |
659 |
return this.categorySlideSequence;
|
|
|
660 |
}
|
|
|
661 |
|
|
|
662 |
|
|
|
663 |
/**
|
|
|
664 |
*
|
|
|
665 |
* @param defType
|
|
|
666 |
* @return
|
|
|
667 |
*/
|
|
|
668 |
private Map<Long, List<Long>> convertCategorySlideSequence(
|
|
|
669 |
DefinitionType defType) {
|
|
|
670 |
Map<Long, List<Long>> catSlideSeq = new HashMap<Long, List<Long>>();
|
|
|
671 |
|
|
|
672 |
List<CategorySlideSequenceType> jaxbCatSlideSeqs =
|
|
|
673 |
defType.getCategorySlideSequence();
|
|
|
674 |
|
|
|
675 |
for(CategorySlideSequenceType jaxbCatSlideSeq : jaxbCatSlideSeqs) {
|
|
|
676 |
long catID = jaxbCatSlideSeq.getCategoryID();
|
|
|
677 |
List<Long> slideDefIDs = jaxbCatSlideSeq.getSlideDefinitionID();
|
| 199 |
naveen |
678 |
|
| 1050 |
rajveer |
679 |
Long lCatID = new Long(catID);
|
|
|
680 |
catSlideSeq.put(lCatID, slideDefIDs);
|
| 199 |
naveen |
681 |
}
|
|
|
682 |
|
| 1050 |
rajveer |
683 |
return catSlideSeq;
|
| 199 |
naveen |
684 |
}
|
|
|
685 |
|
| 1050 |
rajveer |
686 |
|
| 199 |
naveen |
687 |
/**
|
|
|
688 |
* Given a category ID, returns all slide definition IDs in sequence
|
|
|
689 |
* provided by content editor
|
|
|
690 |
*
|
|
|
691 |
* @param categoryID
|
|
|
692 |
* @return List of Slide Definition IDs
|
|
|
693 |
* @throws Exception
|
|
|
694 |
*/
|
| 1050 |
rajveer |
695 |
public List<Long> getCategorySlideSequence(long categoryID) throws Exception {
|
| 199 |
naveen |
696 |
return this.categorySlideSequence.get(new Long(categoryID));
|
|
|
697 |
}
|
|
|
698 |
|
|
|
699 |
/**
|
| 49 |
naveen |
700 |
* Returns all Unit objects in the database
|
| 10 |
shop2020 |
701 |
*
|
| 49 |
naveen |
702 |
* @return Map Null if units are not imported into definitions db
|
|
|
703 |
* (serialized java objects)
|
|
|
704 |
*
|
| 18 |
naveen |
705 |
* @throws Exception
|
| 10 |
shop2020 |
706 |
*/
|
| 1050 |
rajveer |
707 |
public Map<Long, Unit> getUnits() throws Exception {
|
|
|
708 |
return this.units;
|
|
|
709 |
}
|
|
|
710 |
|
|
|
711 |
|
|
|
712 |
/**
|
|
|
713 |
*
|
|
|
714 |
* @param srcFile
|
|
|
715 |
* @return
|
|
|
716 |
* @throws Exception
|
|
|
717 |
*/
|
|
|
718 |
private Object unmarshallSrcFile(String srcFile, String type)
|
|
|
719 |
throws Exception {
|
|
|
720 |
|
|
|
721 |
JAXBContext jc = JAXBContext.newInstance("in.shop2020.metamodel.jaxb." +
|
|
|
722 |
type);
|
|
|
723 |
|
|
|
724 |
// create an Unmarshaller
|
|
|
725 |
Unmarshaller u = jc.createUnmarshaller();
|
|
|
726 |
|
|
|
727 |
JAXBElement<?> element = (JAXBElement<?>)u.unmarshal(
|
|
|
728 |
new FileInputStream(srcFile));
|
|
|
729 |
|
|
|
730 |
return element.getValue();
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
/**
|
|
|
734 |
*
|
|
|
735 |
* @return Map
|
|
|
736 |
*/
|
|
|
737 |
private Map<Long, Unit> convertUnits(DefinitionType defType) {
|
|
|
738 |
|
|
|
739 |
Map<Long, Unit> allUnits = new HashMap<Long, Unit>();
|
|
|
740 |
List<UnitType> jaxbUnits = defType.getUnit();
|
|
|
741 |
Iterator<UnitType> it = jaxbUnits.iterator();
|
|
|
742 |
|
|
|
743 |
while(it.hasNext()) {
|
|
|
744 |
UnitType jaxbUnit = it.next();
|
| 18 |
naveen |
745 |
|
| 1050 |
rajveer |
746 |
Unit unit = new Unit(jaxbUnit.getID());
|
|
|
747 |
unit.setDescription(jaxbUnit.getDescription());
|
|
|
748 |
unit.setFullForm(jaxbUnit.getFullform());
|
|
|
749 |
unit.setShortForm(jaxbUnit.getShortform());
|
|
|
750 |
Utils.info("unit=" + unit);
|
|
|
751 |
|
|
|
752 |
allUnits.put(new Long(jaxbUnit.getID()), unit);
|
| 17 |
naveen |
753 |
}
|
| 18 |
naveen |
754 |
|
| 1050 |
rajveer |
755 |
return allUnits;
|
| 10 |
shop2020 |
756 |
}
|
|
|
757 |
|
| 1050 |
rajveer |
758 |
|
| 10 |
shop2020 |
759 |
/**
|
| 49 |
naveen |
760 |
* Resolves Unit ID into Unit object
|
| 10 |
shop2020 |
761 |
*
|
| 49 |
naveen |
762 |
* @param unitID Unit ID
|
| 10 |
shop2020 |
763 |
* @return Unit
|
| 18 |
naveen |
764 |
* @throws Exception
|
| 10 |
shop2020 |
765 |
*/
|
| 18 |
naveen |
766 |
public Unit getUnit(long unitID) throws Exception {
|
| 10 |
shop2020 |
767 |
return this.units.get(new Long(unitID));
|
|
|
768 |
}
|
|
|
769 |
|
|
|
770 |
/**
|
| 49 |
naveen |
771 |
* Returns all DatatypeDefintion object in database
|
|
|
772 |
*
|
|
|
773 |
* @return the datatypeDefinitions List of DatatypeDefinition objects
|
| 18 |
naveen |
774 |
* @throws Exception
|
| 10 |
shop2020 |
775 |
*/
|
| 1050 |
rajveer |
776 |
public Map<Long, DatatypeDefinition> getDatatypeDefinitions(){
|
|
|
777 |
return this.datatypeDefinitions;
|
|
|
778 |
}
|
|
|
779 |
|
|
|
780 |
|
|
|
781 |
/**
|
|
|
782 |
*
|
|
|
783 |
* @param defType
|
|
|
784 |
* @return
|
|
|
785 |
*/
|
|
|
786 |
private Map<Long, DatatypeDefinition> convertDatatypeDefinition(DefinitionType defType) {
|
| 18 |
naveen |
787 |
|
| 1050 |
rajveer |
788 |
Map<Long, DatatypeDefinition> defs = new HashMap<Long, DatatypeDefinition>();
|
|
|
789 |
|
|
|
790 |
List<DatatypeDefinitionType> jaxbDefs = defType.getDatatypeDefinition();
|
|
|
791 |
Iterator<DatatypeDefinitionType> it = jaxbDefs.iterator();
|
|
|
792 |
|
|
|
793 |
while(it.hasNext()) {
|
|
|
794 |
DatatypeDefinitionType jaxbDef = it.next();
|
| 18 |
naveen |
795 |
|
| 1050 |
rajveer |
796 |
DatatypeDefinition def = null;
|
|
|
797 |
CompositeDefinitionType compositeDefType = jaxbDef.getCompositeDefinition();
|
|
|
798 |
|
|
|
799 |
EnumDefinitionType enumDefType = jaxbDef.getEnumDefinition();
|
|
|
800 |
|
|
|
801 |
// Composite data type
|
|
|
802 |
if(compositeDefType != null) {
|
|
|
803 |
CompositeDefinition compDef = new CompositeDefinition(jaxbDef.getID(), jaxbDef.getName(), compositeDefType.getSeparator());
|
|
|
804 |
|
|
|
805 |
List<CompositePartDefinitionType> jaxbPartDefs = compositeDefType.getCompositePartDefinition();
|
|
|
806 |
|
|
|
807 |
Iterator<CompositePartDefinitionType> itPartDefs = jaxbPartDefs.iterator();
|
|
|
808 |
|
|
|
809 |
// Collect parts
|
|
|
810 |
while(itPartDefs.hasNext()) {
|
|
|
811 |
CompositePartDefinitionType jaxbPartDef = itPartDefs.next();
|
|
|
812 |
CompositePartDefinition partDef = this.convertCompositePartDefinition(jaxbPartDef);
|
|
|
813 |
|
|
|
814 |
compDef.addCompositePartDefinition(partDef);
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
def = compDef;
|
|
|
818 |
}
|
|
|
819 |
|
|
|
820 |
// Enumerated values
|
|
|
821 |
else if(enumDefType != null) {
|
|
|
822 |
EnumDefinition enumDef = new EnumDefinition(jaxbDef.getID(),
|
|
|
823 |
jaxbDef.getName());
|
|
|
824 |
|
|
|
825 |
List<EnumValueType> jaxbEnumValues =
|
|
|
826 |
enumDefType.getEnumValue();
|
|
|
827 |
|
|
|
828 |
Iterator<EnumValueType> itEnumValues =
|
|
|
829 |
jaxbEnumValues.iterator();
|
|
|
830 |
|
|
|
831 |
// Collect individual value
|
|
|
832 |
while(itEnumValues.hasNext()) {
|
|
|
833 |
EnumValueType jaxbEnumValue = itEnumValues.next();
|
|
|
834 |
EnumValue enumValue =
|
|
|
835 |
this.convertEnumValueDefinition(jaxbEnumValue);
|
|
|
836 |
|
|
|
837 |
enumDef.addEnumValue(enumValue);
|
|
|
838 |
}
|
|
|
839 |
|
|
|
840 |
def = enumDef;
|
|
|
841 |
}
|
|
|
842 |
|
|
|
843 |
// Primitive
|
|
|
844 |
else {
|
|
|
845 |
def = new DatatypeDefinition(jaxbDef.getID(),
|
|
|
846 |
jaxbDef.getName());
|
|
|
847 |
}
|
|
|
848 |
|
|
|
849 |
def.setDescription(jaxbDef.getDescription());
|
|
|
850 |
Utils.info("def=" + def);
|
|
|
851 |
|
|
|
852 |
defs.put(new Long(jaxbDef.getID()), def);
|
| 18 |
naveen |
853 |
}
|
| 1050 |
rajveer |
854 |
|
|
|
855 |
return defs;
|
| 10 |
shop2020 |
856 |
}
|
| 18 |
naveen |
857 |
|
|
|
858 |
/**
|
| 1050 |
rajveer |
859 |
*
|
|
|
860 |
* @param jaxbPartDef
|
|
|
861 |
* @return CompositePartDefinition
|
|
|
862 |
*/
|
|
|
863 |
private CompositePartDefinition convertCompositePartDefinition(
|
|
|
864 |
CompositePartDefinitionType jaxbPartDef) {
|
|
|
865 |
|
|
|
866 |
CompositePartDefinition partDef = new CompositePartDefinition(
|
|
|
867 |
jaxbPartDef.getLabel(), jaxbPartDef.getDatatypeDefinitionID(),
|
|
|
868 |
jaxbPartDef.getUnitID());
|
|
|
869 |
|
|
|
870 |
partDef.setDescription(jaxbPartDef.getDescription());
|
|
|
871 |
|
|
|
872 |
return partDef;
|
|
|
873 |
}
|
|
|
874 |
|
|
|
875 |
/**
|
| 49 |
naveen |
876 |
* Resolves Datatype Definition ID into DatetypeDefinition object
|
| 18 |
naveen |
877 |
*
|
| 49 |
naveen |
878 |
* @param unitID Unit ID
|
| 18 |
naveen |
879 |
* @return Unit
|
|
|
880 |
* @throws Exception
|
|
|
881 |
*/
|
|
|
882 |
public DatatypeDefinition getDatatypeDefinition(long id) throws Exception {
|
|
|
883 |
|
|
|
884 |
// Initialize
|
|
|
885 |
if(this.datatypeDefinitions == null) {
|
|
|
886 |
this.getDatatypeDefinitions();
|
|
|
887 |
}
|
|
|
888 |
|
|
|
889 |
return this.datatypeDefinitions.get(new Long(id));
|
|
|
890 |
}
|
| 19 |
naveen |
891 |
|
|
|
892 |
/**
|
| 1050 |
rajveer |
893 |
*
|
|
|
894 |
* @param jaxbEnumValue
|
|
|
895 |
* @return EnumValue
|
|
|
896 |
*/
|
|
|
897 |
private EnumValue convertEnumValueDefinition(EnumValueType jaxbEnumValue) {
|
|
|
898 |
|
|
|
899 |
EnumValue enumValue = new EnumValue(jaxbEnumValue.getID(),
|
|
|
900 |
jaxbEnumValue.getValue());
|
| 2170 |
rajveer |
901 |
if(jaxbEnumValue.getHelpDocDefinitionID() != null){
|
|
|
902 |
enumValue.setHelpDocDefinitionID(jaxbEnumValue.getHelpDocDefinitionID());
|
|
|
903 |
}
|
| 1050 |
rajveer |
904 |
return enumValue;
|
|
|
905 |
}
|
|
|
906 |
/**
|
| 49 |
naveen |
907 |
* Returns EnumValue ID for datatype definition ID and enum value string
|
|
|
908 |
* to match. Match is case insensitive
|
| 19 |
naveen |
909 |
*
|
| 49 |
naveen |
910 |
* @param datatypeDefID DatatypeDefinition ID
|
|
|
911 |
* @param value query enum value string
|
| 19 |
naveen |
912 |
* @return long enumValueID - "-1" if not found
|
|
|
913 |
* @throws Exception
|
|
|
914 |
*/
|
|
|
915 |
public long getEnumValueID(long datatypeDefID, String value)
|
|
|
916 |
throws Exception {
|
|
|
917 |
long enumValueID = -1L;
|
|
|
918 |
|
|
|
919 |
// Let the callers catch ClassCastException
|
|
|
920 |
EnumDefinition enumDef =
|
|
|
921 |
(EnumDefinition)this.getDatatypeDefinition(datatypeDefID);
|
|
|
922 |
|
| 24 |
naveen |
923 |
List<EnumValue> enumValues = enumDef.getEnumValues();
|
| 19 |
naveen |
924 |
for(EnumValue enumValue : enumValues) {
|
|
|
925 |
if(value.equalsIgnoreCase(enumValue.getValue())) {
|
|
|
926 |
enumValueID = enumValue.getID();
|
|
|
927 |
break;
|
|
|
928 |
}
|
|
|
929 |
}
|
|
|
930 |
|
|
|
931 |
return enumValueID;
|
|
|
932 |
}
|
| 17 |
naveen |
933 |
|
| 10 |
shop2020 |
934 |
/**
|
| 49 |
naveen |
935 |
* Returns all category objects in the database
|
|
|
936 |
*
|
| 10 |
shop2020 |
937 |
* @return the categories
|
| 17 |
naveen |
938 |
* @throws Exception
|
| 10 |
shop2020 |
939 |
*/
|
| 1050 |
rajveer |
940 |
public Map<Long, Category> getCategories() {
|
|
|
941 |
return this.categories;
|
|
|
942 |
}
|
|
|
943 |
|
|
|
944 |
|
|
|
945 |
/**
|
|
|
946 |
*
|
|
|
947 |
* @param defType
|
|
|
948 |
* @param catMap
|
|
|
949 |
* @return
|
|
|
950 |
*/
|
|
|
951 |
private Category convertCategories(DefinitionType defType,
|
|
|
952 |
Map<Long, Category> catMap, String srcFile) {
|
|
|
953 |
|
|
|
954 |
List<CategoryType> jaxbCats = defType.getCategory();
|
|
|
955 |
Iterator<CategoryType> it = jaxbCats.iterator();
|
|
|
956 |
|
|
|
957 |
// Get root category
|
|
|
958 |
CategoryType jaxbCat = it.next();
|
|
|
959 |
if(jaxbCat == null) {
|
|
|
960 |
Utils.info("Invalid file: " + srcFile);
|
|
|
961 |
return null;
|
|
|
962 |
}
|
|
|
963 |
|
|
|
964 |
Category root = this.convertCategoryType(jaxbCat, null, catMap);
|
|
|
965 |
return root;
|
|
|
966 |
}
|
|
|
967 |
|
|
|
968 |
|
|
|
969 |
/**
|
|
|
970 |
*
|
|
|
971 |
* @param jaxbCat
|
|
|
972 |
* @param parentCat
|
|
|
973 |
* @param catMap
|
|
|
974 |
* @return
|
|
|
975 |
*/
|
| 17 |
naveen |
976 |
@SuppressWarnings("unchecked")
|
| 1050 |
rajveer |
977 |
private Category convertCategoryType(CategoryType jaxbCat,
|
|
|
978 |
Category parentCat, Map<Long, Category> catMap) {
|
| 17 |
naveen |
979 |
|
| 1050 |
rajveer |
980 |
Category cat = new Category(jaxbCat.getID());
|
|
|
981 |
cat.setLabel(jaxbCat.getName());
|
|
|
982 |
cat.setDescription(jaxbCat.getDescription());
|
|
|
983 |
if(parentCat != null) {
|
|
|
984 |
cat.setParentCategory(parentCat);
|
| 17 |
naveen |
985 |
|
| 1050 |
rajveer |
986 |
// Copy parent's category-slide definitions
|
|
|
987 |
ArrayList<CategorySlideDefinition> parentCSDef =
|
|
|
988 |
(ArrayList<CategorySlideDefinition>)
|
|
|
989 |
parentCat.getCategorySlideDefintions();
|
|
|
990 |
|
|
|
991 |
if(parentCSDef != null) {
|
|
|
992 |
cat.setCategorySlideDefintions(
|
|
|
993 |
(List<CategorySlideDefinition>) parentCSDef.clone());
|
|
|
994 |
}
|
| 17 |
naveen |
995 |
}
|
| 1050 |
rajveer |
996 |
|
|
|
997 |
// Category Slide Definition
|
|
|
998 |
List<CategorySlideDefinitionType> jaxbDefs =
|
|
|
999 |
jaxbCat.getCategorySlideDefinition();
|
|
|
1000 |
|
|
|
1001 |
Iterator<CategorySlideDefinitionType> it = jaxbDefs.iterator();
|
|
|
1002 |
while(it.hasNext()) {
|
|
|
1003 |
CategorySlideDefinitionType jaxbDef = it.next();
|
|
|
1004 |
CategorySlideDefinition catSlideDef
|
|
|
1005 |
= this.convertCategorySlideDefinitionType(jaxbCat.getID(), jaxbDef);
|
|
|
1006 |
|
|
|
1007 |
cat.addCategorySlideDefintion(catSlideDef);
|
|
|
1008 |
}
|
|
|
1009 |
|
|
|
1010 |
// Children
|
|
|
1011 |
List<CategoryType> jaxbChildren = jaxbCat.getChildCategory();
|
|
|
1012 |
//Utils.info("jaxbChildren.size: " + jaxbChildren.size());
|
|
|
1013 |
|
|
|
1014 |
Iterator<CategoryType> itChildren = jaxbChildren.iterator();
|
|
|
1015 |
while(itChildren.hasNext()) {
|
|
|
1016 |
CategoryType jaxbChildCat = itChildren.next();
|
|
|
1017 |
Category childCat = this.convertCategoryType(jaxbChildCat, cat,
|
|
|
1018 |
catMap);
|
|
|
1019 |
cat.addChild(childCat);
|
|
|
1020 |
}
|
|
|
1021 |
|
|
|
1022 |
//FIXME put debug messages
|
|
|
1023 |
//Utils.info("Parent cat: " + cat);
|
|
|
1024 |
// DEBUG ONLY
|
|
|
1025 |
Utils.info("####### Cat ID: " + cat.getID());
|
|
|
1026 |
if(cat.getCategorySlideDefintions() != null) {
|
|
|
1027 |
for(CategorySlideDefinition csd : cat.getCategorySlideDefintions()){
|
|
|
1028 |
Utils.info("####### SlideDefintionID=" + csd.getSlideDefintionID());
|
|
|
1029 |
}
|
|
|
1030 |
}
|
|
|
1031 |
|
|
|
1032 |
catMap.put(new Long(jaxbCat.getID()), cat);
|
|
|
1033 |
return cat;
|
| 10 |
shop2020 |
1034 |
}
|
| 17 |
naveen |
1035 |
|
| 10 |
shop2020 |
1036 |
/**
|
| 1050 |
rajveer |
1037 |
*
|
|
|
1038 |
* @param categoryID
|
|
|
1039 |
* @param jaxbDef
|
|
|
1040 |
* @return
|
|
|
1041 |
*/
|
|
|
1042 |
private CategorySlideDefinition convertCategorySlideDefinitionType(
|
|
|
1043 |
long categoryID, CategorySlideDefinitionType jaxbDef) {
|
|
|
1044 |
|
|
|
1045 |
CategorySlideDefinition catSlideDef = new CategorySlideDefinition(
|
|
|
1046 |
jaxbDef.getSlideDefinitionID());
|
|
|
1047 |
|
|
|
1048 |
catSlideDef.setDescription(jaxbDef.getDescription());
|
|
|
1049 |
|
|
|
1050 |
EditorialImportanceType jaxbEdImp = jaxbDef.getEditorialImportance();
|
|
|
1051 |
EditorialImportance edImp = this.convertEditorialImportance(jaxbEdImp);
|
|
|
1052 |
catSlideDef.setEditorialImportance(edImp);
|
|
|
1053 |
|
|
|
1054 |
return catSlideDef;
|
|
|
1055 |
}
|
|
|
1056 |
|
|
|
1057 |
/**
|
|
|
1058 |
*
|
|
|
1059 |
* @param jaxbEdImp
|
|
|
1060 |
* @return EditorialImportance
|
|
|
1061 |
*/
|
|
|
1062 |
private EditorialImportance convertEditorialImportance(
|
|
|
1063 |
EditorialImportanceType jaxbEdImp) {
|
|
|
1064 |
|
|
|
1065 |
String strEdImp = jaxbEdImp.value();
|
|
|
1066 |
EditorialImportance edImp = null;
|
|
|
1067 |
|
|
|
1068 |
if(strEdImp.equals("Mandatory"))
|
|
|
1069 |
edImp = EditorialImportance.MANDATORY;
|
|
|
1070 |
else if(strEdImp.equals("Optional"))
|
|
|
1071 |
edImp = EditorialImportance.OPTIONAL;
|
|
|
1072 |
else
|
|
|
1073 |
edImp = EditorialImportance.RECOMMENDED;
|
|
|
1074 |
|
|
|
1075 |
return edImp;
|
|
|
1076 |
}
|
|
|
1077 |
|
|
|
1078 |
|
|
|
1079 |
/**
|
| 49 |
naveen |
1080 |
* Resolves Category ID into Category object
|
| 17 |
naveen |
1081 |
*
|
| 49 |
naveen |
1082 |
* @param categoryID Category ID
|
| 17 |
naveen |
1083 |
* @return Category
|
|
|
1084 |
* @throws Exception
|
| 10 |
shop2020 |
1085 |
*/
|
| 1050 |
rajveer |
1086 |
public Category getCategory(long categoryID) {
|
| 17 |
naveen |
1087 |
return this.categories.get(new Long(categoryID));
|
| 10 |
shop2020 |
1088 |
}
|
| 17 |
naveen |
1089 |
|
| 10 |
shop2020 |
1090 |
/**
|
| 49 |
naveen |
1091 |
* Returns expanded Category object. All numeric identifiers are resolved
|
|
|
1092 |
* into detailed objects
|
| 18 |
naveen |
1093 |
*
|
|
|
1094 |
* @param categoryID
|
| 45 |
naveen |
1095 |
* @return ExpandedCategory
|
|
|
1096 |
* @throws Exception
|
|
|
1097 |
*/
|
|
|
1098 |
public ExpandedCategory getExpandedCategory(long categoryID)
|
|
|
1099 |
throws Exception {
|
|
|
1100 |
Category category = this.getCategory(categoryID);
|
|
|
1101 |
|
|
|
1102 |
ExpandedCategory expCategory = new ExpandedCategory(category);
|
|
|
1103 |
|
|
|
1104 |
return expCategory;
|
|
|
1105 |
}
|
|
|
1106 |
|
|
|
1107 |
/**
|
| 49 |
naveen |
1108 |
* Returns all children categories for a Category ID
|
| 45 |
naveen |
1109 |
*
|
|
|
1110 |
* @param categoryID
|
| 49 |
naveen |
1111 |
* @return List<Category> Children Categories
|
| 34 |
naveen |
1112 |
* @throws Exception
|
|
|
1113 |
*/
|
| 1050 |
rajveer |
1114 |
public List<Category> getChildrenCategories(long categoryID){
|
| 34 |
naveen |
1115 |
return this.categories.get(new Long(categoryID)).getChildrenCategory();
|
|
|
1116 |
}
|
| 49 |
naveen |
1117 |
|
| 34 |
naveen |
1118 |
/**
|
| 49 |
naveen |
1119 |
* Returns all CategorySlideDefinition objects for a Category ID
|
| 34 |
naveen |
1120 |
*
|
| 49 |
naveen |
1121 |
* @param categoryID Category ID
|
| 18 |
naveen |
1122 |
* @return List<CategorySlideDefinition>
|
|
|
1123 |
* @throws Exception
|
|
|
1124 |
*/
|
|
|
1125 |
public List<CategorySlideDefinition> getCategorySlideDefinitions(
|
|
|
1126 |
long categoryID) throws Exception {
|
|
|
1127 |
Category category = this.getCategory(categoryID);
|
|
|
1128 |
|
|
|
1129 |
return category.getCategorySlideDefintions();
|
|
|
1130 |
}
|
|
|
1131 |
|
|
|
1132 |
/**
|
| 49 |
naveen |
1133 |
* Returns All SlideDefinition objects in database
|
|
|
1134 |
*
|
| 10 |
shop2020 |
1135 |
* @return the slideDefinitions
|
| 18 |
naveen |
1136 |
* @throws Exception
|
| 10 |
shop2020 |
1137 |
*/
|
| 1050 |
rajveer |
1138 |
public Map<Long, SlideDefinition> getSlideDefinitions(){
|
|
|
1139 |
return this.slideDefinitions;
|
|
|
1140 |
}
|
|
|
1141 |
|
|
|
1142 |
/**
|
|
|
1143 |
*
|
|
|
1144 |
* @return Map
|
|
|
1145 |
*/
|
|
|
1146 |
private Map<Long, SlideDefinition> convertSlideDefinitions(
|
|
|
1147 |
DefinitionType defType) {
|
| 18 |
naveen |
1148 |
|
| 1050 |
rajveer |
1149 |
Map<Long, SlideDefinition> defs =
|
|
|
1150 |
new HashMap<Long, SlideDefinition>();
|
|
|
1151 |
|
|
|
1152 |
List<SlideDefinitionType> jaxbDefs = defType.getSlideDefinition();
|
|
|
1153 |
Iterator<SlideDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
1154 |
|
|
|
1155 |
// Slide definitions
|
|
|
1156 |
while(itjaxbDefs.hasNext()) {
|
|
|
1157 |
SlideDefinitionType jaxbDef = itjaxbDefs.next();
|
| 18 |
naveen |
1158 |
|
| 1050 |
rajveer |
1159 |
Utils.info("Slide label=" + jaxbDef.getLabel());
|
|
|
1160 |
SlideDefinition def = new SlideDefinition(jaxbDef.getID(),
|
|
|
1161 |
jaxbDef.getLabel());
|
|
|
1162 |
def.setDescription(jaxbDef.getDescription());
|
|
|
1163 |
|
|
|
1164 |
// Children Slides
|
|
|
1165 |
Utils.info("jaxbDef.getChildSlideID=" + jaxbDef.getChildSlideID());
|
|
|
1166 |
def.setChildrenSlideDefinitionIDs(jaxbDef.getChildSlideID());
|
|
|
1167 |
|
|
|
1168 |
// Slide Feature Definition
|
|
|
1169 |
List<SlideFeatureDefinitionType> jaxbSlideFeatureDefs =
|
|
|
1170 |
jaxbDef.getSlideFeatureDefinition();
|
|
|
1171 |
|
|
|
1172 |
if(jaxbSlideFeatureDefs != null) {
|
|
|
1173 |
def.setSlideFeatureDefinitions((
|
|
|
1174 |
this.convertSlideFeatureDefinitions(
|
|
|
1175 |
jaxbSlideFeatureDefs)));
|
|
|
1176 |
}
|
|
|
1177 |
Utils.info("def=" + def);
|
|
|
1178 |
|
|
|
1179 |
defs.put(new Long(jaxbDef.getID()), def);
|
| 18 |
naveen |
1180 |
}
|
| 1050 |
rajveer |
1181 |
|
|
|
1182 |
return defs;
|
| 10 |
shop2020 |
1183 |
}
|
| 1050 |
rajveer |
1184 |
|
| 18 |
naveen |
1185 |
|
|
|
1186 |
/**
|
| 2170 |
rajveer |
1187 |
*
|
|
|
1188 |
* @return Map
|
|
|
1189 |
*/
|
|
|
1190 |
private Map<Long, HelpDocDefinition> convertHelpDocDefinitions(DefinitionType defType) {
|
|
|
1191 |
|
|
|
1192 |
Map<Long, HelpDocDefinition> defs =
|
|
|
1193 |
new HashMap<Long, HelpDocDefinition>();
|
|
|
1194 |
|
|
|
1195 |
List<HelpDocDefinitionType> jaxbDefs = defType.getHelpDocDefinition();
|
|
|
1196 |
Iterator<HelpDocDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
1197 |
|
|
|
1198 |
// Help Doc definitions
|
|
|
1199 |
while(itjaxbDefs.hasNext()) {
|
|
|
1200 |
HelpDocDefinitionType jaxbDef = itjaxbDefs.next();
|
|
|
1201 |
|
|
|
1202 |
Utils.info("Helo doc name is =" + jaxbDef.getName());
|
|
|
1203 |
HelpDocDefinition def = new HelpDocDefinition(jaxbDef.getID(), jaxbDef.getName());
|
|
|
1204 |
|
|
|
1205 |
Utils.info("def=" + def);
|
|
|
1206 |
|
|
|
1207 |
defs.put(new Long(jaxbDef.getID()), def);
|
|
|
1208 |
}
|
|
|
1209 |
|
|
|
1210 |
return defs;
|
|
|
1211 |
}
|
|
|
1212 |
|
|
|
1213 |
|
|
|
1214 |
/**
|
| 1050 |
rajveer |
1215 |
*
|
|
|
1216 |
* @param jaxbDefs
|
|
|
1217 |
* @return List<SlideFeatureDefinition>
|
|
|
1218 |
*/
|
|
|
1219 |
private List<SlideFeatureDefinition> convertSlideFeatureDefinitions(
|
|
|
1220 |
List<SlideFeatureDefinitionType> jaxbDefs) {
|
|
|
1221 |
|
|
|
1222 |
List<SlideFeatureDefinition> defs =
|
|
|
1223 |
new ArrayList<SlideFeatureDefinition>();
|
|
|
1224 |
|
|
|
1225 |
Iterator<SlideFeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
1226 |
|
|
|
1227 |
// Slide-feature definitions
|
|
|
1228 |
while(itjaxbDefs.hasNext()) {
|
|
|
1229 |
SlideFeatureDefinitionType jaxbDef = itjaxbDefs.next();
|
|
|
1230 |
SlideFeatureDefinition def = new SlideFeatureDefinition(
|
|
|
1231 |
jaxbDef.getFeatureDefinitionID());
|
|
|
1232 |
|
|
|
1233 |
def.setEditorialImportance(this.convertEditorialImportance(
|
|
|
1234 |
jaxbDef.getEditorialImportance()));
|
|
|
1235 |
|
|
|
1236 |
def.setDescription(jaxbDef.getDescription());
|
|
|
1237 |
|
|
|
1238 |
defs.add(def);
|
|
|
1239 |
}
|
|
|
1240 |
|
|
|
1241 |
return defs;
|
|
|
1242 |
}
|
|
|
1243 |
|
|
|
1244 |
|
|
|
1245 |
/**
|
| 49 |
naveen |
1246 |
* Resolves SlideDefinition ID into SlideDefinition object
|
| 18 |
naveen |
1247 |
*
|
|
|
1248 |
* @param id
|
|
|
1249 |
* @return SlideDefinition
|
|
|
1250 |
* @throws Exception
|
|
|
1251 |
*/
|
|
|
1252 |
public SlideDefinition getSlideDefinition(long id) throws Exception {
|
|
|
1253 |
|
|
|
1254 |
// Initialize
|
|
|
1255 |
if(this.slideDefinitions == null) {
|
|
|
1256 |
this.getSlideDefinitions();
|
|
|
1257 |
}
|
|
|
1258 |
|
|
|
1259 |
return this.slideDefinitions.get(new Long(id));
|
|
|
1260 |
}
|
|
|
1261 |
|
|
|
1262 |
/**
|
| 199 |
naveen |
1263 |
*
|
|
|
1264 |
* @param slideID
|
|
|
1265 |
* @return ExpandedSlideDefinition
|
|
|
1266 |
* @throws Exception
|
|
|
1267 |
*/
|
|
|
1268 |
public ExpandedSlideDefinition getExpandedSlideDefinition(long slideID)
|
|
|
1269 |
throws Exception {
|
|
|
1270 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
1271 |
|
|
|
1272 |
return new ExpandedSlideDefinition(slideDef);
|
|
|
1273 |
}
|
|
|
1274 |
|
|
|
1275 |
/**
|
| 49 |
naveen |
1276 |
* Returns SlideDefinition objects for a category and matching slide label
|
| 18 |
naveen |
1277 |
*
|
| 19 |
naveen |
1278 |
* @param label
|
|
|
1279 |
* @return List<SlideDefinition>
|
|
|
1280 |
* @throws Exception
|
|
|
1281 |
*/
|
| 32 |
naveen |
1282 |
public List<SlideDefinition> getSlideDefinitions(long categoryID,
|
|
|
1283 |
String label) throws Exception {
|
|
|
1284 |
|
|
|
1285 |
// RE-VISIT
|
|
|
1286 |
// May be we need a new data structure, category id to slide definitions
|
|
|
1287 |
// for now
|
|
|
1288 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 19 |
naveen |
1289 |
|
| 32 |
naveen |
1290 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
1291 |
categoryID);
|
|
|
1292 |
|
|
|
1293 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
1294 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
1295 |
csDef.getSlideDefintionID());
|
|
|
1296 |
|
|
|
1297 |
if(sDef.getLabel().equalsIgnoreCase(label)) {
|
|
|
1298 |
matchingSlides.add(sDef);
|
|
|
1299 |
}
|
| 19 |
naveen |
1300 |
}
|
|
|
1301 |
|
| 32 |
naveen |
1302 |
return matchingSlides;
|
|
|
1303 |
}
|
|
|
1304 |
|
|
|
1305 |
/**
|
| 49 |
naveen |
1306 |
* Resolves Category ID into Category object
|
| 32 |
naveen |
1307 |
*
|
|
|
1308 |
* @param categoryID
|
| 49 |
naveen |
1309 |
* @return List<SlideDefinition>
|
| 32 |
naveen |
1310 |
* @throws Exception
|
|
|
1311 |
*/
|
|
|
1312 |
public List<SlideDefinition> getSlideDefinitions(long categoryID)
|
|
|
1313 |
throws Exception {
|
|
|
1314 |
|
|
|
1315 |
// RE-VISIT
|
|
|
1316 |
// May be we need a new data structure, category id to slide definitions
|
|
|
1317 |
// for now
|
| 19 |
naveen |
1318 |
List<SlideDefinition> matchingSlides = new ArrayList<SlideDefinition>();
|
| 32 |
naveen |
1319 |
|
|
|
1320 |
List<CategorySlideDefinition> csDefs = this.getCategorySlideDefinitions(
|
|
|
1321 |
categoryID);
|
|
|
1322 |
|
|
|
1323 |
for(CategorySlideDefinition csDef : csDefs) {
|
|
|
1324 |
SlideDefinition sDef = this.getSlideDefinition(
|
|
|
1325 |
csDef.getSlideDefintionID());
|
| 19 |
naveen |
1326 |
|
| 32 |
naveen |
1327 |
matchingSlides.add(sDef);
|
| 19 |
naveen |
1328 |
}
|
|
|
1329 |
|
|
|
1330 |
return matchingSlides;
|
|
|
1331 |
}
|
| 49 |
naveen |
1332 |
|
| 19 |
naveen |
1333 |
/**
|
| 49 |
naveen |
1334 |
* Returns list of SlideDefinition objects for a category and editorial
|
|
|
1335 |
* importance value
|
| 19 |
naveen |
1336 |
*
|
| 18 |
naveen |
1337 |
* @param categoryID
|
|
|
1338 |
* @param EditorialImportance imp
|
|
|
1339 |
* @return List<SlideDefinition>
|
|
|
1340 |
* @throws Exception
|
|
|
1341 |
*/
|
|
|
1342 |
public List<SlideDefinition> getSlides(long categoryID,
|
|
|
1343 |
EditorialImportance imp)
|
|
|
1344 |
throws Exception {
|
|
|
1345 |
|
|
|
1346 |
List<CategorySlideDefinition> catSlideDefs =
|
|
|
1347 |
this.getCategorySlideDefinitions(categoryID);
|
|
|
1348 |
|
|
|
1349 |
Iterator<CategorySlideDefinition> itCatSlideDefs =
|
|
|
1350 |
catSlideDefs.iterator();
|
|
|
1351 |
|
|
|
1352 |
List<SlideDefinition> slideDefs = new ArrayList<SlideDefinition>();
|
|
|
1353 |
while(itCatSlideDefs.hasNext()) {
|
|
|
1354 |
CategorySlideDefinition catSlideDef = itCatSlideDefs.next();
|
|
|
1355 |
if(catSlideDef.getEditorialImportance() == imp) {
|
|
|
1356 |
long slideDefID = catSlideDef.getSlideDefintionID();
|
|
|
1357 |
slideDefs.add(this.getSlideDefinition(slideDefID));
|
|
|
1358 |
}
|
|
|
1359 |
}
|
|
|
1360 |
return slideDefs;
|
|
|
1361 |
}
|
|
|
1362 |
|
|
|
1363 |
/**
|
| 49 |
naveen |
1364 |
* Returns all FeatureDefinition object in database
|
| 18 |
naveen |
1365 |
*
|
|
|
1366 |
* @return Map<Long, FeatureDefinition>
|
|
|
1367 |
* @throws Exception
|
|
|
1368 |
*/
|
| 1050 |
rajveer |
1369 |
public Map<Long, FeatureDefinition> getFeatureDefinitions(){
|
|
|
1370 |
return this.featureDefinitions;
|
|
|
1371 |
}
|
|
|
1372 |
|
|
|
1373 |
|
|
|
1374 |
/**
|
|
|
1375 |
*
|
|
|
1376 |
* @param defType
|
|
|
1377 |
* @return
|
|
|
1378 |
*/
|
|
|
1379 |
private Map<Long, FeatureDefinition> convertFeatureDefinitions(
|
|
|
1380 |
DefinitionType defType) {
|
| 18 |
naveen |
1381 |
|
| 1050 |
rajveer |
1382 |
Map<Long, FeatureDefinition> defs =
|
|
|
1383 |
new HashMap<Long, FeatureDefinition>();
|
|
|
1384 |
|
|
|
1385 |
List<FeatureDefinitionType> jaxbDefs = defType.getFeatureDefinition();
|
|
|
1386 |
Iterator<FeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
1387 |
|
|
|
1388 |
// Feature definitions
|
|
|
1389 |
while(itjaxbDefs.hasNext()) {
|
|
|
1390 |
FeatureDefinitionType jaxbDef = itjaxbDefs.next();
|
| 1314 |
rajveer |
1391 |
Utils.info("******"+ jaxbDef.getID());
|
| 18 |
naveen |
1392 |
|
| 1050 |
rajveer |
1393 |
//Utils.info("Feature label=" + jaxbDef.getLabel());
|
|
|
1394 |
FeatureDefinition def = new FeatureDefinition(jaxbDef.getID(),
|
|
|
1395 |
jaxbDef.getLabel());
|
|
|
1396 |
def.setAllowsBlank(jaxbDef.isCanbeBlank());
|
|
|
1397 |
def.setDescription(jaxbDef.getDescription());
|
|
|
1398 |
|
|
|
1399 |
// Bullet Definition
|
|
|
1400 |
BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
|
|
|
1401 |
if(jaxbBulletDef != null) {
|
|
|
1402 |
def.setBulletDefinition(this.convertBulletDefinition(
|
|
|
1403 |
jaxbBulletDef));
|
|
|
1404 |
}
|
|
|
1405 |
|
|
|
1406 |
Long normRuleDefID = jaxbDef.getNormalizationRuleDefinitionID();
|
|
|
1407 |
if(normRuleDefID != null) {
|
|
|
1408 |
def.setNormalizationRuleDefinitionID(normRuleDefID.longValue());
|
|
|
1409 |
}
|
|
|
1410 |
Utils.info("def=" + def);
|
|
|
1411 |
|
| 2170 |
rajveer |
1412 |
Long helpDocDefID = jaxbDef.getHelpDocDefinitionID();
|
|
|
1413 |
if(helpDocDefID != null) {
|
|
|
1414 |
def.setHelpDocDefinitionID(helpDocDefID.longValue());
|
|
|
1415 |
}
|
|
|
1416 |
Utils.info("def=" + def);
|
|
|
1417 |
|
| 1050 |
rajveer |
1418 |
defs.put(new Long(jaxbDef.getID()), def);
|
| 18 |
naveen |
1419 |
}
|
| 1050 |
rajveer |
1420 |
|
|
|
1421 |
return defs;
|
| 18 |
naveen |
1422 |
}
|
| 1050 |
rajveer |
1423 |
|
| 19 |
naveen |
1424 |
|
| 10 |
shop2020 |
1425 |
/**
|
| 1050 |
rajveer |
1426 |
*
|
|
|
1427 |
* @param jaxbDef BulletDefinitionType
|
|
|
1428 |
* @return BulletDefinition
|
|
|
1429 |
*/
|
|
|
1430 |
private BulletDefinition convertBulletDefinition(
|
|
|
1431 |
BulletDefinitionType jaxbDef) {
|
|
|
1432 |
|
|
|
1433 |
BulletDefinition def = new BulletDefinition(
|
|
|
1434 |
jaxbDef.getDatatypeDefinitionID());
|
|
|
1435 |
|
|
|
1436 |
List<Long> unitIDs = jaxbDef.getUnitID();
|
|
|
1437 |
if(unitIDs != null && !unitIDs.isEmpty()) {
|
|
|
1438 |
def.setUnitIDs(unitIDs);
|
|
|
1439 |
}
|
|
|
1440 |
Utils.info("jaxbDef.isIsMultivalue=" + jaxbDef.isIsMultivalue());
|
|
|
1441 |
|
|
|
1442 |
def.setMultivalue(jaxbDef.isIsMultivalue());
|
|
|
1443 |
def.setLearned(jaxbDef.isIsLearned());
|
|
|
1444 |
def.setDescription(jaxbDef.getDescription());
|
|
|
1445 |
|
|
|
1446 |
return def;
|
|
|
1447 |
}
|
|
|
1448 |
|
|
|
1449 |
|
|
|
1450 |
/**
|
| 49 |
naveen |
1451 |
* Returns all FeatureDefinition objects for a slide
|
| 18 |
naveen |
1452 |
*
|
| 19 |
naveen |
1453 |
* @param slideID
|
|
|
1454 |
* @return List<FeatureDefinition>
|
|
|
1455 |
* @throws Exception
|
|
|
1456 |
*/
|
|
|
1457 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID)
|
|
|
1458 |
throws Exception {
|
|
|
1459 |
List<FeatureDefinition> featureDefs =
|
|
|
1460 |
new ArrayList<FeatureDefinition>();
|
|
|
1461 |
|
|
|
1462 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
1463 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
1464 |
slideDef.getSlideFeatureDefinitions();
|
|
|
1465 |
|
|
|
1466 |
for(int i=0; i<slideFeatureDefs.size(); i++) {
|
|
|
1467 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
1468 |
slideFeatureDefs.get(i).getFeatureDefintionID()));
|
|
|
1469 |
}
|
|
|
1470 |
|
|
|
1471 |
return featureDefs;
|
|
|
1472 |
}
|
|
|
1473 |
|
|
|
1474 |
/**
|
| 49 |
naveen |
1475 |
* Returns list of FeatureDefinition objects for a slide given editorial
|
|
|
1476 |
* importance
|
| 19 |
naveen |
1477 |
*
|
|
|
1478 |
* @param slideID
|
| 49 |
naveen |
1479 |
* @param imp Editorial Importance enum object
|
| 19 |
naveen |
1480 |
* @return List<FeatureDefinition>
|
|
|
1481 |
* @throws Exception
|
|
|
1482 |
*/
|
|
|
1483 |
public List<FeatureDefinition> getFeatureDefinitions(long slideID,
|
|
|
1484 |
EditorialImportance imp) throws Exception {
|
|
|
1485 |
List<FeatureDefinition> featureDefs =
|
|
|
1486 |
new ArrayList<FeatureDefinition>();
|
|
|
1487 |
|
|
|
1488 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
1489 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
1490 |
slideDef.getSlideFeatureDefinitions();
|
|
|
1491 |
|
|
|
1492 |
for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
|
|
1493 |
if(slideFeatureDef.getEditorialImportance() == imp) {
|
|
|
1494 |
featureDefs.add(this.getFeatureDefinition(
|
|
|
1495 |
slideFeatureDef.getFeatureDefintionID()));
|
|
|
1496 |
}
|
|
|
1497 |
}
|
|
|
1498 |
|
|
|
1499 |
return featureDefs;
|
|
|
1500 |
}
|
|
|
1501 |
|
|
|
1502 |
/**
|
| 49 |
naveen |
1503 |
* Resolves Feature Definition ID into FeatureDefinition object
|
| 19 |
naveen |
1504 |
*
|
| 49 |
naveen |
1505 |
* @param id Feature Definition ID
|
| 19 |
naveen |
1506 |
* @return FeatureDefinition
|
| 18 |
naveen |
1507 |
* @throws Exception
|
| 10 |
shop2020 |
1508 |
*/
|
| 18 |
naveen |
1509 |
public FeatureDefinition getFeatureDefinition(long id) throws Exception {
|
|
|
1510 |
|
|
|
1511 |
// Initialize
|
|
|
1512 |
if(this.featureDefinitions == null) {
|
|
|
1513 |
this.getFeatureDefinitions();
|
|
|
1514 |
}
|
|
|
1515 |
|
|
|
1516 |
return this.featureDefinitions.get(new Long(id));
|
|
|
1517 |
}
|
| 19 |
naveen |
1518 |
|
|
|
1519 |
/**
|
| 49 |
naveen |
1520 |
* Returns matching FeatureDefinition object for slide ID and feature label.
|
|
|
1521 |
* Label matching is case insensitive.
|
| 19 |
naveen |
1522 |
*
|
| 49 |
naveen |
1523 |
* @param slideID Slide ID
|
|
|
1524 |
* @param featureLabel label to match, case is ignored
|
| 19 |
naveen |
1525 |
* @return FeatureDefinition
|
|
|
1526 |
* @throws Exception
|
|
|
1527 |
*/
|
|
|
1528 |
public FeatureDefinition getFeatureDefinition(long slideID,
|
|
|
1529 |
String featureLabel) throws Exception {
|
|
|
1530 |
FeatureDefinition featureDef = null;
|
|
|
1531 |
|
|
|
1532 |
SlideDefinition slideDef = this.getSlideDefinition(slideID);
|
|
|
1533 |
for(SlideFeatureDefinition slideFeatureDef :
|
|
|
1534 |
slideDef.getSlideFeatureDefinitions()) {
|
|
|
1535 |
|
|
|
1536 |
long featureDefID = slideFeatureDef.getFeatureDefintionID();
|
|
|
1537 |
|
|
|
1538 |
FeatureDefinition thisFeatureDef = this.getFeatureDefinition(
|
|
|
1539 |
featureDefID);
|
|
|
1540 |
|
| 28 |
naveen |
1541 |
if(featureLabel.equalsIgnoreCase(thisFeatureDef.getLabel())) {
|
| 19 |
naveen |
1542 |
featureDef = thisFeatureDef;
|
|
|
1543 |
}
|
|
|
1544 |
}
|
|
|
1545 |
|
|
|
1546 |
return featureDef;
|
|
|
1547 |
}
|
| 24 |
naveen |
1548 |
|
|
|
1549 |
/**
|
| 49 |
naveen |
1550 |
* Returns all EnumValue objects in the database
|
|
|
1551 |
*
|
| 24 |
naveen |
1552 |
* @return the enumValues
|
|
|
1553 |
* @throws Exception
|
|
|
1554 |
*/
|
|
|
1555 |
public Map<Long, EnumValue> getEnumValues() throws Exception {
|
|
|
1556 |
return this.enumValues;
|
|
|
1557 |
}
|
| 19 |
naveen |
1558 |
|
| 1050 |
rajveer |
1559 |
|
| 24 |
naveen |
1560 |
/**
|
| 49 |
naveen |
1561 |
* Resolves Enum value ID into EnumValue object
|
| 24 |
naveen |
1562 |
*
|
|
|
1563 |
* @param enumValueID
|
|
|
1564 |
* @return EnumValue
|
|
|
1565 |
* @throws Exception
|
|
|
1566 |
*/
|
|
|
1567 |
public EnumValue getEnumValue(long enumValueID) throws Exception {
|
|
|
1568 |
return this.enumValues.get(new Long(enumValueID));
|
|
|
1569 |
}
|
| 2170 |
rajveer |
1570 |
|
| 62 |
naveen |
1571 |
/**
|
|
|
1572 |
* Returns all FacetDefinition objects in the database
|
|
|
1573 |
*
|
|
|
1574 |
* @return Map Null if facet definitions are not imported into definitions
|
|
|
1575 |
* db (serialized java objects)
|
|
|
1576 |
*
|
|
|
1577 |
* @throws Exception
|
|
|
1578 |
*/
|
| 1050 |
rajveer |
1579 |
public Map<Long, FacetDefinition> getFacetDefinitions(){
|
| 62 |
naveen |
1580 |
return this.facetDefinitions;
|
|
|
1581 |
}
|
|
|
1582 |
|
|
|
1583 |
/**
|
| 1314 |
rajveer |
1584 |
* Get List of Facets for a given slide.
|
|
|
1585 |
*
|
|
|
1586 |
* @return
|
|
|
1587 |
*/
|
|
|
1588 |
public Map<Long, List<FacetDefinition>> getSlideFacetDefinitions(){
|
|
|
1589 |
return slideFacetDefinitions;
|
|
|
1590 |
}
|
|
|
1591 |
/**
|
| 62 |
naveen |
1592 |
* Resolves Facet Definition ID into FacetDefinition object
|
|
|
1593 |
*
|
|
|
1594 |
* @param facetDefinitionID
|
|
|
1595 |
* @return FacetDefinition
|
|
|
1596 |
* @throws Exception
|
|
|
1597 |
*/
|
|
|
1598 |
public FacetDefinition getFacetDefinition(long facetDefinitionID)
|
|
|
1599 |
throws Exception {
|
|
|
1600 |
|
|
|
1601 |
if(this.facetDefinitions == null) {
|
|
|
1602 |
this.getFacetDefinitions();
|
|
|
1603 |
}
|
|
|
1604 |
|
|
|
1605 |
return this.facetDefinitions.get(new Long(facetDefinitionID));
|
|
|
1606 |
}
|
|
|
1607 |
|
|
|
1608 |
/**
|
|
|
1609 |
* Utility method to get Expanded version of ExpandedFacetDefinition object
|
|
|
1610 |
*
|
|
|
1611 |
* @param facetDefinitionID
|
|
|
1612 |
* @return ExpandedFacetDefinition
|
|
|
1613 |
* @throws Exception
|
|
|
1614 |
*/
|
| 1314 |
rajveer |
1615 |
/*
|
| 62 |
naveen |
1616 |
public ExpandedFacetDefinition getExpandedFacetDefinition(
|
|
|
1617 |
long facetDefinitionID) throws Exception {
|
|
|
1618 |
|
|
|
1619 |
FacetDefinition facetDefinition =
|
|
|
1620 |
this.getFacetDefinition(facetDefinitionID);
|
|
|
1621 |
|
|
|
1622 |
ExpandedFacetDefinition expFacetDefinition =
|
|
|
1623 |
new ExpandedFacetDefinition(facetDefinition);
|
|
|
1624 |
|
|
|
1625 |
return expFacetDefinition;
|
|
|
1626 |
}
|
| 1314 |
rajveer |
1627 |
*/
|
| 62 |
naveen |
1628 |
/**
|
|
|
1629 |
* Returns all CategoryFacetDefinition objects in the database
|
|
|
1630 |
*
|
|
|
1631 |
* @return Map Null if category facet definitions are not imported into
|
|
|
1632 |
* definitions db (serialized java objects)
|
|
|
1633 |
*
|
|
|
1634 |
* @throws Exception
|
|
|
1635 |
*/
|
| 1050 |
rajveer |
1636 |
public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions(){
|
| 62 |
naveen |
1637 |
return this.categoryFacetDefinitions;
|
|
|
1638 |
}
|
|
|
1639 |
|
|
|
1640 |
/**
|
|
|
1641 |
* Resolves Category-Facet Definition ID into CategoryFacetDefinition object
|
|
|
1642 |
*
|
|
|
1643 |
* @param categoryID
|
|
|
1644 |
* @return CategoryFacetDefinition
|
|
|
1645 |
* @throws Exception
|
|
|
1646 |
*/
|
| 1050 |
rajveer |
1647 |
public CategoryFacetDefinition getCategoryFacetDefinition(long categoryID){
|
|
|
1648 |
return this.categoryFacetDefinitions.get(new Long(categoryID));
|
| 62 |
naveen |
1649 |
}
|
|
|
1650 |
|
| 1050 |
rajveer |
1651 |
|
| 62 |
naveen |
1652 |
/**
|
|
|
1653 |
* Utility method to get Expanded version of CategoryFacetDefinition object
|
|
|
1654 |
*
|
|
|
1655 |
* @param categoryID
|
|
|
1656 |
* @return ExpandedCategoryFacetDefinition
|
|
|
1657 |
* @throws Exception
|
|
|
1658 |
*/
|
|
|
1659 |
public ExpandedCategoryFacetDefinition getExpandedCategoryFacetDefinition(
|
|
|
1660 |
long categoryID) throws Exception {
|
|
|
1661 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1662 |
this.getCategoryFacetDefinition(categoryID);
|
|
|
1663 |
|
|
|
1664 |
ExpandedCategoryFacetDefinition expCategoryFacetDef =
|
|
|
1665 |
new ExpandedCategoryFacetDefinition(categoryFacetDef);
|
|
|
1666 |
|
|
|
1667 |
return expCategoryFacetDef;
|
|
|
1668 |
}
|
|
|
1669 |
|
|
|
1670 |
/**
|
|
|
1671 |
* Returns all IR Data RuleDefintion objects in the database
|
|
|
1672 |
*
|
|
|
1673 |
* @return Map Null if IR data rule definitions are not imported into
|
|
|
1674 |
* definitions db (serialized java objects)
|
|
|
1675 |
*
|
|
|
1676 |
* @throws Exception
|
|
|
1677 |
*/
|
| 1050 |
rajveer |
1678 |
public Map<Long, RuleDefinition> getIrDataRuleDefinitions(){
|
| 62 |
naveen |
1679 |
return this.irDataRuleDefinitions;
|
|
|
1680 |
}
|
|
|
1681 |
|
|
|
1682 |
/**
|
|
|
1683 |
* Resolves IR Data Rule Definition ID into RuleDefinition object
|
|
|
1684 |
*
|
|
|
1685 |
* @param irDataRuleDefinitionID
|
|
|
1686 |
* @return RuleDefinition
|
|
|
1687 |
* @throws Exception
|
|
|
1688 |
*/
|
| 1050 |
rajveer |
1689 |
public RuleDefinition getIrDataRuleDefinition(long irDataRuleDefinitionID){
|
| 62 |
naveen |
1690 |
return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
|
|
|
1691 |
}
|
|
|
1692 |
|
|
|
1693 |
/**
|
|
|
1694 |
* Returns all IR Meta Data RuleDefintion objects in the database
|
|
|
1695 |
*
|
|
|
1696 |
* @return Map Null if IR meta-data rule definitions are not imported into
|
|
|
1697 |
* definitions db (serialized java objects)
|
|
|
1698 |
*
|
|
|
1699 |
* @throws Exception
|
|
|
1700 |
*/
|
| 1050 |
rajveer |
1701 |
public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions(){
|
| 62 |
naveen |
1702 |
return this.irMetaDataRuleDefinitions;
|
|
|
1703 |
}
|
|
|
1704 |
|
|
|
1705 |
/**
|
|
|
1706 |
* Resolves IR Meta Data Rule Definition ID into RuleDefinition object
|
|
|
1707 |
*
|
|
|
1708 |
* @param irMetaDataRuleDefinitionID
|
|
|
1709 |
* @return RuleDefinition
|
|
|
1710 |
* @throws Exception
|
|
|
1711 |
*/
|
| 1050 |
rajveer |
1712 |
public RuleDefinition getIrMetaDataRuleDefinition(long irMetaDataRuleDefinitionID) {
|
|
|
1713 |
return this.irMetaDataRuleDefinitions.get(new Long(irMetaDataRuleDefinitionID));
|
| 62 |
naveen |
1714 |
}
|
| 70 |
naveen |
1715 |
|
|
|
1716 |
/**
|
|
|
1717 |
* Returns all Comparison RuleDefintion objects in the database
|
|
|
1718 |
*
|
|
|
1719 |
* @return Map Null if Comparison rule definitions are not imported into
|
|
|
1720 |
* definitions db (serialized java objects)
|
|
|
1721 |
*
|
|
|
1722 |
* @throws Exception
|
|
|
1723 |
*/
|
| 1050 |
rajveer |
1724 |
public Map<Long, CMPRuleDefinition> getComparisonRuleDefinitions(){
|
| 70 |
naveen |
1725 |
return this.cmpRuleDefinitions;
|
|
|
1726 |
}
|
|
|
1727 |
|
|
|
1728 |
/**
|
|
|
1729 |
* Resolves IR Data Rule Definition ID into RuleDefinition object
|
|
|
1730 |
*
|
|
|
1731 |
* @param cmpRuleDefinitionID
|
|
|
1732 |
* @return CMPRuleDefinition
|
|
|
1733 |
* @throws Exception
|
|
|
1734 |
*/
|
| 1050 |
rajveer |
1735 |
public CMPRuleDefinition getComparisonRuleDefinition(long cmpRuleDefinitionID) {
|
| 70 |
naveen |
1736 |
return this.cmpRuleDefinitions.get(new Long(cmpRuleDefinitionID));
|
|
|
1737 |
}
|
|
|
1738 |
|
|
|
1739 |
|
|
|
1740 |
/**
|
|
|
1741 |
* Returns all ComparisonSlideRuleDefintion objects in the database
|
|
|
1742 |
*
|
|
|
1743 |
* @return Map Null if Comparison slide-rule definitions are not imported
|
|
|
1744 |
* into definitions db (serialized java objects)
|
|
|
1745 |
*
|
|
|
1746 |
* @throws Exception
|
|
|
1747 |
*/
|
| 1050 |
rajveer |
1748 |
public Map<Long, CMPSlideRuleDefinition> getComparisonSlideRuleDefinitions() {
|
| 70 |
naveen |
1749 |
return this.cmpSlideRuleDefinitions;
|
|
|
1750 |
}
|
|
|
1751 |
|
|
|
1752 |
/**
|
|
|
1753 |
* Resolves Category ID into List of CMPSlideRuleDefinition object
|
|
|
1754 |
*
|
|
|
1755 |
* @param categoryID
|
|
|
1756 |
* @return List<CMPSlideRuleDefinition>
|
|
|
1757 |
* @throws Exception
|
|
|
1758 |
*/
|
| 1050 |
rajveer |
1759 |
public CMPSlideRuleDefinition getComparisonSlideRuleDefinition(long slideDefinitionID) {
|
| 70 |
naveen |
1760 |
return this.cmpSlideRuleDefinitions.get(new Long(slideDefinitionID));
|
|
|
1761 |
}
|
|
|
1762 |
|
|
|
1763 |
|
|
|
1764 |
/**
|
|
|
1765 |
* Resolves Slide Definition ID into ExpandedCMPSlideRuleDefinition object
|
|
|
1766 |
*
|
|
|
1767 |
* @param categoryID
|
|
|
1768 |
* @return ExpandedCMPSlideRuleDefinition
|
|
|
1769 |
* @throws Exception
|
|
|
1770 |
*/
|
| 1050 |
rajveer |
1771 |
public ExpandedCMPSlideRuleDefinition getExpandedComparisonSlideRuleDefinition(long slideDefinitionID) throws Exception{
|
| 71 |
naveen |
1772 |
Utils.info("slideDefinitionID=" + slideDefinitionID);
|
| 70 |
naveen |
1773 |
|
| 1050 |
rajveer |
1774 |
CMPSlideRuleDefinition cmpSlideRuleDef = this.getComparisonSlideRuleDefinition(slideDefinitionID);
|
| 70 |
naveen |
1775 |
|
| 71 |
naveen |
1776 |
if(cmpSlideRuleDef == null) {
|
|
|
1777 |
return null;
|
|
|
1778 |
}
|
|
|
1779 |
|
| 1050 |
rajveer |
1780 |
ExpandedCMPSlideRuleDefinition expDef = new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
|
| 70 |
naveen |
1781 |
return expDef;
|
|
|
1782 |
}
|
| 72 |
naveen |
1783 |
|
| 70 |
naveen |
1784 |
|
| 72 |
naveen |
1785 |
/**
|
|
|
1786 |
* Returns all ComparisonSlideRuleDefintion objects in the database
|
|
|
1787 |
*
|
|
|
1788 |
* @return Map Null if Comparison slide-rule definitions are not imported
|
|
|
1789 |
* into definitions db (serialized java objects)
|
|
|
1790 |
*
|
|
|
1791 |
* @throws Exception
|
|
|
1792 |
*/
|
| 1050 |
rajveer |
1793 |
|
|
|
1794 |
public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions(){
|
| 72 |
naveen |
1795 |
return this.cmpBucketDefinitions;
|
|
|
1796 |
}
|
|
|
1797 |
|
|
|
1798 |
/**
|
|
|
1799 |
* Resolves Category ID into List of CMPBucketDefinition object
|
|
|
1800 |
*
|
|
|
1801 |
* @param categoryID
|
|
|
1802 |
* @return List<CMPBucketDefinition>
|
|
|
1803 |
* @throws Exception
|
|
|
1804 |
*/
|
| 1050 |
rajveer |
1805 |
public List<CMPBucketDefinition> getComparisonBucketDefinitions(long categoryID) {
|
| 72 |
naveen |
1806 |
return this.cmpBucketDefinitions.get(new Long(categoryID));
|
|
|
1807 |
}
|
|
|
1808 |
|
|
|
1809 |
/**
|
|
|
1810 |
* Resolve comparison bucket name for a slide in a particular category
|
|
|
1811 |
*
|
|
|
1812 |
* @param categoryID
|
|
|
1813 |
* @param slideDefintionID
|
|
|
1814 |
* @return Bucket Name if found else Null
|
|
|
1815 |
* @throws Exception
|
|
|
1816 |
*/
|
|
|
1817 |
public String getComparisonBucketName(long categoryID,
|
|
|
1818 |
long slideDefinitionID) throws Exception {
|
|
|
1819 |
List<CMPBucketDefinition> cmpBuckets =
|
|
|
1820 |
this.getComparisonBucketDefinitions(categoryID);
|
| 1949 |
rajveer |
1821 |
if(cmpBuckets == null){
|
|
|
1822 |
return null;
|
|
|
1823 |
}
|
| 72 |
naveen |
1824 |
for (CMPBucketDefinition cmpBucket : cmpBuckets) {
|
|
|
1825 |
List<Long> slideDefinitionIDs = cmpBucket.getSlideDefinitionIDs();
|
|
|
1826 |
|
|
|
1827 |
if(slideDefinitionIDs.contains(new Long(slideDefinitionID))) {
|
|
|
1828 |
return cmpBucket.getName();
|
|
|
1829 |
}
|
|
|
1830 |
}
|
|
|
1831 |
return null;
|
|
|
1832 |
}
|
| 83 |
naveen |
1833 |
|
|
|
1834 |
/**
|
|
|
1835 |
* Returns list of facet definition IDs for given category ID
|
|
|
1836 |
*
|
|
|
1837 |
* @param categoryID
|
|
|
1838 |
* @return list of facet definition IDs
|
|
|
1839 |
* @throws Exception
|
|
|
1840 |
*/
|
|
|
1841 |
public List<Long> getFacetDefinitionIDs(long categoryID) throws Exception {
|
|
|
1842 |
List<Long> facetDefIDs = new ArrayList<Long>();
|
|
|
1843 |
|
|
|
1844 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1845 |
this.getCategoryFacetDefinition(categoryID);
|
| 516 |
rajveer |
1846 |
if(categoryFacetDef == null)
|
|
|
1847 |
return null;
|
| 1314 |
rajveer |
1848 |
List<FacetDefinition> facetDefs =
|
|
|
1849 |
categoryFacetDef.getFacetDefinitions();
|
| 83 |
naveen |
1850 |
|
| 1314 |
rajveer |
1851 |
for(FacetDefinition facetDef : facetDefs) {
|
|
|
1852 |
facetDefIDs.add(new Long(facetDef.getID()));
|
| 83 |
naveen |
1853 |
}
|
|
|
1854 |
|
|
|
1855 |
return facetDefIDs;
|
|
|
1856 |
}
|
|
|
1857 |
|
|
|
1858 |
/**
|
|
|
1859 |
* Returns list of feature definition IDs for given category ID
|
|
|
1860 |
*
|
|
|
1861 |
* @param categoryID
|
|
|
1862 |
* @return list of feature definition IDs
|
|
|
1863 |
* @throws Exception
|
|
|
1864 |
*/
|
|
|
1865 |
public List<Long> getFeatureDefinitionIDs(long categoryID)
|
|
|
1866 |
throws Exception {
|
|
|
1867 |
|
|
|
1868 |
List<Long> featureDefIDs = new ArrayList<Long>();
|
|
|
1869 |
|
|
|
1870 |
List<SlideDefinition> slideDefs = this.getSlideDefinitions(categoryID);
|
|
|
1871 |
|
|
|
1872 |
for(SlideDefinition slideDef : slideDefs) {
|
|
|
1873 |
List<Long> slideFeatureDefIDs =
|
|
|
1874 |
this.getFeatureDefintionIDs(slideDef);
|
|
|
1875 |
|
|
|
1876 |
featureDefIDs.addAll(slideFeatureDefIDs);
|
|
|
1877 |
}
|
|
|
1878 |
|
|
|
1879 |
return featureDefIDs;
|
|
|
1880 |
}
|
|
|
1881 |
|
|
|
1882 |
/**
|
|
|
1883 |
* Returns list of feature definition IDs for given slide definition ID
|
|
|
1884 |
*
|
|
|
1885 |
* @param slideDef
|
|
|
1886 |
* @return list of feature definition IDs
|
|
|
1887 |
*/
|
|
|
1888 |
public List<Long> getFeatureDefintionIDs(SlideDefinition slideDef) {
|
|
|
1889 |
List<Long> featureDefIDs = new ArrayList<Long>();
|
|
|
1890 |
|
|
|
1891 |
List<SlideFeatureDefinition> slideFeatureDefs =
|
|
|
1892 |
slideDef.getSlideFeatureDefinitions();
|
|
|
1893 |
|
|
|
1894 |
for(SlideFeatureDefinition slideFeatureDef : slideFeatureDefs) {
|
| 1050 |
rajveer |
1895 |
featureDefIDs.add(new Long(slideFeatureDef.getFeatureDefintionID()));
|
| 83 |
naveen |
1896 |
}
|
|
|
1897 |
|
|
|
1898 |
return featureDefIDs;
|
|
|
1899 |
}
|
| 88 |
naveen |
1900 |
|
|
|
1901 |
/**
|
|
|
1902 |
*
|
|
|
1903 |
* @param borrowedSlideDefID
|
|
|
1904 |
* @return
|
|
|
1905 |
* @throws Exception
|
|
|
1906 |
*/
|
|
|
1907 |
public boolean isValidSlideDefinitionID(long borrowedSlideDefID)
|
|
|
1908 |
throws Exception {
|
|
|
1909 |
this.getSlideDefinitions();
|
|
|
1910 |
|
|
|
1911 |
return this.slideDefinitions.containsKey(new Long(borrowedSlideDefID));
|
|
|
1912 |
}
|
|
|
1913 |
|
|
|
1914 |
/**
|
|
|
1915 |
* Returns Facet-Rule definition object defined for a category and
|
|
|
1916 |
* slide definition
|
|
|
1917 |
*
|
|
|
1918 |
* @param borrowedCategoryID
|
|
|
1919 |
* @param slideDefID
|
|
|
1920 |
* @return FacetRuleDefinition
|
|
|
1921 |
* @throws Exception
|
|
|
1922 |
*/
|
| 1314 |
rajveer |
1923 |
/*
|
| 88 |
naveen |
1924 |
public FacetRuleDefinition getFacetRuleDefinitionForSlide(long categoryID,
|
|
|
1925 |
long slideDefinitionID) throws Exception {
|
|
|
1926 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1927 |
this.getCategoryFacetDefinition(categoryID);
|
| 1073 |
chandransh |
1928 |
//FIXME Quick fix. Need to investigate
|
|
|
1929 |
if(categoryFacetDef == null){
|
|
|
1930 |
return null;
|
|
|
1931 |
}
|
| 88 |
naveen |
1932 |
List<FacetRuleDefinition> facetRuleDefs =
|
|
|
1933 |
categoryFacetDef.getFacetRuleDefinitions();
|
|
|
1934 |
|
|
|
1935 |
for(FacetRuleDefinition facetRuleDef : facetRuleDefs) {
|
|
|
1936 |
if(facetRuleDef.getSlideDefinitionID() == slideDefinitionID) {
|
|
|
1937 |
return facetRuleDef;
|
|
|
1938 |
}
|
|
|
1939 |
}
|
|
|
1940 |
|
|
|
1941 |
return null;
|
|
|
1942 |
}
|
| 1314 |
rajveer |
1943 |
*/
|
| 88 |
naveen |
1944 |
/**
|
|
|
1945 |
* Returns Facet-Rule definition object defined for a category and
|
|
|
1946 |
* feature definition
|
|
|
1947 |
*
|
|
|
1948 |
* @param categoryID
|
|
|
1949 |
* @param featureDefinitionID
|
|
|
1950 |
* @return FacetRuleDefinition
|
|
|
1951 |
* @throws Exception
|
|
|
1952 |
*/
|
| 1314 |
rajveer |
1953 |
|
|
|
1954 |
/*
|
| 88 |
naveen |
1955 |
public FacetRuleDefinition getFacetRuleDefinitionForFeature(long categoryID,
|
|
|
1956 |
long featureDefinitionID) throws Exception {
|
|
|
1957 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
1958 |
this.getCategoryFacetDefinition(categoryID);
|
| 1074 |
chandransh |
1959 |
if(categoryFacetDef == null){
|
|
|
1960 |
return null;
|
|
|
1961 |
}
|
| 88 |
naveen |
1962 |
List<FacetRuleDefinition> facetRuleDefs =
|
|
|
1963 |
categoryFacetDef.getFacetRuleDefinitions();
|
|
|
1964 |
|
|
|
1965 |
for(FacetRuleDefinition facetRuleDef : facetRuleDefs) {
|
|
|
1966 |
if(facetRuleDef.getFeatureDefinitionID() == featureDefinitionID) {
|
|
|
1967 |
return facetRuleDef;
|
|
|
1968 |
}
|
|
|
1969 |
}
|
|
|
1970 |
|
|
|
1971 |
return null;
|
|
|
1972 |
}
|
| 1314 |
rajveer |
1973 |
*/
|
| 102 |
naveen |
1974 |
/**
|
|
|
1975 |
* Returns all normalization rule defined
|
|
|
1976 |
*
|
|
|
1977 |
* @return Map<Long, RuleDefinition>
|
|
|
1978 |
* @throws Exception
|
|
|
1979 |
*/
|
| 1050 |
rajveer |
1980 |
public Map<Long, RuleDefinition> getNormalizationRules() {
|
| 102 |
naveen |
1981 |
return this.normalizationRuleDefinitions;
|
|
|
1982 |
}
|
|
|
1983 |
|
|
|
1984 |
|
|
|
1985 |
/**
|
|
|
1986 |
* True if feature has normalization rule defined
|
|
|
1987 |
*
|
|
|
1988 |
* @param feature
|
|
|
1989 |
* @return boolean
|
|
|
1990 |
* @throws Exception
|
|
|
1991 |
*/
|
|
|
1992 |
public boolean needsNormalization(long featureDefinitionID)
|
|
|
1993 |
throws Exception {
|
|
|
1994 |
this.getFeatureDefinitions();
|
|
|
1995 |
|
|
|
1996 |
FeatureDefinition featureDef =
|
|
|
1997 |
this.featureDefinitions.get(new Long(featureDefinitionID));
|
|
|
1998 |
|
|
|
1999 |
if(featureDef.getNormalizationRuleDefinitionID() != 0L) {
|
|
|
2000 |
return true;
|
|
|
2001 |
}
|
|
|
2002 |
|
|
|
2003 |
return false;
|
|
|
2004 |
}
|
|
|
2005 |
|
|
|
2006 |
/**
|
|
|
2007 |
* Returns normalization rule definition for rule definition ID
|
|
|
2008 |
*
|
|
|
2009 |
* @param ruleID
|
|
|
2010 |
* @return RuleDefinition
|
|
|
2011 |
* @throws Exception
|
|
|
2012 |
*/
|
| 1050 |
rajveer |
2013 |
public RuleDefinition getNormalizationRuleDefinition(long ruleDefinitionID){
|
|
|
2014 |
return this.normalizationRuleDefinitions.get(new Long(ruleDefinitionID));
|
| 102 |
naveen |
2015 |
}
|
| 2170 |
rajveer |
2016 |
|
|
|
2017 |
public HelpDocDefinition getHelpDocDefinition(long helpDocDefinitionID){
|
|
|
2018 |
return this.helpDocDefinitions.get(helpDocDefinitionID);
|
|
|
2019 |
}
|
| 10 |
shop2020 |
2020 |
}
|