← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17042: Form api resource, including indicators in meta-data

 

------------------------------------------------------------
revno: 17042
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-10 17:21:01 +0200
message:
  Form api resource, including indicators in meta-data
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.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-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2014-10-01 03:58:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2014-10-10 15:21:01 +0000
@@ -63,7 +63,9 @@
     private static final String KEY_PERIOD_TYPE = "periodType";
     private static final String KEY_ALLOW_FUTURE_PERIODS = "allowFuturePeriods";
     private static final String KEY_DATA_ELEMENTS = "dataElements";
+    private static final String KEY_INDICATORS = "indicators";
     private static final String KEY_EXPIRY_DAYS = "expiryDays";
+    private static final String SEP = "-";
 
     public static Form fromDataSet( DataSet dataSet, boolean metaData )
     {
@@ -75,7 +77,7 @@
         form.getOptions().put( KEY_ALLOW_FUTURE_PERIODS, dataSet.isAllowFuturePeriods() );
         form.getOptions().put( KEY_EXPIRY_DAYS, dataSet.getExpiryDays() );
 
-        if ( dataSet.getSections().size() > 0 )
+        if ( dataSet.hasSections() )
         {
             List<Section> sections = new ArrayList<>( dataSet.getSections() );
             Collections.sort( sections, SectionOrderComparator.INSTANCE );
@@ -93,6 +95,7 @@
                 if ( metaData )
                 {
                     group.getMetaData().put( KEY_DATA_ELEMENTS, NameableObjectUtils.getAsNameableObjects( section.getDataElements() ) );
+                    group.getMetaData().put( KEY_INDICATORS, NameableObjectUtils.getAsNameableObjects( section.getIndicators() ) );
                 }
                 
                 form.getGroups().add( group );
@@ -340,7 +343,7 @@
         {
             for ( Field field : group.getFields() )
             {
-                cacheMap.put( field.getDataElement() + "-" + field.getCategoryOptionCombo(), field );
+                cacheMap.put( field.getDataElement() + SEP + field.getCategoryOptionCombo(), field );
             }
         }