dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28025
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13965: Geo feature resource, support for dimensions
------------------------------------------------------------
revno: 13965
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-02-09 19:47:43 +0200
message:
Geo feature resource, support for dimensions
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/GeoFeatureController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/GeoFeature.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/api/controller/WebOptions.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java 2013-09-02 10:47:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/WebOptions.java 2014-02-09 17:47:43 +0000
@@ -68,6 +68,11 @@
return stringAsInt( options.get( "page" ), 1 );
}
+ public String getViewClass()
+ {
+ return stringAsString( options.get( "viewClass" ), null );
+ }
+
public String getViewClass( String defaultValue )
{
return stringAsString( options.get( "viewClass" ), defaultValue );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/GeoFeatureController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/GeoFeatureController.java 2014-02-09 13:59:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/GeoFeatureController.java 2014-02-09 17:47:43 +0000
@@ -32,6 +32,7 @@
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -46,11 +47,15 @@
import org.hisp.dhis.analytics.AggregationType;
import org.hisp.dhis.analytics.AnalyticsService;
import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.api.controller.WebOptions;
import org.hisp.dhis.api.webdomain.GeoFeature;
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.NameableObjectUtils;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.system.filter.OrganisationUnitWithValidCoordinatesFilter;
import org.hisp.dhis.system.util.FilterUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -78,10 +83,16 @@
@Autowired
private AnalyticsService analyticsService;
+ @Autowired
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
@RequestMapping( method = RequestMethod.GET, produces = "application/json" )
- public void getGeoFeatures( @RequestParam String ou,
+ public void getGeoFeatures( @RequestParam String ou, @RequestParam Map<String, String> parameters,
HttpServletRequest request, HttpServletResponse response ) throws IOException
{
+ WebOptions options = new WebOptions( parameters );
+ boolean includeGroupSets = "detailed".equals( options.getViewClass() );
+
Set<String> set = new HashSet<String>();
set.add( ou );
@@ -100,6 +111,8 @@
return;
}
+ Collection<OrganisationUnitGroupSet> groupSets = includeGroupSets ? organisationUnitGroupService.getAllOrganisationUnitGroupSets() : null;
+
List<GeoFeature> features = new ArrayList<GeoFeature>();
for ( OrganisationUnit unit : organisationUnits )
@@ -116,6 +129,19 @@
feature.setTy( FEATURE_TYPE_MAP.get( unit.getFeatureType() ) );
feature.setCo( unit.getCoordinates() );
+ if ( includeGroupSets )
+ {
+ for ( OrganisationUnitGroupSet groupSet : groupSets )
+ {
+ OrganisationUnitGroup group = unit.getGroupInGroupSet( groupSet );
+
+ if ( group != null )
+ {
+ feature.getDimensions().put( groupSet.getUid(), group.getUid() );
+ }
+ }
+ }
+
features.add( feature );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/GeoFeature.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/GeoFeature.java 2014-02-05 14:32:56 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/GeoFeature.java 2014-02-09 17:47:43 +0000
@@ -28,6 +28,9 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.util.HashMap;
+import java.util.Map;
+
import com.fasterxml.jackson.annotation.JsonProperty;
/**
@@ -88,6 +91,11 @@
*/
private String co;
+ /**
+ * Dimensions and dimension items.
+ */
+ private Map<String, String> dimensions = new HashMap<String, String>();
+
public GeoFeature()
{
}
@@ -205,4 +213,15 @@
{
this.co = co;
}
+
+ @JsonProperty
+ public Map<String, String> getDimensions()
+ {
+ return dimensions;
+ }
+
+ public void setDimensions( Map<String, String> dimensions )
+ {
+ this.dimensions = dimensions;
+ }
}