dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35834
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18350: Fix accepting an approval submission from country (catOption level) to global (above catOption le...
------------------------------------------------------------
revno: 18350
committer: jimgrace@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2015-02-20 02:42:23 -0500
message:
Fix accepting an approval submission from country (catOption level) to global (above catOption level)
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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/DefaultDataApprovalService.java 2015-02-20 07:42:23 +0000
@@ -203,6 +203,13 @@
DataApproval d = dataApprovalStore.getDataApproval( da.getDataApprovalLevel(), da.getDataSet(),
da.getPeriod(), da.getOrganisationUnit(), da.getAttributeOptionCombo() );
+ if ( d == null )
+ {
+ log.warn( "unapproveData: approval not found at " + da );
+
+ throw new DataMayNotBeAcceptedException();
+ }
+
dataApprovalStore.deleteDataApproval( d );
}
@@ -255,6 +262,13 @@
DataApproval d = dataApprovalStore.getDataApproval( da.getDataApprovalLevel(), da.getDataSet(),
da.getPeriod(), da.getOrganisationUnit(), da.getAttributeOptionCombo() );
+ if ( d == null )
+ {
+ log.warn( "acceptData: approval not found at " + da );
+
+ throw new DataMayNotBeAcceptedException();
+ }
+
d.setAccepted( true );
dataApprovalStore.updateDataApproval( d );
@@ -307,6 +321,13 @@
DataApproval d = dataApprovalStore.getDataApproval( da.getDataApprovalLevel(), da.getDataSet(),
da.getPeriod(), da.getOrganisationUnit(), da.getAttributeOptionCombo() );
+ if ( d == null )
+ {
+ log.warn( "unacceptData: approval not found at " + da );
+
+ throw new DataMayNotBeAcceptedException();
+ }
+
d.setAccepted( false );
dataApprovalStore.updateDataApproval( d );
=== 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 2015-02-19 09:18:17 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java 2015-02-20 07:42:23 +0000
@@ -369,20 +369,20 @@
readyBelowSubquery + " as ready_below, " +
approvedAboveSubquery + " as approved_above " +
"from ( " + // subquery to get combinations of organisation unit and category option combo
- "select distinct cocco.categoryoptioncomboid, ccoc.categorycomboid, o.organisationunitid " +
+ "select distinct cocco.categoryoptioncomboid, ccoc.categorycomboid, coalesce(coo.organisationunitid, o.organisationunitid) as organisationunitid " +
"from categoryoptioncombos_categoryoptions cocco " +
"join categorycombos_optioncombos ccoc on ccoc.categoryoptioncomboid = cocco.categoryoptioncomboid and ccoc.categorycomboid in (" + categoryComboIds + ") " +
"join dataelementcategoryoption co on co.categoryoptionid = cocco.categoryoptionid " +
"and (co.startdate is null or co.startdate <= '" + maxDate + "') and (co.enddate is null or co.enddate >= '" + minDate + "') " +
"join _orgunitstructure o on " + orgUnitJoinOn + " " +
"left join categoryoption_organisationunits coo on coo.categoryoptionid = co.categoryoptionid " +
- "left join _orgunitstructure ous on ous.idlevel" + orgUnitLevel + "= o.organisationunitid and ous.organisationunitid = coo.organisationunitid " +
+ "left join _orgunitstructure ous on ous.idlevel" + orgUnitLevel + " = o.organisationunitid and ous.organisationunitid = coo.organisationunitid " +
joinAncestors +
"left join dataelementcategoryoptionusergroupaccesses couga on couga.categoryoptionid = cocco.categoryoptionid " +
"left join usergroupaccess uga on uga.usergroupaccessid = couga.usergroupaccessid " +
"left join usergroupmembers ugm on ugm.usergroupid = uga.usergroupid " +
"where ( coo.categoryoptionid is null or ous.organisationunitid is not null " + testAncestors + ") " +
- ( isSuperUser || user == null ? "" : "and ( ugm.userid = " + user.getId() + " or co.userid = " + user.getId() +
+ ( isSuperUser || user == null ? "" : "and ( ugm.userid = " + user.getId() + " or co.userid = " + user.getId() + " " +
"or co.publicaccess is null or left(co.publicaccess, 1) = 'r' ) " ) +
( attributeOptionCombo == null ? "" : "and cocco.categoryoptioncomboid = " + attributeOptionCombo.getId() + " " ) +
") as a";