← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1763: Move DataValueAuditService dependency of DataValueService to service layer.

 

------------------------------------------------------------
revno: 1763
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Sat 2010-04-10 00:04:21 +0700
message:
  Move DataValueAuditService dependency of DataValueService to service layer.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.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/main/resources/META-INF/dhis/beans.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-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2010-01-25 14:08:24 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java	2010-04-09 17:04:21 +0000
@@ -27,6 +27,8 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import static org.hisp.dhis.dataelement.DataElement.AGGREGATION_OPERATOR_AVERAGE;
+
 import java.util.Collection;
 
 import org.apache.commons.logging.Log;
@@ -37,8 +39,6 @@
 import org.hisp.dhis.source.Source;
 import org.springframework.transaction.annotation.Transactional;
 
-import static org.hisp.dhis.dataelement.DataElement.*;
-
 /**
  * @author Kristian Nordal
  * @version $Id: DefaultDataValueService.java 5715 2008-09-17 14:05:28Z larshelg
@@ -60,6 +60,13 @@
     {
         this.dataValueStore = dataValueStore;
     }
+    
+    private DataValueAuditService dataValueAuditService;
+    
+    public void setDataValueAuditService( DataValueAuditService dataValueAuditService )
+    {
+        this.dataValueAuditService = dataValueAuditService;
+    }
 
     // -------------------------------------------------------------------------
     // Basic DataValue
@@ -85,7 +92,7 @@
     {
         if ( dataValue.isNullValue() )
         {
-            dataValueStore.deleteDataValue( dataValue );
+            this.deleteDataValue( dataValue );
         }
         else
         {
@@ -101,18 +108,27 @@
         }
     }
 
+    @Transactional
     public void deleteDataValue( DataValue dataValue )
     {
+        dataValueAuditService.deleteDataValueAuditByDataValue( dataValue );
+
         dataValueStore.deleteDataValue( dataValue );
     }
 
+    @Transactional
     public int deleteDataValuesBySource( Source source )
     {
+        dataValueAuditService.deleteDataValueAuditBySource(source);
+
         return dataValueStore.deleteDataValuesBySource( source );
     }
 
+    @Transactional
     public int deleteDataValuesByDataElement( DataElement dataElement )
     {
+        dataValueAuditService.deleteDataValueAuditByDataElement( dataElement );
+        
         return dataValueStore.deleteDataValuesByDataElement( dataElement );
     }
 

=== 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	2010-04-09 15:15:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java	2010-04-09 17:04:21 +0000
@@ -83,13 +83,6 @@
         this.periodStore = periodStore;
     }
     
-    private DataValueAuditService dataValueAuditService;
-    
-    public void setDataValueAuditService( DataValueAuditService dataValueAuditService )
-    {
-        this.dataValueAuditService = dataValueAuditService;
-    }
-    
     // -------------------------------------------------------------------------
     // Support methods for reloading periods
     // -------------------------------------------------------------------------
@@ -142,35 +135,25 @@
         session.update( dataValue );
     }
 
-    @Transactional
     public void deleteDataValue( DataValue dataValue )
     {
-        dataValueAuditService.deleteDataValueAuditByDataValue( dataValue );
-        
         Session session = sessionFactory.getCurrentSession();
         
         session.delete( dataValue );
     }
     
-    @Transactional
     public int deleteDataValuesBySource( Source source )
     {
-        dataValueAuditService.deleteDataValueAuditBySource(source);
-        
         Session session = sessionFactory.getCurrentSession();
         
         Query query = session.createQuery( "delete DataValue where source = :source" );
         query.setEntity( "source", source );
-        query.executeUpdate();
         
-        return 0;
+        return query.executeUpdate();
     }
 
-    @Transactional
     public int deleteDataValuesByDataElement( DataElement dataElement )
     {
-        dataValueAuditService.deleteDataValueAuditByDataElement( dataElement );
-        
         Session session = sessionFactory.getCurrentSession();
         
         Query query = session.createQuery( "delete DataValue where dataElement = :dataElement" );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-04-09 15:15:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml	2010-04-09 17:04:21 +0000
@@ -53,7 +53,6 @@
     <property name="sessionFactory" ref="sessionFactory"/>
     <property name="statementManager" ref="statementManager"/>
     <property name="periodStore" ref="org.hisp.dhis.period.PeriodStore"/>
-	<property name="dataValueAuditService" ref="org.hisp.dhis.datavalue.DataValueAuditService"/>
   </bean>
   
   <bean id="org.hisp.dhis.indicator.IndicatorStore"
@@ -198,6 +197,7 @@
     class="org.hisp.dhis.datavalue.DefaultDataValueService">
     <property name="dataValueStore"
       ref="org.hisp.dhis.datavalue.DataValueStore"/>
+	<property name="dataValueAuditService" ref="org.hisp.dhis.datavalue.DataValueAuditService"/>
   </bean>
 
   <bean id="org.hisp.dhis.datavalue.DataValueAuditService"