dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22111
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10608: include list of optionSet UIDs in program meta-data
------------------------------------------------------------
revno: 10608
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-04-18 10:33:54 +0700
message:
include list of optionSet UIDs in program meta-data
modified:
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/jsonProgramMetaData.vm
--
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/GetProgramMetaDataAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java 2013-04-04 07:57:59 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/GetProgramMetaDataAction.java 2013-04-18 03:33:54 +0000
@@ -28,9 +28,13 @@
*/
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;
+import org.hisp.dhis.program.ProgramStage;
+import org.hisp.dhis.program.ProgramStageDataElement;
import java.util.ArrayList;
import java.util.HashMap;
@@ -85,6 +89,13 @@
return programAssociations;
}
+ private Set<String> optionSets = new HashSet<String>();
+
+ public Set<String> getOptionSets()
+ {
+ return optionSets;
+ }
+
// -------------------------------------------------------------------------
// Action Impl
// -------------------------------------------------------------------------
@@ -103,8 +114,28 @@
{
programAssociations.get( program.getId() ).add( organisationUnit.getId() );
}
+
+ populateOptionSets( program );
}
return SUCCESS;
}
+
+ private void populateOptionSets( Program program )
+ {
+ for ( ProgramStage programStage : program.getProgramStages() )
+ {
+ Set<ProgramStageDataElement> dataElements = programStage.getProgramStageDataElements();
+
+ for ( ProgramStageDataElement dataElement : dataElements )
+ {
+ OptionSet optionSet = dataElement.getDataElement().getOptionSet();
+
+ if ( optionSet != null )
+ {
+ optionSets.add( optionSet.getUid() );
+ }
+ }
+ }
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm 2013-04-16 04:52:29 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/jsonProgramMetaData.vm 2013-04-18 03:33:54 +0000
@@ -1,4 +1,5 @@
{ "metaData": {
+"optionSets": [#set( $osize = $optionSets.size() )#foreach( $os in $optionSets )"$encoder.jsonEncode( $os )"#if( $velocityCount < $osize ),#end#end],
"programs": {
#set( $psize = $programs.size() )
#foreach( $program in $programs )