dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24063
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11743: Analytics events, query operators
------------------------------------------------------------
revno: 11743
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-08-22 11:26:39 +0200
message:
Analytics events, query operators
modified:
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/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-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/QueryItem.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/QueryItem.java 2013-08-22 07:53:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/QueryItem.java 2013-08-22 09:26:39 +0000
@@ -27,10 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.hisp.dhis.common.IdentifiableObject;
+import org.hisp.dhis.system.util.TextUtils;
/**
* @author Lars Helge Overland
@@ -38,14 +40,14 @@
public class QueryItem
{
public static final Map<String, String> OPERATOR_MAP = new HashMap<String, String>() { {
- put( "like", "like" );
- put( "in", "in" );
put( "eq", "=" );
put( "gt", ">" );
put( "ge", ">=" );
put( "lt", "<" );
put( "le", "<=" );
put( "ne", "!=" );
+ put( "like", "like" );
+ put( "in", "in" );
} };
private IdentifiableObject item;
@@ -81,7 +83,33 @@
public String getSqlOperator()
{
- return OPERATOR_MAP.get( operator );
+ if ( operator == null )
+ {
+ return null;
+ }
+
+ return OPERATOR_MAP.get( operator.toLowerCase() );
+ }
+
+ public String getSqlFilter()
+ {
+ if ( operator == null || filter == null )
+ {
+ return null;
+ }
+
+ if ( operator.equals( "like" ) )
+ {
+ return "'%" + filter.toLowerCase() + "%'";
+ }
+ else if ( operator.equals( "in" ) )
+ {
+ String[] split = filter.toLowerCase().split( ":" );
+
+ return "(" + TextUtils.getQuotedCommaDelimitedString( Arrays.asList( split ) ) + ")";
+ }
+
+ return "'" + filter.toLowerCase() + "'";
}
@Override
=== 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-08-22 07:53:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/DefaultEventAnalyticsService.java 2013-08-22 09:26:39 +0000
@@ -89,6 +89,8 @@
// -------------------------------------------------------------------------
//TODO org unit children / descendants
+ //TODO paging
+ //TODO sorting
public Grid getEvents( EventQueryParams params )
{
=== 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-08-22 07:53:43 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/event/data/JdbcEventAnalyticsManager.java 2013-08-22 09:26:39 +0000
@@ -86,7 +86,7 @@
{
if ( filter.hasFilter() )
{
- sql += "and " + filter.getItem().getUid() + " " + filter.getSqlOperator() + " '" + filter.getFilter() + "' ";
+ sql += "and lower(" + filter.getItem().getUid() + ") " + filter.getSqlOperator() + " " + filter.getSqlFilter() + " ";
}
}