← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4652: aggregate indicator bug fix

 

------------------------------------------------------------
revno: 4652
committer: Wilfred Senyoni <senyoni@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-22 21:02:14 +0300
message:
  aggregate indicator bug fix
modified:
  local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregateAttributeService.java
  local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregatedReportService.java
  local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernateAggregateAttributeStore.java
  local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernatePersonStore.java
  local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/AggregateIndicatorAction.java
  local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/ShowUpdateAggregateIndicatorAction.java
  local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/addCriteriaForm.vm
  local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/javascript/aggregateIndicator.js
  local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/updateCriteriaForm.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/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregateAttributeService.java'
--- local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregateAttributeService.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregateAttributeService.java	2011-09-22 18:02:14 +0000
@@ -196,8 +196,7 @@
 		
 		for(DataElementCategoryOptionCombo dataelementCategotyOptionCombo:aggregateAttribute.getDataelement().getCategoryCombo().getOptionCombos()){
 			optionCombo = dataelementCategotyOptionCombo;
-		}
-		
+		}		
 		
 		Period period = periodService.getPeriod(2067);
 		
@@ -207,24 +206,21 @@
 			
 			if( count != 0 ){
 				
-				DataValue dataValue = new DataValue();
-				
-				dataValue.setDataElement(aggregateAttribute.getDataelement());
-				dataValue.setOptionCombo(optionCombo);
-				dataValue.setSource(organisationUnit);
-				dataValue.setPeriod(period);
-				dataValue.setStoredBy(user);
-				dataValue.setTimestamp(new Date());	
-				dataValue.setValue(Integer.toString(count));
-				
-				
-				if(dataValueService.getDataValue(organisationUnit, aggregateAttribute.getDataelement(), period, optionCombo) == null){
-					
-					dataValueService.addDataValue(dataValue);					
-				}else{
-					
-					dataValueService.updateDataValue(dataValue);
-				}
+				DataValue dataValue = dataValueService.getDataValue( organisationUnit, aggregateAttribute.getDataelement(), period, optionCombo );
+
+		        if ( dataValue == null )
+		        {		           
+		                dataValue = new DataValue( aggregateAttribute.getDataelement(), period, organisationUnit, Integer.toString(count), user, new Date(), null, optionCombo );
+		                dataValueService.addDataValue( dataValue );		           
+		        }
+		        else
+		        {
+		            dataValue.setValue( Integer.toString(count) );
+		            dataValue.setTimestamp( new Date() );
+		            dataValue.setStoredBy( user );
+
+		            dataValueService.updateDataValue( dataValue );
+		        }
 			}
 		}
 	}

=== modified file 'local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregatedReportService.java'
--- local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregatedReportService.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/DefaultAggregatedReportService.java	2011-09-22 18:02:14 +0000
@@ -266,7 +266,7 @@
         // ---------------------------------------------------------------------
 
         CategoryAxis xAxis = plot.getDomainAxis();
-        xAxis.setCategoryLabelPositions( CategoryLabelPositions.STANDARD );
+        xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 );
 
         // ---------------------------------------------------------------------
         // Color & antialias

=== modified file 'local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernateAggregateAttributeStore.java'
--- local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernateAggregateAttributeStore.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernateAggregateAttributeStore.java	2011-09-22 18:02:14 +0000
@@ -2,10 +2,12 @@
 
 
 import java.sql.ResultSet;
+import java.sql.Statement;
 import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Collection;
 
+import org.amplecode.quick.StatementHolder;
 import org.amplecode.quick.StatementManager;
 import org.hibernate.criterion.Restrictions;
 import org.hisp.dhis.hibernate.HibernateGenericStore;
@@ -51,6 +53,8 @@
     	
     	Attribute attribute = new Attribute();
     	
+    	StatementHolder holder = statementManager.getHolder();
+    	
     	//Deal with the criterias first
     	
     	sql = countSql;
@@ -95,14 +99,20 @@
     	
     	try
         {
-            ResultSet resultSet = statementManager.getHolder().getStatement().executeQuery( sql );
+    		Statement statement = holder.getStatement();
+    		
+            ResultSet resultSet = statement.executeQuery( sql );            
 
             resultSet.next();
             return resultSet.getInt( 1 );
         }
         catch ( SQLException ex )
         {
-            throw new RuntimeException( "Failed to get all operands"+sql, ex  );
+            throw new RuntimeException( "Failed to get all operands", ex  );
+        }
+        finally
+        {
+        	holder.close();
         }
     }
 }

=== modified file 'local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernatePersonStore.java'
--- local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernatePersonStore.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-service-hr/src/main/java/org/hisp/dhis/hr/hibernate/HibernatePersonStore.java	2011-09-22 18:02:14 +0000
@@ -303,7 +303,7 @@
 	    	
 	    	if(selectedUnitOnly){
 	    		
-	    		sql += " AND person.organisationunitid =" + organisationUnit;
+	    		sql += " AND person.organisationunitid =" + organisationUnit.getId();
 	    		
 	    	}else{
 	    		

=== modified file 'local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/AggregateIndicatorAction.java'
--- local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/AggregateIndicatorAction.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/AggregateIndicatorAction.java	2011-09-22 18:02:14 +0000
@@ -96,9 +96,9 @@
     	AggregateAttribute aggregateAttribute = aggregateAttributeService.getAggregateAttribute( id );
     	
     	OrganisationUnit unit = organisationUnitService.getOrganisationUnit(organisationUnitId);
-    	
+    	    	
 	    aggregateAttributeService.getCountPersonByAggregateAttribute( aggregateAttribute, unit );
-	
+	    	
 	    return SUCCESS;
     	
     }

=== modified file 'local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/ShowUpdateAggregateIndicatorAction.java'
--- local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/ShowUpdateAggregateIndicatorAction.java	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-web-maintenance-hr/src/main/java/org/hisp/dhis/hr/action/indicator/ShowUpdateAggregateIndicatorAction.java	2011-09-22 18:02:14 +0000
@@ -27,6 +27,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+
 import java.util.ArrayList;
 import java.util.Collection;
 
@@ -129,12 +130,12 @@
     // Action
     // -------------------------------------------------------------------------
 
-    public String execute()
+	public String execute()
         throws Exception
     {
     	aggregateAttribute = aggregateAttributeService.getAggregateAttribute(id);
     	
-    	attributeOptions = new ArrayList<AttributeOptions>( attributeOptionsService.getAllAttributeOptions());
+    	attributeOptions = new ArrayList<AttributeOptions>( attributeOptionsService.getAllAttributeOptions());    	
     	
     	Collection<AttributeOptions> attributeOptionsToExclude = new ArrayList<AttributeOptions>(aggregateAttribute.getAttributeOptions());
     	

=== modified file 'local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/addCriteriaForm.vm'
--- local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/addCriteriaForm.vm	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/addCriteriaForm.vm	2011-09-22 18:02:14 +0000
@@ -36,7 +36,7 @@
 	<td>
 		<select id="attributeId" name="attributeId" style="min-width:20em">
 		#foreach($attribute in $attributes) 
-			<option value="$attribute.id" >$attribute.name </option>
+			<option value="$attribute.id" >$attribute.caption </option>
 		#end	
 		</select>
 	</td>

=== modified file 'local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/javascript/aggregateIndicator.js'
--- local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/javascript/aggregateIndicator.js	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/javascript/aggregateIndicator.js	2011-09-22 18:02:14 +0000
@@ -194,9 +194,9 @@
  
  window.location.href = url;
  
- var request = new Request();
- request.setCallbackSuccess( getReportStatus );
- request.send( url );
+ //var request = new Request();
+ //request.setCallbackSuccess( getReportStatus );
+ //request.send( url );
 
 }
 

=== modified file 'local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/updateCriteriaForm.vm'
--- local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/updateCriteriaForm.vm	2011-07-05 07:41:01 +0000
+++ local/tz/dhis-web-maintenance-hr/src/main/webapp/dhis-web-maintenance-hr/updateCriteriaForm.vm	2011-09-22 18:02:14 +0000
@@ -38,7 +38,7 @@
 	<td>
 		<select id="attributeId" name="attributeId" style="min-width:20em">
 		#foreach($attribute in $attributes) 
-			<option value="$attribute.id"  #if( $attribute.id == $criteria.attribute.getId() ) selected="selected" #end >$attribute.name </option>
+			<option value="$attribute.id"  #if( $attribute.id == $criteria.attribute.getId() ) selected="selected" #end >$attribute.caption </option>
 		#end	
 		</select>
 	</td>