Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
10 shop2020 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.util;
5
 
16 naveen 6
import in.shop2020.metamodel.definitions.BulletDefinition;
10 shop2020 7
import in.shop2020.metamodel.definitions.Category;
8
import in.shop2020.metamodel.definitions.CategorySlideDefinition;
16 naveen 9
import in.shop2020.metamodel.definitions.CompositeDefinition;
10
import in.shop2020.metamodel.definitions.CompositePartDefinition;
11
import in.shop2020.metamodel.definitions.DatatypeDefinition;
10 shop2020 12
import in.shop2020.metamodel.definitions.EditorialImportance;
16 naveen 13
import in.shop2020.metamodel.definitions.EnumDefinition;
14
import in.shop2020.metamodel.definitions.EnumValue;
15
import in.shop2020.metamodel.definitions.FeatureDefinition;
16
import in.shop2020.metamodel.definitions.SlideDefinition;
17
import in.shop2020.metamodel.definitions.SlideFeatureDefinition;
10 shop2020 18
import in.shop2020.metamodel.definitions.Unit;
16 naveen 19
import in.shop2020.metamodel.jaxb.BulletDefinitionType;
10 shop2020 20
import in.shop2020.metamodel.jaxb.CategorySlideDefinitionType;
21
import in.shop2020.metamodel.jaxb.CategoryType;
16 naveen 22
import in.shop2020.metamodel.jaxb.CompositeDefinitionType;
23
import in.shop2020.metamodel.jaxb.CompositePartDefinitionType;
24
import in.shop2020.metamodel.jaxb.DatatypeDefinitionType;
10 shop2020 25
import in.shop2020.metamodel.jaxb.DefinitionType;
26
import in.shop2020.metamodel.jaxb.EditorialImportanceType;
16 naveen 27
import in.shop2020.metamodel.jaxb.EnumDefinitionType;
28
import in.shop2020.metamodel.jaxb.EnumValueType;
29
import in.shop2020.metamodel.jaxb.FeatureDefinitionType;
30
import in.shop2020.metamodel.jaxb.SlideDefinitionType;
31
import in.shop2020.metamodel.jaxb.SlideFeatureDefinitionType;
10 shop2020 32
import in.shop2020.metamodel.jaxb.UnitType;
18 naveen 33
import in.shop2020.util.Utils;
10 shop2020 34
 
35
import java.io.FileInputStream;
16 naveen 36
import java.util.ArrayList;
10 shop2020 37
import java.util.HashMap;
38
import java.util.Iterator;
39
import java.util.List;
40
import java.util.Map;
24 naveen 41
import java.util.TreeMap;
10 shop2020 42
 
43
import javax.xml.bind.JAXBContext;
44
import javax.xml.bind.JAXBElement;
45
import javax.xml.bind.Unmarshaller;
46
 
47
import org.apache.commons.lang.ArrayUtils;
48
import org.apache.commons.lang.StringUtils;
49
 
50
/**
17 naveen 51
 * MM - Meta-Model Tool
52
 * Imports and exports model definitions. Validates against meta model
10 shop2020 53
 * 
54
 * @author naveen
55
 *
56
 */
57
public class MM {
16 naveen 58
	public static final String DEFINITIONS_SRC_PATH = 
59
		"/home/naveen/workspace/eclipse/webapp/src/xml/model/";
60
	public static final String DEFINITIONS_DB_PATH = 
26 naveen 61
		"/home/naveen/workspace/eclipse/db/definitions/";
16 naveen 62
	public static final String ENTITIES_DB_PATH = 
26 naveen 63
		"/home/naveen/workspace/eclipse/db/entities/";
10 shop2020 64
 
65
	private String definitionSetName;
66
	private String srcFile;
67
	private String dbFile;
68
 
69
	/**
70
	 * @param args
71
	 */
72
	public static void main(String[] args) throws Exception {
16 naveen 73
		String[] definitionSetNames = new String[] {"units", 
74
				"datatypedefinitions", "featuredefinitions", "slidedefinitions", 
75
				"categories"};
10 shop2020 76
 
77
		String[] commands = new String[] {"show", "import"};
78
 
16 naveen 79
		String usage = "Usage: MM ["+ StringUtils.join(commands, "|") +"] ["+ 
80
			StringUtils.join(definitionSetNames, "|") +"]";
81
 
10 shop2020 82
		if(args.length < 2) {
83
			System.out.println(usage);
84
			System.exit(-1);
85
		}
18 naveen 86
		Utils.logger.info("MM "+ args[0] + " " + args[1]);
17 naveen 87
 
10 shop2020 88
		String inputCommand = args[0];
89
		String inputDefinitionSet = args[1];
90
 
91
		if(!ArrayUtils.contains(commands, inputCommand)) {
92
			System.out.println(usage);
93
			System.exit(-1);
94
		}
95
 
96
		if(!ArrayUtils.contains(definitionSetNames, inputDefinitionSet)) {
97
			System.out.println(usage);
98
			System.exit(-1);
99
		}
100
 
101
		MM mm = new MM(inputDefinitionSet);
102
		if(inputCommand.equals("import")) {
103
			mm.importDefinitionSet();
104
		}
105
		else if(inputCommand.equals("show")) {
106
			mm.showDefinitionSet();
107
		}
108
	}
109
 
110
	/**
111
	 * 
112
	 * @param definitionSet
113
	 */
114
	public MM(String definitionSetName) {
115
		this.definitionSetName = definitionSetName;
116
		this.srcFile = DEFINITIONS_SRC_PATH + this.definitionSetName + ".xml";
117
		this.dbFile = DEFINITIONS_DB_PATH + this.definitionSetName + ".ser";
118
	}
119
 
120
	/**
121
	 * 
122
	 */
123
	@SuppressWarnings("unchecked")
124
	public void importDefinitionSet() throws Exception {
125
		DefinitionType defType = this.unmarshallSrcFile(this.srcFile);
16 naveen 126
		Object objectToStore = null;
10 shop2020 127
 
128
		// Units
129
		if(this.definitionSetName.equals("units")) {
130
			Map unitsMap = this.convertUnits(defType);
16 naveen 131
			objectToStore = unitsMap;
10 shop2020 132
		}
133
 
134
		// Categories
135
		else if(this.definitionSetName.equals("categories")) {
136
			Map<Long, Category> categoriesMap = new HashMap<Long, Category>();
137
			Category root = this.convertCategories(defType, categoriesMap);
20 naveen 138
			//Utils.logger.info(categoriesMap);
139
			//Utils.logger.info(root);
10 shop2020 140
			//System.exit(0);
141
 
142
			// Tree
16 naveen 143
			String categoryTreeDBFile = DEFINITIONS_DB_PATH + "categorytree" + 
144
				".ser";
145
 
10 shop2020 146
			if(root != null) {
17 naveen 147
				DBUtils.store(root, categoryTreeDBFile);
10 shop2020 148
			}
149
 
150
			// Map
16 naveen 151
			objectToStore = categoriesMap;
10 shop2020 152
		}
16 naveen 153
 
154
		// Datatype Definitions
155
		else if(this.definitionSetName.equals("datatypedefinitions")) {
24 naveen 156
			Map<Long, DatatypeDefinition> datatypeDefsMap = 
157
				this.convertDatatypeDefinition(defType);
16 naveen 158
 
24 naveen 159
			// Store enum value id to value map separately
160
			String enumValueDBFile = DEFINITIONS_DB_PATH + "enumvalues" + 
161
				".ser";
162
 
163
			// RE-VISIT - May not be optimal
164
			Map<Long, EnumValue> enumValuesMap = new TreeMap<Long, EnumValue>();
165
			for(Long datatypeDefID : datatypeDefsMap.keySet()) {
166
				DatatypeDefinition datatypeDef = 
167
					datatypeDefsMap.get(datatypeDefID);
168
 
169
				if(datatypeDef instanceof EnumDefinition) {
170
					List<EnumValue> enumValues = 
171
						((EnumDefinition) datatypeDef).getEnumValues();
172
 
173
					for(EnumValue enumValue : enumValues) {
174
						enumValuesMap.put(new Long(enumValue.getID()), 
175
								enumValue);
176
					}
177
				}
178
			}
179
			Utils.logger.info("enumValuesMap=" + enumValuesMap);
180
			DBUtils.store(enumValuesMap, enumValueDBFile);
181
 
16 naveen 182
			objectToStore = datatypeDefsMap;
183
		}
184
 
185
		// Feature Definitions
186
		else if(this.definitionSetName.equals("featuredefinitions")) {
187
			Map featureDefsMap = this.convertFeatureDefinitions(defType);
188
 
189
			objectToStore = featureDefsMap;
190
		}
191
 
192
		// Slide Definitions
193
		else if(this.definitionSetName.equals("slidedefinitions")) {
194
			Map slideDefsMap = this.convertSlideDefinitions(defType);
195
 
196
			objectToStore = slideDefsMap;
197
		}
198
 
199
		if(objectToStore != null) {
17 naveen 200
			DBUtils.store(objectToStore, this.dbFile);
16 naveen 201
		}
10 shop2020 202
	}
203
 
204
	/**
205
	 * 
206
	 */
207
	public void showDefinitionSet() throws Exception {
17 naveen 208
		Object obj = DBUtils.read(this.dbFile);
18 naveen 209
		Utils.logger.info(obj.toString());
10 shop2020 210
 
211
		if(this.definitionSetName.equals("categories")) {
16 naveen 212
			String categoryTreeDBFile = DEFINITIONS_DB_PATH + "categorytree" + 
213
				".ser";
214
 
17 naveen 215
			Category root = (Category)DBUtils.read(categoryTreeDBFile);
18 naveen 216
			Utils.logger.info(root.toString());
217
			//Utils.logger.info("root.getChildrenCategory().size: " + 
218
			//		root.getChildrenCategory().size());
10 shop2020 219
		}
220
	}
221
 
222
	/**
223
	 * 
224
	 * @return Map
225
	 */
16 naveen 226
	private Map<Long, SlideDefinition> convertSlideDefinitions(
227
			DefinitionType defType) {
228
 
229
		Map<Long, SlideDefinition> defs = 
230
			new HashMap<Long, SlideDefinition>();
231
 
232
		List<SlideDefinitionType> jaxbDefs = defType.getSlideDefinition();
233
		Iterator<SlideDefinitionType> itjaxbDefs = jaxbDefs.iterator();
234
 
235
		// Slide definitions
236
		while(itjaxbDefs.hasNext()) {
237
			SlideDefinitionType jaxbDef = itjaxbDefs.next();
238
 
20 naveen 239
			Utils.logger.info("Slide label=" + jaxbDef.getLabel());
16 naveen 240
			SlideDefinition def = new SlideDefinition(jaxbDef.getID(),
241
					jaxbDef.getLabel());
242
			def.setDescription(jaxbDef.getDescription());
243
 
244
			// Slide Feature Definition
245
			List<SlideFeatureDefinitionType> jaxbSlideFeatureDefs = 
246
				jaxbDef.getSlideFeatureDefinition();
247
 
248
			if(jaxbSlideFeatureDefs != null) {
249
				def.setSlideFeatureDefinitions((
250
						this.convertSlideFeatureDefinitions(
251
								jaxbSlideFeatureDefs)));
252
			}
20 naveen 253
			Utils.logger.info("def=" + def);
16 naveen 254
 
255
			defs.put(new Long(jaxbDef.getID()), def);
256
		}
257
 
258
		return defs;
259
	}
260
 
261
	/**
262
	 * 
263
	 * @param jaxbDefs
264
	 * @return List<SlideFeatureDefinition>
265
	 */
266
	private List<SlideFeatureDefinition> convertSlideFeatureDefinitions(
267
			List<SlideFeatureDefinitionType> jaxbDefs) {
268
 
269
		List<SlideFeatureDefinition> defs = 
270
			new ArrayList<SlideFeatureDefinition>();
271
 
272
		Iterator<SlideFeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
273
 
274
		// Slide-feature definitions
275
		while(itjaxbDefs.hasNext()) {
276
			SlideFeatureDefinitionType jaxbDef = itjaxbDefs.next();
277
			SlideFeatureDefinition def = new SlideFeatureDefinition(
278
					jaxbDef.getFeatureDefinitionID());
279
 
280
			def.setEditorialImportance(this.convertEditorialImportance(
281
					jaxbDef.getEditorialImportance()));
282
 
283
			def.setDescription(jaxbDef.getDescription());
284
 
285
			defs.add(def);
286
		}
287
 
288
		return defs;
289
	}
290
 
291
	/**
292
	 * 
293
	 * @return Map
294
	 */
295
	private Map<Long, FeatureDefinition> convertFeatureDefinitions(
296
			DefinitionType defType) {
297
 
298
		Map<Long, FeatureDefinition> defs = 
299
			new HashMap<Long, FeatureDefinition>();
300
 
301
		List<FeatureDefinitionType> jaxbDefs = defType.getFeatureDefinition();
302
		Iterator<FeatureDefinitionType> itjaxbDefs = jaxbDefs.iterator();
303
 
304
		// Feature definitions
305
		while(itjaxbDefs.hasNext()) {
306
			FeatureDefinitionType jaxbDef = itjaxbDefs.next();
307
 
20 naveen 308
			//Utils.logger.info("Feature label=" + jaxbDef.getLabel());
16 naveen 309
			FeatureDefinition def = new FeatureDefinition(jaxbDef.getID(),
310
					jaxbDef.getLabel());
311
			def.setAllowsBlank(jaxbDef.isCanbeBlank());
312
			def.setDescription(jaxbDef.getDescription());
313
 
314
			// Bullet Definition
315
			BulletDefinitionType jaxbBulletDef = jaxbDef.getBulletDefinition();
316
			if(jaxbBulletDef != null) {
317
				def.setBulletDefinition(this.convertBulletDefinition(
318
						jaxbBulletDef));
319
			}
20 naveen 320
			Utils.logger.info("def=" + def);
16 naveen 321
 
322
			defs.put(new Long(jaxbDef.getID()), def);
323
		}
324
 
325
		return defs;
326
	}
327
 
328
	/**
329
	 * 
330
	 * @param jaxbDef BulletDefinitionType
331
	 * @return BulletDefinition
332
	 */
333
	private BulletDefinition convertBulletDefinition(
334
			BulletDefinitionType jaxbDef) {
335
 
336
		BulletDefinition def = new BulletDefinition(
337
				jaxbDef.getDatatypeDefinitionID());
338
 
339
		Long unitID = jaxbDef.getUnitID();
340
		if(unitID != null) {
341
			def.setUnitID(unitID.longValue());
342
		}
343
		def.setMultivalue(jaxbDef.isIsMultivalue());
344
		def.setLearned(jaxbDef.isIsLearned());
345
		def.setDescription(jaxbDef.getDescription());
346
 
347
		return def;
348
	}
349
 
350
	/**
351
	 * 
352
	 * @return Map
353
	 */
354
	private Map<Long, DatatypeDefinition> convertDatatypeDefinition(
355
			DefinitionType defType) {
356
 
357
		Map<Long, DatatypeDefinition> defs = 
358
			new HashMap<Long, DatatypeDefinition>();
359
 
360
		List<DatatypeDefinitionType> jaxbDefs = defType.getDatatypeDefinition();
361
		Iterator<DatatypeDefinitionType> it = jaxbDefs.iterator();
362
 
363
		while(it.hasNext()) {
364
			DatatypeDefinitionType jaxbDef = it.next();
365
 
366
			DatatypeDefinition def = null;
367
			CompositeDefinitionType compositeDefType = 
368
				jaxbDef.getCompositeDefinition();
369
 
370
			EnumDefinitionType enumDefType = 
371
				jaxbDef.getEnumDefinition();
372
 
373
			// Composite data type
374
			if(compositeDefType != null) {
375
				CompositeDefinition compDef = new CompositeDefinition(
20 naveen 376
						jaxbDef.getID(), jaxbDef.getName(), 
377
						compositeDefType.getSeparator());
16 naveen 378
 
379
				List<CompositePartDefinitionType> jaxbPartDefs = 
380
					compositeDefType.getCompositePartDefinition();
381
 
382
				Iterator<CompositePartDefinitionType> itPartDefs = 
383
					jaxbPartDefs.iterator();
384
 
385
				// Collect parts
386
				while(itPartDefs.hasNext()) {
387
					CompositePartDefinitionType jaxbPartDef = itPartDefs.next();
388
					CompositePartDefinition partDef = 
389
						this.convertCompositePartDefinition(jaxbPartDef);
390
 
391
					compDef.addCompositePartDefinition(partDef);
392
				}
393
 
394
				def = compDef;
395
			}
396
 
397
			// Enumerated values
398
			else if(enumDefType != null) {
399
				EnumDefinition enumDef = new EnumDefinition(jaxbDef.getID(), 
400
						jaxbDef.getName());
401
 
402
				List<EnumValueType> jaxbEnumValues = 
403
					enumDefType.getEnumValue();
404
 
405
				Iterator<EnumValueType> itEnumValues = 
406
					jaxbEnumValues.iterator();
407
 
408
				// Collect individual value
409
				while(itEnumValues.hasNext()) {
410
					EnumValueType jaxbEnumValue = itEnumValues.next();
411
					EnumValue enumValue = 
412
						this.convertEnumValueDefinition(jaxbEnumValue);
413
 
414
					enumDef.addEnumValue(enumValue);
415
				}
416
 
417
				def = enumDef;
418
			}
419
 
420
			// Primitive
421
			else {
422
				def = new DatatypeDefinition(jaxbDef.getID(), 
423
						jaxbDef.getName());
424
			}
425
 
426
			def.setDescription(jaxbDef.getDescription());
20 naveen 427
			Utils.logger.info("def=" + def);
16 naveen 428
 
429
			defs.put(new Long(jaxbDef.getID()), def);
430
		}
431
 
432
		return defs;
433
	}
434
 
435
	/**
436
	 * 
437
	 * @param jaxbEnumValue
438
	 * @return EnumValue
439
	 */
440
	private EnumValue convertEnumValueDefinition(EnumValueType jaxbEnumValue) {
441
 
442
		EnumValue enumValue = new EnumValue(jaxbEnumValue.getID(), 
443
				jaxbEnumValue.getValue());
444
 
445
		return enumValue;
446
	}
447
	/**
448
	 * 
449
	 * @param jaxbPartDef
450
	 * @return CompositePartDefinition
451
	 */
452
	private CompositePartDefinition convertCompositePartDefinition(
453
			CompositePartDefinitionType jaxbPartDef) {
454
 
455
		CompositePartDefinition partDef = new CompositePartDefinition(
456
				jaxbPartDef.getLabel(), jaxbPartDef.getDatatypeDefinitionID(), 
457
				jaxbPartDef.getUnitID());
458
 
459
		partDef.setDescription(jaxbPartDef.getDescription());
460
 
461
		return partDef;
462
	}
463
 
464
	/**
465
	 * 
466
	 * @return Map
467
	 */
468
	private Category convertCategories(DefinitionType defType, 
469
			Map<Long, Category> catMap) {
10 shop2020 470
 
471
		List<CategoryType> jaxbCats = defType.getCategory();
472
		Iterator<CategoryType> it = jaxbCats.iterator();
473
 
474
		// Get root category
475
		CategoryType jaxbCat = it.next();
476
		if(jaxbCat == null) {
20 naveen 477
			Utils.logger.info("Invalid file: " + this.srcFile);
10 shop2020 478
			return null;
479
		}
480
 
481
		Category root = this.convertCategoryType(jaxbCat, null, catMap);
32 naveen 482
		Utils.logger.info("catMap.get(10002)=" + catMap.get(new Long(10002)));
483
 
10 shop2020 484
		return root;
485
	}
486
 
487
	/**
488
	 * 
489
	 * @param jaxbCat
490
	 * @return Category
491
	 */
32 naveen 492
	@SuppressWarnings("unchecked")
16 naveen 493
	private Category convertCategoryType(CategoryType jaxbCat, 
494
			Category parentCat, Map<Long, Category> catMap) {
18 naveen 495
 
10 shop2020 496
		Category cat = new Category(jaxbCat.getID());
497
		cat.setLabel(jaxbCat.getName());
498
		cat.setDescription(jaxbCat.getDescription());
499
		if(parentCat != null) {
500
			cat.setParentCategory(parentCat);
32 naveen 501
 
502
			// Copy parent's category-slide definitions
503
			ArrayList<CategorySlideDefinition> parentCSDef = 
504
				(ArrayList<CategorySlideDefinition>) 
505
				parentCat.getCategorySlideDefintions();
506
 
507
			if(parentCSDef != null) {
508
				cat.setCategorySlideDefintions(
509
					(List<CategorySlideDefinition>) parentCSDef.clone());
510
			}
10 shop2020 511
		}
512
 
513
		// Category Slide Definition
32 naveen 514
		List<CategorySlideDefinitionType> jaxbDefs = 
515
			jaxbCat.getCategorySlideDefinition();
516
 
10 shop2020 517
		Iterator<CategorySlideDefinitionType> it = jaxbDefs.iterator();
518
		while(it.hasNext()) {
519
			CategorySlideDefinitionType jaxbDef = it.next();
32 naveen 520
			CategorySlideDefinition catSlideDef 
521
			= this.convertCategorySlideDefinitionType(jaxbCat.getID(), jaxbDef);
522
 
10 shop2020 523
			cat.addCategorySlideDefintion(catSlideDef);
524
		}
525
 
526
		// Children
527
		List<CategoryType> jaxbChildren = jaxbCat.getChildCategory();
20 naveen 528
		//Utils.logger.info("jaxbChildren.size: " + jaxbChildren.size());
10 shop2020 529
 
530
		Iterator<CategoryType> itChildren = jaxbChildren.iterator();
531
		while(itChildren.hasNext()) {
532
			CategoryType jaxbChildCat = itChildren.next();
32 naveen 533
			Category childCat = this.convertCategoryType(jaxbChildCat, cat, 
534
					catMap);
10 shop2020 535
			cat.addChild(childCat);
536
		}
20 naveen 537
		//Utils.logger.info("Parent cat: " + cat);
32 naveen 538
		// DEBUG ONLY
539
		Utils.logger.info("####### Cat ID: " + cat.getID());
540
		if(cat.getCategorySlideDefintions() != null) {
541
			for(CategorySlideDefinition csd : cat.getCategorySlideDefintions()){
542
				Utils.logger.info("####### SlideDefintionID=" + 
543
						csd.getSlideDefintionID());
544
			}
545
		}
546
 
10 shop2020 547
		catMap.put(new Long(jaxbCat.getID()), cat);
548
		return cat;
549
	}
550
 
551
	/**
552
	 * 
553
	 * @param jaxbDef
554
	 * @return
555
	 */
16 naveen 556
	private CategorySlideDefinition convertCategorySlideDefinitionType(
557
			long categoryID, CategorySlideDefinitionType jaxbDef) {
558
 
10 shop2020 559
		CategorySlideDefinition catSlideDef = new CategorySlideDefinition(
32 naveen 560
				jaxbDef.getSlideDefinitionID());
10 shop2020 561
 
562
		catSlideDef.setDescription(jaxbDef.getDescription());
563
 
564
		EditorialImportanceType jaxbEdImp = jaxbDef.getEditorialImportance();
565
		EditorialImportance edImp = this.convertEditorialImportance(jaxbEdImp);
566
		catSlideDef.setEditorialImportance(edImp);
567
 
568
		return catSlideDef;
569
	}
570
 
571
	/**
572
	 * 
573
	 * @return Map
574
	 */
575
	private Map<Long, Unit> convertUnits(DefinitionType defType) {
576
 
577
		Map<Long, Unit> allUnits = new HashMap<Long, Unit>();
578
		List<UnitType> jaxbUnits = defType.getUnit();
579
		Iterator<UnitType> it = jaxbUnits.iterator();
580
 
581
		while(it.hasNext()) {
582
			UnitType jaxbUnit = it.next();
583
 
584
			Unit unit = new Unit(jaxbUnit.getID());
585
			unit.setDescription(jaxbUnit.getDescription());
586
			unit.setFullForm(jaxbUnit.getFullform());
587
			unit.setShortForm(jaxbUnit.getShortform());
20 naveen 588
			Utils.logger.info("unit=" + unit);
10 shop2020 589
 
590
			allUnits.put(new Long(jaxbUnit.getID()), unit);
591
		}
592
 
593
		return allUnits;
594
	}
595
 
596
	/**
597
	 * 
598
	 * @return DefinitionType
599
	 */
600
	private DefinitionType unmarshallSrcFile(String srcFile) throws Exception {
601
 
16 naveen 602
        JAXBContext jc = JAXBContext.newInstance("in.shop2020.metamodel.jaxb");
10 shop2020 603
 
604
        // create an Unmarshaller
605
        Unmarshaller u = jc.createUnmarshaller();
606
 
16 naveen 607
        JAXBElement<?> element = (JAXBElement<?>)u.unmarshal(
608
        		new FileInputStream(srcFile));
10 shop2020 609
 
610
        return (DefinitionType)element.getValue();
611
	}
612
 
613
	/**
614
	 * 
16 naveen 615
	 * @param jaxbEdImp
616
	 * @return EditorialImportance
617
	 */
618
	private EditorialImportance convertEditorialImportance(
619
			EditorialImportanceType jaxbEdImp) {
620
 
621
		String strEdImp = jaxbEdImp.value();
622
		EditorialImportance edImp = null;
623
 
624
		if(strEdImp.equals("Mandatory"))
625
			edImp = EditorialImportance.MANDATORY;
626
		else if(strEdImp.equals("Optional"))
627
			edImp = EditorialImportance.OPTIONAL;
628
		else 
629
			edImp = EditorialImportance.RECOMMENDED;
630
 
631
		return edImp;
632
	}
10 shop2020 633
}