001: package com.calipso.reportgenerator.userinterface;
002:
003: import com.calipso.reportgenerator.common.ReportSpec;
004: import com.calipso.reportgenerator.common.ReportFilterSpec;
005: import com.calipso.reportgenerator.common.LanguageTraslator;
006: import com.calipso.reportgenerator.reportdefinitions.types.FilterDefinitionFilterTypeType;
007: import com.calipso.reportgenerator.reportdefinitions.types.ParameterValueFilterParameterType;
008: import com.calipso.reportgenerator.reportcalculator.FilterOperation;
009:
010: import java.util.Vector;
011: import java.util.Collection;
012: import java.util.Iterator;
013: import java.util.Map;
014:
015: /**
016: * Crea instancias de <code>UPCollectionElement</code> por cada dimension.
017: * Cada instancia de <code>UPCollectionElement</code> conoce todos los datos
018: * del filtro de una determinada dimension.
019: */
020:
021: public class UPCollection {
022:
023: private ReportSpec reportSpec;
024: private Vector upCollection;
025: private Map existingParams;
026:
027: public UPCollection(ReportSpec reportSpec, Map existingParams) {
028: this .reportSpec = reportSpec;
029: this .existingParams = existingParams;
030: }
031:
032: public Vector getUpCollection() {
033: if (upCollection == null) {
034: upCollection = new Vector();
035: initializeCollection();
036: }
037: return upCollection;
038: }
039:
040: private void initializeCollection() {
041: Collection filterCol = reportSpec.getEditFilterSpecs();
042: for (Iterator filterColIterator = filterCol.iterator(); filterColIterator
043: .hasNext();) {
044: ReportFilterSpec filterDefinition = (ReportFilterSpec) filterColIterator
045: .next();
046: if (filterDefinition.getVisual()
047: && !isPreset(filterDefinition)) {
048: switch (filterDefinition.getFilterType().getType()) {
049: case FilterDefinitionFilterTypeType.RANGE_TYPE:
050: upCollection.add(new UPRangeElement(
051: filterDefinition, reportSpec, "FROM", "TO",
052: LanguageTraslator.traslate("146"),
053: LanguageTraslator.traslate("147")));
054: break;
055: case FilterDefinitionFilterTypeType.EQUALTO_TYPE:
056: upCollection.add(new UPValueElement(
057: filterDefinition, reportSpec, "VALUE",
058: LanguageTraslator.traslate("150")));
059: break;
060: case FilterDefinitionFilterTypeType.GREATERTHAN_TYPE:
061: upCollection.add(new UPValueElement(
062: filterDefinition, reportSpec, "VALUE",
063: LanguageTraslator.traslate("150")));
064: break;
065: case FilterDefinitionFilterTypeType.LESSTHAN_TYPE:
066: upCollection.add(new UPValueElement(
067: filterDefinition, reportSpec, "VALUE",
068: LanguageTraslator.traslate("150")));
069: break;
070: case FilterDefinitionFilterTypeType.BEGINWITH_TYPE:
071: upCollection.add(new UPValueElement(
072: filterDefinition, reportSpec, "VALUE",
073: LanguageTraslator.traslate("150")));
074: break;
075: case FilterDefinitionFilterTypeType.ENDWITH_TYPE:
076: upCollection.add(new UPValueElement(
077: filterDefinition, reportSpec, "VALUE",
078: LanguageTraslator.traslate("150")));
079: break;
080: case FilterDefinitionFilterTypeType.INCLUDES_TYPE:
081: upCollection.add(new UPValueElement(
082: filterDefinition, reportSpec, "VALUE",
083: LanguageTraslator.traslate("150")));
084: break;
085: case FilterDefinitionFilterTypeType.RANKING_TYPE:
086: upCollection.add(new UPValueElement(
087: filterDefinition, reportSpec, "VALUE",
088: LanguageTraslator.traslate("150")));
089: break;
090: case FilterDefinitionFilterTypeType.IN_TYPE:
091: upCollection.add(new UPValueElement(
092: filterDefinition, reportSpec, "VALUES",
093: LanguageTraslator.traslate("390")));
094: break;
095: case FilterDefinitionFilterTypeType.EXCLUDEGROUP_TYPE:
096: upCollection.add(new UPExcludeElement(
097: filterDefinition, reportSpec));
098: break;
099: }
100: }
101: }
102: }
103:
104: private boolean isPreset(ReportFilterSpec filterDefinition) {
105: if (existingParams == null) {
106: return false;
107: } else {
108: return existingParams.containsKey(filterDefinition
109: .getParamNames().get(0));
110: }
111: }
112: }
|