← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9596: Only display datasets that have dataelements that are used in case-aggregate formulas.

 

------------------------------------------------------------
revno: 9596
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-01-24 13:30:16 +0700
message:
  Only display datasets that have dataelements that are used in case-aggregate formulas.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationFormAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml


--
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/caseaggregation/CaseAggregationConditionService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2012-10-26 03:05:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/caseaggregation/CaseAggregationConditionService.java	2013-01-24 06:30:16 +0000
@@ -61,7 +61,6 @@
     CaseAggregationCondition getCaseAggregationCondition( DataElement dataElement, DataElementCategoryOptionCombo optionCombo );
     
     Collection<CaseAggregationCondition> getCaseAggregationCondition( Collection<DataElement> dataElements );
-
     
     Integer parseConditition( CaseAggregationCondition aggregationCondition, OrganisationUnit orgunit, Period period );
         

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationFormAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationFormAction.java	2012-01-25 17:11:43 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/caseaggregation/CaseAggregationFormAction.java	2013-01-24 06:30:16 +0000
@@ -27,14 +27,13 @@
 
 package org.hisp.dhis.caseentry.action.caseaggregation;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
+import java.util.Collection;
+import java.util.HashSet;
 
-import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
+import org.hisp.dhis.caseaggregation.CaseAggregationCondition;
+import org.hisp.dhis.caseaggregation.CaseAggregationConditionService;
+import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataset.DataSet;
-import org.hisp.dhis.dataset.DataSetService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -45,20 +44,20 @@
     // Dependencies
     // -------------------------------------------------------------------------
 
-    private DataSetService dataSetService;
+    private CaseAggregationConditionService aggregationConditionService;
 
-    public void setDataSetService( DataSetService dataSetService )
+    public void setAggregationConditionService( CaseAggregationConditionService aggregationConditionService )
     {
-        this.dataSetService = dataSetService;
+        this.aggregationConditionService = aggregationConditionService;
     }
 
     // -------------------------------------------------------------------------
     // Input/Output
     // -------------------------------------------------------------------------
 
-    private List<DataSet> datasets;
+    private Collection<DataSet> datasets = new HashSet<DataSet>();
 
-    public List<DataSet> getDatasets()
+    public Collection<DataSet> getDatasets()
     {
         return datasets;
     }
@@ -70,21 +69,16 @@
     public String execute()
         throws Exception
     {
-        datasets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
-
-        Iterator<DataSet> dataSetListIterator = datasets.iterator();
-
-        while ( dataSetListIterator.hasNext() )
+        Collection<CaseAggregationCondition> aggConditions = aggregationConditionService
+            .getAllCaseAggregationCondition();
+
+        for ( CaseAggregationCondition aggCondition : aggConditions )
         {
-            DataSet d = (DataSet) dataSetListIterator.next();
-
-            if ( d.getSources().size() <= 0 )
-
-                dataSetListIterator.remove();
+            DataElement dataElement = aggCondition.getAggregationDataElement();
+
+            datasets.addAll( dataElement.getDataSets() );
         }
 
-        Collections.sort( datasets, IdentifiableObjectNameComparator.INSTANCE );
-
         return SUCCESS;
     }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-01-24 04:15:05 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/META-INF/dhis/beans.xml	2013-01-24 06:30:16 +0000
@@ -282,7 +282,7 @@
 		id="org.hisp.dhis.caseentry.action.caseaggregation.CaseAggregationFormAction"
 		class="org.hisp.dhis.caseentry.action.caseaggregation.CaseAggregationFormAction"
 		scope="prototype">
-		<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
+		<property name="aggregationConditionService" ref="org.hisp.dhis.caseaggregation.CaseAggregationConditionService" />
 	</bean>
 
 	<bean