← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22143: Data approval. Including name of organisation unit in /approvals/categoryOptionCombos response. I...

 

------------------------------------------------------------
revno: 22143
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-03-04 13:13:10 +0100
message:
  Data approval. Including name of organisation unit in /approvals/categoryOptionCombos response. Inconvenient to fetch this for clients as it is not possible to know up front which org units which will be part of response.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStatus.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js


--
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/dataapproval/DataApprovalStatus.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStatus.java	2016-01-11 03:14:37 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataapproval/DataApprovalStatus.java	2016-03-04 12:13:10 +0000
@@ -60,10 +60,15 @@
      */
     private DataApprovalLevel actionLevel;
 
-    /*
+    /**
      * If the selection is approved, the OrganisationUnit UID.
      */
     private String organisationUnitUid;
+    
+    /**
+     * If the selection is approved, the OrganisationUnit name.
+     */
+    private String organisationUnitName;
 
     /**
      * If the selection is approved, the attribute category option combo UID.
@@ -108,13 +113,14 @@
 
     public DataApprovalStatus( DataApprovalState state,
         DataApprovalLevel approvedLevel, DataApprovalLevel actionLevel,
-        String organisationUnitUid, String attributeOptionComboUid,
+        String organisationUnitUid, String organisationUnitName, String attributeOptionComboUid,
         boolean accepted, DataApprovalPermissions permissions )
     {
         this.state = state;
         this.approvedLevel = approvedLevel;
         this.actionLevel = actionLevel;
         this.organisationUnitUid = organisationUnitUid;
+        this.organisationUnitName = organisationUnitName;
         this.attributeOptionComboUid = attributeOptionComboUid;
         this.accepted = accepted;
         this.permissions = permissions;
@@ -164,6 +170,16 @@
         this.organisationUnitUid = organisationUnitUid;
     }
 
+    public String getOrganisationUnitName()
+    {
+        return organisationUnitName;
+    }
+
+    public void setOrganisationUnitName( String organisationUnitName )
+    {
+        this.organisationUnitName = organisationUnitName;
+    }
+
     public String getAttributeOptionComboUid()
     {
         return attributeOptionComboUid;

=== 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	2016-03-04 11:29:07 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataapproval/hibernate/HibernateDataApprovalStore.java	2016-03-04 12:13:10 +0000
@@ -352,7 +352,7 @@
         int workflowPeriodId = getWorkflowPeriodId( workflow, endDate );
 
         final String sql =
-            "select coc.uid as categoryoptioncombouid, o.organisationunituid, " +
+            "select coc.uid as cocuid, o.organisationunituid as ouuid, ou.name as ouname, " +
             "(select min(dal.level + case when da.accepted then .0 else .1 end) " +
                 "from dataapproval da " +
                 "join dataapprovallevel dal on dal.dataapprovallevelid = da.dataapprovallevelid " +
@@ -370,6 +370,7 @@
             "join dataelementcategoryoption co on co.categoryoptionid = cocco.categoryoptionid " +
                 "and (co.startdate is null or co.startdate <= '" + endDate + "') and (co.enddate is null or co.enddate >= '" + startDate + "') " +
             "join _orgunitstructure o on " + orgUnitJoinOn + " " +
+            "join organisationunit ou on o.organisationunitid = ou.organisationunitid " +
             "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 " +
             joinAncestors +
@@ -395,9 +396,10 @@
         {
             final String aocUid = rowSet.getString( 1 );
             final String ouUid = rowSet.getString( 2 );
-            final Double highestApproved = rowSet.getDouble( 3 );
-            final boolean readyBelow = rowSet.getBoolean( 4 );
-            final boolean approvedAbove = rowSet.getBoolean( 5 );
+            final String ouName = rowSet.getString( 3 );
+            final Double highestApproved = rowSet.getDouble( 4 );
+            final boolean readyBelow = rowSet.getBoolean( 5 );
+            final boolean approvedAbove = rowSet.getBoolean( 6 );
 
             final int level = highestApproved == null ? 0 : highestApproved.intValue();
             final boolean accepted = ( highestApproved != 0 && highestApproved == level );
@@ -422,7 +424,7 @@
                                 ACCEPTED_HERE :
                                 APPROVED_HERE );
     
-                statusList.add( new DataApprovalStatus( state, approvedLevel, actionLevel, ouUid, aocUid, accepted, null ) );
+                statusList.add( new DataApprovalStatus( state, approvedLevel, actionLevel, ouUid, ouName, aocUid, accepted, null ) );
     
                 log.debug( "Get approval result: level " + level + " dataApprovalLevel " + ( actionLevel != null ? actionLevel.getLevel() : "[none]" )
                     + " approved " + ( approvedLevel != null )

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java	2016-02-11 04:11:46 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DataApprovalController.java	2016-03-04 12:13:10 +0000
@@ -306,6 +306,7 @@
             item.put( "id", status.getAttributeOptionComboUid() );
             item.put( "level", approvalLevel );
             item.put( "ou", status.getOrganisationUnitUid() );
+            item.put( "ouName", status.getOrganisationUnitName() );
             item.put( "accepted", status.isAccepted() );
             item.put( "permissions", status.getPermissions() );
 

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2016-03-03 18:48:22 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataApproval.js	2016-03-04 12:13:10 +0000
@@ -131,7 +131,7 @@
 				html += "<td><input type='checkbox' class='itemCheckbox' id='coc-" + ap.id + "-" + ap.ou + "' data-coc='" + ap.id + "' data-ou='" + ap.ou + "' ";
 				html += "data-approve='" + pm.mayApprove + "' data-unapprove='" + pm.mayUnapprove + "' data-accept='" + pm.mayAccept + "' data-unaccept='" + pm.mayUnaccept + "'>";
 				html += "<label for='coc-" + ap.id + "-" + ap.ou + "'>" + cocName + "</label></td>";
-				html += "<td>" + ap.ou + "</td>";
+				html += "<td>" + ap.ouName + "</td>";
 				html += "<td>" + dhis2.appr.getPermissions( ap ) + "</td>";
 				html += "</tr>";
 			} );