| 10 |
shop2020 |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.metamodel.util;
|
|
|
5 |
|
| 16 |
naveen |
6 |
import in.shop2020.metamodel.definitions.BulletDefinition;
|
| 45 |
naveen |
7 |
import in.shop2020.metamodel.definitions.Catalog;
|
| 10 |
shop2020 |
8 |
import in.shop2020.metamodel.definitions.Category;
|
| 57 |
naveen |
9 |
import in.shop2020.metamodel.definitions.CategoryFacetDefinition;
|
| 10 |
shop2020 |
10 |
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
|
| 16 |
naveen |
11 |
import in.shop2020.metamodel.definitions.CompositeDefinition;
|
|
|
12 |
import in.shop2020.metamodel.definitions.CompositePartDefinition;
|
|
|
13 |
import in.shop2020.metamodel.definitions.DatatypeDefinition;
|
| 45 |
naveen |
14 |
import in.shop2020.metamodel.definitions.DefinitionsContainer;
|
| 10 |
shop2020 |
15 |
import in.shop2020.metamodel.definitions.EditorialImportance;
|
| 16 |
naveen |
16 |
import in.shop2020.metamodel.definitions.EnumDefinition;
|
|
|
17 |
import in.shop2020.metamodel.definitions.EnumValue;
|
| 57 |
naveen |
18 |
import in.shop2020.metamodel.definitions.FacetDefinition;
|
| 16 |
naveen |
19 |
import in.shop2020.metamodel.definitions.FeatureDefinition;
|
| 61 |
naveen |
20 |
import in.shop2020.metamodel.definitions.RuleDefinition;
|
| 16 |
naveen |
21 |
import in.shop2020.metamodel.definitions.SlideDefinition;
|
|
|
22 |
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
|
| 10 |
shop2020 |
23 |
import in.shop2020.metamodel.definitions.Unit;
|
| 57 |
naveen |
24 |
import in.shop2020.metamodel.jaxb.core.BulletDefinitionType;
|
|
|
25 |
import in.shop2020.metamodel.jaxb.core.CategorySlideDefinitionType;
|
|
|
26 |
import in.shop2020.metamodel.jaxb.core.CategoryType;
|
|
|
27 |
import in.shop2020.metamodel.jaxb.core.CompositeDefinitionType;
|
|
|
28 |
import in.shop2020.metamodel.jaxb.core.CompositePartDefinitionType;
|
|
|
29 |
import in.shop2020.metamodel.jaxb.core.DatatypeDefinitionType;
|
|
|
30 |
import in.shop2020.metamodel.jaxb.core.DefinitionType;
|
|
|
31 |
import in.shop2020.metamodel.jaxb.core.EditorialImportanceType;
|
|
|
32 |
import in.shop2020.metamodel.jaxb.core.EnumDefinitionType;
|
|
|
33 |
import in.shop2020.metamodel.jaxb.core.EnumValueType;
|
|
|
34 |
import in.shop2020.metamodel.jaxb.core.FeatureDefinitionType;
|
|
|
35 |
import in.shop2020.metamodel.jaxb.core.SlideDefinitionType;
|
|
|
36 |
import in.shop2020.metamodel.jaxb.core.SlideFeatureDefinitionType;
|
|
|
37 |
import in.shop2020.metamodel.jaxb.core.UnitType;
|
| 61 |
naveen |
38 |
import in.shop2020.metamodel.jaxb.facets.CategoryFacetDefinitionType;
|
|
|
39 |
import in.shop2020.metamodel.jaxb.facets.FacetDefinitionType;
|
| 57 |
naveen |
40 |
import in.shop2020.metamodel.jaxb.facets.IRDefinitionType;
|
| 61 |
naveen |
41 |
import in.shop2020.metamodel.jaxb.facets.RuleDefinitionType;
|
| 18 |
naveen |
42 |
import in.shop2020.util.Utils;
|
| 10 |
shop2020 |
43 |
|
|
|
44 |
import java.io.FileInputStream;
|
| 16 |
naveen |
45 |
import java.util.ArrayList;
|
| 10 |
shop2020 |
46 |
import java.util.HashMap;
|
|
|
47 |
import java.util.Iterator;
|
|
|
48 |
import java.util.List;
|
|
|
49 |
import java.util.Map;
|
| 24 |
naveen |
50 |
import java.util.TreeMap;
|
| 10 |
shop2020 |
51 |
|
|
|
52 |
import javax.xml.bind.JAXBContext;
|
|
|
53 |
import javax.xml.bind.JAXBElement;
|
|
|
54 |
import javax.xml.bind.Unmarshaller;
|
|
|
55 |
|
|
|
56 |
import org.apache.commons.lang.ArrayUtils;
|
|
|
57 |
import org.apache.commons.lang.StringUtils;
|
|
|
58 |
|
|
|
59 |
/**
|
| 51 |
naveen |
60 |
* Command line utility that imports model properties defined in XML
|
|
|
61 |
*
|
| 17 |
naveen |
62 |
* MM - Meta-Model Tool
|
| 10 |
shop2020 |
63 |
*
|
| 51 |
naveen |
64 |
* It can be used to do following things
|
|
|
65 |
*
|
|
|
66 |
* - Import
|
|
|
67 |
* - Datatype definitions
|
|
|
68 |
* - Feature definitions
|
|
|
69 |
* - Slide definitions
|
|
|
70 |
* - Categories
|
|
|
71 |
*
|
|
|
72 |
* - Show
|
|
|
73 |
* - Datatype definitions
|
|
|
74 |
* - Feature definitions
|
|
|
75 |
* - Slide definitions
|
|
|
76 |
* - Categories
|
|
|
77 |
*
|
|
|
78 |
* - Show all definition objects that define a category
|
|
|
79 |
*
|
|
|
80 |
*
|
| 10 |
shop2020 |
81 |
* @author naveen
|
|
|
82 |
*
|
|
|
83 |
*/
|
|
|
84 |
public class MM {
|
| 49 |
naveen |
85 |
/**
|
|
|
86 |
*
|
|
|
87 |
*/
|
| 16 |
naveen |
88 |
public static final String DEFINITIONS_SRC_PATH =
|
|
|
89 |
"/home/naveen/workspace/eclipse/webapp/src/xml/model/";
|
| 34 |
naveen |
90 |
|
| 43 |
naveen |
91 |
// LOCAL
|
| 49 |
naveen |
92 |
/**
|
|
|
93 |
*
|
|
|
94 |
*/
|
| 16 |
naveen |
95 |
public static final String DEFINITIONS_DB_PATH =
|
| 26 |
naveen |
96 |
"/home/naveen/workspace/eclipse/db/definitions/";
|
| 49 |
naveen |
97 |
|
|
|
98 |
/**
|
|
|
99 |
*
|
|
|
100 |
*/
|
| 16 |
naveen |
101 |
public static final String ENTITIES_DB_PATH =
|
| 26 |
naveen |
102 |
"/home/naveen/workspace/eclipse/db/entities/";
|
| 10 |
shop2020 |
103 |
|
| 34 |
naveen |
104 |
/** WEB
|
|
|
105 |
public static final String DEFINITIONS_DB_PATH =
|
|
|
106 |
"/var/lib/tomcat6/webapps/shop2020/db/definitions/";
|
|
|
107 |
public static final String ENTITIES_DB_PATH =
|
|
|
108 |
"/var/lib/tomcat6/webapps/shop2020/db/entities/";
|
|
|
109 |
*/
|
| 43 |
naveen |
110 |
|
|
|
111 |
/** Validation tool
|
|
|
112 |
public static final String DEFINITIONS_DB_PATH =
|
|
|
113 |
"./db/definitions/";
|
|
|
114 |
public static final String ENTITIES_DB_PATH =
|
|
|
115 |
"./db/entities/";
|
|
|
116 |
*/
|
| 34 |
naveen |
117 |
|
| 49 |
naveen |
118 |
/**
|
|
|
119 |
*
|
|
|
120 |
*/
|
| 10 |
shop2020 |
121 |
private String definitionSetName;
|
| 49 |
naveen |
122 |
|
|
|
123 |
/**
|
|
|
124 |
*
|
|
|
125 |
*/
|
| 10 |
shop2020 |
126 |
private String srcFile;
|
| 49 |
naveen |
127 |
|
|
|
128 |
/**
|
|
|
129 |
*
|
|
|
130 |
*/
|
| 10 |
shop2020 |
131 |
private String dbFile;
|
|
|
132 |
|
|
|
133 |
/**
|
| 61 |
naveen |
134 |
* Usage: MM [show|import|showcategory] [units|datatypedefinitions|featuredefinitions|slidedefinitions|categories|facetdefinitions|categoryfacetdefinitions|irdatarules|irmetadatarules] {Category ID}
|
| 51 |
naveen |
135 |
*
|
| 10 |
shop2020 |
136 |
* @param args
|
|
|
137 |
*/
|
|
|
138 |
public static void main(String[] args) throws Exception {
|
| 16 |
naveen |
139 |
String[] definitionSetNames = new String[] {"units",
|
|
|
140 |
"datatypedefinitions", "featuredefinitions", "slidedefinitions",
|
| 61 |
naveen |
141 |
"categories", "facetdefinitions", "categoryfacetdefinitions",
|
|
|
142 |
"irdatarules", "irmetadatarules"};
|
| 10 |
shop2020 |
143 |
|
| 45 |
naveen |
144 |
String[] commands = new String[] {"show", "import", "showcategory"};
|
| 10 |
shop2020 |
145 |
|
| 16 |
naveen |
146 |
String usage = "Usage: MM ["+ StringUtils.join(commands, "|") +"] ["+
|
| 45 |
naveen |
147 |
StringUtils.join(definitionSetNames, "|") + "] {Category ID}";
|
| 16 |
naveen |
148 |
|
| 10 |
shop2020 |
149 |
if(args.length < 2) {
|
|
|
150 |
System.out.println(usage);
|
|
|
151 |
System.exit(-1);
|
|
|
152 |
}
|
| 42 |
naveen |
153 |
Utils.info("MM "+ args[0] + " " + args[1]);
|
| 17 |
naveen |
154 |
|
| 10 |
shop2020 |
155 |
String inputCommand = args[0];
|
|
|
156 |
|
|
|
157 |
if(!ArrayUtils.contains(commands, inputCommand)) {
|
|
|
158 |
System.out.println(usage);
|
|
|
159 |
System.exit(-1);
|
|
|
160 |
}
|
|
|
161 |
|
| 45 |
naveen |
162 |
if(inputCommand.equals("show") || inputCommand.endsWith("import")) {
|
|
|
163 |
String inputDefinitionSet = args[1];
|
|
|
164 |
if(!ArrayUtils.contains(definitionSetNames, inputDefinitionSet)) {
|
|
|
165 |
System.out.println(usage);
|
|
|
166 |
System.exit(-1);
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
MM mm = new MM(inputDefinitionSet);
|
|
|
170 |
if(inputCommand.equals("import")) {
|
|
|
171 |
mm.importDefinitionSet();
|
|
|
172 |
}
|
|
|
173 |
else if(inputCommand.equals("show")) {
|
|
|
174 |
mm.showDefinitionSet();
|
|
|
175 |
}
|
| 10 |
shop2020 |
176 |
}
|
|
|
177 |
|
| 45 |
naveen |
178 |
if(inputCommand.equals("showcategory")) {
|
|
|
179 |
String categoryID = args[1];
|
|
|
180 |
long catID = 0;
|
|
|
181 |
try {
|
|
|
182 |
catID = Long.parseLong(categoryID);
|
|
|
183 |
}
|
|
|
184 |
catch (NumberFormatException nfe) {
|
|
|
185 |
System.out.println("Invalid category ID");
|
|
|
186 |
System.exit(-1);
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
MM mm = new MM();
|
|
|
190 |
mm.showCategory(catID);
|
| 10 |
shop2020 |
191 |
}
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
/**
|
|
|
195 |
*
|
| 45 |
naveen |
196 |
*/
|
|
|
197 |
public MM() {
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
/**
|
|
|
201 |
*
|
| 10 |
shop2020 |
202 |
* @param definitionSet
|
|
|
203 |
*/
|
|
|
204 |
public MM(String definitionSetName) {
|
|
|
205 |
this.definitionSetName = definitionSetName;
|
|
|
206 |
this.srcFile = DEFINITIONS_SRC_PATH + this.definitionSetName + ".xml";
|
|
|
207 |
this.dbFile = DEFINITIONS_DB_PATH + this.definitionSetName + ".ser";
|
|
|
208 |
}
|
|
|
209 |
|
|
|
210 |
/**
|
|
|
211 |
*
|
| 45 |
naveen |
212 |
* @param categoryID
|
|
|
213 |
* @throws Exception
|
| 10 |
shop2020 |
214 |
*/
|
| 45 |
naveen |
215 |
public void showCategory(long categoryID) throws Exception {
|
|
|
216 |
DefinitionsContainer defs =
|
|
|
217 |
Catalog.getInstance().getDefinitionsContainer();
|
|
|
218 |
|
|
|
219 |
ExpandedCategory expCategory = defs.getExpandedCategory(categoryID);
|
|
|
220 |
|
|
|
221 |
Utils.info(expCategory);
|
|
|
222 |
}
|
|
|
223 |
|
|
|
224 |
/**
|
|
|
225 |
*
|
|
|
226 |
*/
|
| 10 |
shop2020 |
227 |
@SuppressWarnings("unchecked")
|
|
|
228 |
public void importDefinitionSet() throws Exception {
|
| 57 |
naveen |
229 |
String type = "core";
|
|
|
230 |
if(this.definitionSetName.equals("facetdefinitions") ||
|
| 61 |
naveen |
231 |
this.definitionSetName.equals("categoryfacetdefinitions") ||
|
|
|
232 |
this.definitionSetName.equals("irdatarules") ||
|
|
|
233 |
this.definitionSetName.equals("irmetadatarules")) {
|
| 57 |
naveen |
234 |
type = "facets";
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
Object oDefType = this.unmarshallSrcFile(this.srcFile, type);
|
|
|
238 |
DefinitionType defType = null;
|
|
|
239 |
IRDefinitionType irDefType = null;
|
|
|
240 |
|
|
|
241 |
if(type.equals("core")) {
|
|
|
242 |
defType = (DefinitionType)oDefType;
|
|
|
243 |
}
|
|
|
244 |
else if (type.equals("facets")) {
|
|
|
245 |
irDefType = (IRDefinitionType)oDefType;
|
|
|
246 |
}
|
|
|
247 |
|
| 16 |
naveen |
248 |
Object objectToStore = null;
|
| 10 |
shop2020 |
249 |
|
| 57 |
naveen |
250 |
// CORE
|
|
|
251 |
|
| 10 |
shop2020 |
252 |
// Units
|
|
|
253 |
if(this.definitionSetName.equals("units")) {
|
|
|
254 |
Map unitsMap = this.convertUnits(defType);
|
| 16 |
naveen |
255 |
objectToStore = unitsMap;
|
| 10 |
shop2020 |
256 |
}
|
|
|
257 |
|
|
|
258 |
// Categories
|
|
|
259 |
else if(this.definitionSetName.equals("categories")) {
|
|
|
260 |
Map<Long, Category> categoriesMap = new HashMap<Long, Category>();
|
|
|
261 |
Category root = this.convertCategories(defType, categoriesMap);
|
| 42 |
naveen |
262 |
//Utils.info(categoriesMap);
|
|
|
263 |
//Utils.info(root);
|
| 10 |
shop2020 |
264 |
//System.exit(0);
|
|
|
265 |
|
|
|
266 |
// Tree
|
| 16 |
naveen |
267 |
String categoryTreeDBFile = DEFINITIONS_DB_PATH + "categorytree" +
|
|
|
268 |
".ser";
|
|
|
269 |
|
| 10 |
shop2020 |
270 |
if(root != null) {
|
| 17 |
naveen |
271 |
DBUtils.store(root, categoryTreeDBFile);
|
| 10 |
shop2020 |
272 |
}
|
|
|
273 |
|
|
|
274 |
// Map
|
| 16 |
naveen |
275 |
objectToStore = categoriesMap;
|
| 10 |
shop2020 |
276 |
}
|
| 16 |
naveen |
277 |
|
|
|
278 |
// Datatype Definitions
|
|
|
279 |
else if(this.definitionSetName.equals("datatypedefinitions")) {
|
| 24 |
naveen |
280 |
Map<Long, DatatypeDefinition> datatypeDefsMap =
|
|
|
281 |
this.convertDatatypeDefinition(defType);
|
| 16 |
naveen |
282 |
|
| 24 |
naveen |
283 |
// Store enum value id to value map separately
|
|
|
284 |
String enumValueDBFile = DEFINITIONS_DB_PATH + "enumvalues" +
|
|
|
285 |
".ser";
|
|
|
286 |
|
|
|
287 |
// RE-VISIT - May not be optimal
|
|
|
288 |
Map<Long, EnumValue> enumValuesMap = new TreeMap<Long, EnumValue>();
|
|
|
289 |
for(Long datatypeDefID : datatypeDefsMap.keySet()) {
|
|
|
290 |
DatatypeDefinition datatypeDef =
|
|
|
291 |
datatypeDefsMap.get(datatypeDefID);
|
|
|
292 |
|
|
|
293 |
if(datatypeDef instanceof EnumDefinition) {
|
|
|
294 |
List<EnumValue> enumValues =
|
|
|
295 |
((EnumDefinition) datatypeDef).getEnumValues();
|
|
|
296 |
|
|
|
297 |
for(EnumValue enumValue : enumValues) {
|
|
|
298 |
enumValuesMap.put(new Long(enumValue.getID()),
|
|
|
299 |
enumValue);
|
|
|
300 |
}
|
|
|
301 |
}
|
|
|
302 |
}
|
| 42 |
naveen |
303 |
Utils.info("enumValuesMap=" + enumValuesMap);
|
| 24 |
naveen |
304 |
DBUtils.store(enumValuesMap, enumValueDBFile);
|
|
|
305 |
|
| 16 |
naveen |
306 |
objectToStore = datatypeDefsMap;
|
|
|
307 |
}
|
|
|
308 |
|
|
|
309 |
// Feature Definitions
|
|
|
310 |
else if(this.definitionSetName.equals("featuredefinitions")) {
|
|
|
311 |
Map featureDefsMap = this.convertFeatureDefinitions(defType);
|
|
|
312 |
|
|
|
313 |
objectToStore = featureDefsMap;
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
// Slide Definitions
|
|
|
317 |
else if(this.definitionSetName.equals("slidedefinitions")) {
|
|
|
318 |
Map slideDefsMap = this.convertSlideDefinitions(defType);
|
|
|
319 |
|
|
|
320 |
objectToStore = slideDefsMap;
|
|
|
321 |
}
|
|
|
322 |
|
| 57 |
naveen |
323 |
// FACETS
|
|
|
324 |
|
|
|
325 |
// Facet Definitions
|
|
|
326 |
else if(this.definitionSetName.equals("facetdefinitions")) {
|
|
|
327 |
Map facetDefsMap = this.convertFacetDefinitions(irDefType);
|
|
|
328 |
|
|
|
329 |
objectToStore = facetDefsMap;
|
|
|
330 |
}
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
// Category Facet Definitions
|
|
|
334 |
else if(this.definitionSetName.equals("categoryfacetdefinitions")) {
|
|
|
335 |
Map categoryFacetDefsMap =
|
|
|
336 |
this.convertCategoryFacetDefinitions(irDefType);
|
|
|
337 |
|
|
|
338 |
objectToStore = categoryFacetDefsMap;
|
|
|
339 |
}
|
|
|
340 |
|
| 61 |
naveen |
341 |
// IR Data Rules
|
|
|
342 |
else if(this.definitionSetName.equals("irdatarules")) {
|
|
|
343 |
Map irdataRuleDefsMap =
|
|
|
344 |
this.convertRuleDefinitions(irDefType);
|
|
|
345 |
|
|
|
346 |
objectToStore = irdataRuleDefsMap;
|
|
|
347 |
}
|
|
|
348 |
|
|
|
349 |
// IR Meta-Data Rules
|
|
|
350 |
else if(this.definitionSetName.equals("irmetadatarules")) {
|
|
|
351 |
Map irmetadataRuleDefsMap =
|
|
|
352 |
this.convertRuleDefinitions(irDefType);
|
|
|
353 |
|
|
|
354 |
objectToStore = irmetadataRuleDefsMap;
|
|
|
355 |
}
|
|
|
356 |
|
| 16 |
naveen |
357 |
if(objectToStore != null) {
|
| 17 |
naveen |
358 |
DBUtils.store(objectToStore, this.dbFile);
|
| 16 |
naveen |
359 |
}
|
| 10 |
shop2020 |
360 |
}
|
|
|
361 |
|
|
|
362 |
/**
|
|
|
363 |
*
|
|
|
364 |
*/
|
|
|
365 |
public void showDefinitionSet() throws Exception {
|
| 17 |
naveen |
366 |
Object obj = DBUtils.read(this.dbFile);
|
| 42 |
naveen |
367 |
Utils.info(obj.toString());
|
| 10 |
shop2020 |
368 |
|
|
|
369 |
if(this.definitionSetName.equals("categories")) {
|
| 16 |
naveen |
370 |
String categoryTreeDBFile = DEFINITIONS_DB_PATH + "categorytree" +
|
|
|
371 |
".ser";
|
|
|
372 |
|
| 17 |
naveen |
373 |
Category root = (Category)DBUtils.read(categoryTreeDBFile);
|
| 42 |
naveen |
374 |
Utils.info(root.toString());
|
|
|
375 |
//Utils.info("root.getChildrenCategory().size: " +
|
| 18 |
naveen |
376 |
// root.getChildrenCategory().size());
|
| 10 |
shop2020 |
377 |
}
|
|
|
378 |
}
|
|
|
379 |
|
|
|
380 |
/**
|
|
|
381 |
*
|
| 57 |
naveen |
382 |
* @param defType
|
|
|
383 |
* @return
|
|
|
384 |
*/
|
| 61 |
naveen |
385 |
private Map<Long, RuleDefinition> convertRuleDefinitions(
|
|
|
386 |
IRDefinitionType defType) {
|
|
|
387 |
Map<Long, RuleDefinition> idRuleDef =
|
|
|
388 |
new TreeMap<Long, RuleDefinition>();
|
|
|
389 |
|
|
|
390 |
List<RuleDefinitionType> jaxbRuleDefs = defType.getRuleDefinition();
|
|
|
391 |
|
|
|
392 |
for(RuleDefinitionType jaxbRuleDef : jaxbRuleDefs) {
|
|
|
393 |
long id = jaxbRuleDef.getID();
|
|
|
394 |
String script = jaxbRuleDef.getScript();
|
|
|
395 |
|
|
|
396 |
RuleDefinition ruleDef = new RuleDefinition(id, script);
|
|
|
397 |
ruleDef.setDescription(jaxbRuleDef.getDescription());
|
|
|
398 |
|
|
|
399 |
idRuleDef.put(new Long(id), ruleDef);
|
|
|
400 |
}
|
|
|
401 |
|
|
|
402 |
Utils.info("idRuleDef=" + idRuleDef);
|
|
|
403 |
return idRuleDef;
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
/**
|
|
|
407 |
*
|
|
|
408 |
* @param defType
|
|
|
409 |
* @return
|
|
|
410 |
*/
|
| 57 |
naveen |
411 |
private Map<Long, FacetDefinition> convertFacetDefinitions(
|
|
|
412 |
IRDefinitionType defType) {
|
| 61 |
naveen |
413 |
List<FacetDefinitionType> jaxbFacetDefs = defType.getFacetDefinition();
|
|
|
414 |
|
|
|
415 |
Map<Long, FacetDefinition> idFacetDefs =
|
|
|
416 |
new TreeMap<Long, FacetDefinition>();
|
|
|
417 |
|
|
|
418 |
for(FacetDefinitionType jaxbFacetDef : jaxbFacetDefs) {
|
|
|
419 |
long id = jaxbFacetDef.getID();
|
|
|
420 |
String target = jaxbFacetDef.getTarget();
|
|
|
421 |
|
|
|
422 |
FacetDefinition facetDef = new FacetDefinition(id, target);
|
|
|
423 |
|
|
|
424 |
if(jaxbFacetDef.getFeatureDefinitionID() != null) {
|
|
|
425 |
long featureDefID = jaxbFacetDef.getFeatureDefinitionID();
|
|
|
426 |
facetDef.setFeatureDefinitionID(featureDefID);
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
if(jaxbFacetDef.getSlideDefinitionID() != null) {
|
|
|
430 |
long slideDefID = jaxbFacetDef.getSlideDefinitionID();
|
|
|
431 |
facetDef.setSlideDefinitionID(slideDefID);
|
|
|
432 |
}
|
|
|
433 |
|
| 62 |
naveen |
434 |
long irDataRuleID = jaxbFacetDef.getIRDataRuleID();
|
|
|
435 |
facetDef.setIrDataRuleID(irDataRuleID);
|
| 61 |
naveen |
436 |
|
| 62 |
naveen |
437 |
long irMetaDataRuleID = jaxbFacetDef.getIRMetaDataRuleID();
|
|
|
438 |
facetDef.setIrMetaDataRuleID(irMetaDataRuleID);
|
|
|
439 |
|
| 61 |
naveen |
440 |
facetDef.setDescription(jaxbFacetDef.getDescription());
|
|
|
441 |
|
|
|
442 |
idFacetDefs.put(new Long(id), facetDef);
|
|
|
443 |
}
|
|
|
444 |
Utils.info("idFacetDefs=" + idFacetDefs);
|
|
|
445 |
return idFacetDefs;
|
| 57 |
naveen |
446 |
}
|
|
|
447 |
|
|
|
448 |
/**
|
|
|
449 |
*
|
|
|
450 |
* @param defType
|
|
|
451 |
* @return
|
| 61 |
naveen |
452 |
* @throws Exception
|
| 57 |
naveen |
453 |
*/
|
|
|
454 |
private Map<Long, CategoryFacetDefinition> convertCategoryFacetDefinitions(
|
| 61 |
naveen |
455 |
IRDefinitionType defType) throws Exception {
|
|
|
456 |
List<CategoryFacetDefinitionType> jaxbCategoryFacetDefs =
|
|
|
457 |
defType.getCategoryFacetDefinition();
|
|
|
458 |
|
|
|
459 |
Map<Long, CategoryFacetDefinition> idCategoryFacetDefs =
|
|
|
460 |
new TreeMap<Long, CategoryFacetDefinition>();
|
|
|
461 |
|
|
|
462 |
for(CategoryFacetDefinitionType jaxbCategoryFacetDef :
|
|
|
463 |
jaxbCategoryFacetDefs) {
|
|
|
464 |
long categoryID = jaxbCategoryFacetDef.getCategoryID();
|
|
|
465 |
|
| 62 |
naveen |
466 |
List<Long> jaxbFacetDefIDs =
|
|
|
467 |
jaxbCategoryFacetDef.getFacetDefinitionID();
|
| 61 |
naveen |
468 |
|
|
|
469 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
470 |
new CategoryFacetDefinition(categoryID);
|
|
|
471 |
|
| 62 |
naveen |
472 |
categoryFacetDef.setFacetDefinitionIDs(jaxbFacetDefIDs);
|
| 61 |
naveen |
473 |
|
|
|
474 |
idCategoryFacetDefs.put(new Long(categoryID), categoryFacetDef);
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
// Append parent's facets
|
|
|
478 |
// Go only one level for now
|
|
|
479 |
// Categories need to be imported first
|
|
|
480 |
DefinitionsContainer defs =
|
|
|
481 |
Catalog.getInstance().getDefinitionsContainer();
|
|
|
482 |
|
|
|
483 |
for(Long categoryID : idCategoryFacetDefs.keySet()) {
|
|
|
484 |
Category category = defs.getCategory(categoryID.longValue());
|
|
|
485 |
Category parentCategory = category.getParentCategory();
|
|
|
486 |
|
|
|
487 |
if(parentCategory != null) {
|
|
|
488 |
long parentCategoryID = parentCategory.getID();
|
|
|
489 |
|
|
|
490 |
CategoryFacetDefinition parentCategoryFacetDef =
|
|
|
491 |
idCategoryFacetDefs.get(new Long(parentCategoryID));
|
|
|
492 |
|
|
|
493 |
if(parentCategoryFacetDef != null) {
|
|
|
494 |
List<Long> parentsFacetIDs =
|
| 62 |
naveen |
495 |
parentCategoryFacetDef.getFacetDefinitionIDs();
|
| 61 |
naveen |
496 |
|
|
|
497 |
if(parentsFacetIDs != null) {
|
|
|
498 |
CategoryFacetDefinition categoryFacetDef =
|
|
|
499 |
idCategoryFacetDefs.get(categoryID);
|
|
|
500 |
|
| 62 |
naveen |
501 |
categoryFacetDef.appendFacetDefinitionIDs(
|
|
|
502 |
parentsFacetIDs);
|
| 61 |
naveen |
503 |
}
|
|
|
504 |
}
|
|
|
505 |
}
|
|
|
506 |
}
|
|
|
507 |
|
|
|
508 |
Utils.info("idCategoryFacetDefs=" + idCategoryFacetDefs);
|
|
|
509 |
return idCategoryFacetDefs;
|
| 57 |
naveen |
510 |
}
|
|
|
511 |
|
|
|
512 |
/**
|
|
|
513 |
*
|
| 10 |
shop2020 |
514 |
* @return Map
|
|
|
515 |
*/
|
| 16 |
naveen |
516 |
private Map<Long, SlideDefinition> convertSlideDefinitions(
|
|
|
517 |
DefinitionType defType) {
|
|
|
518 |
|
|
|
519 |
Map<Long, SlideDefinition> defs =
|
|
|
520 |
new HashMap<Long, SlideDefinition>();
|
|
|
521 |
|
|
|
522 |
List<SlideDefinitionType> jaxbDefs = defType.getSlideDefinition();
|
|
|
523 |
Iterator<SlideDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
524 |
|
|
|
525 |
// Slide definitions
|
|
|
526 |
while(itjaxbDefs.hasNext()) {
|
|
|
527 |
SlideDefinitionType jaxbDef = itjaxbDefs.next();
|
|
|
528 |
|
| 42 |
naveen |
529 |
Utils.info("Slide label=" + jaxbDef.getLabel());
|
| 16 |
naveen |
530 |
SlideDefinition def = new SlideDefinition(jaxbDef.getID(),
|
|
|
531 |
jaxbDef.getLabel());
|
|
|
532 |
def.setDescription(jaxbDef.getDescription());
|
|
|
533 |
|
| 42 |
naveen |
534 |
// Children Slides
|
|
|
535 |
Utils.info("jaxbDef.getChildSlideID=" + jaxbDef.getChildSlideID());
|
|
|
536 |
def.setChildrenSlideDefinitionIDs(jaxbDef.getChildSlideID());
|
|
|
537 |
|
| 16 |
naveen |
538 |
// Slide Feature Definition
|
|
|
539 |
List<SlideFeatureDefinitionType> jaxbSlideFeatureDefs =
|
|
|
540 |
jaxbDef.getSlideFeatureDefinition();
|
|
|
541 |
|
|
|
542 |
if(jaxbSlideFeatureDefs != null) {
|
|
|
543 |
def.setSlideFeatureDefinitions((
|
|
|
544 |
this.convertSlideFeatureDefinitions(
|
|
|
545 |
jaxbSlideFeatureDefs)));
|
|
|
546 |
}
|
| 42 |
naveen |
547 |
Utils.info("def=" + def);
|
| 16 |
naveen |
548 |
|
|
|
549 |
defs.put(new Long(jaxbDef.getID()), def);
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
return defs;
|
|
|
553 |
}
|
|
|
554 |
|
|
|
555 |
/**
|
|
|
556 |
*
|
|
|
557 |
* @param jaxbDefs
|
|
|
558 |
* @return List<SlideFeatureDefinition>
|
|
|
559 |
*/
|
|
|
560 |
private List<SlideFeatureDefinition> convertSlideFeatureDefinitions(
|
|
|
561 |
List<SlideFeatureDefinitionType> jaxbDefs) {
|
|
|
562 |
|
|
|
563 |
List<SlideFeatureDefinition> defs =
|
|
|
564 |
new ArrayList<SlideFeatureDefinition>();
|
|
|
565 |
|
|
|
566 |
Iterator<SlideFeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
567 |
|
|
|
568 |
// Slide-feature definitions
|
|
|
569 |
while(itjaxbDefs.hasNext()) {
|
|
|
570 |
SlideFeatureDefinitionType jaxbDef = itjaxbDefs.next();
|
|
|
571 |
SlideFeatureDefinition def = new SlideFeatureDefinition(
|
|
|
572 |
jaxbDef.getFeatureDefinitionID());
|
|
|
573 |
|
|
|
574 |
def.setEditorialImportance(this.convertEditorialImportance(
|
|
|
575 |
jaxbDef.getEditorialImportance()));
|
|
|
576 |
|
|
|
577 |
def.setDescription(jaxbDef.getDescription());
|
|
|
578 |
|
|
|
579 |
defs.add(def);
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
return defs;
|
|
|
583 |
}
|
|
|
584 |
|
|
|
585 |
/**
|
|
|
586 |
*
|
| 49 |
naveen |
587 |
* @param defType
|
|
|
588 |
* @return
|
| 16 |
naveen |
589 |
*/
|
|
|
590 |
private Map<Long, FeatureDefinition> convertFeatureDefinitions(
|
|
|
591 |
DefinitionType defType) {
|
|
|
592 |
|
|
|
593 |
Map<Long, FeatureDefinition> defs =
|
|
|
594 |
new HashMap<Long, FeatureDefinition>();
|
|
|
595 |
|
|
|
596 |
List<FeatureDefinitionType> jaxbDefs = defType.getFeatureDefinition();
|
|
|
597 |
Iterator<FeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
|
|
|
598 |
|
|
|
599 |
// Feature definitions
|
|
|
600 |
while(itjaxbDefs.hasNext()) {
|
|
|
601 |
FeatureDefinitionType jaxbDef = itjaxbDefs.next();
|
|
|
602 |
|
| 42 |
naveen |
603 |
//Utils.info("Feature label=" + jaxbDef.getLabel());
|
| 16 |
naveen |
604 |
FeatureDefinition def = new FeatureDefinition(jaxbDef.getID(),
|
|
|
605 |
jaxbDef.getLabel());
|
|
|
606 |
def.setAllowsBlank(jaxbDef.isCanbeBlank());
|
|
|
607 |
def.setDescription(jaxbDef.getDescription());
|
|
|
608 |
|
|
|
609 |
// Bullet Definition
|
|
|
610 |
BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
|
|
|
611 |
if(jaxbBulletDef != null) {
|
|
|
612 |
def.setBulletDefinition(this.convertBulletDefinition(
|
|
|
613 |
jaxbBulletDef));
|
|
|
614 |
}
|
| 42 |
naveen |
615 |
Utils.info("def=" + def);
|
| 16 |
naveen |
616 |
|
|
|
617 |
defs.put(new Long(jaxbDef.getID()), def);
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
return defs;
|
|
|
621 |
}
|
|
|
622 |
|
|
|
623 |
/**
|
|
|
624 |
*
|
|
|
625 |
* @param jaxbDef BulletDefinitionType
|
|
|
626 |
* @return BulletDefinition
|
|
|
627 |
*/
|
|
|
628 |
private BulletDefinition convertBulletDefinition(
|
|
|
629 |
BulletDefinitionType jaxbDef) {
|
|
|
630 |
|
|
|
631 |
BulletDefinition def = new BulletDefinition(
|
|
|
632 |
jaxbDef.getDatatypeDefinitionID());
|
|
|
633 |
|
|
|
634 |
Long unitID = jaxbDef.getUnitID();
|
|
|
635 |
if(unitID != null) {
|
|
|
636 |
def.setUnitID(unitID.longValue());
|
|
|
637 |
}
|
| 47 |
naveen |
638 |
Utils.info("jaxbDef.isIsMultivalue=" + jaxbDef.isIsMultivalue());
|
|
|
639 |
|
| 16 |
naveen |
640 |
def.setMultivalue(jaxbDef.isIsMultivalue());
|
|
|
641 |
def.setLearned(jaxbDef.isIsLearned());
|
|
|
642 |
def.setDescription(jaxbDef.getDescription());
|
|
|
643 |
|
|
|
644 |
return def;
|
|
|
645 |
}
|
| 49 |
naveen |
646 |
|
| 16 |
naveen |
647 |
/**
|
|
|
648 |
*
|
| 49 |
naveen |
649 |
* @param defType
|
|
|
650 |
* @return
|
| 16 |
naveen |
651 |
*/
|
|
|
652 |
private Map<Long, DatatypeDefinition> convertDatatypeDefinition(
|
|
|
653 |
DefinitionType defType) {
|
|
|
654 |
|
|
|
655 |
Map<Long, DatatypeDefinition> defs =
|
|
|
656 |
new HashMap<Long, DatatypeDefinition>();
|
|
|
657 |
|
|
|
658 |
List<DatatypeDefinitionType> jaxbDefs = defType.getDatatypeDefinition();
|
|
|
659 |
Iterator<DatatypeDefinitionType> it = jaxbDefs.iterator();
|
|
|
660 |
|
|
|
661 |
while(it.hasNext()) {
|
|
|
662 |
DatatypeDefinitionType jaxbDef = it.next();
|
|
|
663 |
|
|
|
664 |
DatatypeDefinition def = null;
|
|
|
665 |
CompositeDefinitionType compositeDefType =
|
|
|
666 |
jaxbDef.getCompositeDefinition();
|
|
|
667 |
|
|
|
668 |
EnumDefinitionType enumDefType =
|
|
|
669 |
jaxbDef.getEnumDefinition();
|
|
|
670 |
|
|
|
671 |
// Composite data type
|
|
|
672 |
if(compositeDefType != null) {
|
|
|
673 |
CompositeDefinition compDef = new CompositeDefinition(
|
| 20 |
naveen |
674 |
jaxbDef.getID(), jaxbDef.getName(),
|
|
|
675 |
compositeDefType.getSeparator());
|
| 16 |
naveen |
676 |
|
|
|
677 |
List<CompositePartDefinitionType> jaxbPartDefs =
|
|
|
678 |
compositeDefType.getCompositePartDefinition();
|
|
|
679 |
|
|
|
680 |
Iterator<CompositePartDefinitionType> itPartDefs =
|
|
|
681 |
jaxbPartDefs.iterator();
|
|
|
682 |
|
|
|
683 |
// Collect parts
|
|
|
684 |
while(itPartDefs.hasNext()) {
|
|
|
685 |
CompositePartDefinitionType jaxbPartDef = itPartDefs.next();
|
|
|
686 |
CompositePartDefinition partDef =
|
|
|
687 |
this.convertCompositePartDefinition(jaxbPartDef);
|
|
|
688 |
|
|
|
689 |
compDef.addCompositePartDefinition(partDef);
|
|
|
690 |
}
|
|
|
691 |
|
|
|
692 |
def = compDef;
|
|
|
693 |
}
|
|
|
694 |
|
|
|
695 |
// Enumerated values
|
|
|
696 |
else if(enumDefType != null) {
|
|
|
697 |
EnumDefinition enumDef = new EnumDefinition(jaxbDef.getID(),
|
|
|
698 |
jaxbDef.getName());
|
|
|
699 |
|
|
|
700 |
List<EnumValueType> jaxbEnumValues =
|
|
|
701 |
enumDefType.getEnumValue();
|
|
|
702 |
|
|
|
703 |
Iterator<EnumValueType> itEnumValues =
|
|
|
704 |
jaxbEnumValues.iterator();
|
|
|
705 |
|
|
|
706 |
// Collect individual value
|
|
|
707 |
while(itEnumValues.hasNext()) {
|
|
|
708 |
EnumValueType jaxbEnumValue = itEnumValues.next();
|
|
|
709 |
EnumValue enumValue =
|
|
|
710 |
this.convertEnumValueDefinition(jaxbEnumValue);
|
|
|
711 |
|
|
|
712 |
enumDef.addEnumValue(enumValue);
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
def = enumDef;
|
|
|
716 |
}
|
|
|
717 |
|
|
|
718 |
// Primitive
|
|
|
719 |
else {
|
|
|
720 |
def = new DatatypeDefinition(jaxbDef.getID(),
|
|
|
721 |
jaxbDef.getName());
|
|
|
722 |
}
|
|
|
723 |
|
|
|
724 |
def.setDescription(jaxbDef.getDescription());
|
| 42 |
naveen |
725 |
Utils.info("def=" + def);
|
| 16 |
naveen |
726 |
|
|
|
727 |
defs.put(new Long(jaxbDef.getID()), def);
|
|
|
728 |
}
|
|
|
729 |
|
|
|
730 |
return defs;
|
|
|
731 |
}
|
|
|
732 |
|
|
|
733 |
/**
|
|
|
734 |
*
|
|
|
735 |
* @param jaxbEnumValue
|
|
|
736 |
* @return EnumValue
|
|
|
737 |
*/
|
|
|
738 |
private EnumValue convertEnumValueDefinition(EnumValueType jaxbEnumValue) {
|
|
|
739 |
|
|
|
740 |
EnumValue enumValue = new EnumValue(jaxbEnumValue.getID(),
|
|
|
741 |
jaxbEnumValue.getValue());
|
|
|
742 |
|
|
|
743 |
return enumValue;
|
|
|
744 |
}
|
|
|
745 |
/**
|
|
|
746 |
*
|
|
|
747 |
* @param jaxbPartDef
|
|
|
748 |
* @return CompositePartDefinition
|
|
|
749 |
*/
|
|
|
750 |
private CompositePartDefinition convertCompositePartDefinition(
|
|
|
751 |
CompositePartDefinitionType jaxbPartDef) {
|
|
|
752 |
|
|
|
753 |
CompositePartDefinition partDef = new CompositePartDefinition(
|
|
|
754 |
jaxbPartDef.getLabel(), jaxbPartDef.getDatatypeDefinitionID(),
|
|
|
755 |
jaxbPartDef.getUnitID());
|
|
|
756 |
|
|
|
757 |
partDef.setDescription(jaxbPartDef.getDescription());
|
|
|
758 |
|
|
|
759 |
return partDef;
|
|
|
760 |
}
|
| 49 |
naveen |
761 |
|
| 16 |
naveen |
762 |
/**
|
|
|
763 |
*
|
| 49 |
naveen |
764 |
* @param defType
|
|
|
765 |
* @param catMap
|
|
|
766 |
* @return
|
| 16 |
naveen |
767 |
*/
|
|
|
768 |
private Category convertCategories(DefinitionType defType,
|
|
|
769 |
Map<Long, Category> catMap) {
|
| 10 |
shop2020 |
770 |
|
|
|
771 |
List<CategoryType> jaxbCats = defType.getCategory();
|
|
|
772 |
Iterator<CategoryType> it = jaxbCats.iterator();
|
|
|
773 |
|
|
|
774 |
// Get root category
|
|
|
775 |
CategoryType jaxbCat = it.next();
|
|
|
776 |
if(jaxbCat == null) {
|
| 42 |
naveen |
777 |
Utils.info("Invalid file: " + this.srcFile);
|
| 10 |
shop2020 |
778 |
return null;
|
|
|
779 |
}
|
|
|
780 |
|
|
|
781 |
Category root = this.convertCategoryType(jaxbCat, null, catMap);
|
| 42 |
naveen |
782 |
Utils.info("catMap.get(10002)=" + catMap.get(new Long(10002)));
|
| 32 |
naveen |
783 |
|
| 10 |
shop2020 |
784 |
return root;
|
|
|
785 |
}
|
|
|
786 |
|
|
|
787 |
/**
|
|
|
788 |
*
|
|
|
789 |
* @param jaxbCat
|
| 49 |
naveen |
790 |
* @param parentCat
|
|
|
791 |
* @param catMap
|
|
|
792 |
* @return
|
| 10 |
shop2020 |
793 |
*/
|
| 32 |
naveen |
794 |
@SuppressWarnings("unchecked")
|
| 16 |
naveen |
795 |
private Category convertCategoryType(CategoryType jaxbCat,
|
|
|
796 |
Category parentCat, Map<Long, Category> catMap) {
|
| 18 |
naveen |
797 |
|
| 10 |
shop2020 |
798 |
Category cat = new Category(jaxbCat.getID());
|
|
|
799 |
cat.setLabel(jaxbCat.getName());
|
|
|
800 |
cat.setDescription(jaxbCat.getDescription());
|
|
|
801 |
if(parentCat != null) {
|
|
|
802 |
cat.setParentCategory(parentCat);
|
| 32 |
naveen |
803 |
|
|
|
804 |
// Copy parent's category-slide definitions
|
|
|
805 |
ArrayList<CategorySlideDefinition> parentCSDef =
|
|
|
806 |
(ArrayList<CategorySlideDefinition>)
|
|
|
807 |
parentCat.getCategorySlideDefintions();
|
|
|
808 |
|
|
|
809 |
if(parentCSDef != null) {
|
|
|
810 |
cat.setCategorySlideDefintions(
|
|
|
811 |
(List<CategorySlideDefinition>) parentCSDef.clone());
|
|
|
812 |
}
|
| 10 |
shop2020 |
813 |
}
|
|
|
814 |
|
|
|
815 |
// Category Slide Definition
|
| 32 |
naveen |
816 |
List<CategorySlideDefinitionType> jaxbDefs =
|
|
|
817 |
jaxbCat.getCategorySlideDefinition();
|
|
|
818 |
|
| 10 |
shop2020 |
819 |
Iterator<CategorySlideDefinitionType> it = jaxbDefs.iterator();
|
|
|
820 |
while(it.hasNext()) {
|
|
|
821 |
CategorySlideDefinitionType jaxbDef = it.next();
|
| 32 |
naveen |
822 |
CategorySlideDefinition catSlideDef
|
|
|
823 |
= this.convertCategorySlideDefinitionType(jaxbCat.getID(), jaxbDef);
|
|
|
824 |
|
| 10 |
shop2020 |
825 |
cat.addCategorySlideDefintion(catSlideDef);
|
|
|
826 |
}
|
|
|
827 |
|
|
|
828 |
// Children
|
|
|
829 |
List<CategoryType> jaxbChildren = jaxbCat.getChildCategory();
|
| 42 |
naveen |
830 |
//Utils.info("jaxbChildren.size: " + jaxbChildren.size());
|
| 10 |
shop2020 |
831 |
|
|
|
832 |
Iterator<CategoryType> itChildren = jaxbChildren.iterator();
|
|
|
833 |
while(itChildren.hasNext()) {
|
|
|
834 |
CategoryType jaxbChildCat = itChildren.next();
|
| 32 |
naveen |
835 |
Category childCat = this.convertCategoryType(jaxbChildCat, cat,
|
|
|
836 |
catMap);
|
| 10 |
shop2020 |
837 |
cat.addChild(childCat);
|
|
|
838 |
}
|
| 42 |
naveen |
839 |
//Utils.info("Parent cat: " + cat);
|
| 32 |
naveen |
840 |
// DEBUG ONLY
|
| 42 |
naveen |
841 |
Utils.info("####### Cat ID: " + cat.getID());
|
| 32 |
naveen |
842 |
if(cat.getCategorySlideDefintions() != null) {
|
|
|
843 |
for(CategorySlideDefinition csd : cat.getCategorySlideDefintions()){
|
| 42 |
naveen |
844 |
Utils.info("####### SlideDefintionID=" +
|
| 32 |
naveen |
845 |
csd.getSlideDefintionID());
|
|
|
846 |
}
|
|
|
847 |
}
|
|
|
848 |
|
| 10 |
shop2020 |
849 |
catMap.put(new Long(jaxbCat.getID()), cat);
|
|
|
850 |
return cat;
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
/**
|
|
|
854 |
*
|
| 49 |
naveen |
855 |
* @param categoryID
|
| 10 |
shop2020 |
856 |
* @param jaxbDef
|
|
|
857 |
* @return
|
|
|
858 |
*/
|
| 16 |
naveen |
859 |
private CategorySlideDefinition convertCategorySlideDefinitionType(
|
|
|
860 |
long categoryID, CategorySlideDefinitionType jaxbDef) {
|
|
|
861 |
|
| 10 |
shop2020 |
862 |
CategorySlideDefinition catSlideDef = new CategorySlideDefinition(
|
| 32 |
naveen |
863 |
jaxbDef.getSlideDefinitionID());
|
| 10 |
shop2020 |
864 |
|
|
|
865 |
catSlideDef.setDescription(jaxbDef.getDescription());
|
|
|
866 |
|
|
|
867 |
EditorialImportanceType jaxbEdImp = jaxbDef.getEditorialImportance();
|
|
|
868 |
EditorialImportance edImp = this.convertEditorialImportance(jaxbEdImp);
|
|
|
869 |
catSlideDef.setEditorialImportance(edImp);
|
|
|
870 |
|
|
|
871 |
return catSlideDef;
|
|
|
872 |
}
|
|
|
873 |
|
|
|
874 |
/**
|
|
|
875 |
*
|
|
|
876 |
* @return Map
|
|
|
877 |
*/
|
|
|
878 |
private Map<Long, Unit> convertUnits(DefinitionType defType) {
|
|
|
879 |
|
|
|
880 |
Map<Long, Unit> allUnits = new HashMap<Long, Unit>();
|
|
|
881 |
List<UnitType> jaxbUnits = defType.getUnit();
|
|
|
882 |
Iterator<UnitType> it = jaxbUnits.iterator();
|
|
|
883 |
|
|
|
884 |
while(it.hasNext()) {
|
|
|
885 |
UnitType jaxbUnit = it.next();
|
|
|
886 |
|
|
|
887 |
Unit unit = new Unit(jaxbUnit.getID());
|
|
|
888 |
unit.setDescription(jaxbUnit.getDescription());
|
|
|
889 |
unit.setFullForm(jaxbUnit.getFullform());
|
|
|
890 |
unit.setShortForm(jaxbUnit.getShortform());
|
| 42 |
naveen |
891 |
Utils.info("unit=" + unit);
|
| 10 |
shop2020 |
892 |
|
|
|
893 |
allUnits.put(new Long(jaxbUnit.getID()), unit);
|
|
|
894 |
}
|
|
|
895 |
|
|
|
896 |
return allUnits;
|
|
|
897 |
}
|
| 49 |
naveen |
898 |
|
| 10 |
shop2020 |
899 |
/**
|
|
|
900 |
*
|
| 49 |
naveen |
901 |
* @param srcFile
|
|
|
902 |
* @return
|
|
|
903 |
* @throws Exception
|
| 10 |
shop2020 |
904 |
*/
|
| 57 |
naveen |
905 |
private Object unmarshallSrcFile(String srcFile, String type)
|
|
|
906 |
throws Exception {
|
| 10 |
shop2020 |
907 |
|
| 57 |
naveen |
908 |
JAXBContext jc = JAXBContext.newInstance("in.shop2020.metamodel.jaxb." +
|
|
|
909 |
type);
|
| 10 |
shop2020 |
910 |
|
|
|
911 |
// create an Unmarshaller
|
|
|
912 |
Unmarshaller u = jc.createUnmarshaller();
|
|
|
913 |
|
| 16 |
naveen |
914 |
JAXBElement<?> element = (JAXBElement<?>)u.unmarshal(
|
|
|
915 |
new FileInputStream(srcFile));
|
| 10 |
shop2020 |
916 |
|
| 57 |
naveen |
917 |
return element.getValue();
|
| 10 |
shop2020 |
918 |
}
|
|
|
919 |
|
|
|
920 |
/**
|
|
|
921 |
*
|
| 16 |
naveen |
922 |
* @param jaxbEdImp
|
|
|
923 |
* @return EditorialImportance
|
|
|
924 |
*/
|
|
|
925 |
private EditorialImportance convertEditorialImportance(
|
|
|
926 |
EditorialImportanceType jaxbEdImp) {
|
|
|
927 |
|
|
|
928 |
String strEdImp = jaxbEdImp.value();
|
|
|
929 |
EditorialImportance edImp = null;
|
|
|
930 |
|
|
|
931 |
if(strEdImp.equals("Mandatory"))
|
|
|
932 |
edImp = EditorialImportance.MANDATORY;
|
|
|
933 |
else if(strEdImp.equals("Optional"))
|
|
|
934 |
edImp = EditorialImportance.OPTIONAL;
|
|
|
935 |
else
|
|
|
936 |
edImp = EditorialImportance.RECOMMENDED;
|
|
|
937 |
|
|
|
938 |
return edImp;
|
|
|
939 |
}
|
| 10 |
shop2020 |
940 |
}
|