1 package com.calipso.reportgenerator.userinterface; 2 3 import com.calipso.reportgenerator.reportdefinitions.types.FilterDefinitionFilterTypeType; 4 import com.calipso.reportgenerator.common.LanguageTraslator; 5 import com.calipso.reportgenerator.common.ReportSpec; 6 import com.calipso.reportgenerator.common.ReportFilterSpec; 7 8 import java.util.*; 9 10 13 14 public class UserParametersCollection { 15 16 private static final int FROM_TO = 0; 17 private static final int FROM_QUANTITY = 1; 18 private static final int VALUE = 2; 19 20 private ReportSpec reportSpec; 21 private Vector userParametersCollection; 22 23 27 public UserParametersCollection(ReportSpec reportSpec){ 28 this.reportSpec = reportSpec; 29 } 30 31 35 private void fillVisibleFilterDefinitionsVector(){ 36 Collection filterCol = reportSpec.getEditFilterSpecs(); 37 for(Iterator filterColIterator = filterCol.iterator() ; filterColIterator.hasNext() ; ){ 38 ReportFilterSpec filterDefinition = (ReportFilterSpec) filterColIterator.next(); 39 if(filterDefinition.getVisual()){ 40 switch(filterDefinition.getFilterType().getType()){ 41 case FilterDefinitionFilterTypeType.RANGE_TYPE: 42 userParametersCollection.add(initializeElement(FROM_TO, filterDefinition)); 43 break; 44 case FilterDefinitionFilterTypeType.EQUALTO_TYPE: 45 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 46 break; 47 case FilterDefinitionFilterTypeType.GREATERTHAN_TYPE: 48 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 49 break; 50 case FilterDefinitionFilterTypeType.LESSTHAN_TYPE: 51 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 52 break; 53 case FilterDefinitionFilterTypeType.BEGINWITH_TYPE: 54 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 55 break; 56 case FilterDefinitionFilterTypeType.ENDWITH_TYPE: 57 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 58 break; 59 case FilterDefinitionFilterTypeType.RANKING_TYPE: 60 userParametersCollection.add(initializeElement(VALUE, filterDefinition)); 61 break; } 63 } 64 } 65 } 66 67 73 private UserParameterElement initializeElement(int type, ReportFilterSpec filterDefinition){ 74 Hashtable values = new Hashtable(); 75 Vector keysOrder = new Vector(); 76 UserParameterElement userParameterElement = null; 77 String description = reportSpec.getDimensionFromName(filterDefinition.getDimensionName()).getCaption(); 78 String filterDefinitionName = filterDefinition.getName(); 79 switch(type){ 80 case FROM_TO: 81 keysOrder.add(LanguageTraslator.traslate("146")); 82 keysOrder.add(LanguageTraslator.traslate("147")); 83 values.put(LanguageTraslator.traslate("146"), reportSpec.getParamValues(false).get(filterDefinition.getName()+"FROM").toString()); 84 values.put(LanguageTraslator.traslate("147"), reportSpec.getParamValues(false).get(filterDefinition.getName()+"TO").toString()); 85 userParameterElement = new UserParameterElement(description, values, keysOrder, filterDefinitionName, filterDefinition.getDimensionName(), reportSpec); 86 break; 87 case FROM_QUANTITY: 88 keysOrder.add(LanguageTraslator.traslate("146")); 89 keysOrder.add(LanguageTraslator.traslate("149")); 90 values.put(LanguageTraslator.traslate("146"), reportSpec.getParamValues(false).get(filterDefinition.getName()+"FROM").toString()); 91 values.put(LanguageTraslator.traslate("149"), reportSpec.getParamValues(false).get(filterDefinition.getName()+"QUANTITY").toString()); 92 userParameterElement = new UserParameterElement(description, values, keysOrder, filterDefinitionName, filterDefinition.getDimensionName(), reportSpec); 93 break; 94 case VALUE: 95 keysOrder.add(LanguageTraslator.traslate("150")); 96 values.put(LanguageTraslator.traslate("150"), reportSpec.getParamValues(false).get(filterDefinition.getName()+"VALUE").toString()); 97 userParameterElement = new UserParameterElement(description, values, keysOrder, filterDefinitionName, filterDefinition.getDimensionName(), reportSpec); 98 break; 99 } 100 return userParameterElement; 101 } 102 103 107 public Vector getUserParametersCollection(){ 108 if(userParametersCollection == null){ 109 userParametersCollection = new Vector(); 110 fillVisibleFilterDefinitionsVector(); 111 } 112 return userParametersCollection; 113 } 114 } 115 | Popular Tags |