Subversion Repositories SmartDukaan

Rev

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

Rev 88 Rev 102
Line 93... Line 93...
93
	
93
	
94
	/**
94
	/**
95
	 * Hashtable of Category ID to list of CMPBucketDefinition object
95
	 * Hashtable of Category ID to list of CMPBucketDefinition object
96
	 */
96
	 */
97
	private Map<Long, List<CMPBucketDefinition>> cmpBucketDefinitions;
97
	private Map<Long, List<CMPBucketDefinition>> cmpBucketDefinitions;
-
 
98
 
-
 
99
	/**
-
 
100
	 * Hashtable of feature definition ID to normalization rule definition ID
-
 
101
	 */
-
 
102
	private Map<Long, RuleDefinition> normalizationRuleDefinitions;
98
	
103
	
99
	/**
104
	/**
100
	 * Empty constructor. Data structures are initialised as needed
105
	 * Empty constructor. Data structures are initialised as needed
101
	 */
106
	 */
102
	public DefinitionsContainer() {
107
	public DefinitionsContainer() {
Line 1079... Line 1084...
1079
			}
1084
			}
1080
		}
1085
		}
1081
		
1086
		
1082
		return null;
1087
		return null;
1083
	}
1088
	}
-
 
1089
 
-
 
1090
	/**
-
 
1091
	 * Returns all normalization rule defined
-
 
1092
	 * 
-
 
1093
	 * @return Map<Long, RuleDefinition> 
-
 
1094
	 * @throws Exception 
-
 
1095
	 */
-
 
1096
	@SuppressWarnings("unchecked")
-
 
1097
	public Map<Long, RuleDefinition> getNormalizationRules() throws Exception {
-
 
1098
		
-
 
1099
		// De-serialize
-
 
1100
		if(this.normalizationRuleDefinitions == null) {
-
 
1101
			String dbFile = Utils.DEFINITIONS_DB_PATH +	
-
 
1102
				"normalizationrules.ser";
-
 
1103
			
-
 
1104
			Utils.info("dbFile=" + dbFile);
-
 
1105
			
-
 
1106
			this.normalizationRuleDefinitions = 
-
 
1107
				(Map<Long, RuleDefinition>) DBUtils.read(dbFile);
-
 
1108
		}
-
 
1109
		
-
 
1110
		return this.normalizationRuleDefinitions;
-
 
1111
	}
-
 
1112
 
-
 
1113
	
-
 
1114
	/**
-
 
1115
	 * True if feature has normalization rule defined
-
 
1116
	 * 
-
 
1117
	 * @param feature
-
 
1118
	 * @return boolean 
-
 
1119
	 * @throws Exception 
-
 
1120
	 */
-
 
1121
	public boolean needsNormalization(long featureDefinitionID) 
-
 
1122
		throws Exception {
-
 
1123
		this.getFeatureDefinitions();
-
 
1124
		
-
 
1125
		FeatureDefinition featureDef = 
-
 
1126
			this.featureDefinitions.get(new Long(featureDefinitionID));
-
 
1127
		
-
 
1128
		if(featureDef.getNormalizationRuleDefinitionID() != 0L) {
-
 
1129
			return true;
-
 
1130
		}
-
 
1131
		
-
 
1132
		return false;
-
 
1133
	}
-
 
1134
	
-
 
1135
	/**
-
 
1136
	 * Returns normalization rule definition for rule definition ID
-
 
1137
	 * 
-
 
1138
	 * @param ruleID
-
 
1139
	 * @return RuleDefinition 
-
 
1140
	 * @throws Exception 
-
 
1141
	 */
-
 
1142
	public RuleDefinition getNormalizationRuleDefinition(
-
 
1143
			long ruleDefinitionID) throws Exception {
-
 
1144
		this.getNormalizationRules();
-
 
1145
		
-
 
1146
		return this.normalizationRuleDefinitions.get(
-
 
1147
				new Long(ruleDefinitionID));
-
 
1148
	}
1084
}
1149
}