← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21345: Impl DataValueAuditService.deleteDataValueAudits(OrganisationUnit)

 

------------------------------------------------------------
revno: 21345
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-12-05 10:30:42 +0100
message:
  Impl DataValueAuditService.deleteDataValueAudits(OrganisationUnit)
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateCompleteDataSetRegistrationStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.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/datavalue/DataValueAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java	2015-12-01 08:56:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java	2015-12-05 09:30:42 +0000
@@ -53,6 +53,13 @@
     void addDataValueAudit( DataValueAudit dataValueAudit );
 
     /**
+     * Deletes all data value audits for the given organisation unit.
+     * 
+     * @param organisationUnit the organisation unit.
+     */
+    void deleteDataValueAudits( OrganisationUnit organisationUnit );
+    
+    /**
      * Returns all DataValueAudits for the given DataValue.
      *
      * @param dataValue the DataValue to get DataValueAudits for.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java	2015-12-01 08:56:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java	2015-12-05 09:30:42 +0000
@@ -50,7 +50,14 @@
      * @param dataValueAudit the DataValueAudit to add.
      */
     void addDataValueAudit( DataValueAudit dataValueAudit );
-
+    
+    /**
+     * Deletes all data value audits for the given organisation unit.
+     * 
+     * @param organisationUnit the organisation unit.
+     */
+    void deleteDataValueAudits( OrganisationUnit organisationUnit );
+    
     /**
      * Returns all DataValueAudits which match the DataElement, Period, OrganisationUnit
      * and DataElementCategoryOptionCombo of the given DataValue.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateCompleteDataSetRegistrationStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateCompleteDataSetRegistrationStore.java	2015-06-16 05:11:29 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateCompleteDataSetRegistrationStore.java	2015-12-05 09:30:42 +0000
@@ -33,7 +33,6 @@
 import java.util.List;
 
 import org.hibernate.Criteria;
-import org.hibernate.Query;
 import org.hibernate.SessionFactory;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -190,11 +189,8 @@
     {
         String hql = "delete from CompleteDataSetRegistration c where c.dataSet = :dataSet";
         
-        Query query = sessionFactory.getCurrentSession().createQuery( hql );
-        
-        query.setEntity( "dataSet", dataSet );
-        
-        query.executeUpdate();
+        sessionFactory.getCurrentSession().createQuery( hql ).
+            setEntity( "dataSet", dataSet ).executeUpdate();
     }
     
     @Override
@@ -202,10 +198,7 @@
     {
         String hql = "delete from CompleteDataSetRegistration c where c.source = :source";
 
-        Query query = sessionFactory.getCurrentSession().createQuery( hql );
-        
-        query.setEntity( "source", unit );
-        
-        query.executeUpdate();
+        sessionFactory.getCurrentSession().createQuery( hql ).
+            setEntity( "source", unit ).executeUpdate();
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java	2015-12-01 08:56:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java	2015-12-05 09:30:42 +0000
@@ -63,6 +63,12 @@
     {
         dataValueAuditStore.addDataValueAudit( dataValueAudit );
     }
+    
+    @Override
+    public void deleteDataValueAudits( OrganisationUnit organisationUnit )
+    {
+        dataValueAuditStore.deleteDataValueAudits( organisationUnit );
+    }
 
     @Override
     public List<DataValueAudit> getDataValueAudits( DataValue dataValue )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java	2015-12-01 08:56:25 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java	2015-12-05 09:30:42 +0000
@@ -84,6 +84,14 @@
         session.save( dataValueAudit );
     }
 
+    @Override
+    public void deleteDataValueAudits( OrganisationUnit organisationUnit )
+    {
+        String hql = "delete from DataValueAudit d where d.organisationUnit = :unit";
+        
+        sessionFactory.getCurrentSession().createQuery( hql ).
+            setEntity( "unit", organisationUnit ).executeUpdate();
+    }
 
     @Override
     public List<DataValueAudit> getDataValueAudits( DataValue dataValue )

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2015-12-04 16:57:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2015-12-05 09:30:42 +0000
@@ -137,10 +137,8 @@
     {
         String hql = "delete from DataValue d where d.source = :source";
         
-        Query query = sessionFactory.getCurrentSession().createQuery( hql );
-        query.setEntity( "source", organisationUnit );
-        
-        query.executeUpdate();
+        sessionFactory.getCurrentSession().createQuery( hql ).
+            setEntity( "source", organisationUnit ).executeUpdate();
     }
     
     @Override

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java	2015-10-08 14:12:50 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/datavalue/DataValueServiceTest.java	2015-12-05 09:30:42 +0000
@@ -72,29 +72,20 @@
     // -------------------------------------------------------------------------
 
     private DataElement dataElementA;
-
     private DataElement dataElementB;
-
     private DataElement dataElementC;
-
     private DataElement dataElementD;
 
     private DataElementCategoryOptionCombo optionCombo;
     
     private Period periodA;
-
     private Period periodB;
-
     private Period periodC;
-
     private Period periodD;
 
     private OrganisationUnit sourceA;
-
     private OrganisationUnit sourceB;
-
     private OrganisationUnit sourceC;
-
     private OrganisationUnit sourceD;
 
     // -------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java	2015-09-14 18:06:48 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DefaultDeletionManager.java	2015-12-05 09:30:42 +0000
@@ -29,6 +29,8 @@
  */
 
 import javassist.util.proxy.ProxyObject;
+
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.hisp.dhis.common.DeleteNotAllowedException;
@@ -102,7 +104,7 @@
                 {
                     String hint = String.valueOf( allow );
 
-                    String message = handler.getClassName() + (hint.isEmpty() ? "" : (" (" + hint + ")"));
+                    String message = handler.getClassName() + ( hint.isEmpty() ? hint : ( " (" + hint + ")" ) );
 
                     log.info( "Delete was not allowed by " + currentHandler + ": " + message );