Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
36 naveen 1
/**
2
 * 
3
 */
4
package in.shop2020.metamodel.util;
5
 
6
import in.shop2020.metamodel.core.Bullet;
37 naveen 7
import in.shop2020.metamodel.core.CompositeDataObject;
38 naveen 8
import in.shop2020.metamodel.core.Entity;
37 naveen 9
import in.shop2020.metamodel.core.EnumDataObject;
38 naveen 10
import in.shop2020.metamodel.core.Feature;
11
import in.shop2020.metamodel.core.FreeformContent;
37 naveen 12
import in.shop2020.metamodel.core.PrimitiveDataObject;
13
import in.shop2020.metamodel.definitions.BulletDefinition;
14
import in.shop2020.metamodel.definitions.Catalog;
15
import in.shop2020.metamodel.definitions.CompositeDefinition;
16
import in.shop2020.metamodel.definitions.CompositePartDefinition;
17
import in.shop2020.metamodel.definitions.DatatypeDefinition;
18
import in.shop2020.metamodel.definitions.DefinitionsContainer;
19
import in.shop2020.metamodel.definitions.EditorialImportance;
20
import in.shop2020.metamodel.definitions.EntityContainer;
21
import in.shop2020.metamodel.definitions.EnumDefinition;
22
import in.shop2020.metamodel.definitions.FeatureDefinition;
23
import in.shop2020.metamodel.definitions.SlideDefinition;
24
import in.shop2020.metamodel.definitions.Unit;
64 naveen 25
import in.shop2020.util.DBUtils;
37 naveen 26
import in.shop2020.util.Utils;
36 naveen 27
 
28
import java.util.ArrayList;
29
import java.util.HashMap;
30
import java.util.List;
31
import java.util.Map;
32
 
37 naveen 33
import org.apache.commons.lang.ArrayUtils;
36 naveen 34
import org.apache.commons.lang.StringUtils;
35
import org.apache.poi.hslf.HSLFSlideShow;
36
import org.apache.poi.hslf.extractor.PowerPointExtractor;
37
import org.apache.poi.hslf.model.Slide;
38
import org.apache.poi.hslf.model.TextRun;
39
import org.apache.poi.hslf.usermodel.RichTextRun;
40
import org.apache.poi.hslf.usermodel.SlideShow;
41
 
42
/**
51 naveen 43
 * Command line utility to convert MS PPT into shop2020 content model objects. 
44
 * It can be used to 
45
 * 
46
 * - Validate PPT file
47
 * - Import PPT file
48
 * - Show Java objects from already imported PPT
49
 * 
50
 * 
51
 * HSLF - Horrible slide show format (POI API term)
52
 * 
36 naveen 53
 * @author naveen
54
 *
55
 */
56
public class HSLF {
43 naveen 57
	// LOCAL
49 naveen 58
	/**
51 naveen 59
	 * Path to where PPT files will be picked
49 naveen 60
	 */
37 naveen 61
	public static final String CONTENT_SRC_PPT_PATH = 
62
		"/home/naveen/workspace/eclipse/content/ppt/";
43 naveen 63
 
64
	/** Validation tool
65
	public static final String CONTENT_SRC_PPT_PATH = "./ppt/";
66
	*/
67
 
49 naveen 68
	/**
51 naveen 69
	 * Path where exported HTML files are kept
49 naveen 70
	 */
37 naveen 71
	public static final String CONTENT_SRC_HTML_PATH = 
72
		"/home/naveen/workspace/eclipse/content/html/";
49 naveen 73
 
74
	/**
75
	 * 
76
	 */
37 naveen 77
	public static final String CONTENT_SRC_XML_PATH = 
78
		"/home/naveen/workspace/eclipse/content/xml/";
79
 
49 naveen 80
	/**
81
	 * 
82
	 */
83
	public static final int BLUE = -16776961;
84
 
85
	/**
86
	 * 
87
	 */
38 naveen 88
	public static final int PURPLE = -6749953;
49 naveen 89
 
90
	/**
91
	 * 
92
	 */
38 naveen 93
	public static final int GREEN = -16711936;
49 naveen 94
 
95
	/**
96
	 * 
97
	 */
38 naveen 98
	public static final int ORANGE = -26368; 
43 naveen 99
 
100
	// LOCAL
49 naveen 101
	/**
102
	 * 
103
	 */
37 naveen 104
	public static final String CONTENT_DB_PATH =  
105
		"/home/naveen/workspace/eclipse/db/entities/";
106
 
43 naveen 107
	/** Validation tool
108
	public static final String CONTENT_DB_PATH =  
109
		"./db/entities/";
110
	*/
111
 
37 naveen 112
	/** WEB
113
	public static final String CONTENT_DB_PATH =  
114
		"/var/lib/tomcat6/webapps/shop2020/db/entities/";
115
	*/
116
 
49 naveen 117
	/**
118
	 * 
119
	 */
36 naveen 120
	private List<String> slideNames = new ArrayList<String>();
49 naveen 121
 
122
	/**
123
	 * 
124
	 */
36 naveen 125
	private Map<String, List<String>> slideNameChildrenSlideNames = 
126
		new HashMap<String, List<String>>();
49 naveen 127
	/**
128
	 * 
129
	 */
36 naveen 130
	private Map<String, List<String>> slideNameFeatureNames = 
131
		new HashMap<String, List<String>>();
132
 
49 naveen 133
	/**
134
	 * 
135
	 */
37 naveen 136
	private Map<String, Long> slideNameSlideDefID = 
36 naveen 137
		new HashMap<String, Long>();
138
 
49 naveen 139
	/**
140
	 * 
141
	 */
37 naveen 142
	private Map<String, Long> slideNameFeatureNameFeatureDefID =
36 naveen 143
		new HashMap<String, Long>();
49 naveen 144
 
145
	/**
146
	 * 
147
	 */
37 naveen 148
	private Map<String, List<String>> slideNameFeatureNameBulletTexts =
149
		new HashMap<String, List<String>>();
150
 
49 naveen 151
	/**
152
	 * 
153
	 */
37 naveen 154
	private Map<String, List<Bullet>> slideNameFeatureNameBullets =
36 naveen 155
		new HashMap<String, List<Bullet>>();
156
 
49 naveen 157
	/**
158
	 * 
159
	 */
37 naveen 160
	private Map<String, List<String>> containerFCCs = 
36 naveen 161
		new HashMap<String, List<String>>();
162
 
49 naveen 163
	/**
164
	 * 
165
	 */
37 naveen 166
	private long categoryID;
49 naveen 167
 
168
	/**
169
	 * 
170
	 */
37 naveen 171
	private String srcFile;
49 naveen 172
 
173
	/**
174
	 * 
175
	 */
37 naveen 176
	private String dbFile;
49 naveen 177
 
178
	/**
179
	 * 
180
	 */
38 naveen 181
	private String introductionTitle;
49 naveen 182
 
183
	/**
184
	 * 
185
	 */
38 naveen 186
	private String introductionText;
187
 
36 naveen 188
	/**
51 naveen 189
	 * Usage: HSLF [validate|import|show] [{Entity ID}|{Category ID} {PPT file name}]
190
	 * 
36 naveen 191
	 * @param args
192
	 */
193
	public static void main(String[] args) throws Exception {
40 naveen 194
		String[] commands = new String[] {"validate", "import", "show"};
36 naveen 195
 
37 naveen 196
		String usage = "Usage: HSLF ["+ StringUtils.join(commands, "|") +
197
			"] [{Entity ID}|{Category ID} {PPT file name}]\n";
198
 
199
		if(args.length < 2) {
200
			System.out.println(usage);
201
			System.exit(-1);
202
		}
203
 
204
		String inputCommand = args[0];
205
 
206
		if(!ArrayUtils.contains(commands, inputCommand)) {
207
			System.out.println(usage);
208
			System.exit(-1);
209
		}
40 naveen 210
 
211
		if (inputCommand.equals("validate")) {
212
			String inputCategoryID = args[1];
213
			if(args.length < 3) {
214
				System.out.println(usage);
215
				System.exit(-1);
216
			}
37 naveen 217
 
40 naveen 218
			String inputFilename = args[2];
219
			long categoryID = new Long(inputCategoryID).longValue();
220
			HSLF hslf = new HSLF(categoryID, inputFilename);
221
			hslf.validateEntity();
37 naveen 222
			System.exit(0);
223
		}
224
 
225
		if (inputCommand.equals("import")) {
226
			String inputCategoryID = args[1];
227
			if(args.length < 3) {
228
				System.out.println(usage);
229
				System.exit(-1);
230
			}
231
 
232
			String inputFilename = args[2];
233
			long categoryID = new Long(inputCategoryID).longValue();
234
			HSLF hslf = new HSLF(categoryID, inputFilename);
235
			hslf.importEntity();
236
			System.exit(0);
237
		}
40 naveen 238
 
239
		if (inputCommand.equals("show")) {
240
			String entityID = args[1];
241
			HSLF hslf = new HSLF();
242
			hslf.showEntity(new Long(entityID).longValue());
243
			System.exit(0);
244
		}
37 naveen 245
 
36 naveen 246
	}
247
 
37 naveen 248
	/**
249
	 * 
250
	 */
251
	public HSLF() {
252
	}
253
 
254
	/**
255
	 * 
256
	 * @param categoryID
257
	 * @param fileName
258
	 */
259
	public HSLF(long categoryID, String fileName) {
260
		this.categoryID = categoryID;
261
 
262
		this.srcFile = CONTENT_SRC_PPT_PATH + fileName + ".ppt";
263
		this.dbFile = CONTENT_DB_PATH + "entities" + ".ser";
264
	}
49 naveen 265
 
37 naveen 266
	/**
267
	 * 
49 naveen 268
	 * @param entityID
37 naveen 269
	 * @throws Exception
270
	 */
271
	public void showEntity(long entityID) throws Exception {
272
		EntityContainer entContainer = 
273
			Catalog.getInstance().getEntityContainer();
43 naveen 274
		/*
40 naveen 275
		Entity entity = entContainer.getEntity(entityID);
41 naveen 276
		Utils.info("Entity=" + entity);
43 naveen 277
		*/
40 naveen 278
 
37 naveen 279
		ExpandedEntity expandedEntity = 
280
			entContainer.getExpandedEntity(entityID);
281
 
41 naveen 282
		Utils.info("expandedEntity=" + expandedEntity);
37 naveen 283
	}
284
 
40 naveen 285
	/**
286
	 * 
287
	 * @throws Exception
288
	 */
289
	public void validateEntity() throws Exception {
37 naveen 290
		HSLFSlideShow hslfSS = new HSLFSlideShow(this.srcFile);
36 naveen 291
		SlideShow ss = new SlideShow(hslfSS);
292
		Slide[] ssarr = ss.getSlides();
38 naveen 293
 
294
		// Introduction page
295
		this.processIntroductionSlide(ssarr[0]);
296
 
297
		// Rest of the content page
298
		for(int i=1; i < ssarr.length; i++) {
36 naveen 299
			TextRun[] trs = ssarr[i].getTextRuns();
44 naveen 300
			Utils.info("trs.length=" + trs.length);
36 naveen 301
 
44 naveen 302
			/* DEBUG ONLY
303
			for(int j=0;j<trs.length;j++) {
304
				Utils.info("trs["+ j +"].getRawText=" + trs[j].getRawText());
305
				Utils.info("trs[" + j + "].getRichTextRuns().length=" + 
306
						trs[j].getRichTextRuns().length);
307
			}
308
			*/
309
 
37 naveen 310
			String title = StringUtils.lowerCase(
311
					StringUtils.strip(StringUtils.trim(ssarr[i].getTitle())));
36 naveen 312
 
313
			this.slideNames.add(title);
44 naveen 314
			Utils.info("title=" + title);
36 naveen 315
 
40 naveen 316
			// Hack to get to TextRun where bullets are!
44 naveen 317
 
318
			// Assume second textrun will have all the content
36 naveen 319
			TextRun contentTextRun = trs[1];
44 naveen 320
 
36 naveen 321
			RichTextRun[] richTextRuns = contentTextRun.getRichTextRuns();
44 naveen 322
			//Utils.info("richTextRuns.length=" + richTextRuns.length);
323
 
324
			String rawContent = contentTextRun.getRawText();
325
			Utils.info("rawContent=" + rawContent);
326
 
327
			// richTextRuns.length == 1
328
			if(title.equalsIgnoreCase(StringUtils.strip(rawContent)) && 
329
					trs.length > 2) {
40 naveen 330
				contentTextRun = trs[2];
331
				richTextRuns = contentTextRun.getRichTextRuns();
332
			}
44 naveen 333
 
334
			Utils.info("contentTextRun.getRawText=" + 
335
					contentTextRun.getRawText());
336
 
36 naveen 337
			int startIndex = 0;
338
			int indent = 1;
339
			Map<String, Object[]> info = getContents(richTextRuns, startIndex, 
340
					indent);
341
 
41 naveen 342
			Utils.info(info);
36 naveen 343
			//System.exit(0);
344
 
345
			drilldown(richTextRuns, info, indent, title);
44 naveen 346
 
36 naveen 347
		}
44 naveen 348
		//System.exit(0);
36 naveen 349
 
41 naveen 350
		Utils.info("this.slideNames=" + this.slideNames);
351
		Utils.info("this.slideNameChildrenSlideNames=" + 
36 naveen 352
				this.slideNameChildrenSlideNames);
353
 
41 naveen 354
		Utils.info("this.slideNameFeatureNames=" + 
37 naveen 355
				this.slideNameFeatureNames);
356
 
41 naveen 357
		Utils.info("this.slideNameFeatureNameBulletTexts=" + 
37 naveen 358
				this.slideNameFeatureNameBulletTexts);
359
 
41 naveen 360
		Utils.info("this.containerFCCs=" + this.containerFCCs);
37 naveen 361
 
362
		// Start validation and import
363
 
364
		// Validate slides
365
		this.processSlides();
366
 
367
		// Collect Slide Definition IDs
368
		this.collectSlideDefinitionIDs();
41 naveen 369
		Utils.info("this.slideNameSlideDefID=" + 
37 naveen 370
				this.slideNameSlideDefID);
371
 
372
		// Validate features
373
		for(String slideName : this.slideNames) {
42 naveen 374
			this.processFeatures(slideName, slideName);
37 naveen 375
		}
376
 
377
		// Collect Feature Definition IDs
42 naveen 378
		this.collectAllFeatureDefinitionIDs();
41 naveen 379
		Utils.info("this.slideNameFeatureNameFeatureDefID=" + 
37 naveen 380
				this.slideNameFeatureNameFeatureDefID);
42 naveen 381
 
37 naveen 382
		DefinitionsContainer defs = 
383
			Catalog.getInstance().getDefinitionsContainer();
384
 
385
		// Validate bullets
386
		for(String slideName : this.slideNames) {
387
 
40 naveen 388
			Long slideDefID = this.slideNameSlideDefID.get(slideName);
389
			SlideDefinition slideDef = 
390
				defs.getSlideDefinition(slideDefID.longValue());
391
 
42 naveen 392
			this.processBullets(slideName, slideDef.getLabel());
393
		}
394
 
395
		Utils.info("this.slideNameFeatureNameBullets=" + 
396
				this.slideNameFeatureNameBullets);
397
 
398
	}
399
 
400
	/**
401
	 * 
402
	 * @param slideName
403
	 * @param displayTextPrefix
404
	 * @throws Exception
405
	 */
406
	private void processBullets(String slideName, String displayTextPrefix) 
407
		throws Exception {
408
		Utils.info("Process bullets for " + slideName);
409
 
410
		DefinitionsContainer defs = 
411
			Catalog.getInstance().getDefinitionsContainer();
412
 
413
		List<String> featureLabels = 
414
			this.slideNameFeatureNames.get(slideName);
415
 
416
		// Feature-less slide
417
		if(featureLabels != null) {
37 naveen 418
			for(String featureLabel : featureLabels) {
419
				String key = slideName + "_" + featureLabel;
44 naveen 420
				Utils.info("key=" + key);
421
 
37 naveen 422
				List<String> bulletTexts = 
423
					this.slideNameFeatureNameBulletTexts.get(key);
424
 
425
				// Bullet-less feature
426
				if(bulletTexts == null) {
427
					continue;
428
				}
429
 
430
				Long featureDefID = 
431
					this.slideNameFeatureNameFeatureDefID.get(key);
432
 
433
				FeatureDefinition featureDef = 
434
					defs.getFeatureDefinition(featureDefID.longValue());
435
 
42 naveen 436
				String crumb = displayTextPrefix + " > " + 
40 naveen 437
					featureDef.getLabel();
438
 
38 naveen 439
				String prefix = slideName + "_" + featureLabel;
37 naveen 440
				for(String bulletText : bulletTexts) {
441
					Bullet bullet = 
38 naveen 442
						this.processBulletText(bulletText, featureDef, crumb, 
443
								prefix);
37 naveen 444
 
40 naveen 445
					// Can't be imported has errors, skip
37 naveen 446
					if(bullet == null) {
447
						continue;
448
					}
449
 
450
					List<Bullet> bullets = 
451
						this.slideNameFeatureNameBullets.get(key);
452
 
453
					if(bullets == null) {
454
						bullets = new ArrayList<Bullet>();
455
						this.slideNameFeatureNameBullets.put(key, bullets);
456
					}
457
 
458
					bullets.add(bullet);
459
				}
460
			}
461
		}
462
 
42 naveen 463
		// Process bullets of children slides
464
		List<String> childrenSlideNames = 
465
			this.slideNameChildrenSlideNames.get(slideName);
466
		Utils.info("childrenSlideNames=" + childrenSlideNames);
40 naveen 467
 
42 naveen 468
		if(childrenSlideNames != null) {
469
			for(String childSlideName : childrenSlideNames) {
470
				String fullSlideName = slideName + "_" + childSlideName;
471
				Utils.info("fullSlideName=" + fullSlideName);
472
 
473
				Long slideDefID = 
474
					this.slideNameSlideDefID.get(fullSlideName);
475
				Utils.info("slideDefID=" + slideDefID);
476
 
47 naveen 477
				if(slideDefID == null) {
478
					Utils.severe("Unexpected slide " + fullSlideName);
479
					continue;
480
				}
481
 
42 naveen 482
				SlideDefinition childSlideDef = 
483
					defs.getSlideDefinition(slideDefID.longValue());
484
 
485
				String newDisplayTextPrefix = displayTextPrefix + " > " + 
486
					childSlideDef.getLabel();
487
 
488
				this.processBullets(fullSlideName, newDisplayTextPrefix);
489
			}
490
		}
40 naveen 491
	}
492
 
493
	/**
494
	 * 
495
	 * @throws Exception
496
	 */
497
	public void importEntity() throws Exception {
498
 
499
		// Parse and Validate
500
		this.validateEntity();
501
 
38 naveen 502
		// Construct Content Model
503
		Entity entity = this.contructEntityObject();
41 naveen 504
		Utils.info("entity="+entity);
38 naveen 505
 
506
		EntityContainer entContainer = 
507
			Catalog.getInstance().getEntityContainer();
508
 
509
		entContainer.addEntity(entity);
510
 
511
		// RE-VISIT
512
		// Store it back
513
		DBUtils.store(entContainer.getEntities(), this.dbFile);
514
 
515
		// Store the index separately
516
		String entitiesbycategoryDBFile = HSLF.CONTENT_DB_PATH + 
517
			"entitiesbycategory" + ".ser";
518
 
519
		DBUtils.store(entContainer.getEntitiesbyCategory(), 
520
				entitiesbycategoryDBFile);
521
 
36 naveen 522
	}
38 naveen 523
	/**
524
	 * 
525
	 * @param hslfSlide
526
	 */
527
	private void processIntroductionSlide(Slide hslfSlide) {
528
		TextRun[] trs = hslfSlide.getTextRuns();
529
		StringBuffer sbTitle = new StringBuffer();
530
		StringBuffer sbText = new StringBuffer();
531
 
532
		for(int i=0;i<trs.length;i++) {
533
			RichTextRun[] rtrs = trs[i].getRichTextRuns();
534
 
535
			for(int j=0;j<rtrs.length;j++) {
536
				int rgb = rtrs[j].getFontColor().getRGB();
537
				if(rgb == HSLF.ORANGE) {
538
					sbTitle.append(rtrs[j].getRawText());
539
				}
540
				else if(rgb == HSLF.PURPLE) {
541
					sbText.append(rtrs[j].getRawText());
542
				}
543
			}
544
		}
545
 
546
		this.introductionTitle = sbTitle.toString();
547
		this.introductionText = sbText.toString();
41 naveen 548
		Utils.info("this.introductionTitle=" + this.introductionTitle);
549
		Utils.info("this.introductionText=" + this.introductionText);
38 naveen 550
	}
36 naveen 551
 
37 naveen 552
	/**
553
	 * 
38 naveen 554
	 * @return Entity 
555
	 * @throws Exception 
556
	 */
557
	private Entity contructEntityObject() throws Exception {
558
		SequenceGenerator sg = SequenceGenerator.getInstance();
559
		long entityID = sg.getNextSequence(SequenceGenerator.ENTITY);
560
 
561
		Entity entity = new Entity(entityID, this.categoryID);
562
		String brandModel[] = StringUtils.split(this.introductionTitle, " ");
563
 
564
		if(brandModel.length == 1) {
565
			entity.setBrand(StringUtils.strip(brandModel[0]));
566
		}
567
		else if(brandModel.length == 2) {
568
			entity.setBrand(StringUtils.strip(brandModel[0]));
569
			entity.setModelName(StringUtils.strip(brandModel[1]));
570
		}
571
		else if(brandModel.length == 3) {
572
			entity.setBrand(StringUtils.strip(brandModel[0]));
573
			entity.setModelNumber(StringUtils.strip(brandModel[1]));
574
			entity.setModelName(StringUtils.strip(brandModel[2]));
575
		}
576
		else if(brandModel.length == 4) {
577
			entity.setBrand(StringUtils.strip(brandModel[0]) + " " + 
578
					StringUtils.strip(brandModel[1]));
579
 
580
			entity.setModelNumber(StringUtils.strip(brandModel[2]));
581
			entity.setModelName(StringUtils.strip(brandModel[3]));
582
		}
583
 
584
		// Add introduction slide
585
		DefinitionsContainer defs = 
586
			Catalog.getInstance().getDefinitionsContainer();
587
 
588
		List<SlideDefinition> introSlideDefs = 
40 naveen 589
			defs.getSlideDefinitions(this.categoryID, "Introduction");
38 naveen 590
 
591
		// It will only be one
592
		long introSlideDefID = introSlideDefs.get(0).getID();
41 naveen 593
		Utils.info("introSlideDefID=" + introSlideDefID);
38 naveen 594
 
595
		in.shop2020.metamodel.core.Slide introSlide = 
596
			new in.shop2020.metamodel.core.Slide(introSlideDefID);
597
 
598
		introSlide.setFreeformContent(
599
				new FreeformContent(this.introductionText));
41 naveen 600
		Utils.info("introSlide=" + introSlide);
40 naveen 601
 
602
		entity.addSlide(introSlide);
38 naveen 603
 
604
		// Add rest of the slides
605
		for(String slideName : this.slideNames) {
606
			in.shop2020.metamodel.core.Slide slide = 
43 naveen 607
				this.constructSlideObject(slideName);
38 naveen 608
 
43 naveen 609
			entity.addSlide(slide);
610
		}
611
 
612
		return entity;
613
	}
614
 
615
	/**
616
	 * 
617
	 * @param slideName
618
	 * @return
619
	 */
620
	private in.shop2020.metamodel.core.Slide constructSlideObject(
621
			String slideName) {
622
		Utils.info("Constructing slide object for " + slideName);
623
 
624
		List<String> featureNames = 
625
			this.slideNameFeatureNames.get(slideName);
626
 
627
		Long slideDefID = this.slideNameSlideDefID.get(slideName);
47 naveen 628
 
629
		if(slideDefID == null) {
630
			Utils.severe("Unexpected slide " + slideName);
631
			return null;
632
		}
633
 
43 naveen 634
		in.shop2020.metamodel.core.Slide slide = 
635
			new in.shop2020.metamodel.core.Slide(slideDefID.longValue());
636
 
637
		// Only if there are features
638
		if(featureNames != null) {
38 naveen 639
			List<Feature> features = new ArrayList<Feature>();
640
 
43 naveen 641
			for(String featureName : featureNames) {
642
				String key = slideName + "_" + featureName;
38 naveen 643
				Long featureDefID = 
644
					this.slideNameFeatureNameFeatureDefID.get(key);
645
 
646
				List<Bullet> bullets = 
647
					this.slideNameFeatureNameBullets.get(key);
648
 
649
				Feature feature = new Feature(featureDefID.longValue());
650
				feature.setBullets(bullets);
651
 
652
				// Free-form content
653
				List<String> featureFFCs = this.containerFCCs.get(key);
654
				FreeformContent featureFFC = 
655
					new FreeformContent(StringUtils.join(featureFFCs, "|"));
656
 
657
				feature.setFreeformContent(featureFFC);
658
 
659
				features.add(feature);
660
			}
661
 
662
			slide.setFeatures(features);
43 naveen 663
		}
664
 
665
		// Add children slides
666
		List<String> childrenSlideNames = 
667
			this.slideNameChildrenSlideNames.get(slideName);
668
 
669
		if(childrenSlideNames != null) {
670
			for(String childSlideName : childrenSlideNames) {
671
				in.shop2020.metamodel.core.Slide childSlide = 
672
					this.constructSlideObject(slideName + "_" + childSlideName);
673
 
47 naveen 674
				if(childSlide != null) {
675
					slide.addChild(childSlide);
676
				}
43 naveen 677
			}
678
		}
679
 
680
		// Add free-form content is collect above
681
		List<String> slideFFCs = this.containerFCCs.get(slideName);
682
		Utils.info("slideName=" + slideName + 
683
				" slideFFCs=" + slideFFCs);
684
 
685
		if(slideFFCs != null) {
38 naveen 686
			FreeformContent slideFFC = 
687
				new FreeformContent(StringUtils.join(slideFFCs, "|"));
688
 
689
			slide.setFreeformContent(slideFFC);
690
		}
691
 
43 naveen 692
		return slide;
38 naveen 693
	}
694
 
695
	/**
696
	 * 
37 naveen 697
	 * @throws Exception
698
	 */
42 naveen 699
	private void collectAllFeatureDefinitionIDs() throws Exception {
700
 
701
		for(String slideName : this.slideNames) {
702
			this.collectFeatureDefinitionIDs(slideName);
703
		}
704
	}
705
 
706
	/**
707
	 * 
708
	 * @param slideName
709
	 * @throws Exception
710
	 */
44 naveen 711
	private void collectFeatureDefinitionIDs(String slideName) 
712
		throws Exception {
713
		Utils.info("collectFeatureDefinitionIDs for " + slideName);
714
 
37 naveen 715
		DefinitionsContainer defs = 
716
			Catalog.getInstance().getDefinitionsContainer();
717
 
42 naveen 718
		Long slideDefID = this.slideNameSlideDefID.get(slideName);
719
		Utils.info("slideName=" + slideName);
720
 
47 naveen 721
		if(slideDefID == null) {
722
			Utils.severe("Unexpected slide " + slideName);
723
			return;
724
		}
725
 
42 naveen 726
		List<String> featureLabels = 
727
			this.slideNameFeatureNames.get(slideName);
728
		Utils.info("featureLabels=" + featureLabels);
729
 
730
		// Feature-less slide
44 naveen 731
		if(featureLabels != null && !featureLabels.isEmpty()) {
732
			for(String featureLabel : featureLabels) {
47 naveen 733
				Utils.info("defs=" + defs);
734
				Utils.info("slideDefID=" + slideDefID);
735
				Utils.info("featureLabel=" + featureLabel);
736
 
44 naveen 737
				FeatureDefinition featureDef = 
738
					defs.getFeatureDefinition(slideDefID, featureLabel);
739
				String key = slideName + "_" + featureLabel;
740
 
47 naveen 741
				if(featureDef == null) {
742
					Utils.severe("Unexpected feature " + key);
743
					continue;
744
				}
745
 
44 naveen 746
				this.slideNameFeatureNameFeatureDefID.put(key, 
747
						new Long(featureDef.getID()));
748
			}
42 naveen 749
		}
750
 
751
		List<String> childrenSlideNames = 
752
			this.slideNameChildrenSlideNames.get(slideName);
753
 
754
		if(childrenSlideNames != null && !childrenSlideNames.isEmpty()) {
755
			for(String childSlideName : childrenSlideNames) {
756
				String fullSlideName = slideName + "_" + childSlideName;
37 naveen 757
 
42 naveen 758
				this.collectFeatureDefinitionIDs(fullSlideName);
37 naveen 759
			}
760
		}
761
	}
762
 
763
	/**
764
	 * 
765
	 * @throws Exception
766
	 */
767
	private void collectSlideDefinitionIDs() throws Exception {
768
		for(String slideName : this.slideNames) {
42 naveen 769
			SlideDefinition slideDef = this.getSlideDefinition(slideName);
770
			//Utils.info("slideDef=" + slideDef);
37 naveen 771
 
42 naveen 772
			if(slideDef == null) {
37 naveen 773
				continue;
774
			}
775
 
776
			Long slideID = slideDef.getID();
777
			this.slideNameSlideDefID.put(slideName, slideID);
42 naveen 778
 
779
			if(slideDef.hasChildren()) {
780
				this.collectChidrenSlideDefinitionIDs(slideName, slideDef);
781
			}
37 naveen 782
		}
783
	}
784
 
785
	/**
786
	 * 
42 naveen 787
	 * @param parentSlideName
788
	 * @param paretnSlideDef
789
	 * @throws Exception 
790
	 */
791
	private void collectChidrenSlideDefinitionIDs(String parentSlideName, 
792
			SlideDefinition parentSlideDef) throws Exception {
45 naveen 793
		Utils.info("collectChidrenSlideDefinitionIDs for " + parentSlideName);
42 naveen 794
 
795
		// May not be needed as validations have already filtered correct 
796
		// children slide names
797
		List<String> childrenSlideNames = 
798
			this.slideNameChildrenSlideNames.get(parentSlideName);
45 naveen 799
		Utils.info("childrenSlideNames=" + childrenSlideNames);
42 naveen 800
 
801
		List<Long> childrenSlideDefinitionIDs = 
802
			parentSlideDef.getChildrenSlideDefinitionIDs();
45 naveen 803
		Utils.info("childrenSlideDefinitionIDs=" + childrenSlideDefinitionIDs);
42 naveen 804
 
805
		DefinitionsContainer defs = 
806
			Catalog.getInstance().getDefinitionsContainer();
807
 
808
		for(Long childSlideDefID : childrenSlideDefinitionIDs) {
809
			SlideDefinition childSlideDef = 
810
				defs.getSlideDefinition(childSlideDefID.longValue());
811
 
812
			String label = childSlideDef.getLabel();
45 naveen 813
			Utils.info("label="+label);
42 naveen 814
 
815
			if(childrenSlideNames.contains(StringUtils.lowerCase(label))) {
816
				String key = parentSlideName + "_" + 
817
					StringUtils.lowerCase(label);
818
 
819
 				this.slideNameSlideDefID.put(key, childSlideDefID);
820
 
821
 				if(childSlideDef.hasChildren()) {
822
 					this.collectChidrenSlideDefinitionIDs(key, childSlideDef);
823
 				}
824
			}
825
		}
826
	}
827
 
828
	/**
829
	 * 
830
	 * @param slideName
831
	 * @return
832
	 * @throws Exception
833
	 */
834
	private SlideDefinition getSlideDefinition(String slideName) 
835
		throws Exception {
836
		DefinitionsContainer  defs = 
837
			Catalog.getInstance().getDefinitionsContainer();
838
 
839
		List<SlideDefinition> slideDefs = 
840
			defs.getSlideDefinitions(this.categoryID, slideName);
841
 
842
		if(slideDefs == null) {
843
			return null;
844
		}
845
 
846
		if (slideDefs.isEmpty()) {
847
			return null;
848
		} 
849
 
850
		// RE-VISIT
851
		// Pick the first
852
		SlideDefinition slideDef = slideDefs.get(0);
853
		//Utils.info("slideDef=" + slideDef);
854
 
855
		return slideDef;
856
	}
49 naveen 857
 
42 naveen 858
	/**
859
	 * 
49 naveen 860
	 * @param slideName
861
	 * @param displayTextPrefix
37 naveen 862
	 * @throws Exception
863
	 */
42 naveen 864
	private void processFeatures(String slideName, String displayTextPrefix) 
37 naveen 865
		throws Exception {
42 naveen 866
		Utils.info("Processing features for " + slideName);
37 naveen 867
 
47 naveen 868
		if(this.slideNameSlideDefID.get(slideName) == null) {
869
			Utils.severe("Unexpected slide \"" + displayTextPrefix + "\"");
870
			return;
871
		}
872
 
37 naveen 873
		long slideDefID = this.slideNameSlideDefID.get(slideName).longValue();
41 naveen 874
		Utils.info("slideID=" + slideDefID);
37 naveen 875
 
876
		List<String> candidateFeatures = 
877
			this.slideNameFeatureNames.get(slideName);
878
 
41 naveen 879
		Utils.info("slideName=" + slideName);
880
		Utils.info("candidateFeatures=" + candidateFeatures);
37 naveen 881
 
882
		// Get all feature definitions for the slide
883
		DefinitionsContainer defs = 
884
			Catalog.getInstance().getDefinitionsContainer();
885
 
886
		SlideDefinition slideDef = defs.getSlideDefinition(slideDefID);
41 naveen 887
		Utils.info("slideDef=" + slideDef);
37 naveen 888
 
889
		List<FeatureDefinition> featureDefs = 
890
			defs.getFeatureDefinitions(slideDefID);
41 naveen 891
		Utils.info("featureDefs=" + featureDefs);
37 naveen 892
 
45 naveen 893
		// Feature less slide
894
		if(featureDefs == null || featureDefs.isEmpty()) {
895
			Utils.info("Feature-less slide");
896
			return;
897
		}
898
 
37 naveen 899
		List<String> validFeatureLabels = new ArrayList<String>();
900
		for(int i=0; i<featureDefs.size(); i++) {
901
			validFeatureLabels.add(
902
					StringUtils.lowerCase(featureDefs.get(i).getLabel()));
903
 
904
		}
41 naveen 905
		Utils.info("validFeatureLabels=" + validFeatureLabels);
45 naveen 906
 
907
		// Missing features check
908
		if(candidateFeatures == null || candidateFeatures.isEmpty()) {
54 naveen 909
			Utils.info("No features found on the slide");
910
			candidateFeatures = new ArrayList<String>();
45 naveen 911
		}
47 naveen 912
 
54 naveen 913
		// Discard if feature is not one of the valids
914
		List<String> processedFeatureLabels = new ArrayList<String>();
915
		for(String featureLabel : candidateFeatures) {
37 naveen 916
 
54 naveen 917
			if(validFeatureLabels.contains(featureLabel)) {
918
				processedFeatureLabels.add(featureLabel);
37 naveen 919
			}
54 naveen 920
			else {		
921
				Utils.severe("Invalid feature \"" + displayTextPrefix + 
922
						" > " + featureLabel + "\"");
923
			}
37 naveen 924
 
54 naveen 925
		}
926
		Utils.info("processedFeatureLabels=" + processedFeatureLabels);
927
 
928
		// For all further processing
929
		this.slideNameFeatureNames.put(slideName, processedFeatureLabels);
930
 
931
		// Fetch all mandatory features
932
		List<FeatureDefinition> mandatoryFeatureDefs = 
933
			defs.getFeatureDefinitions(slideDefID,
934
			EditorialImportance.MANDATORY);
935
 
936
		Utils.info("mandatoryFeatureDefs=" + mandatoryFeatureDefs);
937
 
938
		// Severe error if mandatory features are not included
939
		for(FeatureDefinition featureDef : mandatoryFeatureDefs) {
940
			if(!processedFeatureLabels.contains(StringUtils.lowerCase(
941
					featureDef.getLabel()))) {
942
				Utils.severe("Mandatory feature \"" + displayTextPrefix 
943
						+ " > " + featureDef.getLabel() + "\" is missing");
37 naveen 944
			}
945
		}
946
 
54 naveen 947
		// Fetch all recommended features
948
		List<FeatureDefinition> recommendedFeatureDefs = 
949
			defs.getFeatureDefinitions(slideDef.getID(),
950
			EditorialImportance.RECOMMENDED);
951
 
952
		Utils.info("recommendedFeatureDefs=" + recommendedFeatureDefs);
953
 
954
		// Warn if recommended features are not included
955
		for(FeatureDefinition featureDef : recommendedFeatureDefs) {
956
			if(!processedFeatureLabels.contains(StringUtils.lowerCase(
957
					featureDef.getLabel()))) {
958
				Utils.warning("Recommended feature \"" + displayTextPrefix + 
959
						" > " + featureDef.getLabel() + 
960
						"\" is missing");
961
			}
962
		}
963
 
42 naveen 964
		// Process features of children slides
965
		List<String> childrenSlideNames = 
966
			this.slideNameChildrenSlideNames.get(slideName);
967
 
968
		if(childrenSlideNames != null && !childrenSlideNames.isEmpty()) {
969
			for(String childSlideName : childrenSlideNames) {
970
				String fullChildSlideName = slideName + "_" + childSlideName;
971
 
972
				String newDisplayTextPrefix = displayTextPrefix + " > " + 
973
					childSlideName;
974
 
975
				this.processFeatures(fullChildSlideName, newDisplayTextPrefix);
976
			}
977
		}
978
 
37 naveen 979
	}
980
 
981
	/**
982
	 * Filter and validate parent slide names
983
	 * 
984
	 * @throws Exception 
985
	 */
986
	private void processSlides() throws Exception {
987
 
988
		// 1 Retrieve meta-data
989
		// 1.1 Retrieve all valid slide names in the content model
990
		DefinitionsContainer defs = 
991
			Catalog.getInstance().getDefinitionsContainer();
992
 
993
		List<SlideDefinition> slideDefs = defs.getSlideDefinitions(
994
				this.categoryID);
995
 
996
		List<String> validSlideNames = new ArrayList<String>();
997
		for (SlideDefinition slideDef : slideDefs) {
998
 
999
			// To avoid Introduction slide
1000
			if(!slideDef.getLabel().isEmpty()) {
1001
				validSlideNames.add(StringUtils.lowerCase(slideDef.getLabel()));
1002
			}
1003
		}
41 naveen 1004
		Utils.info("validSlideNames=" + validSlideNames.toString());
37 naveen 1005
 
1006
		// 2 Rules
1007
		// 2.1 Discard if slide is not one of the valids
1008
		List<String> processedSlideNames = new ArrayList<String>();
1009
		for(String slideName : this.slideNames) {
1010
			if(validSlideNames.contains(slideName)) {
1011
				processedSlideNames.add(slideName);
1012
			}
40 naveen 1013
			else if(slideName.equals("resource urls") || 
1014
					slideName.equals("reference urls")) {
1015
				// ignore
1016
				continue;
1017
			}
37 naveen 1018
			else {
41 naveen 1019
				Utils.severe("Invalid slide \"" + slideName + "\"");
37 naveen 1020
			}
1021
		}
1022
 
42 naveen 1023
		Utils.info("processedSlideNames=" + processedSlideNames.toString());
37 naveen 1024
 
1025
		// For all further processing use processed slide names only
1026
		this.slideNames = processedSlideNames;
1027
 
1028
		// 3 Retrieve "Mandatory" slide names for the category
1029
		List<SlideDefinition> mandatorySlideDefs = 
1030
			defs.getSlides(this.categoryID, EditorialImportance.MANDATORY);
1031
 
41 naveen 1032
		Utils.info("mandatorySlideDefs=" + 
37 naveen 1033
				mandatorySlideDefs.toString());
1034
 
1035
		// 3.1 All mandatory slides exist - Severe
1036
		for(SlideDefinition mandatorySlideDef : mandatorySlideDefs) {
1037
 
1038
			// Avoid introduction slide
1039
			if(mandatorySlideDef.getLabel().isEmpty()) {
1040
				continue;
1041
			}
1042
 
40 naveen 1043
			if(mandatorySlideDef.getLabel().equals("Introduction")) {
1044
				continue;
1045
			}
1046
 
37 naveen 1047
			if(!this.slideNames.contains(
1048
					StringUtils.lowerCase(mandatorySlideDef.getLabel()))) {
1049
 
41 naveen 1050
				Utils.severe("Mandatory slide \"" + 
37 naveen 1051
						mandatorySlideDef.getLabel() + "\" is missing");
1052
			}
1053
		}
1054
 
1055
		// 4 Retrieve "Recommended" slide names for the category
1056
		List<SlideDefinition> recommendedSlideDefs = 
1057
			defs.getSlides(this.categoryID, EditorialImportance.RECOMMENDED);
1058
 
42 naveen 1059
		Utils.info("recommendedSlideDefs=" + recommendedSlideDefs.toString());
37 naveen 1060
 
1061
		// 4.1 All recommended slides exist - Warn	
1062
		for(SlideDefinition recommendedSlideDef : recommendedSlideDefs) {
1063
			if(!this.slideNames.contains(
1064
					StringUtils.lowerCase(recommendedSlideDef.getLabel()))) {
1065
 
41 naveen 1066
				Utils.warning("Recommended slide \"" + 
37 naveen 1067
						recommendedSlideDef.getLabel() + "\" is missing");
1068
			}
1069
		}
42 naveen 1070
 
1071
		// Process children slides
1072
		for(String parentSlideName : this.slideNames) {
1073
			Utils.info("Process children slides for parentSlideName=" + 
1074
					parentSlideName);
1075
 
1076
			SlideDefinition parentSlideDef = 
1077
				this.getSlideDefinition(parentSlideName);
1078
 
1079
			// ignore for now
1080
			if(parentSlideDef == null) {
1081
				continue;
1082
			}
1083
 
1084
			this.processChildrenSlides(parentSlideDef, parentSlideName, 
1085
					parentSlideDef.getLabel());
1086
		}
1087
 
1088
		Utils.info("slideNameChildrenSlideNames=" + 
1089
				slideNameChildrenSlideNames);
37 naveen 1090
	}
1091
 
1092
	/**
1093
	 * 
42 naveen 1094
	 * @param slideName
1095
	 * @param parentSlideDefinition
1096
	 * @param crumb
1097
	 * @throws Exception 
1098
	 */
1099
	private void processChildrenSlides(SlideDefinition parentSlideDef, 
1100
			String crumb, String displayTextPrefix) throws Exception {
1101
 
1102
		List<Long> childrenSlideDefinitionIDs = 
1103
			parentSlideDef.getChildrenSlideDefinitionIDs();
1104
 
1105
		if(childrenSlideDefinitionIDs == null || 
1106
				childrenSlideDefinitionIDs.isEmpty()) {
1107
			return;
1108
		}
1109
 
1110
		DefinitionsContainer defs = 
1111
			Catalog.getInstance().getDefinitionsContainer();
1112
 
1113
		String parentSlideName = parentSlideDef.getLabel();
1114
		Utils.info("parentSlideName=" + parentSlideName + " has " + 
1115
				childrenSlideDefinitionIDs + " children slides to process");
1116
 
1117
		Utils.info("crumb=" + crumb);
1118
 
1119
		List<String> childrenSlideNames = 
1120
			this.slideNameChildrenSlideNames.get(crumb);
1121
		Utils.info("childrenSlideNames=" + childrenSlideNames);
1122
 
1123
		// Collect allowed children slide labels
1124
		List<String> validChildrenSlideNames = new ArrayList<String>();
1125
 
1126
		Map<String, SlideDefinition> childSlideNameSlideDefinition = 
1127
			new HashMap<String, SlideDefinition>();
1128
 
1129
		for(Long childSlideDefID : childrenSlideDefinitionIDs) {
1130
			Utils.info("childSlideDefID=" + childSlideDefID);
1131
 
1132
			SlideDefinition childSlideDef = 
1133
				defs.getSlideDefinition(childSlideDefID.longValue());
1134
			Utils.info("childSlideDef=" + childSlideDef);
1135
 
1136
			String displaytext = displayTextPrefix + " > " + 
1137
				childSlideDef.getLabel();
1138
 
1139
			// All children slides defined are mandatory
1140
			String childSlideName = 
1141
				StringUtils.lowerCase(childSlideDef.getLabel());
1142
			Utils.info("childSlideName=" + childSlideName);
1143
 
1144
			if(childrenSlideNames == null || 
1145
					!childrenSlideNames.contains(childSlideName)) {
1146
				Utils.severe("Missing child slide \"" + displaytext + "\"");
1147
				continue;
1148
			}
1149
 
1150
			validChildrenSlideNames.add(childSlideName);
1151
			childSlideNameSlideDefinition.put(childSlideName, childSlideDef);
1152
		}
1153
 
1154
		this.slideNameChildrenSlideNames.put(crumb, validChildrenSlideNames);
1155
		Utils.info("validChildrenSlideNames=" + validChildrenSlideNames);
1156
 
1157
		for(String childSlideName : childSlideNameSlideDefinition.keySet()) {
1158
			SlideDefinition slideDef = 
1159
				childSlideNameSlideDefinition.get(childSlideName);
1160
 
1161
			String newcrumb = crumb + "_" + 
1162
				StringUtils.lowerCase(childSlideName);
1163
 
1164
			String newDisplayTextPrefix = displayTextPrefix + " > " + 
1165
				slideDef.getLabel();
1166
 
1167
			this.processChildrenSlides(slideDef, newcrumb, 
1168
					newDisplayTextPrefix);
1169
		}
1170
	}
49 naveen 1171
 
42 naveen 1172
	/**
1173
	 * 
37 naveen 1174
	 * @param bulletText
49 naveen 1175
	 * @param featureDef
1176
	 * @param crumb
1177
	 * @param prefix
1178
	 * @return
1179
	 * @throws Exception
37 naveen 1180
	 */
1181
	private Bullet processBulletText(String bulletText, 
38 naveen 1182
			FeatureDefinition featureDef, String crumb, String prefix) 
1183
			throws Exception {
41 naveen 1184
		Utils.info("featureDef.getLabel=" + featureDef.getLabel());
1185
		Utils.info("bulletText=" + bulletText);
40 naveen 1186
 
37 naveen 1187
		BulletDefinition bulletDef = featureDef.getBulletDefinition();
41 naveen 1188
		Utils.info("bulletDefinition=" + bulletDef);
37 naveen 1189
 
1190
		DefinitionsContainer defs = 
1191
			Catalog.getInstance().getDefinitionsContainer();
1192
 
1193
		// If unit is defined
1194
		Unit unitDef =  null;
1195
		if(bulletDef.getUnitID() != 0L) {
1196
			long unitID = bulletDef.getUnitID();
1197
			unitDef = defs.getUnit(unitID);
41 naveen 1198
			Utils.info("unitDef=" + unitDef);
37 naveen 1199
		}
1200
 
1201
		long datatypeDefID = bulletDef.getDatatypeDefinitionID();
1202
		DatatypeDefinition datatypeDef = 
1203
			defs.getDatatypeDefinition(datatypeDefID);
41 naveen 1204
		Utils.info("datatypeDef=" + datatypeDef);
37 naveen 1205
 
1206
		// If primitive
1207
		boolean isEnum = false;
1208
		boolean isComposite = false;
1209
		boolean isPrimitive = false;
1210
		if(datatypeDef instanceof EnumDefinition) {
1211
			isEnum = true;
1212
		}
1213
		else if(datatypeDef instanceof CompositeDefinition) {
1214
			isComposite = true;
1215
		}
1216
		else {
1217
			isPrimitive = true;
1218
		}
1219
 
41 naveen 1220
		Utils.info("isEnum=" + isEnum + " isComposite=" + isComposite +
37 naveen 1221
				" isPrimitive=" + isPrimitive);
1222
 
1223
		// if no unit is defined for this bullet whole is treated as value
1224
		String bulletValue = bulletText;
1225
		Bullet bullet = null;
1226
 
1227
		// If unit is defined
1228
		if(bulletDef.getUnitID() != 0L) {
1229
 
1230
			// Validate unit
1231
			String[] parts = StringUtils.split(bulletText, " ");
1232
			if(parts.length < 2) {
41 naveen 1233
				Utils.severe("Unit is missing, \"" + crumb + "\" = " + 
37 naveen 1234
						bulletText);
1235
 
1236
				return null;
1237
			}
1238
 
1239
			else if(parts.length > 2) {
41 naveen 1240
				Utils.severe("Invalid value, \"" + crumb + "\" = " + 
37 naveen 1241
						bulletText);
1242
 
1243
				return null;
1244
			}
1245
 
1246
			bulletValue = parts[0];
1247
			String unitValue = parts[1];
41 naveen 1248
			Utils.info("unitValue="+unitValue);
37 naveen 1249
 
1250
			if(!(unitValue.equalsIgnoreCase(unitDef.getShortForm()) ||
1251
					unitValue.equalsIgnoreCase(unitDef.getFullForm()))) {
1252
 
41 naveen 1253
				Utils.severe("Invalid unit, \"" + crumb + "\" = " + 
37 naveen 1254
						bulletText);
1255
 
1256
			}
1257
		}
1258
 
1259
		// Validate bullet value
41 naveen 1260
		Utils.info("bulletValue=" + bulletValue);
37 naveen 1261
		if(isPrimitive) {
1262
			if(!this.validatePrimitive(bulletValue, datatypeDef, crumb)) {
1263
				return null;
1264
			}
1265
 
1266
			bullet = new Bullet(new PrimitiveDataObject(bulletValue));
1267
		}
1268
 
1269
		// Enum and fixed
1270
		else if(isEnum && !bulletDef.isLearned()) {
1271
			long enumValueID = defs.getEnumValueID(datatypeDef.getID(), 
1272
					bulletValue);
41 naveen 1273
			Utils.info("enumValueID=" + enumValueID);
37 naveen 1274
 
1275
			// Treat it to be free-form
1276
			if(enumValueID == -1L) {
41 naveen 1277
				Utils.severe("Not one of the valid enum values, \"" +
40 naveen 1278
						crumb + "\" = " + bulletValue);
37 naveen 1279
 
1280
				return null;
1281
			}
1282
 
1283
			EnumDataObject enumDataObject = new EnumDataObject(enumValueID);
1284
			bullet = new Bullet(enumDataObject);
1285
		}
1286
 
1287
		// Composite
1288
		else if(isComposite) {
1289
			CompositeDefinition compositeDef = 
1290
				(CompositeDefinition)datatypeDef;
1291
 
1292
			String separator = compositeDef.getSeparator();
1293
			String[] compositeParts = 
1294
				StringUtils.split(bulletValue, separator);
1295
 
1296
			List<CompositePartDefinition> compositePartDefs = 
1297
				compositeDef.getCompositePartDefinitions();
1298
 
1299
			// Validate number of parts
1300
			if(compositeParts.length != compositePartDefs.size()) {
41 naveen 1301
				Utils.severe("Invalid value, " + crumb + " = " + 
37 naveen 1302
						bulletValue);
1303
 
1304
				return null;
1305
			}
1306
 
1307
			// Remove spurious whitespaces
1308
			boolean validPart = true;
1309
			for(int j=0;j<compositeParts.length;j++) {
1310
				compositeParts[j] = StringUtils.strip(compositeParts[j]);
41 naveen 1311
				Utils.info("compositeParts["+ j + "]=" + 
37 naveen 1312
						compositeParts[j]);
1313
 
1314
				// Validate each part
1315
				// Each part can be enum or composite in itself
1316
				// We will stick to primitive for now
1317
				long partDatatypeDefID = 
1318
					compositePartDefs.get(j).getDatatypeDefinitionID();
1319
 
1320
				DatatypeDefinition partDatatypeDef = 
1321
					defs.getDatatypeDefinition(partDatatypeDefID);
41 naveen 1322
				Utils.info("partDatatypeDef=" + partDatatypeDef);
37 naveen 1323
 
1324
				if(!this.validatePrimitive(compositeParts[j], 
1325
						partDatatypeDef, crumb)) {
1326
					validPart = false;
1327
					break;
1328
				}
1329
			}
1330
 
1331
			if(!validPart) {
1332
				return null;
1333
			}
1334
 
1335
			CompositeDataObject compositeDataObject = 
1336
				new CompositeDataObject();
1337
 
1338
			for(int j=0;j<compositeParts.length;j++) {
1339
				compositeDataObject.addPrimitiveDataObject(
1340
						new PrimitiveDataObject(compositeParts[j]));
1341
			}
1342
 
1343
			bullet = new Bullet(compositeDataObject);
1344
		}
1345
 
38 naveen 1346
		// Free-form content at bullet level
1347
		String key = prefix + "_" + bulletText;
1348
		List<String> bulletFFCs = this.containerFCCs.get(key);
1349
		bullet.setFreeformContent(new FreeformContent(StringUtils.join(
1350
				bulletFFCs, "|")));
1351
 
37 naveen 1352
		return bullet;
1353
	}
1354
 
1355
 
1356
	/**
1357
	 * 
1358
	 * @param bulletValue
1359
	 * @param datatypeDef
1360
	 * @param crumb
1361
	 */
1362
	private boolean validatePrimitive(String bulletValue, 
1363
			DatatypeDefinition datatypeDef, String crumb) {
1364
		String dt = datatypeDef.getName();
1365
 
1366
		// integer
1367
		if(dt.equals("integer")) {
1368
			try {
1369
				Integer.parseInt(bulletValue);
1370
			}
1371
			catch(NumberFormatException nfe) {
41 naveen 1372
				Utils.severe("Invalid integer value, \"" + crumb +
40 naveen 1373
						"\" = " + bulletValue);
39 naveen 1374
				return false;
37 naveen 1375
			}
1376
		}
1377
 
1378
		// decimal
39 naveen 1379
		else if(dt.equals("decimal")) {
37 naveen 1380
			try {
1381
				Float.parseFloat(bulletValue);
1382
			}
1383
			catch(NumberFormatException nfe) {
41 naveen 1384
				Utils.severe("Invalid decimal value, \"" + crumb +
40 naveen 1385
						"\" = " + bulletValue);
39 naveen 1386
				return false;
37 naveen 1387
			}
1388
		}
1389
 
39 naveen 1390
		// hours_mins e.g. 2 hours 40 mins
1391
		else if(dt.equals("hours_mins")) {
1392
			String[]  parts = StringUtils.split(bulletValue, " ");
1393
			if(!(parts.length == 2 || parts.length == 4)) {
42 naveen 1394
				Utils.severe("Invalid value, \"" + crumb +
1395
						"\" = " + bulletValue);
39 naveen 1396
				return false;
1397
			}
1398
			// parts[0]
1399
			try {
1400
				Integer.parseInt(StringUtils.strip(parts[0]));
1401
			}
1402
			catch (NumberFormatException nfe) {
41 naveen 1403
				Utils.severe("Invalid value, \"" + crumb +
40 naveen 1404
						"\" = " + bulletValue);
39 naveen 1405
				return false;
1406
			}
1407
 
1408
			// parts[1]
42 naveen 1409
			if(!"hours".equalsIgnoreCase(StringUtils.strip(parts[1]))) {
41 naveen 1410
				Utils.severe("Invalid value, \"" + crumb +
40 naveen 1411
						"\" = " + bulletValue);
39 naveen 1412
				return false;
1413
			}
1414
 
1415
			if(parts.length == 4) {
1416
				// parts[2]
1417
				try {
1418
					Integer.parseInt(StringUtils.strip(parts[2]));
1419
				}
1420
				catch (NumberFormatException nfe) {
41 naveen 1421
					Utils.severe("Invalid value, \"" + crumb +
40 naveen 1422
							"\" = " + bulletValue);
39 naveen 1423
					return false;
1424
				}
1425
 
1426
				// parts[3]
42 naveen 1427
				if(!"mins".equalsIgnoreCase(StringUtils.strip(parts[3]))) {
41 naveen 1428
					Utils.severe("Invalid value, \"" + crumb +
40 naveen 1429
							"\" = " + bulletValue);
39 naveen 1430
					return false;
1431
				}
1432
			}
1433
		} 
1434
 
1435
		// days_hours e.g. 9 days 14 hours
1436
		else if(dt.equals("days_hours")) {
1437
			String[]  parts = StringUtils.split(bulletValue, " ");
1438
			if(!(parts.length == 2 || parts.length == 4)) {
42 naveen 1439
				Utils.severe("Invalid value, \"" + crumb +
1440
						"\" = " + bulletValue);
39 naveen 1441
				return false;
1442
			}
1443
 
1444
			// parts[0]
1445
			try {
1446
				Integer.parseInt(StringUtils.strip(parts[0]));
1447
			}
1448
			catch (NumberFormatException nfe) {
41 naveen 1449
				Utils.severe("Invalid value, \"" + crumb +
40 naveen 1450
						"\" = " + bulletValue);
39 naveen 1451
				return false;
1452
			}
1453
 
1454
			// parts[1]
42 naveen 1455
			if(!"days".equalsIgnoreCase(StringUtils.strip(parts[1]))) {
41 naveen 1456
				Utils.severe("Invalid value, \"" + crumb +
40 naveen 1457
						"\" = " + bulletValue);
39 naveen 1458
				return false;
1459
			}
1460
 
1461
			if(parts.length == 4) {
1462
				// parts[2]
1463
				try {
1464
					Integer.parseInt(StringUtils.strip(parts[2]));
1465
				}
1466
				catch (NumberFormatException nfe) {
41 naveen 1467
					Utils.severe("Invalid value, \"" + crumb +
40 naveen 1468
							"\" = " + bulletValue);
39 naveen 1469
					return false;
1470
				}
1471
 
1472
				// parts[3]
42 naveen 1473
				if("hours".equalsIgnoreCase(StringUtils.strip(parts[3]))) {
41 naveen 1474
					Utils.severe("Invalid value, \"" + crumb +
40 naveen 1475
							"\" = " + bulletValue);
39 naveen 1476
					return false;
1477
				}
1478
			}
1479
		}
1480
 
1481
		return true;
37 naveen 1482
	}
1483
 
1484
	/**
1485
	 * 
1486
	 * @param richTextRuns
1487
	 * @param info
1488
	 * @param indent
1489
	 * @param prefix
1490
	 */
36 naveen 1491
	@SuppressWarnings("unchecked")
1492
	private void drilldown(RichTextRun[] richTextRuns, 
37 naveen 1493
			Map<String, Object[]> info, int indent, String prefix) {
41 naveen 1494
		Utils.info("drilldown");
36 naveen 1495
		//System.exit(0);
1496
 
1497
 
40 naveen 1498
		Object[] featuresInfo = info.get("features");
1499
		if(featuresInfo != null) {
1500
			List<String> featureLabels = (List<String>) featuresInfo[0];
1501
			List<Integer> featureIndices = (List<Integer>) featuresInfo[1];
41 naveen 1502
			Utils.info("featureLabels=" + featureLabels);
1503
			Utils.info("featureIndices=" + featureIndices);
36 naveen 1504
 
41 naveen 1505
			Utils.info("processing features");
40 naveen 1506
			for(int i=0;i<featureLabels.size();i++) {
1507
				String featureLabel = featureLabels.get(i);
41 naveen 1508
				Utils.info("featureLabel="+featureLabel);
40 naveen 1509
 
1510
				featureLabels.set(i, StringUtils.lowerCase(
1511
						StringUtils.strip(StringUtils.trim(featureLabel))));
1512
 
1513
				int contentStartIndex = featureIndices.get(i) + 1;
1514
				int contentIndent = indent + 1;
1515
 
1516
				Map<String, Object[]> info1 = 
1517
					getContents(richTextRuns, contentStartIndex, contentIndent);
1518
 
1519
				String newprefix = StringUtils.lowerCase(prefix + "_" + 
1520
						featureLabel);
1521
 
1522
				drilldown(richTextRuns, info1, contentIndent, newprefix);
1523
			}
36 naveen 1524
 
40 naveen 1525
			if(featureLabels.size() > 0) {
44 naveen 1526
				Utils.info("prefix=" + prefix);
1527
				Utils.info("featureLabels=" + featureLabels);
1528
 
40 naveen 1529
				this.slideNameFeatureNames.put(prefix, featureLabels);
1530
			}
36 naveen 1531
		}
1532
		//System.exit(0);
1533
 
40 naveen 1534
 
1535
		Object[] bulletsInfo = info.get("bullets");
1536
		if(bulletsInfo != null) {
1537
			List<String> bulletLabels = (List<String>) bulletsInfo[0];
1538
			List<Integer> bulletIndices = (List<Integer>) bulletsInfo[1];
41 naveen 1539
			Utils.info("bulletLabels=" + bulletLabels);
1540
			Utils.info("bulletIndices=" + bulletIndices);
36 naveen 1541
 
41 naveen 1542
			Utils.info("processing bullets");
40 naveen 1543
			for(int i=0;i<bulletLabels.size();i++) {
1544
				String bulletLabel = bulletLabels.get(i);
41 naveen 1545
				Utils.info("bulletLabel="+bulletLabel);
40 naveen 1546
 
1547
				int contentStartIndex = bulletIndices.get(i) + 1;
1548
				int contentIndent = indent + 1;
1549
 
1550
				Map<String, Object[]> info1 = getContents(richTextRuns, 
1551
						contentStartIndex, contentIndent);
1552
 
1553
				drilldown(richTextRuns, info1, contentIndent, prefix);
1554
			}
36 naveen 1555
 
40 naveen 1556
			if(bulletLabels.size() > 0) {
1557
				this.slideNameFeatureNameBulletTexts.put(prefix, bulletLabels);
1558
			}
36 naveen 1559
		}
1560
		//System.exit(0);
1561
 
40 naveen 1562
 
1563
		Object[] childrenSlidesInfo = info.get("childrenSlides");
1564
		if(childrenSlidesInfo != null) {
1565
			List<String> childrenSlideLabels = 
1566
				(List<String>) childrenSlidesInfo[0];
36 naveen 1567
 
40 naveen 1568
			List<Integer> childrenSlideIndices = 
1569
				(List<Integer>) childrenSlidesInfo[1];
36 naveen 1570
 
41 naveen 1571
			Utils.info("childrenSlideLabels=" + 
40 naveen 1572
					childrenSlideLabels);
36 naveen 1573
 
41 naveen 1574
			Utils.info("childrenSlideIndices=" + 
40 naveen 1575
					childrenSlideIndices);
36 naveen 1576
 
41 naveen 1577
			Utils.info("processing children slides");
40 naveen 1578
			for(int i=0;i<childrenSlideLabels.size();i++) {
1579
				String slideLabel = childrenSlideLabels.get(i);
41 naveen 1580
				Utils.info("slideLabel="+slideLabel);
40 naveen 1581
 
1582
				childrenSlideLabels.set(i, StringUtils.lowerCase(slideLabel));
1583
 
1584
				int contentStartIndex = childrenSlideIndices.get(i) + 1;
1585
				int contentIndent = indent + 1;
1586
 
1587
				Map<String, Object[]> info1 = getContents(richTextRuns, 
1588
						contentStartIndex, contentIndent);
1589
 
1590
				String newprefix = StringUtils.lowerCase(prefix + "_" + 
1591
						slideLabel);
1592
 
1593
				drilldown(richTextRuns, info1, contentIndent, newprefix);
1594
			}
37 naveen 1595
 
40 naveen 1596
			if(childrenSlideLabels.size() > 0) {
1597
				this.slideNameChildrenSlideNames.put(prefix, 
1598
						childrenSlideLabels);
1599
			}
36 naveen 1600
		}
40 naveen 1601
 
36 naveen 1602
 
40 naveen 1603
		Object[] ffcInfo = info.get("ffc");
1604
		if(ffcInfo != null) {
1605
			List<String> ffcTexts = (List<String>) ffcInfo[0];
1606
			List<Integer> ffcIndices = (List<Integer>) ffcInfo[1];
41 naveen 1607
			Utils.info("ffcTexts=" + ffcTexts);
1608
			Utils.info("ffcIndices=" + ffcIndices);
40 naveen 1609
 
41 naveen 1610
			Utils.info("processing ffc");
40 naveen 1611
			if(ffcTexts.size() > 0) {
1612
				this.containerFCCs.put(prefix, ffcTexts);
1613
			}
37 naveen 1614
		}
36 naveen 1615
	}
1616
 
37 naveen 1617
	/**
1618
	 * 
1619
	 * @param richTextRuns
1620
	 * @param startIndex
1621
	 * @param indent
1622
	 * @return
1623
	 */
36 naveen 1624
	private Map<String, Object[]> getContents(RichTextRun[] richTextRuns, 
1625
			int startIndex, int indent) {
1626
		Map<String, Object[]> info = new HashMap<String, Object[]>();
1627
 
1628
		Object[] childrenSlidesInfo = getChildrenSlides(richTextRuns, 
1629
				startIndex, indent);
1630
		info.put("childrenSlides", childrenSlidesInfo);
1631
 
40 naveen 1632
		if(childrenSlidesInfo != null) {
41 naveen 1633
			Utils.info("childrenSlidesInfo[0]=" + 
40 naveen 1634
					childrenSlidesInfo[0]);
1635
 
41 naveen 1636
			Utils.info("childrenSlidesInfo[1]=" + 
40 naveen 1637
					childrenSlidesInfo[1]);
1638
		}
1639
 
36 naveen 1640
		Object[] featuresInfo = getFeatures(richTextRuns, 
1641
				startIndex, indent);
1642
		info.put("features", featuresInfo);
1643
 
40 naveen 1644
		if(featuresInfo != null) {
41 naveen 1645
			Utils.info("featuresInfo[0]=" + featuresInfo[0]);
1646
			Utils.info("featuresInfo[1]=" + featuresInfo[1]);
40 naveen 1647
		}
36 naveen 1648
 
1649
		Object[] bulletsInfo = getBulletInfo(richTextRuns, 
1650
				startIndex, indent);
1651
		info.put("bullets", bulletsInfo);
1652
 
40 naveen 1653
		if(bulletsInfo != null) {
41 naveen 1654
			Utils.info("bulletsInfo[0]=" + bulletsInfo[0]);
1655
			Utils.info("bulletsInfo[1]=" + bulletsInfo[1]);
40 naveen 1656
		}
36 naveen 1657
 
1658
		Object[] ffcInfo = getFreeformContent(richTextRuns, 
1659
				startIndex, indent);
1660
		info.put("ffc", ffcInfo);
1661
 
40 naveen 1662
		if(ffcInfo != null) {
41 naveen 1663
			Utils.info("ffcInfo[0]=" + ffcInfo[0]);
1664
			Utils.info("ffcInfo[1]=" + ffcInfo[1]);
40 naveen 1665
		}
36 naveen 1666
 
1667
		return info;
1668
	}
1669
 
37 naveen 1670
	/**
1671
	 * 
1672
	 * @param richTextRuns
1673
	 * @param startIndex
1674
	 * @param indent
1675
	 * @return
1676
	 */
36 naveen 1677
	private Object[] getBulletInfo(RichTextRun[] richTextRuns, 
1678
			int startIndex, int indent) {
1679
 
37 naveen 1680
		// -16776961 - Blue
36 naveen 1681
		Object[] bulletsInfo = this.getInfo(richTextRuns, startIndex, indent, 
38 naveen 1682
				HSLF.BLUE, true);
36 naveen 1683
 
1684
		return bulletsInfo;
1685
	}
1686
 
37 naveen 1687
	/**
1688
	 * 
1689
	 * @param richTextRuns
1690
	 * @param startIndex
1691
	 * @param indent
1692
	 * @return
1693
	 */
36 naveen 1694
	private Object[] getFreeformContent(RichTextRun[] richTextRuns, 
1695
			int startIndex, int indent) {
1696
 
37 naveen 1697
		// -6749953 - Purple
36 naveen 1698
		Object[] ffcInfo = this.getInfo(richTextRuns, startIndex, 
40 naveen 1699
				indent, HSLF.PURPLE, true);
36 naveen 1700
 
1701
 
1702
		return ffcInfo;
1703
	}
1704
 
37 naveen 1705
	/**
1706
	 * 
1707
	 * @param richTextRuns
1708
	 * @param startIndex
1709
	 * @param indent
1710
	 * @return
1711
	 */
36 naveen 1712
	private Object[] getFeatures(RichTextRun[] richTextRuns, 
1713
			int startIndex, int indent) {
1714
 
37 naveen 1715
		// -16711936 - Green
36 naveen 1716
		Object[] featuresInfo = this.getInfo(richTextRuns, startIndex, 
40 naveen 1717
				indent, HSLF.GREEN, true);
36 naveen 1718
 
1719
		return featuresInfo;
1720
	}
1721
 
37 naveen 1722
	/**
1723
	 * 
1724
	 * @param richTextRuns
1725
	 * @param startIndex
1726
	 * @param indent
1727
	 * @return
1728
	 */
36 naveen 1729
	private Object[] getChildrenSlides(RichTextRun[] richTextRuns, 
1730
			int startIndex, int indent) {
1731
 
37 naveen 1732
		// -26368 - Orange
36 naveen 1733
		Object[] childrenSlidesInfo = this.getInfo(richTextRuns, startIndex, 
40 naveen 1734
				indent, HSLF.ORANGE, true);
36 naveen 1735
 
1736
		return childrenSlidesInfo;
1737
	}
1738
 
37 naveen 1739
	/**
1740
	 * 
1741
	 * @param rts
1742
	 * @param startIndex
1743
	 * @param indent
1744
	 * @param rgb
1745
	 * @param debug
1746
	 * @return
1747
	 */
36 naveen 1748
	private Object[] getInfo(RichTextRun[] rts, int startIndex, 
1749
			int indent, int rgb, boolean debug) {
1750
		List<String> labels = new ArrayList<String>();
1751
		List<Integer> indices = new ArrayList<Integer>();
40 naveen 1752
 
1753
		if(startIndex >= rts.length) {
1754
			return null;
1755
		}
1756
 
36 naveen 1757
		int i = startIndex;
1758
		while(true) {
1759
			if(debug) {
41 naveen 1760
				Utils.info("rts["+i+"].getRawText=" + 
36 naveen 1761
						rts[i].getRawText());
1762
 
41 naveen 1763
				Utils.info("rts["+i+"].isBullet=" + rts[i].isBullet());
1764
				Utils.info("rts["+i+"].getIndentLevel=" + 
36 naveen 1765
						rts[i].getIndentLevel());
1766
 
41 naveen 1767
				Utils.info("rts["+i+"].getBulletColor().getRGB=" + 
36 naveen 1768
						rts[i].getBulletColor().getRGB());
1769
 
1770
 
41 naveen 1771
				Utils.info("rts["+i+"].getFontColor().getRGB=" + 
36 naveen 1772
						rts[i].getFontColor().getRGB());
1773
 
41 naveen 1774
				Utils.info("rgb=" + rgb);
1775
				Utils.info("indent=" + indent);
37 naveen 1776
 
41 naveen 1777
				Utils.info("rts.length=" + rts.length);
36 naveen 1778
			}
40 naveen 1779
			// rts[i].isBullet() && 
1780
			// rts[i].getBulletColor().getRGB() == rgb
1781
			// rts[i].getFontColor().getRGB()
1782
			if(rts[i].getIndentLevel() == indent &&
1783
					(rts[i].getBulletColor().getRGB() == rgb || 
1784
							rts[i].getFontColor().getRGB() == rgb)) {
1785
 
41 naveen 1786
				Utils.info("Criteria of color, indent etc. is met");
36 naveen 1787
				i = this.getValidLabel(i, rts, labels, indices, debug);
41 naveen 1788
				if(debug) Utils.info("new i="+ i);
36 naveen 1789
			}
41 naveen 1790
			Utils.info("labels=" + labels);
1791
			Utils.info("indices=" + indices);
36 naveen 1792
 
41 naveen 1793
			Utils.info("(i >= (rts.length-1))" + (i >= (rts.length-1)));
40 naveen 1794
			if(i >= (rts.length-1)) {
1795
				break;
1796
			}
36 naveen 1797
 
40 naveen 1798
			// rts[i+1].isBullet() && 
1799
			if(rts[i+1].getIndentLevel() < indent) {
1800
				break;
1801
			}
1802
 
36 naveen 1803
			i++;
1804
		}
1805
		return new Object[] {labels, indices};
1806
	}
1807
 
37 naveen 1808
	/**
1809
	 * 
1810
	 * @param index
1811
	 * @param rts
1812
	 * @param labels
1813
	 * @param indices
1814
	 * @param debug
1815
	 * @return
1816
	 */
36 naveen 1817
	private int getValidLabel(int index, RichTextRun[] rts, 
1818
		List<String> labels, List<Integer> indices, boolean debug){
1819
		StringBuffer sb = new StringBuffer();
1820
		while(true) {
37 naveen 1821
			if(index > rts.length - 1) {
1822
				break;
1823
			}
1824
 
36 naveen 1825
			String text = rts[index].getRawText();
1826
		    if(text.equals("\r")) {
1827
		    	break;
1828
		    }
1829
		    sb.append(text);
1830
		    index++;
1831
		}
41 naveen 1832
		if(debug)Utils.info("before label=]"+sb.toString()+"[");
36 naveen 1833
		String label = StringUtils.strip(StringUtils.trim(sb.toString()));
41 naveen 1834
		if(debug)Utils.info("after label=]"+label+"[");
36 naveen 1835
 
41 naveen 1836
		//for(int i=0;i<label.length();i++) Utils.info(label.charAt(i));
36 naveen 1837
 
1838
		if(!label.isEmpty()) {
1839
			indices.add(new Integer(index));
37 naveen 1840
 
1841
			// Remove hardspace character \xa0
1842
			char hardspace = (char)160;
1843
			char softspace = (char)32;
1844
			label = StringUtils.strip(StringUtils.replaceChars(label, 
1845
					hardspace, softspace));
1846
 
36 naveen 1847
			labels.add(label);
1848
		}
1849
 
1850
		return index;
1851
	}
41 naveen 1852
 
37 naveen 1853
	/**
1854
	 * TEST ONLY
1855
	 * 
1856
	 * @param filename
1857
	 * @throws Exception
1858
	 */
36 naveen 1859
	public static void showAllRichText(String filename) throws Exception {
1860
		HSLFSlideShow hslfSS = new HSLFSlideShow(filename);
1861
		SlideShow ss = new SlideShow(hslfSS);
1862
		Slide[] ssarr = ss.getSlides();
1863
 
1864
		for(int i=0; i < ssarr.length; i++) {
1865
			TextRun[] trarr = ssarr[i].getTextRuns();
1866
			//System.out.println("\nTitle=" + ssarr[i].getTitle());
1867
			//System.out.println(ssarr[i].getTitle());
1868
 
1869
			for(int j=0; j < trarr.length; j++) {
1870
				System.out.println("\ntrarr[" + j + "].getRawText=" + 
1871
						trarr[j].getRawText());
1872
 
1873
				RichTextRun[] rtrarr = trarr[j].getRichTextRuns();
1874
 
1875
				StringBuffer indent2 = new StringBuffer();
1876
 
1877
				for(int k=0; k < rtrarr.length; k++) {
1878
					String rawText = rtrarr[k].getRawText();
1879
					System.out.println("\nrtrarr[" + k + "].getRawText=" + 
1880
							rawText);
1881
					System.out.println("rtrarr[" + k + "].isBullet=" + 
1882
							rtrarr[k].isBullet());
1883
 
1884
					System.out.println("rtrarr[" + k + "].isUnderlined=" + 
1885
							rtrarr[k].isUnderlined());
1886
 
1887
					//System.out.println("Ends with CR=" + 
1888
					//		StringUtils.endsWith(rawText, "\r"));
1889
 
1890
					//System.out.println("\nRawText=" + rawText);
1891
 
1892
					/*
1893
					if(StringUtils.strip(rawText).isEmpty()) {
1894
						continue;
1895
					}
1896
					*/
1897
 
1898
					int indent = rtrarr[k].getIndentLevel();
1899
					System.out.println("indent=" + indent);
1900
					if(indent == 2) {
1901
						indent2.append(rawText);
1902
					}
1903
 
1904
					int rgb = rtrarr[k].getBulletColor().getRGB();
1905
					System.out.println("rgb=" + rgb);
1906
 
1907
					int fontrgb = rtrarr[k].getFontColor().getRGB();
1908
					System.out.println("font rgb=" + fontrgb);
1909
 
1910
					String fontname = rtrarr[k].getFontName();
1911
					System.out.println("font rgb=" + fontname);
1912
 
1913
				}
1914
			}
1915
		}
1916
	}
1917
 
37 naveen 1918
	/**
1919
	 * TEST ONLY
1920
	 * 
1921
	 * @param filename
1922
	 * @throws Exception
1923
	 */
36 naveen 1924
	public static void showAllText(String filename) throws Exception {
1925
		PowerPointExtractor ppe = new PowerPointExtractor(filename);
1926
		System.out.println(ppe.getText());		
1927
	}
1928
}