← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14747: TEI query, fixed bug

 

------------------------------------------------------------
revno: 14747
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-04-08 17:19:50 +0200
message:
  TEI query, fixed bug
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js


--
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/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2014-04-08 14:44:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2014-04-08 15:19:50 +0000
@@ -252,6 +252,34 @@
     }
         
     /**
+     * Add the given attributes to this params if they are not already present.
+     */
+    public void addAttributesIfNotExist( List<QueryItem> attrs )
+    {
+        for ( QueryItem attr : attrs )
+        {
+            if ( attributes != null && !attributes.contains( attr ) )
+            {
+                attributes.add( attr );            
+            }
+        }
+    }
+    
+    /**
+     * Adds the given filters to this params if they are not already present.
+     */
+    public void addFiltersIfNotExist( List<QueryItem> filtrs )
+    {
+        for ( QueryItem filter : filtrs )
+        {
+            if ( filters != null && !filters.contains( filter ) )
+            {
+                filters.add( filter );
+            }
+        }
+    }
+    
+    /**
      * Indicates whether this params specifies any attributes and/or filters.
      */
     public boolean hasAttributesOrFilters()

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-04-08 14:57:15 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-04-08 15:19:50 +0000
@@ -152,11 +152,6 @@
     @Override
     public Grid getTrackedEntityInstances( TrackedEntityInstanceQueryParams params )
     {
-        if ( params != null )
-        {
-            params.conform();
-        }
-        
         validate( params );
 
         // ---------------------------------------------------------------------
@@ -177,11 +172,11 @@
         // attributes.
         // ---------------------------------------------------------------------
 
-        if ( !params.hasAttributesOrFilters() )
+        if ( params.isOrQuery() || !params.hasAttributes() )
         {
             if ( params.hasProgram() )
             {
-                params.getAttributes().addAll( QueryItem.getQueryItems( params.getProgram().getTrackedEntityAttributes() ) );
+                params.addAttributesIfNotExist( QueryItem.getQueryItems( params.getProgram().getTrackedEntityAttributes() ) );
             }
             else 
             {
@@ -189,17 +184,23 @@
                 Collection<TrackedEntityAttribute> attributes = attributeService.getTrackedEntityAttributesDisplayInList( true );
                 filters.removeAll( attributes );
                 
-                params.getAttributes().addAll( QueryItem.getQueryItems( attributes ) );
-                params.getFilters().addAll( QueryItem.getQueryItems( filters ) );
+                params.addAttributesIfNotExist( QueryItem.getQueryItems( attributes ) );
+                params.addFiltersIfNotExist( QueryItem.getQueryItems( filters ) );
             }
         }
 
-        Grid grid = new ListGrid();
+        // ---------------------------------------------------------------------
+        // Conform params
+        // ---------------------------------------------------------------------
+
+        params.conform();
 
         // ---------------------------------------------------------------------
         // Grid headers
         // ---------------------------------------------------------------------
 
+        Grid grid = new ListGrid();
+
         grid.addHeader( new GridHeader( TRACKED_ENTITY_INSTANCE_ID, "Instance" ) );
         grid.addHeader( new GridHeader( CREATED_ID, "Created" ) );
         grid.addHeader( new GridHeader( LAST_UPDATED_ID, "Last updated" ) );

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2014-04-08 14:06:52 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2014-04-08 15:19:50 +0000
@@ -152,7 +152,7 @@
 							if (item.value == 'programDate') {
 								p += "&programDate=";
 							} else {
-								p += "&attribute=" + item.value;
+								p += "&filter=" + item.value;
 							}
 						} else if (item.name == 'dateOperator') {
 							dateOperator = item.value;