dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #26618
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13166: Event analytics, case sensitive issue fixed
------------------------------------------------------------
revno: 13166
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-12-06 16:47:52 +0100
message:
Event analytics, case sensitive issue fixed
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.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/common/QueryItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2013-12-06 15:16:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/QueryItem.java 2013-12-06 15:47:52 +0000
@@ -54,6 +54,8 @@
private String operator;
private String filter;
+
+ private boolean numeric;
// -------------------------------------------------------------------------
// Constructors
@@ -64,11 +66,12 @@
this.item = item;
}
- public QueryItem( IdentifiableObject item, String operator, String filter )
+ public QueryItem( IdentifiableObject item, String operator, String filter, boolean numeric )
{
this.item = item;
this.operator = operator;
this.filter = filter;
+ this.numeric = numeric;
}
// -------------------------------------------------------------------------
@@ -157,4 +160,14 @@
{
this.filter = filter;
}
+
+ public boolean isNumeric()
+ {
+ return numeric;
+ }
+
+ public void setNumeric( boolean numeric )
+ {
+ this.numeric = numeric;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-12-06 15:16:51 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-12-06 15:47:52 +0000
@@ -488,21 +488,21 @@
if ( de != null && program.getAllDataElements().contains( de ) )
{
- return new QueryItem( de, operator, filter );
+ return new QueryItem( de, operator, filter, de.isNumericType() );
}
PatientAttribute at = attributeService.getPatientAttribute( item );
if ( at != null && program.getPatientAttributes().contains( at ) )
{
- return new QueryItem( at, operator, filter );
+ return new QueryItem( at, operator, filter, at.isNumericType() );
}
PatientIdentifierType it = identifierTypeService.getPatientIdentifierType( item );
if ( it != null && program.getPatientIdentifierTypes().contains( it ) )
{
- return new QueryItem( it, operator, filter );
+ return new QueryItem( it, operator, filter, false );
}
throw new IllegalQueryException( "Item identifier does not reference any item part of the program: " + item );
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2013-12-06 14:42:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2013-12-06 15:47:52 +0000
@@ -376,16 +376,16 @@
for ( QueryItem item : params.getItems() )
{
if ( item.hasFilter() )
- {
- sql += "and " + statementBuilder.columnQuote( item.getItem().getUid() ) + " " + item.getSqlOperator() + " " + getSqlFilter( item ) + " ";
+ {
+ sql += "and " + getColumn( item ) + " " + item.getSqlOperator() + " " + getSqlFilter( item ) + " ";
}
}
for ( QueryItem filter : params.getItemFilters() )
{
if ( filter.hasFilter() )
- {
- sql += "and " + statementBuilder.columnQuote( filter.getItem().getUid() ) + " " + filter.getSqlOperator() + " " + getSqlFilter( filter ) + " ";
+ {
+ sql += "and " + getColumn( filter ) + " " + filter.getSqlOperator() + " " + getSqlFilter( filter ) + " ";
}
}
@@ -393,6 +393,16 @@
}
/**
+ * Returns an encoded column name wrapped in lower directive if not numeric.
+ */
+ private String getColumn( QueryItem item )
+ {
+ String col = statementBuilder.columnQuote( item.getItem().getUid() );
+
+ return item.isNumeric() ? col : "lower(" + col + ")";
+ }
+
+ /**
* Returns the filter value for the given query item.
*/
private String getSqlFilter( QueryItem item )