dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23057
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11208: Error when to run aggregate query builder fomulas with number data element.
------------------------------------------------------------
revno: 11208
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-06-14 11:17:29 +0700
message:
Error when to run aggregate query builder fomulas with number data element.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java
dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.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 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-05-29 09:00:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationCondition.java 2013-06-14 04:17:29 +0000
@@ -101,6 +101,9 @@
+ SEPARATOR_OBJECT + "([0-9]+" + SEPARATOR_ID + "[0-9]+" + SEPARATOR_ID + "[0-9]+)+\\])\\s*(,)+\\s*("
+ OBJECT_PROGRAM_PROPERTY_INCIDENT_DATE + "|" + OBJECT_PROGRAM_PROPERTY_REPORT_DATE_DATE + "|" + OBJECT_PROGRAM_PROPERTY_ENROLLEMENT_DATE + ")+\\s*\\)\\s*";
+ // Group 2
+ public static final String operatorRegExp = "\\]\\s*(>=|<=|!=|>|<|=)+\\s*(.*)";
+
// -------------------------------------------------------------------------
// Fields
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java 2013-06-07 08:15:22 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/caseaggregation/jdbc/JdbcCaseAggregationConditionManager.java 2013-06-14 04:17:29 +0000
@@ -287,6 +287,7 @@
Integer aggregateDeId, String aggregateDeName, Integer optionComboId, String optionComboName, Integer deSumId,
Collection<Integer> orgunitIds, Period period )
{
+ caseExpression = formatExpression( caseExpression );
String sql = "SELECT '" + aggregateDeId + "' as dataelementid, '" + optionComboId
+ "' as categoryoptioncomboid, ou.organisationunitid as sourceid, '" + period.getId() + "' as periodid,'"
+ CaseAggregationCondition.AUTO_STORED_BY + "' as comment, ";
@@ -1068,4 +1069,20 @@
return false;
}
+ private String formatExpression( String expression )
+ {
+ StringBuffer result = new StringBuffer();
+ Pattern pattern = Pattern.compile( CaseAggregationCondition.operatorRegExp );
+ Matcher matcher = pattern.matcher( expression );
+ while ( matcher.find() )
+ {
+ String value = matcher.group( 2 );
+ value = value.startsWith( "\'" ) ? value : "\'" + value;
+ value = value.endsWith( "\'" ) ? value : value + "\'";
+
+ value = "]" + matcher.group( 1 ) + " " + value;
+ matcher.appendReplacement( result, value );
+ }
+ return result.toString();
+ }
}