Subversion Repositories SmartDukaan

Rev

Rev 49 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 49 Rev 62
Line 3... Line 3...
3
 */
3
 */
4
package in.shop2020.metamodel.definitions;
4
package in.shop2020.metamodel.definitions;
5
 
5
 
6
import in.shop2020.metamodel.util.DBUtils;
6
import in.shop2020.metamodel.util.DBUtils;
7
import in.shop2020.metamodel.util.ExpandedCategory;
7
import in.shop2020.metamodel.util.ExpandedCategory;
-
 
8
import in.shop2020.metamodel.util.ExpandedCategoryFacetDefinition;
-
 
9
import in.shop2020.metamodel.util.ExpandedFacetDefinition;
8
import in.shop2020.metamodel.util.MM;
10
import in.shop2020.metamodel.util.MM;
9
 
11
 
10
import java.io.Serializable;
12
import java.io.Serializable;
11
import java.util.ArrayList;
13
import java.util.ArrayList;
12
import java.util.Iterator;
14
import java.util.Iterator;
Line 55... Line 57...
55
	 * Hashtable of Unit ID to Unit object
57
	 * Hashtable of Unit ID to Unit object
56
	 */
58
	 */
57
	private Map<Long, Unit> units;
59
	private Map<Long, Unit> units;
58
	
60
	
59
	/**
61
	/**
-
 
62
	 * Hashtable of Facet Definition ID to FacetDefinition object
-
 
63
	 */
-
 
64
	private Map<Long, FacetDefinition> facetDefinitions;
-
 
65
	
-
 
66
	/**
-
 
67
	 * Hashtable of Category Facet Definition ID to CategoryFacetDefinition 
-
 
68
	 * object
-
 
69
	 */
-
 
70
	private Map<Long, CategoryFacetDefinition> categoryFacetDefinitions;
-
 
71
	
-
 
72
	/**
-
 
73
	 * Hashtable of IR Data Rule ID to RuleDefinition object
-
 
74
	 */
-
 
75
	private Map<Long, RuleDefinition> irDataRuleDefinitions;	
-
 
76
	
-
 
77
	/**
-
 
78
	 * Hashtable of IR Meta Data Rule ID to RuleDefinition object
-
 
79
	 */
-
 
80
	private Map<Long, RuleDefinition> irMetaDataRuleDefinitions;
-
 
81
 
-
 
82
	
-
 
83
	/**
60
	 * Empty constructor. Data structures are initialised as needed
84
	 * Empty constructor. Data structures are initialised as needed
61
	 */
85
	 */
62
	public DefinitionsContainer() {
86
	public DefinitionsContainer() {
63
		// Lazy initialization
87
		// Lazy initialization
64
	}
88
	}
Line 527... Line 551...
527
			this.getEnumValues();
551
			this.getEnumValues();
528
		}
552
		}
529
		
553
		
530
		return this.enumValues.get(new Long(enumValueID));
554
		return this.enumValues.get(new Long(enumValueID));
531
	}
555
	}
-
 
556
	
-
 
557
	/**
-
 
558
	 * Returns all FacetDefinition objects in the database
-
 
559
	 * 
-
 
560
	 * @return Map Null if facet definitions are not imported into definitions 
-
 
561
	 * db (serialized java objects)
-
 
562
	 * 
-
 
563
	 * @throws Exception 
-
 
564
	 */
-
 
565
	@SuppressWarnings("unchecked")
-
 
566
	public Map<Long, FacetDefinition> getFacetDefinitions() throws Exception {
-
 
567
		
-
 
568
		// De-serialize
-
 
569
		if(this.facetDefinitions == null) {
-
 
570
			String dbFile = MM.DEFINITIONS_DB_PATH + "facetdefintions" + ".ser";
-
 
571
			
-
 
572
			this.facetDefinitions = 
-
 
573
				(Map<Long, FacetDefinition>) DBUtils.read(dbFile);
-
 
574
		}
-
 
575
		
-
 
576
		return this.facetDefinitions;
-
 
577
	}
-
 
578
	
-
 
579
	/**
-
 
580
	 * Resolves Facet Definition ID into FacetDefinition object
-
 
581
	 * 
-
 
582
	 * @param facetDefinitionID
-
 
583
	 * @return FacetDefinition
-
 
584
	 * @throws Exception
-
 
585
	 */
-
 
586
	public FacetDefinition getFacetDefinition(long facetDefinitionID) 
-
 
587
		throws Exception {
-
 
588
		
-
 
589
		if(this.facetDefinitions == null) {
-
 
590
			this.getFacetDefinitions();
-
 
591
		}
-
 
592
		
-
 
593
		return this.facetDefinitions.get(new Long(facetDefinitionID));
-
 
594
	}
-
 
595
	
-
 
596
	/**
-
 
597
	 * Utility method to get Expanded version of ExpandedFacetDefinition object 
-
 
598
	 * 
-
 
599
	 * @param facetDefinitionID
-
 
600
	 * @return ExpandedFacetDefinition
-
 
601
	 * @throws Exception
-
 
602
	 */
-
 
603
	public ExpandedFacetDefinition getExpandedFacetDefinition(
-
 
604
			long facetDefinitionID) throws Exception {
-
 
605
		
-
 
606
		FacetDefinition facetDefinition = 
-
 
607
			this.getFacetDefinition(facetDefinitionID);
-
 
608
		
-
 
609
		ExpandedFacetDefinition expFacetDefinition = 
-
 
610
			new ExpandedFacetDefinition(facetDefinition);
-
 
611
		
-
 
612
		return expFacetDefinition;
-
 
613
	}
-
 
614
	
-
 
615
	/**
-
 
616
	 * Returns all CategoryFacetDefinition objects in the database
-
 
617
	 * 
-
 
618
	 * @return Map Null if category facet definitions are not imported into 
-
 
619
	 * definitions db (serialized java objects)
-
 
620
	 * 
-
 
621
	 * @throws Exception 
-
 
622
	 */
-
 
623
	@SuppressWarnings("unchecked")
-
 
624
	public Map<Long, CategoryFacetDefinition> getCategoryFacetDefinitions() 
-
 
625
		throws Exception {
-
 
626
		
-
 
627
		// De-serialize
-
 
628
		if(this.categoryFacetDefinitions == null) {
-
 
629
			String dbFile = MM.DEFINITIONS_DB_PATH + "categoryfacetdefintions" + 
-
 
630
				".ser";
-
 
631
			
-
 
632
			this.categoryFacetDefinitions = 
-
 
633
				(Map<Long, CategoryFacetDefinition>) DBUtils.read(dbFile);
-
 
634
		}
-
 
635
		
-
 
636
		return this.categoryFacetDefinitions;
-
 
637
	}
-
 
638
	
-
 
639
	/**
-
 
640
	 * Resolves Category-Facet Definition ID into CategoryFacetDefinition object
-
 
641
	 * 
-
 
642
	 * @param categoryID
-
 
643
	 * @return CategoryFacetDefinition
-
 
644
	 * @throws Exception
-
 
645
	 */
-
 
646
	public CategoryFacetDefinition getCategoryFacetDefinition(
-
 
647
			long categoryID) throws Exception {
-
 
648
		
-
 
649
		if(this.categoryFacetDefinitions == null) {
-
 
650
			this.getCategoryFacetDefinitions();
-
 
651
		}
-
 
652
		
-
 
653
		return this.categoryFacetDefinitions.get(
-
 
654
				new Long(categoryID));
-
 
655
	}
-
 
656
	
-
 
657
	/**
-
 
658
	 * Utility method to get Expanded version of CategoryFacetDefinition object 
-
 
659
	 * 
-
 
660
	 * @param categoryID
-
 
661
	 * @return ExpandedCategoryFacetDefinition
-
 
662
	 * @throws Exception
-
 
663
	 */
-
 
664
	public ExpandedCategoryFacetDefinition getExpandedCategoryFacetDefinition(
-
 
665
			long categoryID) throws Exception  {
-
 
666
		CategoryFacetDefinition categoryFacetDef = 
-
 
667
			this.getCategoryFacetDefinition(categoryID);
-
 
668
		
-
 
669
		ExpandedCategoryFacetDefinition expCategoryFacetDef = 
-
 
670
			new ExpandedCategoryFacetDefinition(categoryFacetDef);
-
 
671
		
-
 
672
		return expCategoryFacetDef;
-
 
673
	}
-
 
674
	
-
 
675
	/**
-
 
676
	 * Returns all IR Data RuleDefintion objects in the database
-
 
677
	 * 
-
 
678
	 * @return Map Null if IR data rule definitions are not imported into 
-
 
679
	 * definitions db (serialized java objects)
-
 
680
	 * 
-
 
681
	 * @throws Exception 
-
 
682
	 */
-
 
683
	@SuppressWarnings("unchecked")
-
 
684
	public Map<Long, RuleDefinition> getIrDataRuleDefinitions() 
-
 
685
		throws Exception {
-
 
686
		
-
 
687
		// De-serialize
-
 
688
		if(this.irDataRuleDefinitions == null) {
-
 
689
			String dbFile = MM.DEFINITIONS_DB_PATH + "irdatarules" + ".ser";
-
 
690
			
-
 
691
			this.irDataRuleDefinitions = 
-
 
692
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
-
 
693
		}
-
 
694
		
-
 
695
		return this.irDataRuleDefinitions;
-
 
696
	}
-
 
697
	
-
 
698
	/**
-
 
699
	 * Resolves IR Data Rule Definition ID into RuleDefinition object
-
 
700
	 * 
-
 
701
	 * @param irDataRuleDefinitionID
-
 
702
	 * @return RuleDefinition
-
 
703
	 * @throws Exception
-
 
704
	 */
-
 
705
	public RuleDefinition getIrDataRuleDefinition(
-
 
706
			long irDataRuleDefinitionID) throws Exception {
-
 
707
		
-
 
708
		if(this.irDataRuleDefinitions == null) {
-
 
709
			this.getIrDataRuleDefinitions();
-
 
710
		}
-
 
711
		
-
 
712
		return this.irDataRuleDefinitions.get(new Long(irDataRuleDefinitionID));
-
 
713
	}
-
 
714
	
-
 
715
	/**
-
 
716
	 * Returns all IR Meta Data RuleDefintion objects in the database
-
 
717
	 * 
-
 
718
	 * @return Map Null if IR meta-data rule definitions are not imported into 
-
 
719
	 * definitions db (serialized java objects)
-
 
720
	 * 
-
 
721
	 * @throws Exception 
-
 
722
	 */
-
 
723
	@SuppressWarnings("unchecked")
-
 
724
	public Map<Long, RuleDefinition> getIrMetaDataRuleDefinitions() 
-
 
725
		throws Exception {
-
 
726
		
-
 
727
		// De-serialize
-
 
728
		if(this.irMetaDataRuleDefinitions == null) {
-
 
729
			String dbFile = MM.DEFINITIONS_DB_PATH + "irmetadatarules" + ".ser";
-
 
730
			
-
 
731
			this.irMetaDataRuleDefinitions = 
-
 
732
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
-
 
733
		}
-
 
734
		
-
 
735
		return this.irMetaDataRuleDefinitions;
-
 
736
	}
-
 
737
	
-
 
738
	/**
-
 
739
	 * Resolves IR Meta Data Rule Definition ID into RuleDefinition object
-
 
740
	 * 
-
 
741
	 * @param irMetaDataRuleDefinitionID
-
 
742
	 * @return RuleDefinition
-
 
743
	 * @throws Exception
-
 
744
	 */
-
 
745
	public RuleDefinition getIrMetaDataRuleDefinition(
-
 
746
			long irMetaDataRuleDefinitionID) throws Exception {
-
 
747
		
-
 
748
		if(this.irMetaDataRuleDefinitions == null) {
-
 
749
			this.getIrMetaDataRuleDefinitions();
-
 
750
		}
-
 
751
		
-
 
752
		return this.irMetaDataRuleDefinitions.get(
-
 
753
				new Long(irMetaDataRuleDefinitionID));
-
 
754
	}
532
}
755
}