← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14305: TEI query, using 'attributes to display when no program' if not attributes are specified

 

------------------------------------------------------------
revno: 14305
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-03-19 19:43:44 +0100
message:
  TEI query, using 'attributes to display when no program' if not attributes are specified
modified:
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.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-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-03-19 13:02:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-03-19 18:43:44 +0000
@@ -140,6 +140,11 @@
     // Implementation methods
     // -------------------------------------------------------------------------
 
+    //TODO Bug: use full outer join when no filter
+    
+    //TODO queries with multiple words
+    //TODO lower index on attribute value?
+    
     @Override
     public Grid getTrackedEntityInstances( TrackedEntityInstanceQueryParams params )
     {
@@ -150,15 +155,20 @@
         // attributes from program if exists, if not, use all attributes.
         // ---------------------------------------------------------------------
 
-        if ( params.isOrQuery() && !params.hasAttributesOrFilters() )
+        if ( !params.hasAttributesOrFilters() )
         {
             if ( params.hasProgram() )
             {
                 params.getAttributes().addAll( QueryItem.getQueryItems( params.getProgram().getTrackedEntityAttributes() ) );
             }
-            else
+            else 
             {
-                params.getAttributes().addAll( QueryItem.getQueryItems( attributeService.getAllTrackedEntityAttributes() ) );
+                Collection<TrackedEntityAttribute> filters = attributeService.getAllTrackedEntityAttributes();
+                Collection<TrackedEntityAttribute> attributes = attributeService.getTrackedEntityAttributesDisplayedInList( true );
+                filters.removeAll( attributes );
+                
+                params.getAttributes().addAll( QueryItem.getQueryItems( attributes ) );
+                params.getFilters().addAll( QueryItem.getQueryItems( filters ) );
             }
         }