dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11016
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3051: Simplified section data set report slightly
------------------------------------------------------------
revno: 3051
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-03-16 17:26:53 +0100
message:
Simplified section data set report slightly
renamed:
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewCustomDataSetReportForm.vm => dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewDefaultDataSetReportForm.vm => dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewSectionDataSetReportForm.vm => dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm
modified:
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateSectionDataSetReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateSectionDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateSectionDataSetReportAction.java 2011-03-11 12:35:11 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateSectionDataSetReportAction.java 2011-03-16 16:26:53 +0000
@@ -34,9 +34,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.aggregation.AggregationService;
@@ -44,7 +42,6 @@
import org.hisp.dhis.common.GridHeader;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
-import org.hisp.dhis.dataelement.comparator.DataElementCategoryOptionComboNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.Section;
import org.hisp.dhis.dataset.comparator.SectionOrderComparator;
@@ -102,7 +99,7 @@
// Output
// -------------------------------------------------------------------------
- private List<Grid> grids;
+ private List<Grid> grids = new ArrayList<Grid>();
private String reportingUnit;
@@ -195,55 +192,33 @@
public String execute()
throws Exception
{
- String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY,
- DEFAULT_AGGREGATION_STRATEGY );
-
- // ---------------------------------------------------------------------
- // Get option-combo by sectionId
- // ---------------------------------------------------------------------
+ String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY );
List<Section> sections = new ArrayList<Section>( selectedDataSet.getSections() );
-
Collections.sort( sections, new SectionOrderComparator() );
- Map<Integer, List<DataElementCategoryOptionCombo>> optionCombosMap = new HashMap<Integer, List<DataElementCategoryOptionCombo>>();
-
- for ( Section section : sections )
- {
- List<DataElementCategoryOptionCombo> optionCombos = new ArrayList<DataElementCategoryOptionCombo>( section
- .getDataElements().iterator().next().getCategoryCombo().getOptionCombos() );
-
- Collections.sort( optionCombos, new DataElementCategoryOptionComboNameComparator() );
-
- optionCombosMap.put( section.getId(), optionCombos );
- }
-
// ---------------------------------------------------------------------
// Create a grid for each section
// ---------------------------------------------------------------------
- grids = new ArrayList<Grid>();
-
for ( Section section : sections )
{
Grid grid = new ListGrid().setTitle( section.getName() );
- List<DataElementCategoryOptionCombo> optionComnbos = optionCombosMap.get( section.getId() );
-
- // ---------------------------------------------------------------------
- // Headers for GRID
- // ---------------------------------------------------------------------
-
- grid.addHeader( new GridHeader( i18n.getString( "dataelement" ), false, true ) );
-
- for ( DataElementCategoryOptionCombo optionCombo : optionComnbos )
+ // -----------------------------------------------------------------
+ // Grid headers
+ // -----------------------------------------------------------------
+
+ grid.addHeader( new GridHeader( i18n.getString( "dataelement" ), false, true ) ); // Data element header
+
+ for ( DataElementCategoryOptionCombo optionCombo : section.getCategoryCombo().getOptionCombos() ) // Value headers
{
grid.addHeader( new GridHeader( optionCombo.isDefault() ? DEFAULT_HEADER : optionCombo.getName(), false, false ) );
}
- // ---------------------------------------------------------------------
- // Values for GRID
- // ---------------------------------------------------------------------
+ // -----------------------------------------------------------------
+ // Grid values
+ // -----------------------------------------------------------------
List<DataElement> dataElements = new ArrayList<DataElement>( section.getDataElements() );
Collections.sort( dataElements, dataElementComparator );
@@ -252,28 +227,24 @@
for ( DataElement dataElement : dataElements )
{
grid.addRow();
- grid.addValue( dataElement.getName() );
+ grid.addValue( dataElement.getName() ); // Data element name
- for ( DataElementCategoryOptionCombo optionCombo : optionComnbos )
+ for ( DataElementCategoryOptionCombo optionCombo : section.getCategoryCombo().getOptionCombos() ) // Values
{
- String value = "";
+ String value = null;
if ( selectedUnitOnly )
{
- DataValue dataValue = dataValueService.getDataValue( selectedOrgunit, dataElement,
- selectedPeriod, optionCombo );
+ DataValue dataValue = dataValueService.getDataValue( selectedOrgunit, dataElement, selectedPeriod, optionCombo );
value = (dataValue != null) ? dataValue.getValue() : null;
}
else
{
Double aggregatedValue = aggregationStrategy.equals( AGGREGATION_STRATEGY_REAL_TIME ) ? aggregationService
- .getAggregatedDataValue( dataElement, optionCombo, selectedPeriod.getStartDate(),
- selectedPeriod.getEndDate(), selectedOrgunit )
- : aggregatedDataValueService.getAggregatedValue( dataElement, optionCombo,
- selectedPeriod, selectedOrgunit );
+ .getAggregatedDataValue( dataElement, optionCombo, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedOrgunit )
+ : aggregatedDataValueService.getAggregatedValue( dataElement, optionCombo, selectedPeriod, selectedOrgunit );
- value = (aggregatedValue != null) ? String.valueOf( MathUtils.getRounded( aggregatedValue,
- 0 ) ) : null;
+ value = ( aggregatedValue != null ) ? String.valueOf( MathUtils.getRounded( aggregatedValue, 0 ) ) : null;
}
grid.addValue( value );
@@ -284,7 +255,6 @@
}
reportingUnit = selectedOrgunit.getName();
-
reportingPeriod = format.formatPeriod( selectedPeriod );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-03-14 20:51:30 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/struts.xml 2011-03-16 16:26:53 +0000
@@ -290,7 +290,7 @@
<action name="generateCustomDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateCustomDataSetReportAction">
<result name="success" type="velocity">/popup.vm</result>
<result name="error" type="chain">showDataSetReportForm</result>
- <param name="page">/dhis-web-reporting/previewCustomDataSetReportForm.vm</param>
+ <param name="page">/dhis-web-reporting/renderCustomDataSetReportForm.vm</param>
<param name="javascripts">../dhis-web-commons/util/jquery.jqprint.0.3.js</param>
<interceptor-ref name="organisationUnitTreeStack"/>
</action>
@@ -298,7 +298,7 @@
<action name="generateSectionDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateSectionDataSetReportAction">
<result name="success" type="velocity">/popup.vm</result>
<result name="error" type="chain">showDataSetReportForm</result>
- <param name="page">/dhis-web-reporting/previewSectionDataSetReportForm.vm</param>
+ <param name="page">/dhis-web-reporting/renderSectionDataSetReportForm.vm</param>
<param name="javascripts">../dhis-web-commons/util/jquery.jqprint.0.3.js</param>
<interceptor-ref name="organisationUnitTreeStack"/>
</action>
@@ -306,7 +306,7 @@
<action name="generateDefaultDataSetReport" class="org.hisp.dhis.reporting.dataset.action.GenerateDefaultDataSetReportAction">
<result name="success" type="velocity">/popup.vm</result>
<result name="error" type="chain">showDataSetReportForm</result>
- <param name="page">/dhis-web-reporting/previewDefaultDataSetReportForm.vm</param>
+ <param name="page">/dhis-web-reporting/renderDefaultDataSetReportForm.vm</param>
<param name="javascripts">../dhis-web-commons/util/jquery.jqprint.0.3.js</param>
<interceptor-ref name="organisationUnitTreeStack"/>
</action>
=== renamed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewCustomDataSetReportForm.vm' => 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderCustomDataSetReportForm.vm'
=== renamed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewDefaultDataSetReportForm.vm' => 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderDefaultDataSetReportForm.vm'
=== renamed file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewSectionDataSetReportForm.vm' => 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/previewSectionDataSetReportForm.vm 2011-03-11 12:35:11 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2011-03-16 16:26:53 +0000
@@ -1,7 +1,7 @@
<h3>$i18n.getString('reporting_unit'): $reportingUnit $i18n.getString('reporting_period'): $reportingPeriod</h3>
<p><input type="button" value="$i18n.getString( 'back' )" style="width:100px" onclick="javascript:window.location.href='showDataSetReportForm.action'"/></p>
-<div id="printDateSetPreviewDiv">
+<div id="printDateSetPreviewDiv" style="margin-bottom:20px">
#foreach( $grid in $grids )
<h3>$!encoder.htmlEncode( $grid.title )</h3>