← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3764: Fix bug: Save many dataelement-operands for the same dataelement into Edit Compulsary Dataelemen...

 

------------------------------------------------------------
revno: 3764
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-27 15:32:58 +0700
message:
  Fix bug: Save many dataelement-operands for the same dataelement into  Edit Compulsary Dataelement form.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/compulsory/GetCompulsoryDataElementsAction.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-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/compulsory/GetCompulsoryDataElementsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/compulsory/GetCompulsoryDataElementsAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/compulsory/GetCompulsoryDataElementsAction.java	2011-05-27 08:32:58 +0000
@@ -29,6 +29,7 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 import org.hisp.dhis.dataelement.DataElementOperand;
@@ -55,7 +56,7 @@
     {
         this.dataSetService = dataSetService;
     }
-    
+
     private DataElementService dataElementService;
 
     public void setDataElementService( DataElementService dataElementService )
@@ -68,7 +69,7 @@
     // -------------------------------------------------------------------------
 
     private Integer id;
-        
+
     public Integer getId()
     {
         return id;
@@ -82,7 +83,7 @@
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
-    
+
     private List<DataElementOperand> availableOperands;
 
     public List<DataElementOperand> getAvailableOperands()
@@ -106,12 +107,27 @@
         DataSet dataSet = dataSetService.getDataSet( id );
 
         selectedOperands = new ArrayList<DataElementOperand>( dataSet.getCompulsoryDataElementOperands() );
-        
-        availableOperands = new ArrayList<DataElementOperand>( dataElementService.getAllGeneratedOperands( dataSet.getDataElements() ) );
-        availableOperands.removeAll( selectedOperands );
-        
-        Collections.sort( availableOperands, new DataElementOperandNameComparator() );        
-        
+
+        availableOperands = new ArrayList<DataElementOperand>( dataElementService.getAllGeneratedOperands( dataSet
+            .getDataElements() ) );
+        
+        
+        for ( DataElementOperand selectedOperand : selectedOperands )
+        {
+            Iterator<DataElementOperand> iter = availableOperands.iterator();
+        
+            while ( iter.hasNext() )
+            {
+                DataElementOperand item = iter.next();
+                if ( selectedOperand.getPersistedId().equals( item.getOperandId() + "" ))
+                {
+                    iter.remove();
+                }
+            }
+        }
+
+        Collections.sort( availableOperands, new DataElementOperandNameComparator() );
+
         return SUCCESS;
     }
 }