dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28713
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14367: TEI query, allowing org unit selection mode ALL from java api
------------------------------------------------------------
revno: 14367
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-24 15:49:29 +0100
message:
TEI query, allowing org unit selection mode ALL from java api
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java
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-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-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java 2014-03-24 14:03:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java 2014-03-24 14:49:29 +0000
@@ -33,5 +33,5 @@
*/
public enum OrganisationUnitSelectionMode
{
- SELECTED, CHILDREN, DESCENDANTS;
+ SELECTED, CHILDREN, DESCENDANTS, ALL
}
=== 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-03-24 14:16:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-03-24 14:49:29 +0000
@@ -210,7 +210,7 @@
{
return organisationUnitMode != null && organisationUnitMode.equals( mode );
}
-
+
/**
* Indicates whether paging is enabled.
*/
=== 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-24 14:16:32 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java 2014-03-24 14:49:29 +0000
@@ -33,9 +33,11 @@
import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.ORG_UNIT_ID;
import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_ID;
import static org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams.TRACKED_ENTITY_INSTANCE_ID;
+import static org.hisp.dhis.common.OrganisationUnitSelectionMode.*;
import java.lang.reflect.Type;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
@@ -243,7 +245,7 @@
{
violation = "Program and tracked entity cannot be specified simultaneously";
}
-
+
if ( violation != null )
{
log.warn( "Validation failed: " + violation );
@@ -306,7 +308,14 @@
{
throw new IllegalQueryException( "Tracked entity does not exist: " + program );
}
+
+ List<OrganisationUnitSelectionMode> VALID_OU_MODES = new ArrayList<OrganisationUnitSelectionMode>( Arrays.asList( SELECTED, CHILDREN, DESCENDANTS ) );
+ if ( ouMode != null && !VALID_OU_MODES.contains( ouMode ) )
+ {
+ throw new IllegalQueryException( "Invalid organisation unit selection mode: " + ouMode );
+ }
+
params.setQuery( query );
params.setProgram( pr );
params.setTrackedEntity( te );
=== 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-24 14:16:32 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-03-24 14:49:29 +0000
@@ -196,7 +196,10 @@
sql = sql.substring( 0, sql.length() - 3 ); // Remove last or
}
- else // SELECTED
+ else if ( params.isOrganisationUnitMode( OrganisationUnitSelectionMode.ALL ) )
+ {
+ }
+ else // SELECTED (default)
{
sql += hlp.whereAnd() + " tei.organisationunitid in (" + getCommaDelimitedString( getIdentifiers( params.getOrganisationUnits() ) ) + ") ";
}