← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14270: TEI query, impl program filter

 

------------------------------------------------------------
revno: 14270
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 19:34:31 +0100
message:
  TEI query, impl program filter
modified:
  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/hibernate/HibernateTrackedEntityInstanceStore.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-17 18:16:56 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-03-17 18:34:31 +0000
@@ -213,6 +213,8 @@
             throw new IllegalQueryException( "Tracked entity does not exist: " + program );
         }
         
+        params.setProgram( pr );
+        params.setTrackedEntity( te );
         params.setOrganisationUnitMode( ouMode );
         params.setPage( page );
         params.setPageSize( pageSize );

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-03-17 18:16:56 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-03-17 18:34:31 +0000
@@ -177,7 +177,7 @@
         
         if ( params.hasTrackedEntity() )
         {
-            sql += hlp.whereAnd() + " tei.trackedentityid = " + params.getTrackedEntity().getId();
+            sql += hlp.whereAnd() + " tei.trackedentityid = " + params.getTrackedEntity().getId() + " ";
         }
 
         if ( params.isOrganisationUnitMode( DimensionalObject.OU_MODE_DESCENDANTS ) )
@@ -195,6 +195,14 @@
         {
             sql += hlp.whereAnd() + " tei.organisationunitid in (" + getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ) + ") ";
         }
+        
+        if ( params.hasProgram() )
+        {
+            sql += 
+                hlp.whereAnd() + " exists ( select trackedentityinstanceid from programinstance pi " +
+                "where pi.trackedentityinstanceid=tei.trackedentityinstanceid " +
+                "and pi.programid = " + params.getProgram().getId() + ") ";
+        }
 
         // ---------------------------------------------------------------------
         // Paging clause