dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31117
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15827: Centralized method for converting dimension query parameters
------------------------------------------------------------
revno: 15827
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-06-24 13:30:23 +0200
message:
Centralized method for converting dimension query parameters
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.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/ContextUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java 2014-06-16 19:51:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/ContextUtils.java 2014-06-24 11:30:23 +0000
@@ -37,12 +37,16 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.IOUtils;
+import org.hisp.dhis.common.DimensionalObjectUtils;
import org.hisp.dhis.setting.SystemSettingManager;
import org.hisp.dhis.system.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -275,6 +279,36 @@
return new ArrayList<String>( Arrays.asList( values ) );
}
+
+ /**
+ * Returns a mapping of dimension identifiers and dimension option identifiers
+ * based on the given set of dimension strings. Splits the strings using : as
+ * separator. Returns null of dimensions are null or empty.
+ *
+ * @param dimensions the set of strings on format dimension:dimension-option.
+ * @return a map of dimensions and dimension options.
+ */
+ public static Map<String, String> getDimensionsAndOptions( Set<String> dimensions )
+ {
+ if ( dimensions == null || dimensions.isEmpty() )
+ {
+ return null;
+ }
+
+ Map<String, String> map = new HashMap<String, String>();
+
+ for ( String dim : dimensions )
+ {
+ String[] dims = dim.split( DimensionalObjectUtils.DIMENSION_NAME_SEP );
+
+ if ( dims.length == 2 && dims[0] != null && dims[1] != null )
+ {
+ map.put( dims[0], dims[1] );
+ }
+ }
+
+ return map;
+ }
/**
* Adds basic authentication by adding an Authorization header to the
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js 2013-11-06 10:41:43 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/oust/selectionTreeSelect.js 2014-06-24 11:30:23 +0000
@@ -10,17 +10,10 @@
{
selectedOrganisationUnitList__.empty();
- if( ids && ids.length > 0 ) {
+ if ( ids && ids.length > 0 ) {
selectedOrganisationUnitList__.append('<option value="' + ids[0] + '" selected="selected">' + ids[0] + '</option>');
}
- /*
- jQuery.each(ids, function( i, item )
- {
- selectedOrganisationUnitList__.append('<option value="' + item + '" selected="selected">' + item + '</option>');
- });
- */
-
byId('treeSelectedId').selectedIndex = 0;
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2014-06-23 21:31:31 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2014-06-24 11:30:23 +0000
@@ -32,7 +32,6 @@
import static org.hisp.dhis.dataset.DataSet.TYPE_SECTION;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -40,10 +39,6 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.InputUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
-import org.hisp.dhis.common.DimensionalObjectUtils;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataset.CompleteDataSetRegistration;
@@ -58,6 +53,9 @@
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
+import org.hisp.dhis.webapi.utils.InputUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.opensymphony.xwork2.Action;
@@ -269,20 +267,7 @@
selectedOrgunit = organisationUnitService.getOrganisationUnit( ou );
- Map<String, String> dimensions = new HashMap<String, String>();
-
- if ( dimension != null )
- {
- for ( String dim : dimension )
- {
- String[] dims = dim.split( DimensionalObjectUtils.DIMENSION_NAME_SEP );
-
- if ( dims.length == 2 && dims[0] != null && dims[1] != null )
- {
- dimensions.put( dims[0], dims[1] );
- }
- }
- }
+ Map<String, String> dimensions = ContextUtils.getDimensionsAndOptions( dimension );
String dataSetType = selectedDataSet.getDataSetType();