← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17449: local/in add validated role in maintancance rbf

 

------------------------------------------------------------
revno: 17449
committer: Mithilesh Kumar Thakur <mithilesh.hisp@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-12 09:32:10 +0000
message:
  local/in add validated role in maintancance rbf
modified:
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/Lookup.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java
  local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java
  local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml
  local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm


--
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 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/Lookup.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/Lookup.java	2014-10-29 08:07:54 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/api/Lookup.java	2014-11-12 09:32:10 +0000
@@ -28,6 +28,9 @@
     
     public static final String OPTION_SET_PARTNER = "OPTION_SET_PARTNER";
     
+    public static final String CATEGORY_QUANTITY_REPORTED = "CATEGORY_QUANTITY_REPORTED";
+    public static final String CATEGORY_QUANTITY_VALIDATED = "CATEGORY_QUANTITY_VALIDATED";
+    public static final String CATEGORY_QUANTITY_EXTERNAL_VERIFICATION = "CATEGORY_QUANTITY_EXTERNAL_VERIFICATION";
     
     private String type;
     

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java	2014-10-29 08:07:54 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/dataentry/LoadDataEntryFormAction.java	2014-11-12 09:32:10 +0000
@@ -316,21 +316,26 @@
             totalDataElementId = totalDataElement.getId();
         }
         
+        optionsMap = new HashMap<Integer, Option>();
+        
         Lookup partnerOptionSetLookup = lookupService.getLookupByName( Lookup.OPTION_SET_PARTNER );
         
-        OptionSet activitesOptionSet = optionService.getOptionSet( Integer.parseInt( partnerOptionSetLookup.getValue() ) );
-        
-        List<Option> options = new ArrayList<Option>();
-        if( activitesOptionSet != null )
-        {
-            options.addAll( activitesOptionSet.getOptions() );
-        }
-        
-        for( Option option : options )
-        {
-            optionsMap.put( option.getId(), option );
-        }
-        
+        if( partnerOptionSetLookup != null )
+        {
+            OptionSet activitesOptionSet = optionService.getOptionSet( Integer.parseInt( partnerOptionSetLookup.getValue() ) );
+            
+            List<Option> options = new ArrayList<Option>();
+            if( activitesOptionSet != null )
+            {
+                options.addAll( activitesOptionSet.getOptions() );
+            }
+            
+            for( Option option : options )
+            {
+                optionsMap.put( option.getId(), option );
+            }
+        }
+                
         /*
         String abc = null;
         System.out.println( " Test ABC " +  abc );

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java'
--- local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java	2014-09-04 10:07:26 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/java/org/hisp/dhis/rbf/impl/DefaultPBFAggregationService.java	2014-11-12 09:32:10 +0000
@@ -24,6 +24,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.rbf.api.Lookup;
+import org.hisp.dhis.rbf.api.LookupService;
 import org.hisp.dhis.user.CurrentUserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
@@ -81,6 +82,9 @@
     @Autowired
     private OrganisationUnitService organisationUnitService;
     
+    @Autowired
+    private LookupService lookupService;
+    
     // -------------------------------------------------------------------------
     //
     // -------------------------------------------------------------------------
@@ -139,8 +143,6 @@
         
         SimpleDateFormat simpleDateFormat = new SimpleDateFormat( "yyyy-MM-dd" );
         
-        
-        
         try
         {
             Map<String, Double> maxScoreResultMap = new HashMap<String, Double>();
@@ -236,6 +238,8 @@
                 Integer periodId = rs.getInt( 2 );
                 Double value = rs.getDouble( 3 );
                 
+                
+                
                 try
                 {
                     Double maxScore = maxScoreResultMap.get( orgUnitId+":"+periodId );
@@ -243,7 +247,7 @@
                     {
                         Double overAllQualityScore = ( value / maxScore ) * 100.0;
                         
-                        aggregationResultMap.put( orgUnitId+":"+dataElement.getId()+":"+periodId, overAllQualityScore );                            
+                        aggregationResultMap.put( orgUnitId+ ":" +dataElement.getId() +":" +dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId() + ":" +periodId, overAllQualityScore );                            
                     }
                 }
                 catch( Exception e )
@@ -305,7 +309,7 @@
                 Integer orgUnitId = rs.getInt( 1 );
                 Integer periodId = rs.getInt( 2 );
                 Double countValue = rs.getDouble( 3 );
-                aggregationResultMap.put( orgUnitId+":"+dataElement.getId()+":"+periodId, countValue );
+                aggregationResultMap.put( orgUnitId+":"+dataElement.getId()+ ":" +dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId() + ":"+periodId, countValue );
             }
         }
         catch( Exception e )
@@ -320,13 +324,28 @@
     {
         Map<String, Double> aggregationResultMap = new HashMap<String, Double>();
         
+        Lookup catQtyReportedLookup = lookupService.getLookupByName( Lookup.CATEGORY_QUANTITY_REPORTED );
+        
+        Lookup catQtyValidatedLookup = lookupService.getLookupByName( Lookup.CATEGORY_QUANTITY_VALIDATED );
+        
+        Lookup catQtyExternalVerificationLookup = lookupService.getLookupByName( Lookup.CATEGORY_QUANTITY_EXTERNAL_VERIFICATION );
+        
         try
-        {
+        {   
+            /*
             String query = "SELECT organisationunitid, dataelementid, periodid, qtyvalidated FROM pbfdatavalue " +
                             " WHERE " + 
                                 " periodid IN ( "+ Lookup.PERIODID_BY_COMMA +" ) AND "+
                                 " organisationunitid IN ( " + Lookup.ORGUNITID_BY_COMMA + " ) ";
             
+            */
+            
+            String query = "SELECT organisationunitid, dataelementid, periodid, qtyreported, qtyvalidated, qtyexternalverification FROM pbfdatavalue " +
+                " WHERE " + 
+                    " periodid IN ( "+ Lookup.PERIODID_BY_COMMA +" ) AND "+
+                    " organisationunitid IN ( " + Lookup.ORGUNITID_BY_COMMA + " ) ";
+            
+            
             //System.out.println( "Query Before Replace : --" +  orgUnits.size() + " -- "+  query  );
             
             if( periods != null && periods.size() > 0 )
@@ -359,11 +378,29 @@
                 Integer orgUnitId = rs.getInt( 1 );
                 Integer dataElementId = rs.getInt( 2 );
                 Integer periodId = rs.getInt( 3 );
-                Double qtyValidated = rs.getDouble( 4 );
-                if( qtyValidated != null )
-                {
-                    aggregationResultMap.put( orgUnitId+":"+dataElementId+":"+periodId, qtyValidated );
-                }
+                
+                Double qtyReported = rs.getDouble( 4 );
+                Double qtyValidated = rs.getDouble( 5 );
+                Double qtyExternalVerification = rs.getDouble( 6 );
+                
+                if( qtyReported != null && catQtyReportedLookup != null  )
+                {
+                    //aggregationResultMap.put( orgUnitId+":"+dataElementId+":"+periodId, qtyValidated );
+                    aggregationResultMap.put( orgUnitId+":"+dataElementId +":" +catQtyReportedLookup.getValue() + ":"+periodId, qtyReported );
+                }
+                
+                if( qtyValidated != null && catQtyValidatedLookup != null )
+                {
+                    //aggregationResultMap.put( orgUnitId+":"+dataElementId+":"+periodId, qtyValidated );
+                    aggregationResultMap.put( orgUnitId+":"+dataElementId +":" +catQtyValidatedLookup.getValue() + ":"+periodId, qtyValidated );
+                }
+                
+                if( qtyExternalVerification != null && catQtyExternalVerificationLookup != null )
+                {
+                    //aggregationResultMap.put( orgUnitId+":"+dataElementId+":"+periodId, qtyValidated );
+                    aggregationResultMap.put( orgUnitId+":"+dataElementId +":" +catQtyExternalVerificationLookup.getValue() + ":"+periodId, qtyExternalVerification );
+                }
+                
             }
         }
         catch( Exception e )
@@ -497,10 +534,13 @@
                 String[] oneRow = cellKey.split( ":" );
                 Integer orgUnitId = Integer.parseInt( oneRow[0] );
                 Integer deId = Integer.parseInt( oneRow[1] );
+                Integer deCOCId = Integer.parseInt( oneRow[2] );
+                
                 //Integer periodId = period.getId();
-                Integer periodId = Integer.parseInt( oneRow[2] );
-                
-                Integer deCOCId = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId();
+                Integer periodId = Integer.parseInt( oneRow[3] );
+                
+                //Integer deCOCId = dataElementCategoryService.getDefaultDataElementCategoryOptionCombo().getId();
+                
                 String value = aggregationResultMap.get( cellKey ) + "";
 
                 query = "SELECT value FROM datavalue WHERE dataelementid = " + deId + " AND categoryoptioncomboid = " + deCOCId + " AND periodid = " + periodId + " AND sourceid = " + orgUnitId;
@@ -606,14 +646,9 @@
         return orgUnitGroupId;
         
         
-        
-        
         //"SELECT orgunitgroupid from orgunitgroupsetmembers where orgunitgroupsetid = 1372 and orgunitgroupid in ( select orgunitgroupid from orgunitgroupmembers where organisationunitid = 1230 )";
 
         
-        
-        
-        
     }    
     
     

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml'
--- local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml	2014-10-24 11:05:35 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/resources/struts.xml	2014-11-12 09:32:10 +0000
@@ -134,8 +134,14 @@
 		<param name="page">/dhis-web-maintenance-rbf/loadDataEntryForm.vm</param>		
 	 	<param name="requiredAuthorities">F_QUANTITY_EXTERNAL_VERIFICATION</param>		
 	</action>	
-	
-	
+
+	<!-- for PBF Admin DataEntry Role Quanitity External Verification-->	 
+	<action name="quanitityReported" class="org.hisp.dhis.rbf.action.NoAction">
+		<result name="success" type="velocity">/content.vm</result>
+		<param name="page">/dhis-web-maintenance-rbf/loadDataEntryForm.vm</param>		
+	 	<param name="requiredAuthorities">F_QUANTITY_REPORTED</param>		
+	</action>
+
 	<!-- for PBF Admin DataEntry Role Quanitity External Verification-->	 
 	<action name="pbfAdminDataEntry" class="org.hisp.dhis.rbf.action.NoAction">
 		<result name="success" type="velocity">/content.vm</result>

=== modified file 'local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm'
--- local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm	2014-11-05 06:31:00 +0000
+++ local/in/dhis-web-maintenance-rbf/src/main/webapp/dhis-web-maintenance-rbf/loadDataEntryForm.vm	2014-11-12 09:32:10 +0000
@@ -139,7 +139,8 @@
 					<td>
         				<input onblur="savePBFDataValue('$dataElement.id', 1 )" type="text" name="pbfdv_qty_reported_$dataElement.id" id="pbfdv_qty_reported_$dataElement.id" 
         						value="$!pbfDataValue.quantityReported" tabindex="$tabIndex" style="text-align: center;" 
-        						#if($dataElement.type =='number') class="{validate:{number:true}}" 
+        						#if( $auth.hasAccess( "dhis-web-maintenance-rbf", "pbfAdminDataEntry" ) || $auth.hasAccess( "dhis-web-maintenance-rbf", "quanitityReported") )  #else readonly = "readonly" #end
+								#if($dataElement.type =='number') class="{validate:{number:true}}" 
         						#elseif($dataElement.type =='int') class="{validate:{integer:true}}"
         						#elseif($dataElement.type =='positiveNumber') class="{validate:{positive_integer:true}}"
         						#elseif($dataElement.type =='negativeNumber') class="{validate:{negative_integer:true}}"