← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21094: TEI query. Using organisationunit.path instead of _orgunistructure resource table.

 

------------------------------------------------------------
revno: 21094
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-11-17 18:21:07 +0100
message:
  TEI query. Using organisationunit.path instead of _orgunistructure resource table.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
  dhis-2/dhis-services/dhis-service-core/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-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2015-08-25 21:48:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java	2015-11-17 17:21:07 +0000
@@ -38,7 +38,6 @@
 import org.hisp.dhis.common.OrganisationUnitSelectionMode;
 import org.hisp.dhis.common.QueryFilter;
 import org.hisp.dhis.common.QueryItem;
-import org.hisp.dhis.common.SetMap;
 import org.hisp.dhis.event.EventStatus;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
@@ -239,21 +238,6 @@
     }
     
     /**
-     * Returns a mapping between level and organisation units.
-     */
-    public SetMap<Integer, OrganisationUnit> getLevelOrgUnitMap()
-    {
-        SetMap<Integer, OrganisationUnit> setMap = new SetMap<>();
-        
-        for ( OrganisationUnit ou : organisationUnits )
-        {
-            setMap.putValue( ou.getLevel(), ou );
-        }
-        
-        return setMap;
-    }
-
-    /**
      * Add the given attributes to this params if they are not already present.
      */
     public void addAttributesIfNotExist( List<QueryItem> attrs )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2015-11-12 12:21:41 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2015-11-17 17:21:07 +0000
@@ -39,7 +39,6 @@
 import org.hisp.dhis.common.QueryFilter;
 import org.hisp.dhis.common.QueryItem;
 import org.hisp.dhis.common.QueryOperator;
-import org.hisp.dhis.common.SetMap;
 import org.hisp.dhis.common.hibernate.HibernateIdentifiableObjectStore;
 import org.hisp.dhis.commons.util.SqlHelper;
 import org.hisp.dhis.event.EventStatus;
@@ -342,11 +341,6 @@
             }
         }
 
-        if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.DESCENDANTS ) )
-        {
-            sql += "left join _orgunitstructure ous on tei.organisationunitid = ous.organisationunitid ";
-        }
-
         if ( params.hasTrackedEntity() )
         {
             sql += hlp.whereAnd() + " tei.trackedentityid = " + params.getTrackedEntity().getId() + " ";
@@ -358,12 +352,9 @@
         }
         else if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.DESCENDANTS ) )
         {
-            SetMap<Integer, OrganisationUnit> levelOuMap = params.getLevelOrgUnitMap();
-
-            for ( Integer level : levelOuMap.keySet() )
+            for ( OrganisationUnit unit : params.getOrganisationUnits() )
             {
-                sql += hlp.whereAnd() + " ous.idlevel" + level + " in ("
-                    + getCommaDelimitedString( getIdentifiers( levelOuMap.get( level ) ) ) + ") or ";
+                sql += hlp.whereAnd() + " ou.path like '" + unit.getPath() + "%' or ";
             }
 
             sql = removeLastOr( sql );