← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15143: Add deletion-handler of TrackedEntity for Program and TEI.

 

------------------------------------------------------------
revno: 15143
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-05-04 22:04:41 +0800
message:
  Add deletion-handler of TrackedEntity for Program and TEI.
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/ProgramDeletionHandler.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/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml


--
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-04-23 20:15:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceService.java	2014-05-04 14:04:41 +0000
@@ -422,5 +422,13 @@
      */
     int countSearchTrackedEntityInstances( List<String> searchKeys, Collection<OrganisationUnit> orgunit,
         Boolean followup, Integer statusEnrollment );
+    /**
+     * 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-04-23 20:15:31 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceStore.java	2014-05-04 14:04:41 +0000
@@ -239,4 +239,13 @@
      */
     int countSearch( List<String> searchKeys, Collection<OrganisationUnit> orgunits, Boolean followup,
         Integer statusEnrollment );
+
+     /**
+     * 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/ProgramDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java	2014-04-24 12:27:51 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/program/ProgramDeletionHandler.java	2014-05-04 14:04:41 +0000
@@ -106,7 +106,7 @@
     }
 
     @Override
-    public String allowTrackedEntity( TrackedEntity trackedEntity )
+    public String allowDeleteTrackedEntity( TrackedEntity trackedEntity )
     {
         Collection<Program> programs = programService.getProgramsByTrackedEntity( trackedEntity );
 

=== 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-04-23 23:45:11 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackedEntityInstanceService.java	2014-05-04 14:04:41 +0000
@@ -816,5 +816,11 @@
     {
         return trackedEntityInstanceStore.countSearch( searchKeys, orgunits, followup, statusEnrollment );
     }
+    
+    @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-03-18 08:10:10 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceDeletionHandler.java	2014-05-04 14:04:41 +0000
@@ -32,8 +32,6 @@
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.system.deletion.DeletionHandler;
-import org.hisp.dhis.trackedentity.TrackedEntityInstance;
-import org.hisp.dhis.trackedentity.TrackedEntityInstanceService;
 
 public class TrackedEntityInstanceDeletionHandler
     extends DeletionHandler
@@ -76,5 +74,14 @@
     {
         return instanceService.getTrackedEntityInstances( unit, 0, Integer.MAX_VALUE ).size() == 0 ? null : ERROR;
     }
+    
+    @Override
+    public String allowDeleteTrackedEntity( TrackedEntity trackedEntity )
+    {
+        Collection<TrackedEntityInstance> entityInstances = instanceService.getTrackedEntityInstances( trackedEntity );
+
+        return (entityInstances != null && entityInstances.size() > 0) ? ERROR : null;
+    }
+
 
 }

=== 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-04-24 14:03:06 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/trackedentity/hibernate/HibernateTrackedEntityInstanceStore.java	2014-05-04 14:04:41 +0000
@@ -80,6 +80,7 @@
 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;
@@ -1113,4 +1114,11 @@
             null, null );
         return jdbcTemplate.queryForObject( sql, Integer.class );
     }
+    
+    @SuppressWarnings( "unchecked" )
+    @Override
+    public Collection<TrackedEntityInstance> get( TrackedEntity trackedEntity )
+    {
+        return getCriteria( Restrictions.eq( "trackedEntity", trackedEntity ) ).list();
+    }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-04-04 15:58:13 +0000
+++ dhis-2/dhis-services/dhis-service-tracker/src/main/resources/META-INF/dhis/beans.xml	2014-05-04 14:04:41 +0000
@@ -570,6 +570,9 @@
 		<aop:aspect ref="deletionInterceptor">
 
 			<aop:before
+				pointcut="execution( * org.hisp.dhis.trackedentity.TrackedEntityService.delete*(..) )"
+				method="intercept" />
+			<aop:before
 				pointcut="execution( * org.hisp.dhis.trackedentity.TrackedEntityInstanceService.delete*(..) )"
 				method="intercept" />
 			<aop:before
@@ -620,7 +623,7 @@
 			<aop:before
 				pointcut="execution( * org.hisp.dhis.caseaggregation.CaseAggregationConditionService.delete*(..) )"
 				method="intercept" />
-
+		
 		</aop:aspect>
 
 	</aop:config>

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2014-04-07 04:27:17 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2014-05-04 14:04:41 +0000
@@ -770,7 +770,7 @@
     {
     }
     
-    public String allowTrackedEntity( TrackedEntity trackedEntity )
+    public String allowDeleteTrackedEntity( TrackedEntity trackedEntity )
     {
         return null;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java	2014-03-31 16:44:18 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/java/org/hisp/dhis/trackedentity/action/trackedentity/RemoveTrackedEntityAction.java	2014-05-04 14:04:41 +0000
@@ -55,9 +55,9 @@
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private String id;
+    private Integer id;
 
-    public void setId( String id )
+    public void setId( Integer id )
     {
         this.id = id;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml	2014-04-29 08:31:32 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-program/src/main/resources/struts.xml	2014-05-04 14:04:41 +0000
@@ -1224,6 +1224,9 @@
       <result name="success" type="velocity-json">
         /dhis-web-commons/ajax/jsonResponseSuccess.vm
       </result>
+      <result name="error" type="velocity-json">
+        /dhis-web-commons/ajax/jsonResponseError.vm
+      </result>
       <param name="requiredAuthorities">F_TRACKED_ENTITY_DELETE</param>
     </action>