← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10612: changed to using dataElementUids to fetch optionset (align with autocomplete js methods)

 

------------------------------------------------------------
revno: 10612
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-18 14:03:12 +0700
message:
  changed to using dataElementUids to fetch optionset (align with autocomplete js methods)
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetOptionSetAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js


--
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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetOptionSetAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetOptionSetAction.java	2013-04-18 06:05:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetOptionSetAction.java	2013-04-18 07:03:12 +0000
@@ -28,6 +28,8 @@
  */
 
 import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementService;
 import org.hisp.dhis.option.OptionService;
 import org.hisp.dhis.option.OptionSet;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,17 +44,17 @@
     // -------------------------------------------------------------------------
 
     @Autowired
-    private OptionService optionService;
+    private DataElementService dataElementService;
 
     // -------------------------------------------------------------------------
     // Input & Output
     // -------------------------------------------------------------------------
 
-    private String optionSetUid;
+    private String dataElementUid;
 
-    public void setOptionSetUid( String optionSetUid )
+    public void setDataElementUid( String dataElementUid )
     {
-        this.optionSetUid = optionSetUid;
+        this.dataElementUid = dataElementUid;
     }
 
     private OptionSet optionSet;
@@ -69,12 +71,19 @@
     @Override
     public String execute() throws Exception
     {
-        if ( optionSetUid == null )
+        if ( dataElementUid == null )
         {
             return INPUT;
         }
 
-        optionSet = optionService.getOptionSet( optionSetUid );
+        DataElement dataElement = dataElementService.getDataElement( dataElementUid );
+
+        if ( dataElement == null || dataElement.getOptionSet() == null )
+        {
+            return ERROR;
+        }
+
+        optionSet = dataElement.getOptionSet();
 
         return SUCCESS;
     }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java	2013-04-18 03:33:54 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java	2013-04-18 07:03:12 +0000
@@ -28,8 +28,6 @@
  */
 
 import com.opensymphony.xwork2.Action;
-import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.option.OptionSet;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.program.Program;
 import org.hisp.dhis.program.ProgramService;
@@ -125,15 +123,13 @@
     {
         for ( ProgramStage programStage : program.getProgramStages() )
         {
-            Set<ProgramStageDataElement> dataElements = programStage.getProgramStageDataElements();
+            Set<ProgramStageDataElement> programStageDataElements = programStage.getProgramStageDataElements();
 
-            for ( ProgramStageDataElement dataElement : dataElements )
+            for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
             {
-                OptionSet optionSet = dataElement.getDataElement().getOptionSet();
-
-                if ( optionSet != null )
+                if ( programStageDataElement.getDataElement().getOptionSet() != null )
                 {
-                    optionSets.add( optionSet.getUid() );
+                    optionSets.add( programStageDataElement.getDataElement().getUid() );
                 }
             }
         }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-18 06:05:48 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-04-18 07:03:12 +0000
@@ -979,14 +979,14 @@
     });
 }
 
-function loadOptionSets(optionSetUids, success ) {
+function loadOptionSets(uids, success ) {
     DAO.optionSets = new dhis2.storage.Store( {name: OPTION_SET_STORE, adapter: 'dom-ss'}, function ( store ) {
         var deferred = $.Deferred();
         var promise = deferred.promise();
 
-        _.each( optionSetUids, function(item, idx) {
+        _.each( uids, function(item, idx) {
             promise = promise.pipe($.ajax({
-                url: 'getOptionSet.action?optionSetUid=' + item,
+                url: 'getOptionSet.action?dataElementUid=' + item,
                 dataType: 'json',
                 success: function(json) {
                     DAO.optionSets.add(item, json);