← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17220: Sorting of option sets, cleaned up code

 

------------------------------------------------------------
revno: 17220
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-10-23 09:09:30 +0200
message:
  Sorting of option sets, cleaned up code
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.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-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java	2014-08-15 07:40:20 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/option/SortOptionsAction.java	2014-10-23 07:09:30 +0000
@@ -1,3 +1,5 @@
+package org.hisp.dhis.dataadmin.action.option;
+
 /*
  * Copyright (c) 2004-2014, University of Oslo
  * All rights reserved.
@@ -26,8 +28,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-package org.hisp.dhis.dataadmin.action.option;
-
 import java.util.ArrayList;
 import java.util.List;
 
@@ -39,8 +39,6 @@
 
 /**
  * @author Chau Thu Tran
- *
- * @version $ SortOptionsAction.java Jul 28, 2014 8:41:52 PM $
  */
 public class SortOptionsAction
     implements Action
@@ -72,41 +70,34 @@
         return optionSetId;
     }
 
-    private List<Integer> optionIds = new ArrayList<>();
+    private List<String> optionIds = new ArrayList<>();
 
-    public void setOptionIds( List<Integer> optionIds )
+    public void setOptionIds( List<String> optionIds )
     {
         this.optionIds = optionIds;
     }
 
-    // -------------------------------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Action implementation
-    // -------------------------------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
 
     @Override
     public String execute()
         throws Exception
     {
-        try
+        OptionSet optionSet = optionService.getOptionSet( optionSetId );
+        
+        List<Option> options = new ArrayList<>();
+        
+        for ( String optionId : optionIds )
         {
-            OptionSet optionSet = optionService.getOptionSet( optionSetId );
-            // optionSet.getOptions().clear();
-            List<Option> options = new ArrayList<>();
-            for ( int optionId : optionIds )
-            {
-                Option option = optionService.getOption( optionId );
-                options.add( option );
-            }
-            optionSet.setOptions( options );
-            optionService.updateOptionSet( optionSet );
-            System.out.println( "\n  optionSet: " + optionSet );
+            Option option = optionService.getOption( Integer.valueOf( optionId ) );
+            options.add( option );
+        }
+        
+        optionSet.setOptions( options );
+        optionService.updateOptionSet( optionSet );
 
-            return SUCCESS;
-        }
-        catch ( Exception ex )
-        {
-            System.out.println( ex.getMessage() );
-        }
-        return ERROR;
+        return SUCCESS;
     }
 }