← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3533: Centralized code

 

Merge authors:
  Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 3533 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-05-07 23:09:32 +0200
message:
  Centralized code
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.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/dataelement/DataElementCategoryOptionCombo.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java	2011-05-05 21:14:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombo.java	2011-05-07 19:53:42 +0000
@@ -236,6 +236,7 @@
     // Getters and setters
     // -------------------------------------------------------------------------
 
+    @Override
     public String getName()
     {
         StringBuilder name = new StringBuilder();
@@ -257,36 +258,43 @@
         return name.toString();
     }
 
+    @Override
     public void setName( String name )
     {
         throw new UnsupportedOperationException( "Cannot set name on DataElementCategoryOptionCombo: " + name );
     }
 
+    @Override
     public String getShortName()
     {
         return getName();
     }
 
+    @Override
     public void setShortName( String shortName )
     {
         throw new UnsupportedOperationException( "Cannot set shortName on DataElementCategoryOptionCombo: " + shortName );
     }
 
+    @Override
     public String getCode()
     {
         return getName();
     }
 
+    @Override
     public void setCode( String code )
     {
         throw new UnsupportedOperationException( "Cannot set code on DataElementCategoryOptionCombo: " + code );
     }
 
+    @Override
     public String getAlternativeName()
     {
         return getName();
     }
 
+    @Override
     public void setAlternativeName( String alternativeName )
     {
         throw new UnsupportedOperationException( "Cannot set alternativename on DataElementCategoryOptionCombo: "

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java	2011-05-07 18:58:19 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/dataentryform/ViewDataEntryFormAction.java	2011-05-07 20:35:31 +0000
@@ -29,13 +29,11 @@
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.dataelement.DataElementCategoryOption;
 import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
 import org.hisp.dhis.dataelement.DataElementCategoryService;
 import org.hisp.dhis.dataelement.DataElementOperand;
@@ -229,21 +227,7 @@
                 int optionComboId = Integer.parseInt( dataElementMatcher.group( 2 ) );
                 DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
                     .getDataElementCategoryOptionCombo( optionComboId );
-                String optionComboName = "";
-
-                if ( optionCombo != null )
-                {
-                    List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>(
-                        optionCombo.getCategoryOptions() );
-                    Iterator<DataElementCategoryOption> categoryOptionsIterator = categoryOptions.iterator();
-
-                    while ( categoryOptionsIterator.hasNext() )
-                    {
-                        DataElementCategoryOption categoryOption = categoryOptionsIterator.next();
-
-                        optionComboName += categoryOption.getName() + " ";
-                    }
-                }
+                String optionComboName = optionCombo != null ? optionCombo.getName() : "";
 
                 // -------------------------------------------------------------
                 // Insert name of data element in output code
@@ -281,7 +265,7 @@
                     }
 
                     StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
-                        append( dataElement.getName() ).append( " - " ).append( optionCombo.getId() ).append( " - " ).
+                        append( dataElement.getName() ).append( " - " ).append( optionComboId ).append( " - " ).
                         append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
                     
                     if ( dataElementCode.contains( "title=\"\"" ) )
@@ -378,23 +362,8 @@
                 DataElement dataElement = dataElementService.getDataElement( dataElementId );
 
                 int optionComboId = Integer.parseInt( dataElementMatcher.group( 2 ) );
-                DataElementCategoryOptionCombo optionCombo = dataElementCategoryService
-                    .getDataElementCategoryOptionCombo( optionComboId );
-                String optionComboName = "";
-
-                if ( optionCombo != null )
-                {
-                    List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>(
-                        optionCombo.getCategoryOptions() );
-                    Iterator<DataElementCategoryOption> categoryOptionsIterator = categoryOptions.iterator();
-
-                    while ( categoryOptionsIterator.hasNext() )
-                    {
-                        DataElementCategoryOption categoryOption = categoryOptionsIterator.next();
-
-                        optionComboName += categoryOption.getName() + " ";
-                    }
-                }
+                DataElementCategoryOptionCombo optionCombo = dataElementCategoryService.getDataElementCategoryOptionCombo( optionComboId );
+                String optionComboName = optionCombo != null ? optionCombo.getName() : "";
                 
                 // -------------------------------------------------------------
                 // Insert name of data element in output code.
@@ -432,7 +401,7 @@
                     }
 
                     StringBuilder title = new StringBuilder( "title=\"" ).append( dataElement.getId() ).append( " - " ).
-                        append( dataElement.getName() ).append( " - " ).append( optionCombo.getId() ).append( " - " ).
+                        append( dataElement.getName() ).append( " - " ).append( optionComboId ).append( " - " ).
                         append( optionComboName ).append( " - " ).append( dataElement.getType() ).append( "\"" );
                     
                     if ( dataElementCode.contains( "title=\"\"" ) )