dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28709
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14363: Removed redundant object. Added OrganisationUnitSelectionMode enum.
------------------------------------------------------------
revno: 14363
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-24 15:03:51 +0100
message:
Removed redundant object. Added OrganisationUnitSelectionMode enum.
removed:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityQueryParams.java
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java
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/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.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
=== added 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 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/OrganisationUnitSelectionMode.java 2014-03-24 14:03:51 +0000
@@ -0,0 +1,37 @@
+package org.hisp.dhis.common;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @author Lars Helge Overland
+ */
+public enum OrganisationUnitSelectionMode
+{
+ SELECTED, CHILDREN, DESCENDANTS;
+}
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitSelectionMode.java 1970-01-01 00:00:00 +0000
@@ -1,37 +0,0 @@
-package org.hisp.dhis.organisationunit;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-public enum OrganisationUnitSelectionMode
-{
- EXPLICIT,
- SUBTREE,
- ACCESSIBLE,
- 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-18 16:11:21 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-03-24 14:03:51 +0000
@@ -51,22 +51,50 @@
public static final String TRACKED_ENTITY_ATTRIBUTE_ID = "teattribute";
public static final String TRACKED_ENTITY_ATTRIBUTE_VALUE_ID = "tevalue";
+ /**
+ * Query value, will apply to all relevant attributes.
+ */
private String query;
+ /**
+ * Attributes to be included in the response. Can be used to filter response.
+ */
private List<QueryItem> attributes = new ArrayList<QueryItem>();
+ /**
+ * Filters for the response.
+ */
private List<QueryItem> filters = new ArrayList<QueryItem>();
+ /**
+ * Organisation units for which instances in the response were registered at.
+ * Is related to the specified OrganisationUnitMode.
+ */
private Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
+ /**
+ * Program for which instances in the response must be enrolled in.
+ */
private Program program;
+ /**
+ * Tracked entity of the instances in the response.
+ */
private TrackedEntity trackedEntity;
+ /**
+ * Selection mode for the specified organisation units.
+ */
private String organisationUnitMode;
+ /**
+ * Page number.
+ */
private Integer page;
+ /**
+ * Page size.
+ */
private Integer pageSize;
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java 2014-03-24 14:03:51 +0000
@@ -81,8 +81,6 @@
Collection<TrackedEntityInstance> getByOrgUnitProgram( OrganisationUnit organisationUnit, Program program,
Integer min, Integer max );
- List<TrackedEntityInstance> query( TrackedEntityQueryParams params );
-
/**
* Search instances who has the same representative
*
=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityQueryParams.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityQueryParams.java 1970-01-01 00:00:00 +0000
@@ -1,107 +0,0 @@
-package org.hisp.dhis.trackedentity;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.hisp.dhis.common.QueryItem;
-import org.hisp.dhis.organisationunit.OrganisationUnit;
-import org.hisp.dhis.organisationunit.OrganisationUnitSelectionMode;
-import org.hisp.dhis.program.Program;
-
-/**
- * @author Lars Helge Overland
- */
-public class TrackedEntityQueryParams
-{
- private Program program;
-
- private List<QueryItem> attributes = new ArrayList<QueryItem>();
-
- private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
-
- private OrganisationUnitSelectionMode orgUnitSelectionMode;
-
- private Integer enrollmentStatus; // 0, 1 or null
-
- // -------------------------------------------------------------------------
- // Getters and setters
- // -------------------------------------------------------------------------
-
- public Program getProgram()
- {
- return program;
- }
-
- public void setProgram( Program program )
- {
- this.program = program;
- }
-
- public List<QueryItem> getAttributes()
- {
- return attributes;
- }
-
- public void setAttributes( List<QueryItem> attributes )
- {
- this.attributes = attributes;
- }
-
- public List<OrganisationUnit> getOrganisationUnits()
- {
- return organisationUnits;
- }
-
- public void setOrganisationUnits( List<OrganisationUnit> organisationUnits )
- {
- this.organisationUnits = organisationUnits;
- }
-
- public OrganisationUnitSelectionMode getOrgUnitSelectionMode()
- {
- return orgUnitSelectionMode;
- }
-
- public void setOrgUnitSelectionMode( OrganisationUnitSelectionMode orgUnitSelectionMode )
- {
- this.orgUnitSelectionMode = orgUnitSelectionMode;
- }
-
- public Integer getEnrollmentStatus()
- {
- return enrollmentStatus;
- }
-
- public void setEnrollmentStatus( Integer enrollmentStatus )
- {
- this.enrollmentStatus = enrollmentStatus;
- }
-}
=== 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-22 15:22:59 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java 2014-03-24 14:03:51 +0000
@@ -81,7 +81,6 @@
import org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
import org.hisp.dhis.trackedentity.TrackedEntityInstanceStore;
-import org.hisp.dhis.trackedentity.TrackedEntityQueryParams;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue;
import org.hisp.dhis.validation.ValidationCriteria;
import org.springframework.jdbc.core.RowMapper;
@@ -299,30 +298,6 @@
return query.list();
}
- @SuppressWarnings( "unchecked" )
- public List<TrackedEntityInstance> query( TrackedEntityQueryParams params )
- {
- SqlHelper hlp = new SqlHelper();
-
- String hql = "select pt from TrackedEntityInstance pt left join pt.attributeValues av";
-
- for ( QueryItem at : params.getAttributes() )
- {
- hql += " " + hlp.whereAnd();
- hql += " (av.attribute = :attr" + at.getItemId() + " and av.value = :filt" + at.getItemId() + ")";
- }
-
- Query query = getQuery( hql );
-
- for ( QueryItem at : params.getAttributes() )
- {
- query.setEntity( "attr" + at.getItemId(), at.getItem() );
- query.setString( "filt" + at.getItemId(), at.getFilter() );
- }
-
- return query.list();
- }
-
@Override
@SuppressWarnings( "unchecked" )
public Collection<TrackedEntityInstance> getByProgram( Program program, Integer min, Integer max )
=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java 2014-03-24 14:03:51 +0000
@@ -320,20 +320,4 @@
assertEquals( 1, entityInstances.size() );
assertTrue( entityInstances.contains( entityInstanceA3 ) );
}
-
- @Test
- public void testQuery()
- {
- entityInstanceStore.save( entityInstanceA1 );
- entityInstanceStore.save( entityInstanceA2 );
- entityInstanceStore.save( entityInstanceA3 );
- entityInstanceStore.save( entityInstanceB1 );
- entityInstanceStore.save( entityInstanceB2 );
-
- TrackedEntityQueryParams params = new TrackedEntityQueryParams();
-
- List<TrackedEntityInstance> list = entityInstanceStore.query( params );
-
- assertEquals( 5, list.size() );
- }
}