Source Code Cross Referenced for PivotTableProperties.java in  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » userinterface » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Report » jmagallanes 1.0 » com.calipso.reportgenerator.userinterface 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.calipso.reportgenerator.userinterface;
002:
003:        import com.calipso.reportgenerator.reportdefinitions.types.*;
004:        import com.calipso.reportgenerator.reportdefinitions.ReportView;
005:        import com.calipso.reportgenerator.reportdefinitions.DimensionProperty;
006:        import com.calipso.reportgenerator.reportdefinitions.*;
007:        import com.calipso.reportgenerator.reportcalculator.expression.*;
008:        import com.calipso.reportgenerator.reportcalculator.SharedFloat;
009:        import com.calipso.reportgenerator.reportcalculator.SharedInteger;
010:        import com.calipso.reportgenerator.common.*;
011:
012:        import java.util.*;
013:        import java.awt.*;
014:        import java.text.DateFormat;
015:        import java.text.SimpleDateFormat;
016:        import java.text.ParseException;
017:
018:        import com.calipso.reportgenerator.common.InfoException;
019:
020:        /**
021:         * User: pgore
022:         * Date: Jun 12, 2003
023:         * Time: 1:13:21 PM
024:         */
025:        /**
026:         * Esta clase implementa el comportamiento de una vista
027:         */
028:        public class PivotTableProperties {
029:            private ArrayList columnProperties;
030:            private boolean withTotal;
031:            private ArrayList visibleMetrics;
032:            private ColorConditionManager conditionManager;
033:            private ReportResult reportResult;
034:            private Map params;
035:            private Map metricStates;
036:            private final int DEFAULT_COLUMN_WIDTH = 75;
037:
038:            /**
039:             * Crea un objeto PivotTableProperties
040:             */
041:            public PivotTableProperties() {
042:                columnProperties = new ArrayList();
043:                visibleMetrics = new ArrayList();
044:            }
045:
046:            public PivotTableProperties(ReportResult reportResult)
047:                    throws InfoException {
048:                columnProperties = new ArrayList();
049:                visibleMetrics = new ArrayList();
050:                this .reportResult = reportResult;
051:                initTableProperties();
052:            }
053:
054:            /**
055:             * Asigna las propiedades desde el view
056:             * @param reportView
057:             * @throws InfoException
058:             */
059:            public void assignFromView(ReportView reportView)
060:                    throws InfoException {
061:                overrideDimensionProperties(reportView);
062:                overrideMetricsProperties(reportView);
063:                overrideLightBoxerProperties(reportView);
064:                this .withTotal = reportView.getVisibleTotals();
065:            }
066:
067:            /**
068:             * Iniocializa el objeto PivotTablePropertie
069:             * @throws InfoException
070:             */
071:            private void initTableProperties() throws InfoException {
072:                try {
073:                    ArrayList rowList = (ArrayList) reportResult
074:                            .getReportQuery().getDimensionsByLocation(
075:                                    DimensionDefinitionLocationType.ROW);
076:                    fillColumnsProperties(rowList,
077:                            DimensionDefinitionLocationType.ROW.toString());
078:                    ArrayList pageList = (ArrayList) reportResult
079:                            .getReportQuery().getDimensionsByLocation(
080:                                    DimensionDefinitionLocationType.PAGE);
081:                    fillColumnsProperties(pageList,
082:                            DimensionDefinitionLocationType.PAGE.toString());
083:                    ArrayList columnList = (ArrayList) reportResult
084:                            .getReportQuery().getDimensionsByLocation(
085:                                    DimensionDefinitionLocationType.COLUMN);
086:                    fillColumnsProperties(columnList,
087:                            DimensionDefinitionLocationType.COLUMN.toString());
088:                } catch (Exception e) {
089:                    throw new InfoException(LanguageTraslator.traslate("227"));
090:                }
091:                getMetricStates();
092:            }
093:
094:            /**
095:             * Retorna un map con los estados de las metricas
096:             * @return
097:             */
098:            public Map getMetricStates() {
099:                if (metricStates == null) {
100:                    metricStates = new HashMap();
101:                    loadAllMetrics(metricStates);
102:                }
103:                return metricStates;
104:            }
105:
106:            /**
107:             * Carga el valor de todas las metricas y setea pivotTableProperties
108:             * @param states
109:             */
110:            private void loadAllMetrics(Map states) {
111:                java.util.List list = reportResult.getReportQuery()
112:                        .getMetrics();
113:                for (int index = 0; index < list.size(); index++) {
114:                    QueryMetric queryMetric = (QueryMetric) list.get(index);
115:                    ReportMetricSpec metricSpec = reportResult
116:                            .getMetricFromName(queryMetric.getName());
117:                    MetricState metricState = new MetricState(metricSpec);
118:                    metricState.setVisible(queryMetric.getVisible());
119:                    states.put(metricSpec.getName(), metricState);
120:                    setVisibleMetrics(metricState);
121:                }
122:            }
123:
124:            /**
125:             * Llena las propiedades de las Columnas de la vista correspondiente
126:             * @param list
127:             * @param location
128:             * @throws InfoException
129:             */
130:            private void fillColumnsProperties(ArrayList list, String location)
131:                    throws InfoException {
132:                Iterator iterator = list.iterator();
133:                while (iterator.hasNext()) {
134:                    QueryDimension dimension = (QueryDimension) iterator.next();
135:                    ColumnProperties properties = new ColumnProperties();
136:                    properties.setColumnName(dimension.getName());
137:                    properties.setWidth(DEFAULT_COLUMN_WIDTH);
138:                    int indexDimension = reportResult.getReportQuery()
139:                            .getQueryDimensionFromName(
140:                                    properties.getColumnName()).getIndex();
141:                    if (reportResult.getReportQuery().getExcludedValues(
142:                            indexDimension) != null) {
143:                        properties.setExcludeValue(reportResult
144:                                .getReportQuery().getExcludedValues(
145:                                        indexDimension));
146:                    } else {
147:                        properties.setExcludeValue(new TreeSet());
148:                    }
149:                    properties.setOrder(reportResult.getReportQuery()
150:                            .getQueryDimensionFromName(
151:                                    properties.getColumnName()).getOrder());
152:                    properties.setLocation(location);
153:                    properties.setRankMetricName(reportResult.getReportQuery()
154:                            .getQueryDimensionFromName(
155:                                    properties.getColumnName())
156:                            .getRankMetricName());
157:                    properties.setOrder(reportResult.getReportQuery()
158:                            .getQueryDimensionFromName(
159:                                    properties.getColumnName()).getOrder());
160:                    getColumnProperties().add(properties);
161:                }
162:            }
163:
164:            /**
165:             * Borra los valores excluidos que contenga la columna y agrega los que trae de la definicion del perfil
166:             * @param dimensionProperty
167:             * @param columnProperty
168:             */
169:            private void overrideExcludeValues(
170:                    DimensionProperty dimensionProperty,
171:                    ColumnProperties columnProperty) {
172:                if ((dimensionProperty != null) && (columnProperty != null)
173:                        && (columnProperty.getExcludeValue() != null)) {
174:                    columnProperty.getExcludeValue().clear();
175:                    ReportDimensionSpec dimensionSpec = reportResult
176:                            .getReportSpec().getDimensionFromName(
177:                                    dimensionProperty.getDimensionName());
178:                    switch (dimensionSpec.getDataType().getType()) {
179:                    case ReportDataType.DATETIME_TYPE:
180:                    case ReportDataType.DATE_TYPE:
181:                        overrideDateExcludeValues(dimensionProperty,
182:                                columnProperty);
183:                        break;
184:                    case ReportDataType.STRING_TYPE:
185:                        overrideStringExludeValues(dimensionProperty,
186:                                columnProperty);
187:                        break;
188:                    case ReportDataType.FLOAT_TYPE:
189:                        overrideFloatExcludeValues(dimensionProperty,
190:                                columnProperty);
191:                    case ReportDataType.INTEGER_TYPE:
192:                        overrideIntegerExcludeValues(dimensionProperty,
193:                                columnProperty);
194:                        break;
195:                    case ReportDataType.BOOLEAN_TYPE:
196:                        overrideBooleanExcludeValues(dimensionProperty,
197:                                columnProperty);
198:                        break;
199:                    }
200:                }
201:            }
202:
203:            private void overrideBooleanExcludeValues(
204:                    DimensionProperty dimensionProperty,
205:                    ColumnProperties columnProperty) {
206:                for (int i = 0; i < dimensionProperty.getExcludeValueCount(); i++) {
207:                    String value = dimensionProperty.getExcludeValue()[i]
208:                            .getValue();
209:                    columnProperty.getExcludeValue()
210:                            .add(Boolean.valueOf(value));
211:                }
212:            }
213:
214:            private void overrideIntegerExcludeValues(
215:                    DimensionProperty dimensionProperty,
216:                    ColumnProperties columnProperty) {
217:                for (int i = 0; i < dimensionProperty.getExcludeValueCount(); i++) {
218:                    String value = dimensionProperty.getExcludeValue()[i]
219:                            .getValue();
220:                    columnProperty.getExcludeValue().add(
221:                            SharedInteger.newFrom(new Integer(value)));
222:                }
223:            }
224:
225:            private void overrideFloatExcludeValues(
226:                    DimensionProperty dimensionProperty,
227:                    ColumnProperties columnProperty) {
228:                for (int i = 0; i < dimensionProperty.getExcludeValueCount(); i++) {
229:                    String value = dimensionProperty.getExcludeValue()[i]
230:                            .getValue();
231:                    columnProperty.getExcludeValue().add(
232:                            SharedFloat.newFrom(new Float(value)));
233:                }
234:            }
235:
236:            private void overrideStringExludeValues(
237:                    DimensionProperty dimensionProperty,
238:                    ColumnProperties columnProperty) {
239:                for (int i = 0; i < dimensionProperty.getExcludeValueCount(); i++) {
240:                    columnProperty.getExcludeValue().add(
241:                            dimensionProperty.getExcludeValue()[i].getValue());
242:                }
243:            }
244:
245:            private void overrideDateExcludeValues(
246:                    DimensionProperty dimensionProperty,
247:                    ColumnProperties columnProperty) {
248:                for (int i = 0; i < dimensionProperty.getExcludeValueCount(); i++) {
249:                    try {
250:                        String value = dimensionProperty.getExcludeValue()[i]
251:                                .getValue();
252:                        DateFormat dateFormat = SimpleDateFormat
253:                                .getDateInstance(DateFormat.SHORT,
254:                                        LanguageTraslator.getLocale());
255:                        columnProperty.getExcludeValue().add(
256:                                dateFormat.parse(value));
257:                    } catch (ParseException e) {
258:                        e.printStackTrace();
259:                    }
260:                }
261:            }
262:
263:            /**
264:             * Carga los semáforos para la vista
265:             *
266:             * @param reportView
267:             */
268:            private void overrideLightBoxerProperties(ReportView reportView) {
269:                LightBoxDefinition lightBoxDefinition;
270:                Expression expresion = null;
271:                boolean andExpresion;
272:
273:                boolean isRange = false;
274:                conditionManager.clearValues();
275:                int lightBoxDefinitionCount = reportView.getLightBoxer() == null ? 0
276:                        : reportView.getLightBoxer()
277:                                .getLightBoxDefinitionCount();
278:                for (int i = 0; i < lightBoxDefinitionCount; i++) {
279:                    andExpresion = false;
280:                    lightBoxDefinition = reportView.getLightBoxer()
281:                            .getLightBoxDefinition()[i];
282:                    if (isRange) {
283:                        isRange = false;
284:                        expresion = getEndRangeExpresion(expresion,
285:                                lightBoxDefinition);
286:                        andExpresion = true;
287:                    } else {
288:                        if (lightBoxDefinition.getType().getType() == LightBoxDefinitionTypeType.RANGE
289:                                .getType()) {
290:                            isRange = true;
291:                            expresion = getStartRangeExpresion(lightBoxDefinition);
292:                            andExpresion = false;
293:                        } else {
294:                            expresion = getSimpleExpresion(lightBoxDefinition);
295:                            andExpresion = true;
296:                        }
297:                    }
298:                    if (andExpresion) {
299:                        Color color = new Color(lightBoxDefinition
300:                                .getColorRed(), lightBoxDefinition
301:                                .getColorGreen(), lightBoxDefinition
302:                                .getColorBlue());
303:                        MetricState metricState = new MetricState(
304:                                getReportResult().getReportSpec()
305:                                        .getMetricFromName(
306:                                                lightBoxDefinition
307:                                                        .getMetricName()));
308:                        metricState.setVisible(true);
309:                        ColorCondition colorCondition = new ColorCondition(
310:                                expresion, color, metricState);
311:                        conditionManager.put(colorCondition);
312:                    }
313:                }
314:            }
315:
316:            private void overrideMetricsProperties(ReportView reportView)
317:                    throws InfoException {
318:                if (reportView.getMetricProperties() != null) {
319:                    MetricProperty metricProperty;
320:                    for (int i = 0; i < visibleMetrics.size(); i++) {
321:                        MetricState metricsState = (MetricState) visibleMetrics
322:                                .get(i);
323:                        metricProperty = getMetricPropertyFromName(metricsState
324:                                .getName(), reportView);
325:                        if (metricProperty != null) {
326:                            metricsState
327:                                    .setVisible(metricProperty.getVisible());
328:                        }
329:                    }
330:                }
331:            }
332:
333:            private MetricProperty getMetricPropertyFromName(String metricName,
334:                    ReportView reportView) throws InfoException {
335:                if (reportView.getMetricProperties() != null) {
336:                    int size = reportView.getMetricProperties()
337:                            .getMetricPropertyCount();
338:                    MetricProperty metricProperty;
339:                    for (int i = 0; i < size; i++) {
340:                        metricProperty = reportView.getMetricProperties()
341:                                .getMetricProperty()[i];
342:                        if (metricProperty.getMetricName().equalsIgnoreCase(
343:                                metricName)) {
344:                            return metricProperty;
345:                        }
346:                    }
347:                }
348:                throw new InfoException(LanguageTraslator.traslate("107"));
349:            }
350:
351:            private DimensionProperty getDimensionPropertyFromName(
352:                    String DimensionName, ReportView reportView) {
353:                if (reportView.getDimensionProperties() != null) {
354:                    int size = reportView.getDimensionProperties()
355:                            .getDimensionPropertyCount();
356:                    DimensionProperty DimensionProperty;
357:                    for (int i = 0; i < size; i++) {
358:                        DimensionProperty = reportView.getDimensionProperties()
359:                                .getDimensionProperty()[i];
360:                        if (DimensionProperty.getDimensionName()
361:                                .equalsIgnoreCase(DimensionName)) {
362:                            return DimensionProperty;
363:                        }
364:                    }
365:                }
366:                return null;
367:                //    throw new InfoException("INFO - No se encontró la dimension");//todo :Activar
368:            }
369:
370:            private void overrideDimensionProperties(ReportView reportView) {
371:                if (reportView.getDimensionProperties() != null) {
372:                    DimensionProperty dimensionProperty;
373:                    ColumnProperties columnProperty;
374:                    for (int i = 0; i < columnProperties.size(); i++) {
375:                        columnProperty = (ColumnProperties) columnProperties
376:                                .get(i);
377:                        dimensionProperty = getDimensionPropertyFromName(
378:                                columnProperty.getColumnName(), reportView);
379:                        if (dimensionProperty != null) {
380:                            columnProperty.setWidth(dimensionProperty
381:                                    .getWidth());
382:                        }
383:                        overrideExcludeValues(dimensionProperty, columnProperty);
384:                        columnProperty.setLocation(dimensionProperty
385:                                .getLocation().toString());
386:                        columnProperty.setUbication(dimensionProperty
387:                                .getUbication());
388:                        columnProperty
389:                                .setOrder(getDimensionDefinitionOrderType(dimensionProperty
390:                                        .getOrder()));
391:                        columnProperty.setRankMetricName(dimensionProperty
392:                                .getRankMetricName());
393:                    }
394:                }
395:            }
396:
397:            /**
398:             * Transforma DimensionPropertyOrderType a un DimensionDefinitionOrderType
399:             * @param order
400:             * @return
401:             */
402:            private DimensionDefinitionOrderType getDimensionDefinitionOrderType(
403:                    DimensionPropertyOrderType order) {
404:                if (order.toString().equalsIgnoreCase(
405:                        DimensionDefinitionOrderType.A.toString())) {
406:                    return DimensionDefinitionOrderType.A;
407:                } else if (order.toString().equalsIgnoreCase(
408:                        DimensionDefinitionOrderType.D.toString())) {
409:                    return DimensionDefinitionOrderType.D;
410:                }
411:                return null;
412:            }
413:
414:            /**
415:             * Retorna todas las ColumnProperties para la vista
416:             * @return
417:             */
418:            public ArrayList getColumnProperties() {
419:                return columnProperties;
420:            }
421:
422:            public void setColumnProperties(ColumnProperties properties) {
423:                this .columnProperties.add(properties);
424:            }
425:
426:            /**
427:             * Determina si la vista es con o sin totales
428:             * @return
429:             */
430:            public boolean isWithTotal() {
431:                return withTotal;
432:            }
433:
434:            /**
435:             * Setea la vista con totales o sin totales
436:             * @param withTotal
437:             */
438:            public void setWithTotal(boolean withTotal) {
439:                this .withTotal = withTotal;
440:            }
441:
442:            public ArrayList getMetricProperies() {
443:                return visibleMetrics;
444:            }
445:
446:            public void setVisibleMetrics(MetricState state) {
447:                this .visibleMetrics.add(state);
448:            }
449:
450:            public ColorConditionManager getConditionManager() {
451:                return conditionManager;
452:            }
453:
454:            public void setConditionManager(
455:                    ColorConditionManager conditionManager) {
456:                this .conditionManager = conditionManager;
457:            }
458:
459:            /**
460:             * Construye un report view a partir de las propiedades actualies del cubo
461:             * @param ID
462:             * @param userID
463:             * @param description
464:             * @return
465:             */
466:            public ReportView getReportView(String ID, String userID,
467:                    String description) {
468:                ReportView reportView = ReportViewBuilder
469:                        .getDefaultReportViewHeader(ID, userID, description,
470:                                reportResult);
471:                buildDimensionsProperties(reportView);
472:                buildMetricsProperties(reportView);
473:                buildLigthBox(reportView);
474:                //reportView.setDefault();
475:                return reportView;
476:            }
477:
478:            /**
479:             * Contruye los objetos para serializar del semáforo
480:             * @param reportView
481:             */
482:            private void buildLigthBox(ReportView reportView) {
483:                LightBoxer ligthBoxer = new LightBoxer();
484:                reportView.setLightBoxer(ligthBoxer);
485:                LightBoxDefinition lightBox;
486:                ColorCondition colorCondition;
487:                Expression expression;
488:                Vector conditions;
489:                for (int i = 0; i < getConditionManagerSize(); i++) {
490:                    conditions = (Vector) conditionManager
491:                            .getValuesMetricConditions().values().toArray()[i];
492:                    for (int cond = 0; cond < conditions.size(); cond++) {
493:                        colorCondition = (ColorCondition) conditions.toArray()[cond];
494:                        lightBox = new LightBoxDefinition();
495:                        ligthBoxer.addLightBoxDefinition(lightBox);
496:                        lightBox.setMetricName(colorCondition.getMetricName());
497:                        lightBox.setColorBlue(colorCondition.getColor()
498:                                .getBlue());
499:                        lightBox.setColorGreen(colorCondition.getColor()
500:                                .getGreen());
501:                        lightBox
502:                                .setColorRed(colorCondition.getColor().getRed());
503:                        expression = colorCondition.getExpression();
504:                        lightBox.setType(getTypeLightBox(expression));
505:                        if (expression instanceof  AndExp) {
506:                            lightBox
507:                                    .setParameter(LightBoxDefinitionParameterType.FROM);
508:                            lightBox.setValue(getArgumentConstant(expression
509:                                    .getArguments()[0].getArguments()));
510:
511:                            lightBox = new LightBoxDefinition();
512:                            ligthBoxer.addLightBoxDefinition(lightBox);
513:                            lightBox.setMetricName(colorCondition
514:                                    .getMetricName());
515:                            lightBox.setColorBlue(colorCondition.getColor()
516:                                    .getBlue());
517:                            lightBox.setColorGreen(colorCondition.getColor()
518:                                    .getGreen());
519:                            lightBox.setColorRed(colorCondition.getColor()
520:                                    .getRed());
521:                            lightBox.setType(getTypeLightBox(expression));
522:                            lightBox.setValue(getArgumentConstant(expression
523:                                    .getArguments()[1].getArguments()));
524:                            lightBox
525:                                    .setParameter(LightBoxDefinitionParameterType.TO);
526:                        } else {
527:                            lightBox.setValue(getArgumentConstant(expression
528:                                    .getArguments()));
529:                            lightBox
530:                                    .setParameter(LightBoxDefinitionParameterType.VALUE);
531:                        }
532:                    }
533:                }
534:
535:            }
536:
537:            /**
538:             * Deuleve de los argumentos cuna el la cosntante
539:             * @param arguments
540:             * @return
541:             */
542:            private String getArgumentConstant(Expression[] arguments) {
543:                if (arguments[0].isConstant()) {
544:                    return arguments[0].toString();
545:                } else if (arguments[1].isConstant()) {
546:                    return arguments[1].toString();
547:                }
548:                return "";
549:            }
550:
551:            /**
552:             * Devuelve la cantidad de elementos que contiene el semáforo
553:             * @return
554:             */
555:            private int getConditionManagerSize() {
556:                if (conditionManager == null) {
557:                    return 0;
558:                } else {
559:                    return conditionManager.getValuesMetricConditions()
560:                            .values().size();
561:                }
562:            }
563:
564:            /**
565:             * Devuelve los tipo de filtros segun la expresion generada
566:             * @param expression
567:             * @return
568:             */
569:            private LightBoxDefinitionTypeType getTypeLightBox(
570:                    Expression expression) {
571:                if (expression instanceof  AndExp) {
572:                    return LightBoxDefinitionTypeType.RANGE;
573:                } else if (expression instanceof  EqualTo) {
574:                    return LightBoxDefinitionTypeType.EQUAL;
575:                } else if (expression instanceof  GreaterOrEqualTo) {
576:                    return LightBoxDefinitionTypeType.GREATEREQUALTHAN;
577:                } else if (expression instanceof  GreaterThan) {
578:                    return LightBoxDefinitionTypeType.GREATERTHAN;
579:                } else if (expression instanceof  LessOrEqualTo) {
580:                    return LightBoxDefinitionTypeType.LESSEQUALTHAN;
581:                } else if (expression instanceof  LessThan) {
582:                    return LightBoxDefinitionTypeType.LESSTHAN;
583:                }
584:                return null;
585:            }
586:
587:            /**
588:             * Contruye los objetos para serializar de la métricas
589:             * @param reportView
590:             */
591:            private void buildMetricsProperties(ReportView reportView) {
592:                MetricProperties metricProperties = new MetricProperties();
593:                reportView.setMetricProperties(metricProperties);
594:                MetricProperty metricProperty;
595:                MetricState metricState;
596:                for (int i = 0; i < visibleMetrics.size(); i++) {
597:                    metricState = (MetricState) visibleMetrics.get(i);
598:                    metricProperty = new MetricProperty();
599:                    metricProperties.addMetricProperty(metricProperty);
600:                    metricProperty.setMetricName(metricState.getName());
601:                    metricProperty.setVisible(metricState.getVisible());
602:                }
603:            }
604:
605:            /**
606:             * Contruye los objetos para serializar de las dimensiones
607:             * @param reportView
608:             */
609:            private void buildDimensionsProperties(ReportView reportView) {
610:                DimensionProperties dimensionsProperties = new DimensionProperties();
611:                reportView.setDimensionProperties(dimensionsProperties);
612:                DimensionProperty dimensionProperty;
613:                ColumnProperties columnProperty;
614:                for (int i = 0; i < columnProperties.size(); i++) {
615:                    columnProperty = (ColumnProperties) columnProperties.get(i);
616:                    dimensionProperty = new DimensionProperty();
617:                    dimensionsProperties
618:                            .addDimensionProperty(dimensionProperty);
619:                    dimensionProperty.setDimensionName(columnProperty
620:                            .getColumnName());
621:                    dimensionProperty.setWidth(columnProperty.getWidth());
622:                    dimensionProperty.setOrder(ReportViewBuilder
623:                            .getDimensionPropertyOrder(columnProperty
624:                                    .getOrder()));
625:                    dimensionProperty.setLocation(ReportViewBuilder
626:                            .getDimensionPropertyLocation(columnProperty
627:                                    .getLocation()));
628:                    dimensionProperty.setUbication(columnProperty
629:                            .getUbication());
630:                    dimensionProperty.setRankMetricName(columnProperty
631:                            .getRankMetricName());
632:                    buildExcludeValues(dimensionProperty, columnProperty);
633:                }
634:
635:            }
636:
637:            /**
638:             * Conruye los valores excluidos para la dimension
639:             * @param dimensionProperty
640:             * @param columnProperty
641:             */
642:            private void buildExcludeValues(
643:                    DimensionProperty dimensionProperty,
644:                    ColumnProperties columnProperty) {
645:                Iterator excludedValues = columnProperty.getExcludeValue()
646:                        .iterator();
647:                while (excludedValues.hasNext()) {
648:                    Object value = excludedValues.next();
649:                    ExcludeValue excludeValue = new ExcludeValue();
650:                    excludeValue.setValue(value.toString());
651:                    dimensionProperty.addExcludeValue(excludeValue);
652:                }
653:            }
654:
655:            public ReportResult getReportResult() {
656:                return reportResult;
657:            }
658:
659:            public void setReportResult(ReportResult reportResult)
660:                    throws InfoException {
661:                this .reportResult = reportResult;
662:                updateColumnsProperties();
663:            }
664:
665:            public void updateColumnsProperties() throws InfoException {
666:                Iterator iterator = this .getColumnProperties().iterator();
667:                while (iterator.hasNext()) {
668:                    ColumnProperties properties = (ColumnProperties) iterator
669:                            .next();
670:                    Set set = reportResult
671:                            .getDimensionUnCheckedValues(properties
672:                                    .getColumnName());
673:                    if (set != null) {
674:                        properties.setExcludeValue(set);
675:                    } else {
676:                        properties.setExcludeValue(new TreeSet());
677:                    }
678:                }
679:            }
680:
681:            private Expression getSimpleExpresion(
682:                    LightBoxDefinition lightBoxDefinition) {
683:                if (lightBoxDefinition.getType().toString().equalsIgnoreCase(
684:                        LightBoxDefinitionTypeType.EQUAL.toString())) {
685:                    return (new VariableExp("VALUE")
686:                            .newEqualTo(new ConstantExp(new Float(
687:                                    lightBoxDefinition.getValue()))));
688:                } else if (lightBoxDefinition.getType().toString()
689:                        .equalsIgnoreCase(
690:                                LightBoxDefinitionTypeType.GREATEREQUALTHAN
691:                                        .toString())) {
692:                    return (new VariableExp("VALUE")
693:                            .newGreaterOrEqualTo(new ConstantExp(new Float(
694:                                    lightBoxDefinition.getValue()))));
695:                } else if (lightBoxDefinition.getType().toString()
696:                        .equalsIgnoreCase(
697:                                LightBoxDefinitionTypeType.GREATERTHAN
698:                                        .toString())) {
699:                    return (new VariableExp("VALUE")
700:                            .newGreaterThan(new ConstantExp(new Float(
701:                                    lightBoxDefinition.getValue()))));
702:                } else if (lightBoxDefinition.getType().toString()
703:                        .equalsIgnoreCase(
704:                                LightBoxDefinitionTypeType.LESSEQUALTHAN
705:                                        .toString())) {
706:                    return (new VariableExp("VALUE")
707:                            .newLessOrEquealTo(new ConstantExp(new Float(
708:                                    lightBoxDefinition.getValue()))));
709:                } else if (lightBoxDefinition.getType().toString()
710:                        .equalsIgnoreCase(
711:                                LightBoxDefinitionTypeType.LESSTHAN.toString())) {
712:                    return (new VariableExp("VALUE")
713:                            .newLessThan(new ConstantExp(new Float(
714:                                    lightBoxDefinition.getValue()))));
715:                }
716:                return null;
717:            }
718:
719:            //(new VariableExp("VALUE")).newLessOrEquealTo(new ConstantExp(new Float(value)));
720:
721:            private Expression getStartRangeExpresion(
722:                    LightBoxDefinition lightBoxDefinition) {
723:                return (new VariableExp("VALUE")
724:                        .newGreaterThan(new ConstantExp(new Float(
725:                                lightBoxDefinition.getValue()))));
726:            }
727:
728:            private Expression getEndRangeExpresion(Expression expresion,
729:                    LightBoxDefinition lightBoxDefinition) {
730:                return new AndExp(expresion, (new VariableExp("VALUE")
731:                        .newLessThan(new ConstantExp(new Float(
732:                                lightBoxDefinition.getValue())))));
733:            }
734:
735:            /**
736:             * Devuelve la columna segun el nombre solicicitado
737:             * @param columnName
738:             */
739:            public ColumnProperties getRowColumn(String columnName) {
740:                ColumnProperties currentColumnProperties;
741:                for (int i = 0; i < columnProperties.size(); i++) {
742:                    currentColumnProperties = (ColumnProperties) columnProperties
743:                            .get(i);
744:                    if (currentColumnProperties.getColumnName()
745:                            .equalsIgnoreCase(columnName)) {
746:                        return currentColumnProperties;
747:                    }
748:                }
749:                return null;
750:            }
751:
752:            /**
753:             * Devuelve los filter parameters values
754:             * @return
755:             */
756:            public Map getParams() {
757:                if (params == null) {
758:                    params = new Hashtable();
759:                }
760:                return params;
761:            }
762:
763:            public void newColumnPropertiesArrayList(ArrayList list) {
764:                columnProperties = null;
765:                columnProperties = list;
766:            }
767:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.