dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41656
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21238: minor changes to Audit Services
------------------------------------------------------------
revno: 21238
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-11-30 12:36:05 +0700
message:
minor changes to Audit Services
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-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditStore.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditStore.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/trackedentityattributevalue/DefaultTrackedEntityAttributeValueAuditService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueAuditService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java
dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.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-11-27 10:16:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -66,17 +66,18 @@
* OrganisationUnit and DataElementCategoryOptionCombo.
*
* @param dataElement the DataElement of the DataValueAudits.
- * @param period the Period of the DataValueAudits.
- * @param organisationUnit the OrganisationUnit of the DataValueAudits.
+ * @param periods the Period of the DataValueAudits.
+ * @param organisationUnits the OrganisationUnit of the DataValueAudits.
* @param categoryOptionCombo the DataElementCategoryOptionCombo of the DataValueAudits.
* @param attributeOptionCombo the attribute option combo.
* @return a list of DataValueAudits which matches the given DataElement, Period,
* OrganisationUnit and DataElementCategoryOptionCombo, or an empty collection if
* there are not matches.
*/
- List<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period, OrganisationUnit organisationUnit,
+ List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType );
List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
- DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType );
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType,
+ int first, int max );
}
=== 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-11-27 10:16:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -81,42 +81,6 @@
List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> period, List<OrganisationUnit> organisationUnits,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType );
- /**
- * Deletes a DataValueAudit.
- *
- * @param dataValueAudit the DataValueAudit to delete.
- */
- void deleteDataValueAudit( DataValueAudit dataValueAudit );
-
- /**
- * Deletes all DataValueAudits for the given DataElement.
- *
- * @param dataElement the DataElement for which the DataValueAudits should be deleted.
- * @return the number of deleted DataValueAudits.
- */
- int deleteDataValueAuditByDataElement( DataElement dataElement );
-
- /**
- * Deletes all DataValueAudits for the given Period.
- *
- * @param period the Period for which the DataValueAudits should be deleted.
- * @return the number of deleted DataValueAudits.
- */
- int deleteDataValueAuditByPeriod( Period period );
-
- /**
- * Deletes all DataValues for the given OrganisationUnit.
- *
- * @param organisationUnit the OrganisationUnit for which the DataValueAudits should be deleted.
- * @return the number of deleted DataValueAudits.
- */
- int deleteDataValueAuditByOrganisationUnit( OrganisationUnit organisationUnit );
-
- /**
- * Deletes all DataValues for the given DataElementCategoryOptionCombo.
- *
- * @param categoryOptionCombo the DataElementCategoryOptionCombo for which the DataValueAudits should be deleted.
- * @return the number of deleted DataValueAudits.
- */
- int deleteDataValueAuditByCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo );
+ List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType, int first, int max );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditService.java 2015-11-30 03:21:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -43,4 +43,7 @@
List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType );
+
+ List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
+ List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType, int first, int max );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditStore.java 2015-11-30 03:21:59 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentityattributevalue/TrackedEntityAttributeValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -43,4 +43,7 @@
List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType );
+
+ List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
+ List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType, int first, int max );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditService.java 2015-11-27 10:16:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -49,4 +49,7 @@
List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements, List<ProgramStageInstance> programStageInstances,
AuditType auditType );
+
+ List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements, List<ProgramStageInstance> programStageInstances,
+ AuditType auditType, int first, int max );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditStore.java 2015-11-27 10:16:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentitydatavalue/TrackedEntityDataValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -43,4 +43,7 @@
List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
List<ProgramStageInstance> programStageInstances, AuditType auditType );
+
+ List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
+ List<ProgramStageInstance> programStageInstances, AuditType auditType, int first, int max );
}
=== 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-11-27 10:16:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -28,7 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.google.common.collect.Lists;
import org.hisp.dhis.common.AuditType;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -72,16 +71,16 @@
}
@Override
- public List<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period, OrganisationUnit organisationUnit,
- DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType )
- {
- return getDataValueAudits( dataElement, Lists.newArrayList( period ), Lists.newArrayList( organisationUnit ), categoryOptionCombo, attributeOptionCombo, auditType );
- }
-
- @Override
public List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType )
{
return dataValueAuditStore.getDataValueAudits( dataElement, periods, organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType );
}
+
+ @Override
+ public List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType, int first, int max )
+ {
+ return dataValueAuditStore.getDataValueAudits( dataElement, periods, organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType, first, max );
+ }
}
=== 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-11-27 10:16:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -30,7 +30,6 @@
import com.google.common.collect.Lists;
import org.hibernate.Criteria;
-import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Order;
@@ -81,7 +80,6 @@
public void addDataValueAudit( DataValueAudit dataValueAudit )
{
Session session = sessionFactory.getCurrentSession();
-
session.save( dataValueAudit );
}
@@ -98,7 +96,8 @@
public List<DataValueAudit> getDataValueAudits( DataElement dataElement, Period period, OrganisationUnit organisationUnit,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType )
{
- return getDataValueAudits( dataElement, Lists.newArrayList( period ), Lists.newArrayList( organisationUnit ), categoryOptionCombo, attributeOptionCombo, auditType );
+ return getDataValueAudits( dataElement, Lists.newArrayList( period ), Lists.newArrayList( organisationUnit ),
+ categoryOptionCombo, attributeOptionCombo, auditType );
}
@Override
@@ -106,6 +105,25 @@
public List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType )
{
+ Criteria criteria = getDataValueAuditCriteria( dataElement, periods, organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType );
+ return criteria.list();
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public List<DataValueAudit> getDataValueAudits( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits,
+ DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType auditType, int first, int max )
+ {
+ Criteria criteria = getDataValueAuditCriteria( dataElement, periods, organisationUnits, categoryOptionCombo, attributeOptionCombo, auditType );
+ criteria.setFirstResult( first );
+ criteria.setMaxResults( max );
+
+ return criteria.list();
+ }
+
+ private Criteria getDataValueAuditCriteria( DataElement dataElement, List<Period> periods, List<OrganisationUnit> organisationUnits, DataElementCategoryOptionCombo categoryOptionCombo, DataElementCategoryOptionCombo attributeOptionCombo, AuditType
+ auditType )
+ {
Session session = sessionFactory.getCurrentSession();
List<Period> storedPeriods = new ArrayList<>();
@@ -156,56 +174,6 @@
criteria.addOrder( Order.desc( "timestamp" ) );
- return criteria.list();
- }
-
- @Override
- public void deleteDataValueAudit( DataValueAudit dataValueAudit )
- {
- Session session = sessionFactory.getCurrentSession();
-
- session.delete( dataValueAudit );
- }
-
- @Override
- public int deleteDataValueAuditByDataElement( DataElement dataElement )
- {
- Query query = sessionFactory.getCurrentSession()
- .createQuery( "delete DataValueAudit where dataElement = :dataElement" )
- .setEntity( "dataElement", dataElement );
-
- return query.executeUpdate();
- }
-
- @Override
- public int deleteDataValueAuditByPeriod( Period period )
- {
- Period storedPeriod = periodStore.reloadPeriod( period );
-
- Query query = sessionFactory.getCurrentSession()
- .createQuery( "delete DataValueAudit where period = :period" )
- .setEntity( "period", storedPeriod );
-
- return query.executeUpdate();
- }
-
- @Override
- public int deleteDataValueAuditByOrganisationUnit( OrganisationUnit organisationUnit )
- {
- Query query = sessionFactory.getCurrentSession()
- .createQuery( "delete DataValueAudit where organisationUnit = :organisationUnit" )
- .setEntity( "organisationUnit", organisationUnit );
-
- return query.executeUpdate();
- }
-
- @Override
- public int deleteDataValueAuditByCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo )
- {
- Query query = sessionFactory.getCurrentSession()
- .createQuery( "delete DataValueAudit where categoryOptionCombo = :categoryOptionCombo or attributeOptionCombo = :categoryOptionCombo" )
- .setEntity( "categoryOptionCombo", categoryOptionCombo );
-
- return query.executeUpdate();
+ return criteria;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueAuditService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueAuditService.java 2015-11-30 03:21:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/DefaultTrackedEntityAttributeValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -56,4 +56,12 @@
{
return trackedEntityAttributeValueAuditStore.getTrackedEntityAttributeValueAudits( trackedEntityAttributes, trackedEntityInstances, auditType );
}
+
+ @Override
+ public List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
+ List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType, int first, int max )
+ {
+ return trackedEntityAttributeValueAuditStore.getTrackedEntityAttributeValueAudits( trackedEntityAttributes, trackedEntityInstances,
+ auditType, first, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java 2015-11-30 03:21:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentityattributevalue/hibernate/HibernateTrackedEntityAttributeValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -38,7 +38,6 @@
import org.hisp.dhis.trackedentity.TrackedEntityInstance;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAudit;
import org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueAuditStore;
-import org.hisp.dhis.trackedentitydatavalue.TrackedEntityDataValueAudit;
import java.util.List;
@@ -75,6 +74,24 @@
public List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType )
{
+ Criteria criteria = getTrackedEntityAttributeValueAuditCriteria( trackedEntityAttributes, trackedEntityInstances, auditType );
+ return criteria.list();
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public List<TrackedEntityAttributeValueAudit> getTrackedEntityAttributeValueAudits( List<TrackedEntityAttribute> trackedEntityAttributes,
+ List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType, int first, int max )
+ {
+ Criteria criteria = getTrackedEntityAttributeValueAuditCriteria( trackedEntityAttributes, trackedEntityInstances, auditType );
+ criteria.setFirstResult( first );
+ criteria.setFirstResult( max );
+
+ return criteria.list();
+ }
+
+ private Criteria getTrackedEntityAttributeValueAuditCriteria( List<TrackedEntityAttribute> trackedEntityAttributes, List<TrackedEntityInstance> trackedEntityInstances, AuditType auditType )
+ {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( TrackedEntityAttributeValueAudit.class );
@@ -95,6 +112,6 @@
criteria.addOrder( Order.desc( "timestamp" ) );
- return criteria.list();
+ return criteria;
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueAuditService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueAuditService.java 2015-11-27 10:16:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/DefaultTrackedEntityDataValueAuditService.java 2015-11-30 05:36:05 +0000
@@ -41,7 +41,8 @@
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@Transactional
-public class DefaultTrackedEntityDataValueAuditService implements TrackedEntityDataValueAuditService
+public class DefaultTrackedEntityDataValueAuditService
+ implements TrackedEntityDataValueAuditService
{
// -------------------------------------------------------------------------
// Dependencies
@@ -79,9 +80,16 @@
}
@Override
- public List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements, List<ProgramStageInstance> programStageInstances,
- AuditType auditType )
+ public List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
+ List<ProgramStageInstance> programStageInstances, AuditType auditType )
{
return trackedEntityDataValueAuditStore.getTrackedEntityDataValueAudits( dataElements, programStageInstances, auditType );
}
+
+ @Override
+ public List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
+ List<ProgramStageInstance> programStageInstances, AuditType auditType, int first, int max )
+ {
+ return trackedEntityDataValueAuditStore.getTrackedEntityDataValueAudits( dataElements, programStageInstances, auditType, first, max );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java 2015-11-27 10:16:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentitydatavalue/hibernate/HibernateTrackedEntityDataValueAuditStore.java 2015-11-30 05:36:05 +0000
@@ -44,7 +44,8 @@
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
-public class HibernateTrackedEntityDataValueAuditStore implements TrackedEntityDataValueAuditStore
+public class HibernateTrackedEntityDataValueAuditStore
+ implements TrackedEntityDataValueAuditStore
{
// -------------------------------------------------------------------------
// Dependencies
@@ -73,6 +74,25 @@
public List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
List<ProgramStageInstance> programStageInstances, AuditType auditType )
{
+ Criteria criteria = getTrackedEntityDataValueAuditCriteria( dataElements, programStageInstances, auditType );
+ return criteria.list();
+ }
+
+ @Override
+ @SuppressWarnings( "unchecked" )
+ public List<TrackedEntityDataValueAudit> getTrackedEntityDataValueAudits( List<DataElement> dataElements,
+ List<ProgramStageInstance> programStageInstances, AuditType auditType, int first, int max )
+ {
+ Criteria criteria = getTrackedEntityDataValueAuditCriteria( dataElements, programStageInstances, auditType );
+ criteria.setFirstResult( first );
+ criteria.setMaxResults( max );
+
+ return criteria.list();
+ }
+
+ private Criteria getTrackedEntityDataValueAuditCriteria( List<DataElement> dataElements, List<ProgramStageInstance> programStageInstances,
+ AuditType auditType )
+ {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria( TrackedEntityDataValueAudit.class );
@@ -93,6 +113,6 @@
criteria.addOrder( Order.desc( "timestamp" ) );
- return criteria.list();
+ return criteria;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2015-11-27 10:16:01 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetHistoryAction.java 2015-11-30 05:36:05 +0000
@@ -28,8 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Collection;
-
+import com.google.common.collect.Lists;
+import com.opensymphony.xwork2.Action;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementCategoryService;
@@ -40,6 +40,7 @@
import org.hisp.dhis.datavalue.DataValueAudit;
import org.hisp.dhis.datavalue.DataValueAuditService;
import org.hisp.dhis.datavalue.DataValueService;
+import org.hisp.dhis.dxf2.utils.InputUtils;
import org.hisp.dhis.option.OptionSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
@@ -47,10 +48,9 @@
import org.hisp.dhis.period.PeriodType;
import org.hisp.dhis.user.UserCredentials;
import org.hisp.dhis.user.UserService;
-import org.hisp.dhis.dxf2.utils.InputUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import com.opensymphony.xwork2.Action;
+import java.util.Collection;
/**
* @author Torgeir Lorange Ostby
@@ -195,7 +195,7 @@
{
return historyInvalid;
}
-
+
private boolean minMaxInvalid;
public boolean isMinMaxInvalid()
@@ -223,7 +223,7 @@
{
return storedBy;
}
-
+
private OptionSet commentOptionSet;
public OptionSet getCommentOptionSet()
@@ -259,7 +259,8 @@
DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo( cc, cp );
- dataValueAudits = dataValueAuditService.getDataValueAudits( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo, null );
+ dataValueAudits = dataValueAuditService.getDataValueAudits( dataElement, Lists.newArrayList( period ), Lists.newArrayList( organisationUnit ),
+ categoryOptionCombo, attributeOptionCombo, null );
dataValue = dataValueService.getDataValue( dataElement, period, organisationUnit, categoryOptionCombo, attributeOptionCombo );
@@ -276,7 +277,7 @@
minMaxInvalid = !dataElement.getValueType().isNumeric();
commentOptionSet = dataElement.getCommentOptionSet();
-
+
return SUCCESS;
}
}