dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #05349
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1754: Update service layer of DataValueAudit stuff.
------------------------------------------------------------
revno: 1754
committer: Quang <Quang@Quang-PC>
branch nick: trunk
timestamp: Fri 2010-04-09 00:02:20 +0700
message:
Update service layer of DataValueAudit stuff.
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/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/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-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2010-03-31 16:21:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2010-04-08 17:02:20 +0000
@@ -29,6 +29,9 @@
import java.util.Collection;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.source.Source;
+
/**
* @author Quang Nguyen
* @version Mar 30, 2010 9:39:38 PM
@@ -42,7 +45,11 @@
void deleteDataValueAudit( DataValueAudit dataValueAudit );
- int deleteDataValuesByDataValue( DataValue dataValue );
+ int deleteDataValueAuditByDataValue( DataValue dataValue );
+
+ void deleteDataValueAuditBySource( Source source );
+
+ void deleteDataValueAuditByDataElement( DataElement dataElement );
Collection<DataValueAudit> getDataValueAuditByDataValue( DataValue dataValue );
=== 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 2010-03-31 16:21:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2010-04-08 17:02:20 +0000
@@ -29,6 +29,9 @@
import java.util.Collection;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.source.Source;
+
/**
* @author Quang Nguyen
* @version Mar 30, 2010 10:32:19 PM
@@ -41,7 +44,11 @@
void deleteDataValueAudit( DataValueAudit dataValueAudit );
- int deleteDataValuesByDataValue( DataValue dataValue );
+ int deleteDataValueAuditByDataValue( DataValue dataValue );
+
+ void deleteDataValueAuditBySource( Source source );
+
+ void deleteDataValueAuditByDataElement( DataElement dataElement );
Collection<DataValueAudit> getDataValueAuditByDataValue( DataValue dataValue );
=== 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 2010-03-31 16:21:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2010-04-08 17:02:20 +0000
@@ -31,6 +31,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.source.Source;
/**
* @author Quang Nguyen
@@ -66,9 +68,9 @@
dataValueAuditStore.deleteDataValueAudit( dataValueAudit );
}
- public int deleteDataValuesByDataValue( DataValue dataValue )
+ public int deleteDataValueAuditByDataValue( DataValue dataValue )
{
- return dataValueAuditStore.deleteDataValuesByDataValue( dataValue );
+ return dataValueAuditStore.deleteDataValueAuditByDataValue( dataValue );
}
public Collection<DataValueAudit> getDataValueAuditByDataValue( DataValue dataValue )
@@ -80,4 +82,15 @@
{
return dataValueAuditStore.getAll();
}
+
+ public void deleteDataValueAuditBySource( Source source )
+ {
+ dataValueAuditStore.deleteDataValueAuditBySource( source );
+ }
+
+ public void deleteDataValueAuditByDataElement( DataElement dataElement )
+ {
+ dataValueAuditStore.deleteDataValueAuditByDataElement( dataElement );
+
+ }
}
=== 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 2010-03-31 16:21:57 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2010-04-08 17:02:20 +0000
@@ -34,9 +34,11 @@
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Restrictions;
+import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.datavalue.DataValue;
import org.hisp.dhis.datavalue.DataValueAudit;
import org.hisp.dhis.datavalue.DataValueAuditStore;
+import org.hisp.dhis.source.Source;
/**
* @author Quang Nguyen
@@ -71,7 +73,7 @@
session.delete( dataValueAudit );
}
- public int deleteDataValuesByDataValue( DataValue dataValue )
+ public int deleteDataValueAuditByDataValue( DataValue dataValue )
{
Session session = sessionFactory.getCurrentSession();
@@ -81,6 +83,16 @@
return query.executeUpdate();
}
+ public void deleteDataValueAuditBySource( Source source )
+ {
+ for(DataValueAudit each : getAll()) {
+ if(each.getDataValue().getSource().equals( source ))
+ {
+ deleteDataValueAudit( each );
+ }
+ }
+ }
+
@SuppressWarnings( "unchecked" )
public Collection<DataValueAudit> getDataValueAuditByDataValue( DataValue dataValue )
{
@@ -93,7 +105,6 @@
}
@SuppressWarnings( "unchecked" )
- @Override
public Collection<DataValueAudit> getAll()
{
Session session = sessionFactory.getCurrentSession();
@@ -103,4 +114,14 @@
return criteria.list();
}
+ public void deleteDataValueAuditByDataElement( DataElement dataElement )
+ {
+ for(DataValueAudit each : getAll()) {
+ if(each.getDataValue().getDataElement().equals( dataElement ))
+ {
+ deleteDataValueAudit( each );
+ }
+ }
+ }
+
}
=== 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-05 14:15:54 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2010-04-08 17:02:20 +0000
@@ -42,10 +42,12 @@
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.datavalue.DataValue;
+import org.hisp.dhis.datavalue.DataValueAuditStore;
import org.hisp.dhis.datavalue.DataValueStore;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodStore;
import org.hisp.dhis.source.Source;
+import org.springframework.transaction.annotation.Transactional;
/**
* @author Torgeir Lorange Ostby
@@ -80,6 +82,13 @@
this.periodStore = periodStore;
}
+ private DataValueAuditStore dataValueAuditStore;
+
+ public void setDataValueAuditStore( DataValueAuditStore dataValueAuditStore )
+ {
+ this.dataValueAuditStore = dataValueAuditStore;
+ }
+
// -------------------------------------------------------------------------
// Support methods for reloading periods
// -------------------------------------------------------------------------
@@ -132,38 +141,36 @@
session.update( dataValue );
}
+ @Transactional
public void deleteDataValue( DataValue dataValue )
{
+ dataValueAuditStore.deleteDataValueAuditByDataValue( dataValue );
+
Session session = sessionFactory.getCurrentSession();
- Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue = :dataValue" );
- queryAudit.setEntity( "dataValue", dataValue );
- queryAudit.executeUpdate();
-
session.delete( dataValue );
}
-
+
+ @Transactional
public int deleteDataValuesBySource( Source source )
{
+ dataValueAuditStore.deleteDataValueAuditBySource(source);
+
Session session = sessionFactory.getCurrentSession();
-
- Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue.source = :source" );
- queryAudit.setEntity( "source", source );
- queryAudit.executeUpdate();
Query query = session.createQuery( "delete DataValue where source = :source" );
query.setEntity( "source", source );
-
- return query.executeUpdate();
+ query.executeUpdate();
+
+ return 0;
}
+ @Transactional
public int deleteDataValuesByDataElement( DataElement dataElement )
{
+ dataValueAuditStore.deleteDataValueAuditByDataElement( dataElement );
+
Session session = sessionFactory.getCurrentSession();
-
- Query queryAudit = session.createQuery( "delete DataValueAudit where dataValue.dataElement = :dataElement" );
- queryAudit.setEntity( "dataElement", dataElement );
- queryAudit.executeUpdate();
Query query = session.createQuery( "delete DataValue where dataElement = :dataElement" );
query.setEntity( "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-07 12:27:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2010-04-08 17:02:20 +0000
@@ -53,6 +53,7 @@
<property name="sessionFactory" ref="sessionFactory"/>
<property name="statementManager" ref="statementManager"/>
<property name="periodStore" ref="org.hisp.dhis.period.PeriodStore"/>
+ <property name="dataValueAuditStore" ref="org.hisp.dhis.datavalue.DataValueAuditStore"/>
</bean>
<bean id="org.hisp.dhis.indicator.IndicatorStore"