← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15327: Tracker, removed method from TrackedEntityStore/Service for checking representative. We should re...

 

------------------------------------------------------------
revno: 15327
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-05-21 10:00:16 +0200
message:
  Tracker, removed method from TrackedEntityStore/Service for checking representative. We should reconsider the representative implementation or re-implemet in main TEI query.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.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/DefaultTrackedEntityInstanceService.java
  dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.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/TrackedEntityInstanceServiceTest.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
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-05-21 07:51:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-05-21 08:00:16 +0000
@@ -192,15 +192,6 @@
     TrackedEntityInstance getTrackedEntityInstance( String uid );
 
     /**
-     * Get entityInstances who has the same representative
-     * 
-     * @params entityInstance The representatives
-     * 
-     * @return TrackedEntityInstance List
-     * **/
-    Collection<TrackedEntityInstance> getRepresentatives( TrackedEntityInstance entityInstance );
-
-    /**
      * Register a new entityInstance
      * 
      * @param entityInstance TrackedEntityInstance

=== 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-05-21 07:51:28 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java	2014-05-21 08:00:16 +0000
@@ -28,7 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
@@ -52,15 +51,6 @@
     int getTrackedEntityInstanceCount( TrackedEntityInstanceQueryParams params );
 
     /**
-     * Search instances who has the same representative
-     * 
-     * @param instances Representative
-     * 
-     * @return List of entityInstances
-     */
-    Collection<TrackedEntityInstance> getRepresentatives( TrackedEntityInstance instances );
-
-    /**
      * Returns null if valid, a descriptive, non-null string if invalid.
      * 
      * @param instance

=== 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-05-21 07:51:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-05-21 08:00:16 +0000
@@ -583,12 +583,6 @@
     }
     
     @Override
-    public Collection<TrackedEntityInstance> getRepresentatives( TrackedEntityInstance instance )
-    {
-        return trackedEntityInstanceStore.getRepresentatives( instance );
-    }
-
-    @Override
     public String validateTrackedEntityInstance( TrackedEntityInstance instance, Program program, I18nFormat format )
     {
         if ( program != null )

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.java	2014-05-21 07:51:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.java	2014-05-21 08:00:16 +0000
@@ -28,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-
 import org.hisp.dhis.common.Grid;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.system.deletion.DeletionHandler;
@@ -66,13 +64,8 @@
     @Override
     public void deleteTrackedEntityInstance( TrackedEntityInstance instance )
     {
-        Collection<TrackedEntityInstance> representatives = instanceService.getRepresentatives( instance );
-
-        for ( TrackedEntityInstance representative : representatives )
-        {
-            representative.setRepresentative( null );
-            instanceService.updateTrackedEntityInstance( representative );
-        }
+        //TODO handle instance representative
+        //TODO re-consider representative concept / implement in TEI query
     }
 
     @Override

=== 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-05-21 07:51:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-05-21 08:00:16 +0000
@@ -45,7 +45,6 @@
 import static org.hisp.dhis.trackedentity.TrackedEntityInstanceService.SEPARATOR;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -393,15 +392,6 @@
     }
 
     @Override
-    @SuppressWarnings( "unchecked" )
-    public Collection<TrackedEntityInstance> getRepresentatives( TrackedEntityInstance instance )
-    {
-        String hql = "select distinct p from TrackedEntityInstance p where p.representative = :representative order by p.id DESC";
-
-        return getQuery( hql ).setEntity( "representative", instance ).list();
-    }
-
-    @Override
     public String validate( TrackedEntityInstance instance, TrackedEntityAttributeValue attributeValue, Program program )
     {
         TrackedEntityAttribute attribute = attributeValue.getAttribute();

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java	2014-05-21 07:51:28 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceServiceTest.java	2014-05-21 08:00:16 +0000
@@ -84,8 +84,6 @@
 
     private TrackedEntityInstance entityInstanceA1;
 
-    private TrackedEntityInstance entityInstanceA2;
-
     private TrackedEntityInstance entityInstanceA3;
 
     private TrackedEntityInstance entityInstanceB1;
@@ -107,7 +105,6 @@
         attributeService.addTrackedEntityAttribute( entityInstanceAttribute );
 
         entityInstanceA1 = createTrackedEntityInstance( 'A', organisationUnit );
-        entityInstanceA2 = createTrackedEntityInstance( 'A', organisationUnitB );
         entityInstanceA3 = createTrackedEntityInstance( 'A', organisationUnit, entityInstanceAttribute );
         entityInstanceB1 = createTrackedEntityInstance( 'B', organisationUnit );
         entityInstanceB1.setUid( "UID-B1" );
@@ -180,20 +177,6 @@
     }
 
     @Test
-    public void testGetRepresentatives()
-    {
-        entityInstanceService.addTrackedEntityInstance( entityInstanceB1 );
-
-        entityInstanceA1.setRepresentative( entityInstanceB1 );
-        entityInstanceA2.setRepresentative( entityInstanceB1 );
-
-        entityInstanceService.addTrackedEntityInstance( entityInstanceA1 );
-        entityInstanceService.addTrackedEntityInstance( entityInstanceA2 );
-
-        assertEquals( 2, entityInstanceService.getRepresentatives( entityInstanceB1 ).size() );
-    }
-
-    @Test
     public void testCreateTrackedEntityInstanceAndRelative()
     {
         entityInstanceService.addTrackedEntityInstance( entityInstanceB1 );

=== 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-05-20 16:40:25 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/test/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStoreTest.java	2014-05-21 08:00:16 +0000
@@ -72,8 +72,6 @@
 
     private TrackedEntityInstance entityInstanceA1;
 
-    private TrackedEntityInstance entityInstanceA2;
-
     private TrackedEntityInstance entityInstanceB1;
 
     private OrganisationUnit organisationUnit;
@@ -92,7 +90,6 @@
         attributeService.addTrackedEntityAttribute( entityInstanceAttributeB );
       
         entityInstanceA1 = createTrackedEntityInstance( 'A', organisationUnit );
-        entityInstanceA2 = createTrackedEntityInstance( 'A', organisationUnitB );
         entityInstanceB1 = createTrackedEntityInstance( 'B', organisationUnit );
     }
 
@@ -144,17 +141,4 @@
 
         assertTrue( equals( entityInstanceStore.getAll(), entityInstanceA1, entityInstanceB1 ) );
     }
-
-    @Test
-    public void testGetRepresentatives()
-    {
-        entityInstanceStore.save( entityInstanceB1 );
-
-        entityInstanceA1.setRepresentative( entityInstanceB1 );
-        entityInstanceA2.setRepresentative( entityInstanceB1 );
-        entityInstanceStore.save( entityInstanceA1 );
-        entityInstanceStore.save( entityInstanceA2 );
-
-        assertEquals( 2, entityInstanceStore.getRepresentatives( entityInstanceB1 ).size() );
-    }
 }