← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15320: Tracker, removed unused methods

 

------------------------------------------------------------
revno: 15320
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-05-20 18:30:51 +0200
message:
  Tracker, removed unused methods
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/program/DefaultProgramInstanceService.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


--
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-16 15:26:10 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-05-20 16:30:51 +0000
@@ -89,6 +89,7 @@
  * </pre>
  * 
  * @author Abyot Asalefew Gizaw
+ * @author Lars Helge Overland
  */
 public interface TrackedEntityInstanceService
 {
@@ -266,13 +267,4 @@
      * @return ValidationCriteria object which is violated
      */
     ValidationCriteria validateEnrollment( TrackedEntityInstance entityInstance, Program program, I18nFormat format );
-
-    /**
-     * Get entityInstances by {@link TrackedEntity}
-     * 
-     * @param trackedEntity {@link TrackedEntity}
-     * 
-     * @return List of entityInstance
-     */
-    Collection<TrackedEntityInstance> getTrackedEntityInstances( TrackedEntity trackedEntity );
 }

=== 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-20 16:20:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java	2014-05-20 16:30:51 +0000
@@ -111,24 +111,4 @@
      * @return ValidationCriteria object which is violated
      */
     ValidationCriteria validateEnrollment( TrackedEntityInstance entityinstance, Program program, I18nFormat format );
-
-    /**
-     * Validate instances attribute values and validation criteria by program
-     * before registering / updating information
-     * 
-     * @param searchText The value of a TrackedEntityAttribute
-     * @param attributeId The id of a TrackedEntityAttribute
-     * 
-     * @return TrackedEntityInstance list
-     */
-    Collection<TrackedEntityInstance> getByAttributeValue( String searchText, int attributeId, Integer min, Integer max );
-
-     /**
-     * Get entityInstances by {@link TrackedEntity}
-     * 
-     * @param trackedEntity {@link TrackedEntity}
-     * 
-     * @return List of entityInstance
-     */
-    Collection<TrackedEntityInstance> get( TrackedEntity trackedEntity );
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-05-16 15:26:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2014-05-20 16:30:51 +0000
@@ -669,13 +669,11 @@
 
         for ( ProgramStageInstance programStageInstance : programStageInstances )
         {
-            grid.addRow();
-            grid.addValue( "" );
-            grid.addValue( "" );
+            grid.addRow().addEmptyValues( 2 );
 
             grid.addRow();
             grid.addValue( programStageInstance.getProgramStage().getName() );
-            grid.addValue( "" );
+            grid.addEmptyValues( 1 );
 
             // -----------------------------------------------------------------
             // due-date && report-date

=== 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-16 15:26:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-05-20 16:30:51 +0000
@@ -606,10 +606,4 @@
     {
         return trackedEntityInstanceStore.validateEnrollment( instance, program, format );
     }
-
-    @Override
-    public Collection<TrackedEntityInstance> getTrackedEntityInstances( TrackedEntity trackedEntity )
-    {
-        return trackedEntityInstanceStore.get( trackedEntity );
-    }
 }

=== 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-04 14:04:41 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.java	2014-05-20 16:30:51 +0000
@@ -32,6 +32,8 @@
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
 
 public class TrackedEntityInstanceDeletionHandler
     extends DeletionHandler
@@ -46,6 +48,9 @@
     {
         this.instanceService = instanceService;
     }
+    
+    @Autowired
+    private JdbcTemplate jdbcTemplate;
 
     // -------------------------------------------------------------------------
     // DeletionHandler implementation
@@ -78,10 +83,8 @@
     @Override
     public String allowDeleteTrackedEntity( TrackedEntity trackedEntity )
     {
-        Collection<TrackedEntityInstance> entityInstances = instanceService.getTrackedEntityInstances( trackedEntity );
+        String sql = "select count(*) from trackedentityinstance where trackedentityid = " + trackedEntity.getId();
 
-        return (entityInstances != null && entityInstances.size() > 0) ? ERROR : null;
+        return jdbcTemplate.queryForObject( sql, Integer.class ) == 0 ? null : ERROR;
     }
-
-
 }

=== 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-16 15:26:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-05-20 16:30:51 +0000
@@ -68,7 +68,6 @@
 import org.hisp.dhis.program.ProgramStatus;
 import org.hisp.dhis.system.util.SqlHelper;
 import org.hisp.dhis.system.util.Timer;
-import org.hisp.dhis.trackedentity.TrackedEntity;
 import org.hisp.dhis.trackedentity.TrackedEntityAttribute;
 import org.hisp.dhis.trackedentity.TrackedEntityInstance;
 import org.hisp.dhis.trackedentity.TrackedEntityInstanceQueryParams;
@@ -564,38 +563,4 @@
             throw new RuntimeException( ex );
         }
     }
-
-    @SuppressWarnings( "unchecked" )
-    @Override
-    public Collection<TrackedEntityInstance> getByAttributeValue( String searchText, int attributeId, Integer min,
-        Integer max )
-    {
-        String hql = "FROM TrackedEntityAttributeValue pav WHERE lower (pav.value) LIKE lower ('%" + searchText
-            + "%') AND pav.attribute.id =:attributeId order by pav.entityInstance";
-
-        Query query = getQuery( hql );
-
-        query.setInteger( "attributeId", attributeId );
-
-        if ( min != null && max != null )
-        {
-            query.setFirstResult( min ).setMaxResults( max );
-        }
-
-        List<TrackedEntityInstance> entityInstances = new ArrayList<TrackedEntityInstance>();
-        Collection<TrackedEntityAttributeValue> attributeValue = query.list();
-        for ( TrackedEntityAttributeValue pv : attributeValue )
-        {
-            entityInstances.add( pv.getEntityInstance() );
-        }
-
-        return entityInstances;
-    }
-    
-    @SuppressWarnings( "unchecked" )
-    @Override
-    public Collection<TrackedEntityInstance> get( TrackedEntity trackedEntity )
-    {
-        return getCriteria( Restrictions.eq( "trackedEntity", trackedEntity ) ).list();
-    }
 }