dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33707
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17259: Approval, performance, move db call outside loop
------------------------------------------------------------
revno: 17259
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-24 12:44:54 +0200
message:
Approval, performance, move db call outside loop
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2014-10-24 10:01:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2014-10-24 10:44:54 +0000
@@ -378,7 +378,9 @@
List<DataApprovalStatus> statusList = new ArrayList<>();
- for ( DataApproval da : dataApprovalStore.getUserDataApprovals( dataSets, periods ) )
+ Set<DataApproval> approvals = dataApprovalStore.getUserDataApprovals( dataSets, periods );
+
+ for ( DataApproval da : approvals )
{
DataApprovalPermissions permissions = new DataApprovalPermissions();
@@ -404,6 +406,7 @@
permissions.setMayAccept( mayAcceptOrUnaccept );
permissions.setMayUnaccept( mayAcceptOrUnaccept );
}
+
boolean mayReadData = true; //TODO: Fix.
permissions.setMayReadData( mayReadData );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2014-10-24 10:26:58 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2014-10-24 10:44:54 +0000
@@ -241,6 +241,8 @@
int previousPeriodId = 0;
int previousLevel = 0;
+ DataElementCategoryOptionCombo defaultOptionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
+
Set<DataApproval> userDataApprovals = new HashSet<>();
while ( rowSet.next() )
@@ -266,7 +268,7 @@
OrganisationUnit orgUnit = ( orgUnitId == null ? null : organisationUnitService.getOrganisationUnit( orgUnitId ) );
//TODO: currently special cased for PEFPAR's requirements. Can we make it more generic?
- if ( level > 1 && attributeOptionCombo.equals ( categoryService.getDefaultDataElementCategoryOptionCombo() ) )
+ if ( level > 1 && attributeOptionCombo.equals( defaultOptionCombo ) )
{
for ( OrganisationUnit ou : getUserOrgsAtLevel( 3 ) )
{
@@ -277,6 +279,7 @@
continue;
}
+
DataApproval da = new DataApproval( dataApprovalLevel, null, period, orgUnit, attributeOptionCombo, accepted, null, null );
userDataApprovals.add( da );