Subversion Repositories SmartDukaan

Rev

Rev 22647 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
479 rajveer 1
package in.shop2020.metamodel.util;
2
 
3
import in.shop2020.metamodel.core.Entity;
1050 rajveer 4
import in.shop2020.metamodel.core.EntityState;
7286 amit.gupta 5
import in.shop2020.metamodel.core.ExpertReview;
6
import in.shop2020.metamodel.core.ExpertReviewSource;
1153 rajveer 7
import in.shop2020.metamodel.core.Feature;
2275 rajveer 8
import in.shop2020.metamodel.core.Helpdoc;
1153 rajveer 9
import in.shop2020.metamodel.core.Slide;
7286 amit.gupta 10
import in.shop2020.metamodel.core.SpecialPage;
8749 amit.gupta 11
import in.shop2020.storage.mongo.StorageManager;
1584 chandransh 12
import in.shop2020.util.Utils;
479 rajveer 13
 
1584 chandransh 14
import java.io.File;
479 rajveer 15
import java.io.PrintWriter;
16
import java.io.StringWriter;
17
import java.io.Writer;
8749 amit.gupta 18
import java.lang.reflect.Type;
1153 rajveer 19
import java.util.ArrayList;
1050 rajveer 20
import java.util.Collection;
7286 amit.gupta 21
import java.util.HashMap;
479 rajveer 22
import java.util.List;
23
import java.util.Map;
7286 amit.gupta 24
import java.util.Set;
479 rajveer 25
 
8749 amit.gupta 26
import com.google.gson.reflect.TypeToken;
27
 
479 rajveer 28
/**
1154 rajveer 29
 * All storage and retrival utility methods
1050 rajveer 30
 * @author rajveer
479 rajveer 31
 *
32
 */
33
public class CreationUtils {
1050 rajveer 34
 
35
	private static final String LEARNED_BULLETS = "LEARNED_BULLETS";
36
	private static final String DEFAULT_ENTITY_SCORES = "DEFAULT_ENTITY_SCORES";
37
	private static final String FACET_VALUES = "FACET_VALUES";
38
	private static final String SLIDE_SCORES = "SLIDE_SCORES";
8024 amit.gupta 39
	private static final String CUSTOM_SLIDE_SCORES = "CUSTOM_SLIDE_SCORES";
1443 rajveer 40
	private static final String CONTENT_GENERATION_TIME = "CONTENT_GENERATION_TIME";
2094 rajveer 41
	private static final String INCONSISTENT_ENTITIES = "INCONSISTENT_ENTITIES";
2471 rajveer 42
	private static final String HELPDOC_ENTITYIDS = "HELPDOC_ENTITYIDS";
2651 rajveer 43
	private static final String RELATED_ACCESSORIES = "RELATED_ACCESSORIES";
2733 rajveer 44
	private static final String COMPARISON_STATS = "COMPARISON_STATS";
5600 amit.gupta 45
	private static final String SEARCH_STATS = "SEARCH_STATS";
5074 amit.gupta 46
	private static final String SYNONYMS = "SYNONYMS";
7286 amit.gupta 47
	private static final String EXPERT_REVIEWS = "EXPERT_REVIEWS";
48
	private static final String EXPERT_REVIEW_SOURCES = "EXPERT_REVIEW_SOURCES";
2275 rajveer 49
	private static long helpDocId;
2838 mandeep.dh 50
    private static long specialPageId;
8749 amit.gupta 51
 
479 rajveer 52
	/**
53
	 * 
1050 rajveer 54
	 * @param aThrowable
479 rajveer 55
	 * @return
56
	 */
1050 rajveer 57
	public static String getStackTrace(Throwable aThrowable) {
58
	    final Writer result = new StringWriter();
59
	    final PrintWriter printWriter = new PrintWriter(result);
60
	    aThrowable.printStackTrace(printWriter);
61
	    return result.toString();
479 rajveer 62
	}
63
 
2094 rajveer 64
    /**
65
     * 
66
     * @param entity
67
     * @throws Exception
68
     */
69
    public static void storeInconsistentEntities(List<Long> inconsistentEntities) throws Exception {
70
        StorageManager.getStorageManager().storeDataObject(CreationUtils.INCONSISTENT_ENTITIES, inconsistentEntities);      
71
    }
72
 
73
    /**
74
     * 
75
     * @return
76
     * @throws Exception
77
     */
78
    @SuppressWarnings("unchecked")
79
    public static List<Long> getInconsistentEntities() throws Exception {
8749 amit.gupta 80
    	Type t = new TypeToken<List<Long>>() {}.getType();
81
        return (List<Long>) StorageManager.getStorageManager().getDataObject(CreationUtils.INCONSISTENT_ENTITIES,t);       
2094 rajveer 82
    }
83
 
84
 
85
 
2471 rajveer 86
    /**
87
     * 
88
     * @param entity
89
     * @throws Exception
90
     */
5600 amit.gupta 91
    public static void storeSearchStats(String date, List<String> searchStats) throws Exception {
8749 amit.gupta 92
    	Map<String,List<String>> map = new HashMap<String, List<String>>();
93
    	map.put(date, searchStats);
94
    	StorageManager.getStorageManager().storeSearchStats(Long.parseLong(date), map);      
5600 amit.gupta 95
    }
2733 rajveer 96
 
5600 amit.gupta 97
    /**
98
     * 
99
     * @param entity
100
     * @throws Exception
101
     */
102
    public static void deleteSearchStats(String date) throws Exception {
8749 amit.gupta 103
    	StorageManager.getStorageManager().deleteSearchStats(Long.parseLong(date));      
5600 amit.gupta 104
    }
105
 
106
 
107
    /**
108
     * 
109
     * @return
110
     * @throws Exception
111
     */
112
    public static List<String> getSearchStats(String date) throws Exception {
8749 amit.gupta 113
    	return StorageManager.getStorageManager().getSearchStats(Long.parseLong(date));       
5600 amit.gupta 114
    }
115
 
479 rajveer 116
	/**
117
	 * 
1154 rajveer 118
	 * @param slideScoresByEntity
119
	 * @throws Exception
120
	 */
1929 rajveer 121
	public static void storeSlideScores( Map<Long, Map<Long, Double>> slideScoresByEntity) throws Exception {
1050 rajveer 122
		StorageManager.getStorageManager().storeDataObject(CreationUtils.SLIDE_SCORES, slideScoresByEntity);
123
	}
8749 amit.gupta 124
 
125
 
1050 rajveer 126
 
1154 rajveer 127
	/**
128
	 * 
129
	 * @param entityID
130
	 * @return
131
	 * @throws Exception
132
	 */
1050 rajveer 133
	@SuppressWarnings("unchecked")
1929 rajveer 134
	public static Map<Long, Double> getSlideComparisonScores(long entityID) throws Exception{
8749 amit.gupta 135
		Type t = new TypeToken<Map<Long, Map<Long,Double>>>() {}.getType();
136
		return  ((Map<Long, Map<Long,Double>>)StorageManager.getStorageManager().getDataObject(CreationUtils.SLIDE_SCORES, t)).get(entityID);
479 rajveer 137
	}
138
 
8024 amit.gupta 139
	/**
140
	 * 
141
	 * @param entityID
142
	 * @return
143
	 * @throws Exception
144
	 */
145
	@SuppressWarnings("unchecked")
146
	public static Map<Long, Double> getCustomSlideComparisonScores(long entityID) throws Exception{
8749 amit.gupta 147
		return  StorageManager.getStorageManager().getCustomSlideScores(entityID);
8024 amit.gupta 148
	}
1050 rajveer 149
 
1154 rajveer 150
	/**
151
	 * 
8024 amit.gupta 152
	 * @param entityID
153
	 * @return
154
	 * @throws Exception
155
	 */
156
	public static void storeCustomSlideComparisonScores(long entityID, Map<Long, Double> customSlideScores) throws Exception{
8749 amit.gupta 157
		StorageManager.getStorageManager().storeCustomSlideScores(entityID, customSlideScores);
8024 amit.gupta 158
	}
159
 
160
 
161
	/**
162
	 * 
1154 rajveer 163
	 * @return
164
	 * @throws Exception
165
	 */
1443 rajveer 166
	public static Long getLastContentGenerationTime() throws Exception {
8749 amit.gupta 167
		return (Long) StorageManager.getStorageManager().getDataObject(CreationUtils.CONTENT_GENERATION_TIME, Long.class);
1443 rajveer 168
	}
479 rajveer 169
 
170
	/**
1443 rajveer 171
	 * 
172
	 * @param storageTime
173
	 * @throws Exception
174
	 */
175
	public static void storeLastContentGenerationTime(Long storageTime) throws Exception {
176
		StorageManager.getStorageManager().storeDataObject(CreationUtils.CONTENT_GENERATION_TIME, storageTime);
177
	}
178
	/**
1050 rajveer 179
	 * Resolves Entity ID into Entity object
479 rajveer 180
	 * 
181
	 * @param entityID
1050 rajveer 182
	 * @return Entity
183
	 * @throws Exception 
479 rajveer 184
	 */
1050 rajveer 185
	public static Entity getEntity(long entityID) throws Exception{
186
		return StorageManager.getStorageManager().getEntity(entityID);
479 rajveer 187
	}
188
 
1154 rajveer 189
	/**
190
	 * 
191
	 * @param entity
192
	 * @throws Exception
193
	 */
1050 rajveer 194
	public static void updateEntity(Entity entity) throws Exception {
2471 rajveer 195
		//FIXME This should not happen here. 
1379 rajveer 196
		entity.reorderSlides(entity.getSlideSequence());
8865 amit.gupta 197
		//CreationUtils.learn(entity);
1050 rajveer 198
		StorageManager.getStorageManager().updateEntity(entity);
1226 rajveer 199
 
1379 rajveer 200
 
2471 rajveer 201
 
479 rajveer 202
	}
203
 
1154 rajveer 204
	/**
205
	 * 
206
	 * @param entity
207
	 * @param entityMetadata
208
	 * @throws Exception
209
	 */
1050 rajveer 210
	public static void createEntity(Entity entity, EntityState entityMetadata) throws Exception {
1584 chandransh 211
		/*
212
		 * Creating media directory by default. Even if there is no media uploaded yet.
213
		 */
214
		String mediaDirPath = Utils.CONTENT_DB_PATH + "media" + File.separator + entity.getID();
215
		File mediaDir = new File(mediaDirPath);
216
		if(!mediaDir.exists()) {
217
			mediaDir.mkdir();
218
		}
1050 rajveer 219
		StorageManager.getStorageManager().createEntity(entity, entityMetadata);
479 rajveer 220
	}
1050 rajveer 221
 
1154 rajveer 222
	/**
223
	 * 
224
	 * @param entityId
225
	 * @throws Exception
226
	 */
1050 rajveer 227
	public static void deleteEntity(long entityId) throws Exception  {
228
		StorageManager.getStorageManager().deleteEntity(entityId);
479 rajveer 229
	}
230
 
1050 rajveer 231
 
1154 rajveer 232
	/**
233
	 * 
234
	 * @return
235
	 * @throws Exception
236
	 */
8749 amit.gupta 237
	public static Map<Long, EntityState> getEntitiesState() {
1050 rajveer 238
		return StorageManager.getStorageManager().getEntitiesMetadata();
479 rajveer 239
	}
240
 
1154 rajveer 241
	/**
242
	 * 
243
	 * @param entityId
244
	 * @return
245
	 * @throws Exception
246
	 */
8749 amit.gupta 247
	public static EntityState getEntityState(long entityId) {
1050 rajveer 248
		return StorageManager.getStorageManager().getEntityMetadata(entityId);
249
	}
479 rajveer 250
 
1154 rajveer 251
	/**
252
	 * 
253
	 * @param entityMetadata
254
	 * @throws Exception
255
	 */
8749 amit.gupta 256
	public static void updateEntityState(EntityState entityMetadata) {
1050 rajveer 257
		StorageManager.getStorageManager().updateEntityMetadata(entityMetadata);
479 rajveer 258
	}
1050 rajveer 259
 
1154 rajveer 260
	/**
261
	 * 
262
	 * @param entity
263
	 * @throws Exception
264
	 */
1050 rajveer 265
	private static void learn(Entity entity) throws Exception{
266
		CN cn = new CN();
2471 rajveer 267
		cn.learn(entity);
268
		cn.learnHelpdocs(entity);
1050 rajveer 269
	}
270
 
1154 rajveer 271
	/**
272
	 * 
273
	 * @return
274
	 * @throws Exception
275
	 */
1050 rajveer 276
	public static Map<Long, Entity> getEntities() throws Exception {
277
		return StorageManager.getStorageManager().getEntities();
278
	}
279
 
1154 rajveer 280
	/**
281
	 * 
282
	 * @param categoryId
283
	 * @return
284
	 * @throws Exception
285
	 */
1050 rajveer 286
	public static Collection<Entity> getEntities(long categoryId) throws Exception {
287
		return StorageManager.getStorageManager().getEntitisByCategory(categoryId);
288
	}
1153 rajveer 289
 
2275 rajveer 290
 
291
	public static void storeHelpdoc(Helpdoc helpdoc) throws Exception {
292
		StorageManager.getStorageManager().updateHelpdoc(helpdoc);
293
	}
294
 
295
	public static Helpdoc getHelpdoc(Long helpdocId) throws Exception {
296
		return StorageManager.getStorageManager().getHelpdoc(helpdocId);
297
	}
298
 
299
	public static Map<Long, Helpdoc> getHelpdocs() throws Exception {
300
		return StorageManager.getStorageManager().getHelpdocs();
301
	}
3485 rajveer 302
 
303
	public static void deleteHelpdoc(Long helpdocId) throws Exception {
304
		StorageManager.getStorageManager().deleteHelpdoc(helpdocId);
305
	}
306
 
2275 rajveer 307
	public static long getNewHelpdocId() {
308
		if(helpDocId == 0){
309
			helpDocId = 200000;
310
			Map<Long, Helpdoc> helpdocs = StorageManager.getStorageManager().getHelpdocs();
311
			if(helpdocs != null){
312
				for(long id : StorageManager.getStorageManager().getHelpdocs().keySet()){
313
					if(helpDocId <= id){
314
						helpDocId = id;
315
					}
316
				}
317
			}	
318
		}
319
		return ++helpDocId;
320
	}
321
 
322
 
1153 rajveer 323
	/**
324
	 * 
325
	 * @param slide
326
	 * @param featureDefinitionID
327
	 * @return Feature
328
	 */
329
	public static Feature getFeature(Slide slide, long featureDefinitionID) {
330
		List<Feature> features = slide.getFeatures();
331
 
332
		if(features != null) {
333
			for(Feature feature : features) {
334
				if(feature.getFeatureDefinitionID() == featureDefinitionID) {
335
					return feature;
336
				}
337
			}
338
		}
339
 
340
		Feature feature = null;
341
 
342
		List<Slide> childrenSlides = slide.getChildrenSlides();
343
		if(childrenSlides != null) {
344
			for(Slide childSlide : childrenSlides) {
345
 
346
				feature = CreationUtils.getFeature(childSlide, featureDefinitionID);
347
				if(feature == null) {
348
					continue;
349
				}
350
				else {
351
					break;
352
				}
353
			}
354
		}
355
 
356
		return feature;
357
	}
479 rajveer 358
 
1153 rajveer 359
 
360
	/**
361
	 * Utility method to find out Slide object in Entity instance
362
	 * 
363
	 * @param entityID
364
	 * @param slideDefinitionID
365
	 * @return
366
	 * @throws Exception 
367
	 */
368
	public static Slide getSlide(long entityID, long slideDefinitionID) 
369
		throws Exception {
370
		Entity entity = CreationUtils.getEntity(entityID);
371
 
372
		List<Slide> slides = entity.getSlides();
373
 
374
		Slide resultSlide = null;
375
 
376
		if(slides != null) {
377
			for(Slide slide : slides) {
378
 
379
				if(slide.getSlideDefinitionID() == slideDefinitionID) {
380
					return slide;
381
				}
382
 
383
				resultSlide = CreationUtils.getSlide(slide, slideDefinitionID);
384
 
385
				if(resultSlide == null) {
386
					continue;
387
				}
388
				else {
389
					break;
390
				}
391
			}
392
		}
393
 
394
		return resultSlide;
395
	}
396
 
397
 
398
	/**
399
	 * 
400
	 * @param slide
401
	 * @param slideDefinitionID
402
	 * @return
403
	 */
404
	public static Slide getSlide(Slide slide, long slideDefinitionID) {
405
 
406
		List<Slide> childrenSlides = slide.getChildrenSlides();
407
 
408
		Slide resultSlide = null;
409
 
410
		if(childrenSlides != null) {
411
			for(Slide childSlide : childrenSlides) {
412
				if(childSlide.getSlideDefinitionID() == slideDefinitionID) {
413
					return childSlide;
414
				}
415
 
416
				resultSlide = CreationUtils.getSlide(childSlide, slideDefinitionID);
417
				if(resultSlide == null) {
418
					continue;
419
				}
420
				else {
421
					break;
422
				}
423
			}
424
		}
425
 
426
		return resultSlide;
427
	}
428
 
429
	/**
430
	 * Utility method to find out Feature object in Entity instance
431
	 * 
432
	 * @param entityID
433
	 * @param featureDefinitionID
434
	 * @return Feature
435
	 * @throws Exception 
436
	 */
437
	public static Feature getFeature(long entityID, long featureDefinitionID) 
438
		throws Exception {
439
		Entity entity = CreationUtils.getEntity(entityID);
440
 
441
		Feature feature = null;
442
 
443
		List<Slide> slides = entity.getSlides();
444
		for(Slide slide : slides) {
445
			feature = CreationUtils.getFeature(slide, featureDefinitionID);
446
 
447
			// Until all slides are searched
448
			if(feature == null) {
449
				continue;
450
			}
451
			else {
452
				break;
453
			}
454
		}
455
 
456
		return feature;
457
	}
458
 
459
 
460
	/**
461
	 * Returns expand form of entity object. All references are resolved into 
462
	 * corresponding detail object
463
	 * 
464
	 * @param entityID
465
	 * @return ExpandedEntity 
466
	 * @throws Exception 
467
	 */
468
	public static ExpandedEntity getExpandedEntity(long entityID) throws Exception {
469
		Entity entity = CreationUtils.getEntity(entityID);
470
		if(entity==null){
471
			System.out.println("Entity is null");
472
			return null;
473
		}
474
		System.out.println( entity.getCategoryID());
475
		ExpandedEntity expEntity = new ExpandedEntity(entity);
476
		return expEntity;
477
	}
478
 
479
	/**
480
	 * Returns first parent slide with matching label
481
	 * 
482
	 * @param expEntity2
483
	 * @param slideLabel
484
	 * @return Null if not found
485
	 */
486
	public static ExpandedSlide getParentExpandedSlide(ExpandedEntity expEntity2, String slideLabel) {
487
 
488
		ExpandedSlide matchingSlide = null;
489
		List<ExpandedSlide> expSlides = expEntity2.getExpandedSlides();
490
 
491
		for(ExpandedSlide expSlide : expSlides) {
492
			if(expSlide.getSlideDefinition().getLabel().equals(slideLabel)) {
493
				matchingSlide = expSlide;
494
				break;
495
			}
496
		}
497
 
498
		return matchingSlide;
499
	}
1165 rajveer 500
 
501
 
2768 mandeep.dh 502
	/**
2838 mandeep.dh 503
	 * Special page ids start from 300000. Here, we pick the last one used and return
2768 mandeep.dh 504
     * a value one more than it.
505
	 */
2838 mandeep.dh 506
    public static long getNewSpecialPageId() {
8749 amit.gupta 507
    	if (specialPageId == 0) {
508
    		specialPageId = StorageManager.getStorageManager().getMaxPageId();
509
    		if(specialPageId == 0) {
510
    			specialPageId = 300000;
511
    		}
2768 mandeep.dh 512
        }
513
 
2838 mandeep.dh 514
        return ++specialPageId;
2768 mandeep.dh 515
    }
516
 
517
    /**
2838 mandeep.dh 518
     * Updates a given special page object in database.
2768 mandeep.dh 519
     */
2838 mandeep.dh 520
    public static void storeSpecialPage(SpecialPage specialPage) {
521
        StorageManager.getStorageManager().updateSpecialPage(specialPage);        
2768 mandeep.dh 522
    }
523
 
524
    /**
2838 mandeep.dh 525
     * Looks up a special page given its Id from database and returns the same.
2768 mandeep.dh 526
     */
2838 mandeep.dh 527
    public static SpecialPage getSpecialPage(long specialPageId) {
528
        return StorageManager.getStorageManager().getSpecialPage(specialPageId);
2768 mandeep.dh 529
    }
530
 
531
    /**
2838 mandeep.dh 532
     * Returns all special pages in the database.
2768 mandeep.dh 533
     */
2838 mandeep.dh 534
    public static Map<Long, SpecialPage> getSpecialPages() {
535
        return StorageManager.getStorageManager().getSpecialPages();
2768 mandeep.dh 536
    }
3356 rajveer 537
 
538
    /**
539
     * delete the special pages from database.
540
     */
541
    public static void deleteSpecialPage(long specialPageId) {
542
        StorageManager.getStorageManager().deleteSpecialPage(specialPageId);
543
    }
8749 amit.gupta 544
 
545
    /**
546
     * 
547
     * @param Synonym that contains map of brand/category name as keys and their synonyms as values. 
548
     * @throws Exception
549
     */
550
    public static List<ExpertReview> getExpertReviewByEntity(long entityId) throws Exception {
551
    	return StorageManager.getStorageManager().getExpertReviewByEntity(entityId);      
552
    }
553
 
554
    public static Set<ExpertReviewSource> getExpertReviewSources() throws Exception {
555
    	return StorageManager.getStorageManager().getExpertReviewSources();      
556
    }
557
 
558
    public static void addExpertReviewSource(ExpertReviewSource expertReviewSource) throws Exception {
559
    	StorageManager.getStorageManager().storeExpertReviewSource(expertReviewSource);      
560
    }
561
 
562
    public static void deleteExpertReviewSource(ExpertReviewSource expertReviewSource) throws Exception {
563
    	StorageManager.getStorageManager().deleteExpertReviewSource(expertReviewSource);      
564
 
565
    }
566
 
567
 
568
    public static void storeExpertReview(long entityId, List<ExpertReview> expertReviews) throws Exception {
569
    	StorageManager.getStorageManager().storeExpertReview(entityId, expertReviews);      
570
    }
8905 amit.gupta 571
 
572
    public static void storeExpertReview(long entityId, ExpertReview expertReview) throws Exception {
573
    	StorageManager.getStorageManager().storeExpertReview(entityId, expertReview);      
574
    }
8749 amit.gupta 575
 
576
    public static void deleteExpertReview(long entityId, int index) throws Exception {
577
    	StorageManager.getStorageManager().deleteExpertReview(entityId, index);      
578
    }
579
 
580
    public static Map<Long, List<ExpertReview>> getExpertReviews() throws Exception {
581
    	return StorageManager.getStorageManager().getExpertReviews();      
582
    }
583
 
584
    /**
585
     * 
586
     * @param Synonym that contains map of brand/category name as keys and their synonyms as values. 
587
     * @throws Exception
588
     */
589
    public static void deleteExpertReviews(long entityId) throws Exception {
590
    	StorageManager.getStorageManager().deleteExpertReview(entityId);      
591
    }
592
 
593
 
594
 
595
    /**
596
     * 
597
     * @return
598
     * @throws Exception
599
     */
600
    @SuppressWarnings("unchecked")
601
    public static Map<Long, Map<Long, Long>> getComparisonStats() throws Exception {
602
    	Type t = new TypeToken<Map<Long, Map<Long, Long>>>() {}.getType();
603
    	return (Map<Long, Map<Long, Long>>) StorageManager.getStorageManager().getDataObject(CreationUtils.COMPARISON_STATS, t);       
604
    }
605
    /**
606
     * 
607
     * @param entity
608
     * @throws Exception
609
     */
610
    public static void storeComparisonStats(Map<Long, Map<Long, Long>> comparisonStats) throws Exception {
611
        StorageManager.getStorageManager().storeDataObject(CreationUtils.COMPARISON_STATS, comparisonStats);      
612
    }
613
 
614
 
615
    public static Map<Long, List<ExpandedBullet>> getLearnedBullets() throws Exception {
616
        return StorageManager.getStorageManager().getLearnedBullets();       
617
    }
618
 
619
    /**
620
     * 
621
     * @param entity
622
     * @throws Exception
623
     */
624
    public static void storeLearnedBullets(Map<Long, List<ExpandedBullet>> learnedBullets) throws Exception {
625
    	StorageManager.getStorageManager().storeLearnedBullets(learnedBullets);      
626
    }
627
 
628
	/**
629
	 * 
630
	 * @param featureDefinitionID
631
	 * @return
632
	 * @throws Exception
633
	 */
634
	public static List<ExpandedBullet> getLearnedBullets(long featureDefinitionID) throws Exception {
635
		Set<ExpandedBullet> expBullets = StorageManager.getStorageManager().getLearnedBulletsByFeatureId(featureDefinitionID);
636
		if(expBullets == null) return null;
637
		return new ArrayList<ExpandedBullet>(expBullets);
638
 
639
	}
640
 
641
    /**
642
     * 
643
     * @param entity
644
     * @throws Exception
645
     */
646
    public static void storeHelpdocEntityIds(Map<Long, List<Long>> helpdocEntityIds) throws Exception {
647
 
648
        StorageManager.getStorageManager().storeDataObject(CreationUtils.HELPDOC_ENTITYIDS, helpdocEntityIds);      
649
    }
650
 
651
    /**
652
     * 
653
     * @return
654
     * @throws Exception
655
     */
656
    public static Map<Long,List<Long>> getHelpdocEntityIds() throws Exception {
657
        return StorageManager.getStorageManager().getHelpdocEntityIds();       
658
    }
659
 
660
    /**
661
     * 
662
     * @return
663
     * @throws Exception
664
     */
665
    @SuppressWarnings("unchecked")
666
    public static Map<Long, Map<Long, List<Long>>> getRelatedAccessories() throws Exception {
667
    	Type t = new TypeToken<Map<Long, Map<Long, List<Long>>>>() {}.getType();
668
        return (Map<Long, Map<Long, List<Long>>>) StorageManager.getStorageManager().getDataObject(CreationUtils.RELATED_ACCESSORIES, t);       
669
    }
670
 
671
    /**
672
     * 
673
     * @param entity
674
     * @throws Exception
675
     */
676
    public static void storeRelatedAccessories(Map<Long, Map<Long, List<Long>>> relatedAccessories) throws Exception {
677
        StorageManager.getStorageManager().storeDataObject(CreationUtils.RELATED_ACCESSORIES, relatedAccessories);      
678
    }
679
 
680
    /**
681
     * 
682
     * @param Synonym that contains map of brand/category name as keys and their synonyms as values. 
683
     * @throws Exception
684
     */
685
    @SuppressWarnings("unchecked")
686
    public static Map<String, Map<String, String>> getSynonyms() throws Exception {
687
    	Type t = new TypeToken<Map<String, Map<String, String>>>() {}.getType();
688
    	return (Map<String, Map<String,String>>)StorageManager.getStorageManager().getDataObject(CreationUtils.SYNONYMS, t);      
689
    }
690
 
691
    /**
692
     * 
693
     * @param Synonym that contains map of brand/category name as keys and their synonyms as values. 
694
     * @throws Exception
695
     */
696
    public static void storeSynonyms(Map<String, Map<String, String>> synonyms) throws Exception {
697
    	StorageManager.getStorageManager().storeDataObject(CreationUtils.SYNONYMS, synonyms);      
698
    }
22647 amit.gupta 699
 
22648 amit.gupta 700
    public static List<Long> getEntitiesMarkedReady(long time) throws Exception {
22647 amit.gupta 701
    	List<Long> entityIds = StorageManager.getStorageManager().getEntityIdsAfter(time);
22648 amit.gupta 702
    	/*List<Entity> returnEntities = new ArrayList<Entity>();
22647 amit.gupta 703
    	for (Long entityId: entityIds) {
704
    		returnEntities.add(CreationUtils.getEntity(entityId));
705
    	}
22648 amit.gupta 706
    	return returnEntities;*/
707
    	return entityIds;
22647 amit.gupta 708
    }
8749 amit.gupta 709
 
479 rajveer 710
}