Subversion Repositories SmartDukaan

Rev

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

Rev 71 Rev 72
Line 90... Line 90...
90
	 * Hashtable of SlideDefinition ID to CMPSlideRuleDefinition object
90
	 * Hashtable of SlideDefinition ID to CMPSlideRuleDefinition object
91
	 */
91
	 */
92
	private Map<Long, CMPSlideRuleDefinition> cmpSlideRuleDefinitions;
92
	private Map<Long, CMPSlideRuleDefinition> cmpSlideRuleDefinitions;
93
	
93
	
94
	/**
94
	/**
-
 
95
	 * Hashtable of Category ID to list of CMPBucketDefinition object
-
 
96
	 */
-
 
97
	private Map<Long, List<CMPBucketDefinition>> cmpBucketDefinitions;
-
 
98
	
-
 
99
	/**
95
	 * Empty constructor. Data structures are initialised as needed
100
	 * Empty constructor. Data structures are initialised as needed
96
	 */
101
	 */
97
	public DefinitionsContainer() {
102
	public DefinitionsContainer() {
98
		// Lazy initialization
103
		// Lazy initialization
99
	}
104
	}
Line 876... Line 881...
876
		ExpandedCMPSlideRuleDefinition expDef = 
881
		ExpandedCMPSlideRuleDefinition expDef = 
877
			new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
882
			new ExpandedCMPSlideRuleDefinition(cmpSlideRuleDef);
878
		
883
		
879
		return expDef;
884
		return expDef;
880
	}
885
	}
-
 
886
 
881
	
887
	
-
 
888
	/**
-
 
889
	 * Returns all ComparisonSlideRuleDefintion objects in the database
-
 
890
	 * 
-
 
891
	 * @return Map Null if Comparison slide-rule definitions are not imported 
-
 
892
	 * into definitions db (serialized java objects)
-
 
893
	 * 
-
 
894
	 * @throws Exception 
-
 
895
	 */
-
 
896
	@SuppressWarnings("unchecked")
-
 
897
	public Map<Long, List<CMPBucketDefinition>> getComparisonBucketDefinitions() 
-
 
898
		throws Exception {
-
 
899
		
-
 
900
		// De-serialize
-
 
901
		if(this.cmpBucketDefinitions == null) {
-
 
902
			String dbFile = Utils.DEFINITIONS_DB_PATH +	"comparisonbuckets.ser";
-
 
903
			Utils.info("dbFile=" + dbFile);
-
 
904
			
-
 
905
			this.cmpBucketDefinitions = 
-
 
906
				(Map<Long, List<CMPBucketDefinition>>) DBUtils.read(dbFile);
-
 
907
		}
-
 
908
		
-
 
909
		return this.cmpBucketDefinitions;
-
 
910
	}
-
 
911
	
-
 
912
	/**
-
 
913
	 * Resolves Category ID into List of CMPBucketDefinition object
-
 
914
	 * 
-
 
915
	 * @param categoryID
-
 
916
	 * @return List<CMPBucketDefinition> 
-
 
917
	 * @throws Exception
-
 
918
	 */
-
 
919
	public List<CMPBucketDefinition> getComparisonBucketDefinitions(
-
 
920
			long categoryID) throws Exception {
-
 
921
		
-
 
922
		if(this.cmpBucketDefinitions == null) {
-
 
923
			this.getComparisonBucketDefinitions();
-
 
924
		}
-
 
925
		
-
 
926
		return this.cmpBucketDefinitions.get(new Long(categoryID));
-
 
927
	}
-
 
928
	
-
 
929
	/**
-
 
930
	 * Resolve comparison bucket name for a slide in a particular category
-
 
931
	 * 
-
 
932
	 * @param categoryID
-
 
933
	 * @param slideDefintionID
-
 
934
	 * @return Bucket Name if found else Null
-
 
935
	 * @throws Exception 
-
 
936
	 */
-
 
937
	public String getComparisonBucketName(long categoryID, 
-
 
938
			long slideDefinitionID) throws Exception {
-
 
939
		List<CMPBucketDefinition> cmpBuckets = 
-
 
940
			this.getComparisonBucketDefinitions(categoryID);
-
 
941
		
-
 
942
		for (CMPBucketDefinition cmpBucket : cmpBuckets) {
-
 
943
			List<Long> slideDefinitionIDs = cmpBucket.getSlideDefinitionIDs();
-
 
944
			
-
 
945
			if(slideDefinitionIDs.contains(new Long(slideDefinitionID))) {
-
 
946
				return cmpBucket.getName();
-
 
947
			}
-
 
948
		}
-
 
949
		
-
 
950
		return null;
-
 
951
	}
882
}
952
}