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