dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11065
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3097: Removing decimals from section dataset report
------------------------------------------------------------
revno: 3097
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-03-20 14:35:54 +0100
message:
Removing decimals from section dataset report
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java
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/webapp/dhis-web-reporting/dataSetReportForm.vm
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-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2011-03-18 09:47:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java 2011-03-20 13:35:54 +0000
@@ -46,6 +46,7 @@
{
private static final DecimalFormat FORMAT_VALUE = new DecimalFormat( "#.#;#.#" ); // Fixed for now
private static final String EMPTY = "";
+ private static final String NAN = "NaN";
private ResourceBundle resourceBundle;
@@ -185,7 +186,19 @@
public String formatValue( Object value )
{
- return value != null ? FORMAT_VALUE.format( value ) : EMPTY;
+ if ( value == null )
+ {
+ return EMPTY;
+ }
+
+ try
+ {
+ return FORMAT_VALUE.format( value );
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ return NAN;
+ }
}
// -------------------------------------------------------------------------
=== 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-16 21:25:24 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateSectionDataSetReportAction.java 2011-03-20 13:35:54 +0000
@@ -57,7 +57,6 @@
import org.hisp.dhis.system.filter.AggregatableDataElementFilter;
import org.hisp.dhis.system.grid.ListGrid;
import org.hisp.dhis.system.util.FilterUtils;
-import org.hisp.dhis.system.util.MathUtils;
import com.opensymphony.xwork2.Action;
@@ -250,20 +249,18 @@
for ( DataElementCategoryOptionCombo optionCombo : categoryCombo.getOptionCombos() ) // Values
{
- String value = null;
+ Double value = null;
if ( selectedUnitOnly )
{
DataValue dataValue = dataValueService.getDataValue( selectedOrgunit, dataElement, selectedPeriod, optionCombo );
- value = (dataValue != null) ? dataValue.getValue() : null;
+ value = dataValue != null && dataValue.getValue() != null ? Double.parseDouble( dataValue.getValue() ) : null;
}
else
{
- Double aggregatedValue = realTime ?
+ value = realTime ?
aggregationService.getAggregatedDataValue( dataElement, optionCombo, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedOrgunit ) :
aggregatedDataValueService.getAggregatedValue( dataElement, optionCombo, selectedPeriod, selectedOrgunit );
-
- value = aggregatedValue != null ? String.valueOf( MathUtils.getRounded( aggregatedValue, 0 ) ) : null;
}
grid.addValue( value );
@@ -277,7 +274,7 @@
aggregationService.getAggregatedDataValue( dataElement, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedOrgunit, categoryOption ) :
aggregatedDataValueService.getAggregatedValue( dataElement, categoryOption, selectedPeriod, selectedOrgunit );
- grid.addValue( value != null ? String.valueOf( MathUtils.getRounded( value, 0 ) ) : null );
+ grid.addValue( value );
}
}
@@ -287,7 +284,7 @@
aggregationService.getAggregatedDataValue( dataElement, null, selectedPeriod.getStartDate(), selectedPeriod.getEndDate(), selectedOrgunit ) :
aggregatedDataValueService.getAggregatedValue( dataElement, selectedPeriod, selectedOrgunit );
- grid.addValue( value != null ? String.valueOf( MathUtils.getRounded( value, 0 ) ) : null );
+ grid.addValue( value );
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2011-03-19 22:30:32 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2011-03-20 13:35:54 +0000
@@ -64,7 +64,7 @@
</tr>
<tr>
<td>
- <div id="selectionTree" style="width:350px;height:220px;overflow:auto;border:1px solid #cccccc">
+ <div id="selectionTree" style="width:350px;height:200px;overflow:auto;border:1px solid #cccccc">
<script type="text/javascript">
selectionTreeSelection.setMultipleSelectionAllowed( false );
selectionTree.clearSelectedOrganisationUnits();
=== modified file '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/renderSectionDataSetReportForm.vm 2011-03-20 09:53:16 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/renderSectionDataSetReportForm.vm 2011-03-20 13:35:54 +0000
@@ -1,3 +1,9 @@
+<style>
+.val
+{
+ text-align:center;
+}
+</style>
<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>
@@ -10,25 +16,24 @@
<table class="listTable gridTable">
<thead>
- <tr>
- #foreach( $header in $grid.getVisibleHeaders() )
- <th #if( !$header.meta )style="text-align:center;"#end>$!encoder.htmlEncode( $header.name )</th>
- #end
- </tr>
+<tr>
+#foreach( $header in $grid.getVisibleHeaders() )
+<th #if( !$header.meta )class="val"#end>$!encoder.htmlEncode( $header.name )</th>
+#end
+</tr>
</thead>
<tbody>
#foreach( $row in $grid.getVisibleRows() )
- <tr>
- #foreach( $col in $row )
- #set( $index = ( $velocityCount - 1 ) )
- <td #if( !$grid.getVisibleHeaders().get( $index ).meta )style="text-align:center;"#end>$!encoder.htmlEncode( $col )</td>
- #end
- </tr>
+<tr>
+#foreach( $col in $row )
+#set( $index = ( $velocityCount - 1 ) )
+#if( $grid.getVisibleHeaders().get( $index ).meta )<td>$!encoder.htmlEncode( $col )</td>#else <td class="val">$!format.formatValue( $col )</td>#end
+#end
+</tr>
#end
</tbody>
</table>
-
<br>
#end
</div>