← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2418: Merged r1966 from 2.0.5. Exception thrown when editing sections without datelements

 

------------------------------------------------------------
revno: 2418
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2010-10-22 15:49:25 +0200
message:
  Merged r1966 from 2.0.5. Exception thrown when editing sections without datelements
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.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-api/src/main/java/org/hisp/dhis/dataset/Section.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2010-08-25 09:31:57 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/Section.java	2010-10-22 13:49:25 +0000
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Set;
 import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
 import org.hisp.dhis.dataelement.DataElementOperand;
 
 public class Section
@@ -63,6 +64,15 @@
     }
 
     // -------------------------------------------------------------------------
+    // Logic
+    // -------------------------------------------------------------------------
+
+    public DataElementCategoryCombo getCategoryCombo()
+    {
+        return dataElements != null && dataElements.size() > 0 ? dataElements.iterator().next().getCategoryCombo() : null;
+    }
+    
+    // -------------------------------------------------------------------------
     // hashCode, equals and toString
     // -------------------------------------------------------------------------
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java	2010-09-07 05:24:21 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/section/EditSectionAction.java	2010-10-22 13:49:25 +0000
@@ -171,8 +171,6 @@
 
         dataSet = section.getDataSet();
 
-        categoryCombo = section.getDataElements().iterator().next().getCategoryCombo();
-
         dataElementOfDataSet = new ArrayList<DataElement>( dataSet.getDataElements() );
 
         Collection<Section> sections = dataSet.getSections();
@@ -182,15 +180,20 @@
             dataElementOfDataSet.removeAll( s.getDataElements() );
         }
 
-        Iterator<DataElement> dataElementIterator = dataElementOfDataSet.iterator();
-
-        while ( dataElementIterator.hasNext() )
-        {
-            DataElement de = dataElementIterator.next();
-
-            if ( !de.getCategoryCombo().getName().equalsIgnoreCase( categoryCombo.getName() ) )
+        categoryCombo = section.getCategoryCombo();
+        
+        if ( categoryCombo != null )
+        {        
+            Iterator<DataElement> dataElementIterator = dataElementOfDataSet.iterator();
+            
+            while ( dataElementIterator.hasNext() )
             {
-                dataElementIterator.remove();
+                DataElement de = dataElementIterator.next();
+                
+                if ( !de.getCategoryCombo().getName().equalsIgnoreCase( categoryCombo.getName() ) )
+                {
+                    dataElementIterator.remove();
+                }
             }
         }
 
@@ -204,5 +207,4 @@
 
         return SUCCESS;
     }
-
 }