From 125cb3291c406f74eac4135675d7bf51660801ad Mon Sep 17 00:00:00 2001 From: Manish Vishnoi Date: Fri, 11 Mar 2016 22:44:15 +0530 Subject: [PATCH 1/2] Fixes order in Indicators export in long period projects --- .../servlet/exporter/template/IndicatorEntryCalcTemplate.java | 1 + .../servlet/exporter/template/IndicatorEntryExcelTemplate.java | 1 + .../org/sigmah/shared/dto/pivot/content/PivotTableData.java | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java index e41adfd18..6e8637840 100644 --- a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java +++ b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java @@ -218,6 +218,7 @@ private void createDetailSheet(final IndicatorDTO indicator) throws Throwable { Map columnIndexMap = new HashMap(); for (PivotTableData.Axis axis : leaves) { CalcUtils.putHeader(row, ++cellIndex, axis.getLabel()); + axis.setLabel(String.valueOf(cellIndex)); columnIndexMap.put(axis.getLabel(), cellIndex); } diff --git a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java index 704a68ae5..5840866de 100644 --- a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java +++ b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java @@ -215,6 +215,7 @@ private void createDetailSheet(final IndicatorDTO indicator) { Map columnIndexMap = new HashMap(); for (PivotTableData.Axis axis : leaves) { utils.putHeader(row, ++cellIndex, axis.getLabel()); + axis.setLabel(String.valueOf(cellIndex)); columnIndexMap.put(axis.getLabel(), cellIndex); } diff --git a/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java b/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java index fef0e502e..c651a169c 100644 --- a/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java +++ b/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java @@ -384,7 +384,7 @@ private void setCategory(DimensionCategory category) { } @SuppressWarnings("unused") - private void setLabel(String label) { + public void setLabel(String label) { this.label = label; } From bc91322eea8f501222128a5096576941eee727bf Mon Sep 17 00:00:00 2001 From: Manish Vishnoi Date: Fri, 25 Mar 2016 21:26:43 +0530 Subject: [PATCH 2/2] change by making function not changing immutability --- .../exporter/template/IndicatorEntryCalcTemplate.java | 2 +- .../exporter/template/IndicatorEntryExcelTemplate.java | 2 +- .../sigmah/shared/dto/pivot/content/PivotTableData.java | 9 +++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java index 6e8637840..67847f01c 100644 --- a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java +++ b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryCalcTemplate.java @@ -218,7 +218,7 @@ private void createDetailSheet(final IndicatorDTO indicator) throws Throwable { Map columnIndexMap = new HashMap(); for (PivotTableData.Axis axis : leaves) { CalcUtils.putHeader(row, ++cellIndex, axis.getLabel()); - axis.setLabel(String.valueOf(cellIndex)); + axis.cellIndexValue(String.valueOf(cellIndex)); columnIndexMap.put(axis.getLabel(), cellIndex); } diff --git a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java index 5840866de..9169ea9be 100644 --- a/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java +++ b/src/main/java/org/sigmah/server/servlet/exporter/template/IndicatorEntryExcelTemplate.java @@ -215,7 +215,7 @@ private void createDetailSheet(final IndicatorDTO indicator) { Map columnIndexMap = new HashMap(); for (PivotTableData.Axis axis : leaves) { utils.putHeader(row, ++cellIndex, axis.getLabel()); - axis.setLabel(String.valueOf(cellIndex)); + axis.cellIndexValue(String.valueOf(cellIndex)); columnIndexMap.put(axis.getLabel(), cellIndex); } diff --git a/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java b/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java index c651a169c..00b11226c 100644 --- a/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java +++ b/src/main/java/org/sigmah/shared/dto/pivot/content/PivotTableData.java @@ -59,7 +59,7 @@ public PivotTableData(List rowDimensions, List columnDimen rootRow = new Axis(); rootColumn = new Axis(); } - + public boolean isEmpty() { return rootRow.isLeaf() && rootColumn.isLeaf(); } @@ -215,6 +215,11 @@ public Axis(Axis parent, Dimension dimension, DimensionCategory category, String this.category = category; this.label = label; } + + public void cellIndexValue(String label){ + + this.label = label; + } public Axis getChild(DimensionCategory category) { return childMap.get(category); @@ -384,7 +389,7 @@ private void setCategory(DimensionCategory category) { } @SuppressWarnings("unused") - public void setLabel(String label) { + private void setLabel(String label) { this.label = label; }