dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41819
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21343: Impl method deleteDataValues(OrganisationUnit)
------------------------------------------------------------
revno: 21343
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-12-04 17:57:18 +0100
message:
Impl method deleteDataValues(OrganisationUnit)
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java
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
--
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/DataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2015-09-21 12:17:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueService.java 2015-12-04 16:57:18 +0000
@@ -84,6 +84,13 @@
* @param dataValue the DataValue to delete.
*/
void deleteDataValue( DataValue dataValue );
+
+ /**
+ * Deletes all data values for the given organisation unit.
+ *
+ * @param organisationUnit the organisation unit.
+ */
+ void deleteDataValues( OrganisationUnit organisationUnit );
/**
* Returns a DataValue.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2015-09-21 12:17:42 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueStore.java 2015-12-04 16:57:18 +0000
@@ -79,6 +79,13 @@
void deleteDataValue( DataValue dataValue );
/**
+ * Deletes all data values for the given organisation unit.
+ *
+ * @param organisationUnit the organisation unit.
+ */
+ void deleteDataValues( OrganisationUnit organisationUnit );
+
+ /**
* Returns a DataValue.
*
* @param dataElement the DataElement of the DataValue.
=== 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 2015-12-01 04:59:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueService.java 2015-12-04 16:57:18 +0000
@@ -189,7 +189,14 @@
dataValueStore.deleteDataValue( dataValue );
}
-
+
+ @Override
+ @Transactional
+ public void deleteDataValues( OrganisationUnit organisationUnit )
+ {
+ dataValueStore.deleteDataValues( organisationUnit );
+ }
+
@Override
public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source, DataElementCategoryOptionCombo categoryOptionCombo )
{
=== 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-09-21 12:17:42 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueStore.java 2015-12-04 16:57:18 +0000
@@ -133,6 +133,17 @@
}
@Override
+ public void deleteDataValues( OrganisationUnit organisationUnit )
+ {
+ String hql = "delete from DataValue d where d.source = :source";
+
+ Query query = sessionFactory.getCurrentSession().createQuery( hql );
+ query.setEntity( "source", organisationUnit );
+
+ query.executeUpdate();
+ }
+
+ @Override
public DataValue getDataValue( DataElement dataElement, Period period, OrganisationUnit source,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo )
{