← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2800: (GIS) Orgunit group name for 'type' group set provided in geojson + Forthcoming periods filtered ...

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2800 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-02-02 14:37:42 +0100
message:
  (GIS) Orgunit group name for 'type' group set provided in geojson + Forthcoming periods filtered out.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetPeriodsByPeriodTypeAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPoint.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPolygon.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.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-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-01-31 19:47:04 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnit.java	2011-02-02 13:36:42 +0000
@@ -89,6 +89,8 @@
     
     private transient boolean currentParent;
     
+    private transient String type;
+    
     // -------------------------------------------------------------------------
     // Constructors
     // -------------------------------------------------------------------------
@@ -538,4 +540,14 @@
     {
         this.currentParent = currentParent;
     }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
 }

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java	2010-12-20 22:21:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java	2011-02-02 13:36:42 +0000
@@ -30,6 +30,8 @@
 import java.util.Collection;
 
 import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSetPopulator;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.system.filter.OrganisationUnitWithCoordinatesFilter;
 import org.hisp.dhis.system.util.FilterUtils;
@@ -54,6 +56,13 @@
         this.organisationUnitService = organisationUnitService;
     }
 
+    private OrganisationUnitGroupService organisationUnitGroupService;
+
+    public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+    {
+        this.organisationUnitGroupService = organisationUnitGroupService;
+    }
+
     // -------------------------------------------------------------------------
     // Input
     // -------------------------------------------------------------------------
@@ -64,14 +73,14 @@
     {
         this.parentId = id;
     }
-    
+
     private Integer level;
-    
+
     public void setLevel( Integer level )
     {
         this.level = level;
     }
-    
+
     // -------------------------------------------------------------------------
     // Output
     // -------------------------------------------------------------------------
@@ -91,14 +100,25 @@
         throws Exception
     {
         OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId );
-        
+
         level = level == null ? organisationUnitService.getLevelOfOrganisationUnit( parent ) : level;
-        
+
         object = organisationUnitService.getOrganisationUnitsAtLevel( level, parent );
-        
+
+        for ( OrganisationUnit organisationUnit : object )
+        {
+            if ( organisationUnit.getFeatureType() != null )
+            {
+                if ( organisationUnit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) )
+                {
+                    organisationUnit.setType( organisationUnit.getGroupNameInGroupSet( organisationUnitGroupService
+                        .getOrganisationUnitGroupSetByName( OrganisationUnitGroupSetPopulator.NAME_TYPE ) ) );
+                }
+            }
+        }
+
         FilterUtils.filter( object, new OrganisationUnitWithCoordinatesFilter() );
-        
+
         return object.size() > 0 ? object.iterator().next().getFeatureType() : NONE;
     }
 }
-

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetPeriodsByPeriodTypeAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetPeriodsByPeriodTypeAction.java	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetPeriodsByPeriodTypeAction.java	2011-02-02 13:36:42 +0000
@@ -36,6 +36,8 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.period.comparator.PeriodComparator;
+import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter;
+import org.hisp.dhis.system.util.FilterUtils;
 
 import com.opensymphony.xwork2.Action;
 
@@ -104,6 +106,8 @@
                 period.setName( format.formatPeriod( period ) );
             }
             
+            FilterUtils.filter( object, new PastAndCurrentPeriodFilter() );
+            
             Collections.sort( object, new PeriodComparator() );
         }
                 

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2011-01-26 11:42:12 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2011-02-02 10:36:33 +0000
@@ -274,6 +274,8 @@
         scope="prototype">
         <property name="organisationUnitService"
             ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+        <property name="organisationUnitGroupService"
+            ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
     </bean>
 
     <bean id="org.hisp.dhis.mapping.action.GetGeoJsonByParentAction"

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPoint.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPoint.vm	2010-11-29 11:21:06 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPoint.vm	2011-02-02 13:36:42 +0000
@@ -1,2 +1,2 @@
 #set( $size = $object.size() )
-{"type":"FeatureCollection","features":[#foreach($unit in $object){"type":"Feature","id":"${unit.id}","geometry":{"type":"Point","coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},"featureType":"$!encoder.jsonEncode( ${unit.featureType} )","type":"Facility"}}#if( $velocityCount < $size ),#end #end ],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file
+{"type":"FeatureCollection","features":[#foreach($unit in $object){"geometry":{"type":"Point","coordinates":$!encoder.jsEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},"type":"$!encoder.jsonEncode( ${unit.type} )"}}#if( $velocityCount < $size ),#end #end ],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPolygon.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPolygon.vm	2010-11-29 11:21:06 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/geojsonPolygon.vm	2011-02-02 13:36:42 +0000
@@ -1,2 +1,2 @@
 #set( $size = $object.size() )
-{"type":"FeatureCollection","features":[#foreach($unit in $object){"type":"Feature","id":"districts.1","geometry":{"type":"MultiPolygon","coordinates":$!encoder.jsonEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()},"featureType":"$!encoder.jsonEncode( ${unit.featureType} )"}}#if( $velocityCount < $size ),#end #end],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file
+{"type":"FeatureCollection","features":[#foreach($unit in $object){"geometry":{"type":"MultiPolygon","coordinates":$!encoder.jsonEncode( $!{unit.validCoordinates} )},"properties":{"id":"$!{unit.id}","name":"$!encoder.jsonEncode( ${unit.name} )","hasChildrenWithCoordinates":$!{unit.hasChildrenWithCoordinates()}}}#if( $velocityCount < $size ),#end #end],"crs":{"type":"EPSG","properties":{"code":"4326"}}}
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-02-01 13:27:46 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-02-02 13:36:42 +0000
@@ -53,8 +53,11 @@
     map_selection_type_parent: 'parent',
     map_selection_type_level: 'level',
     map_feature_type_multipolygon: 'MultiPolygon',
+    map_feature_type_multipolygon_class_name: 'OpenLayers.Geometry.MultiPolygon',
     map_feature_type_polygon: 'Polygon',
+    map_feature_type_polygon_class_name: 'OpenLayers.Geometry.Polygon',
     map_feature_type_point: 'Point',
+    map_feature_type_point_class_name: 'OpenLayers.Geometry.Point',
     map_view_access_level_user: 'user',
     map_view_access_level_system: 'system',
     aggregation_strategy_real_time: 'real_time',

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2011-02-01 13:27:46 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2011-02-02 13:36:42 +0000
@@ -2039,14 +2039,14 @@
                                                     var color = Ext.getCmp('highlightcolor_cf').getValue();
                                                     var symbolizer;
                                                     
-                                                    if (feature.attributes.featureType == G.conf.map_feature_type_multipolygon ||
-                                                        feature.attributes.featureType == G.conf.map_feature_type_polygon) {
+                                                    if (feature.geometry.CLASS_NAME == G.conf.map_feature_type_multipolygon_class_name ||
+                                                        feature.geometry.CLASS_NAME == G.conf.map_feature_type_polygon_class_name) {
                                                         symbolizer = new OpenLayers.Symbolizer.Polygon({
                                                             'strokeColor': color,
                                                             'fillColor': color
                                                         });
                                                     }
-                                                    else if (feature.attributes.featureType == G.conf.map_feature_type_point) {
+                                                    else if (feature.geometry.CLASS_NAME == G.conf.map_feature_type_point_class_name) {
                                                         symbolizer = new OpenLayers.Symbolizer.Point({
                                                             'pointRadius': 7,
                                                             'fillColor': color
@@ -2480,8 +2480,7 @@
                 G.vars.map.events.register('addlayer', null, function(e) {
                     var svg = document.getElementsByTagName('svg');
                     e.layer.svgId = svg[svg.length-1].id;
-                });
-                               
+                });               
             }
         }
     });