dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17253
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6805: local vn - Fixed get value type as Text.
------------------------------------------------------------
revno: 6805
committer: Hieu <hieu.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-04-29 01:30:18 +0700
message:
local vn - Fixed get value type as Text.
modified:
local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java
--
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 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java'
--- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java 2012-04-25 09:59:24 +0000
+++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/utils/ExpressionUtils.java 2012-04-28 18:30:18 +0000
@@ -38,6 +38,7 @@
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
import org.hisp.dhis.dataelement.DataElementService;
+import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
@@ -53,6 +54,8 @@
{
static final String NULL_REPLACEMENT = "0";
+ static final String EMPTY = "";
+
/**
* Converts an expression on the form<br>
* [34] + [23], where the numbers are IDs of DataElements, to the form<br>
@@ -79,7 +82,7 @@
{
String replaceString = matcher.group();
- replaceString = replaceString.replaceAll( "[\\[\\]]", "" );
+ replaceString = replaceString.replaceAll( "[\\[\\]]", EMPTY );
String dataElementIdString = replaceString.substring( 0, replaceString.indexOf( SEPARATOR ) );
String optionComboIdString = replaceString.substring( replaceString.indexOf( SEPARATOR ) + 1,
@@ -94,8 +97,7 @@
.getDataElementCategoryOptionCombo( optionComboId );
{
- replaceString = getValue( dataElement, optionCombo, organisationUnit, period, dataValueService )
- + "";
+ replaceString = getValue( dataElement, optionCombo, organisationUnit, period, dataValueService );
matcher.appendReplacement( buffer, replaceString );
}
@@ -144,7 +146,7 @@
{
replaceString = getValue( dataElement, optionCombo, organisationUnit, startDate, endDate,
aggregationService )
- + "";
+ + EMPTY;
matcher.appendReplacement( buffer, replaceString );
}
@@ -215,10 +217,14 @@
private static String getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,
OrganisationUnit organisationUnit, Period period, DataValueService dataValueService )
{
- String aggregatedValue = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo )
- .getValue();
-
- return (aggregatedValue == null) ? "" : aggregatedValue;
+ if ( period == null )
+ {
+ return EMPTY;
+ }
+
+ DataValue dv = dataValueService.getDataValue( organisationUnit, dataElement, period, optionCombo );
+
+ return (dv == null ? EMPTY : dv.getValue());
}
private static double getValue( DataElement dataElement, DataElementCategoryOptionCombo optionCombo,