← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3529: Data entry cleanup

 

------------------------------------------------------------
revno: 3529
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-05-07 15:38:00 +0200
message:
  Data entry cleanup
modified:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java
  dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.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-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2011-04-06 16:49:03 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/FormAction.java	2011-05-07 13:38:00 +0000
@@ -380,18 +380,20 @@
             // Calculating the number of times each category should be repeated
             // -----------------------------------------------------------------
 
-            int catColSpan = optionCombos.size();
-
             Map<Integer, Integer> catRepeat = new HashMap<Integer, Integer>();
 
             Map<Integer, Collection<Integer>> colRepeat = new HashMap<Integer, Collection<Integer>>();
 
+            int catColSpan = optionCombos.size();
+
             for ( DataElementCategory cat : categoryCombo.getCategories() )
             {
-                if ( catColSpan > 0 && cat.getCategoryOptions().size() > 0 )
+                int categoryOptionSize = cat.getCategoryOptions().size();
+                
+                if ( catColSpan > 0 && categoryOptionSize > 0 )
                 {
-                    catColSpan = catColSpan / cat.getCategoryOptions().size();
-                    int total = optionCombos.size() / (catColSpan * cat.getCategoryOptions().size());
+                    catColSpan = catColSpan / categoryOptionSize;
+                    int total = optionCombos.size() / ( catColSpan * categoryOptionSize );
                     Collection<Integer> cols = new ArrayList<Integer>( total );
 
                     for ( int i = 0; i < total; i++ )

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java	2011-04-12 12:15:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/SectionFormAction.java	2011-05-07 13:38:00 +0000
@@ -319,12 +319,13 @@
 
         for ( Section section : sections )
         {
-            if ( section.getDataElements().size() > 0 )
+            DataElementCategoryCombo sectionCategoryCombo = section.getCategoryCombo();
+            
+            if ( sectionCategoryCombo != null )
             {
-                orderedCategoryCombos.add( section.getDataElements().iterator().next().getCategoryCombo() );
+                orderedCategoryCombos.add( sectionCategoryCombo );
 
-                sectionCombos.put( section.getId(), section.getDataElements().iterator().next().getCategoryCombo()
-                    .getId() );
+                sectionCombos.put( section.getId(), sectionCategoryCombo.getId() );
             }
 
             if ( section.hasMultiDimensionalDataElement() )
@@ -373,18 +374,20 @@
             // Calculating the number of times each category should be repeated
             // -----------------------------------------------------------------
 
-            int catColSpan = optionCombos.size();
-
             Map<Integer, Integer> catRepeat = new HashMap<Integer, Integer>();
 
             Map<Integer, Collection<Integer>> colRepeat = new HashMap<Integer, Collection<Integer>>();
 
+            int catColSpan = optionCombos.size();
+
             for ( DataElementCategory cat : categoryCombo.getCategories() )
             {
-                if ( !cat.getCategoryOptions().isEmpty() )
+                int categoryOptionSize = cat.getCategoryOptions().size();
+                
+                if ( catColSpan > 0 && categoryOptionSize > 0 )
                 {
-                    catColSpan = catColSpan / cat.getCategoryOptions().size();
-                    int total = optionCombos.size() / (catColSpan * cat.getCategoryOptions().size());
+                    catColSpan = catColSpan / categoryOptionSize;
+                    int total = optionCombos.size() / ( catColSpan * categoryOptionSize );
                     Collection<Integer> cols = new ArrayList<Integer>( total );
 
                     for ( int i = 0; i < total; i++ )