=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2011-11-10 20:57:29 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2011-11-12 12:54:31 +0000 @@ -32,7 +32,6 @@ import java.util.Set; import org.hisp.dhis.aggregation.AggregatedMapValue; -import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.period.Period; /** @@ -72,14 +71,6 @@ final String MAP_LAYER_TYPE_OVERLAY = "overlay"; // ------------------------------------------------------------------------- - // Organisation units - // ------------------------------------------------------------------------- - - boolean isPointMinority( Collection organisationUnits ); - - Collection removeMinorityFeatureType( Collection object ); - - // ------------------------------------------------------------------------- // IndicatorMapValue // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java' --- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2011-11-10 20:57:29 +0000 +++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2011-11-12 12:54:31 +0000 @@ -32,7 +32,6 @@ import static org.hisp.dhis.options.SystemSettingManager.DEFAULT_AGGREGATION_STRATEGY; import static org.hisp.dhis.options.SystemSettingManager.KEY_AGGREGATION_STRATEGY; -import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashSet; @@ -188,52 +187,6 @@ return organisationUnits; } - public boolean isPointMinority( Collection object ) - { - int polygons = 0, points = 0; - - for ( OrganisationUnit unit : object ) - { - polygons = unit.isPolygon() ? polygons + 1 : polygons; - - points = unit.isPoint() ? points + 1 : points; - } - - return polygons > points ? true : false; - } - - public Collection removeMinorityFeatureType( Collection object ) - { - boolean isPointMinority = isPointMinority( object ); - - Collection majority = new ArrayList(); - - if ( isPointMinority ) - { - for ( OrganisationUnit unit : object ) - { - if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_MULTIPOLYGON ) - || unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POLYGON ) ) - { - majority.add( unit ); - } - } - } - - else - { - for ( OrganisationUnit unit : object ) - { - if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) ) - { - majority.add( unit ); - } - } - } - - return majority; - } - // ------------------------------------------------------------------------- // IndicatorMapValues // ------------------------------------------------------------------------- @@ -259,10 +212,10 @@ { String aggregationStrategy = (String) systemSettingManager.getSystemSetting( KEY_AGGREGATION_STRATEGY, DEFAULT_AGGREGATION_STRATEGY ); - + Assert.isTrue( !(period != null && (startDate != null || endDate != null)) ); Assert.isTrue( !(aggregationStrategy.equals( AGGREGATION_STRATEGY_BATCH ) && period == null) ); - Assert.isTrue( !(indicatorId == null || parentOrganisationUnitId == null || level == null) ); + Assert.isTrue( indicatorId != null && parentOrganisationUnitId != null && level != null ); Collection values = new HashSet(); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithCoordinatesFilter.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithCoordinatesFilter.java 2010-08-28 10:27:45 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithCoordinatesFilter.java 2011-11-12 12:54:31 +0000 @@ -39,6 +39,6 @@ @Override public boolean retain( OrganisationUnit object ) { - return object != null && object.hasCoordinates(); + return object != null && object.getFeatureType() != null && object.hasCoordinates(); } } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithValidPointCoordinateFilter.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithValidPointCoordinateFilter.java 2011-10-28 15:43:36 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/filter/OrganisationUnitWithValidPointCoordinateFilter.java 2011-11-12 12:54:31 +0000 @@ -40,6 +40,12 @@ @Override public boolean retain( OrganisationUnit object ) { - return object != null && object.hasCoordinates() && ValidationUtils.coordinateIsValid( object.getCoordinates() ); + if ( object != null && object.hasCoordinates() ) + { + return object.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) ? + ValidationUtils.coordinateIsValid( object.getCoordinates() ) : true; + } + + return false; } } === 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 2011-11-10 20:57:29 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java 2011-11-12 12:54:31 +0000 @@ -27,9 +27,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.ArrayList; import java.util.Collection; -import org.hisp.dhis.mapping.MappingService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; @@ -65,13 +65,6 @@ { this.organisationUnitGroupService = organisationUnitGroupService; } - - private MappingService mappingService; - - public void setMappingService( MappingService mappingService ) - { - this.mappingService = mappingService; - } // ------------------------------------------------------------------------- // Input @@ -113,31 +106,40 @@ level = level == null ? organisationUnitService.getLevelOfOrganisationUnit( parent ) : level; - object = organisationUnitService.getOrganisationUnitsAtLevel( level, parent ); - - FilterUtils.filter( object, new OrganisationUnitWithCoordinatesFilter() ); - - object = mappingService.removeMinorityFeatureType( object ); - - String returnType = object.size() > 0 ? object.iterator().next().getFeatureType() : NONE; - - if ( returnType.equals( OrganisationUnit.FEATURETYPE_POINT ) ) - { - FilterUtils.filter( object, new OrganisationUnitWithValidPointCoordinateFilter() ); - - OrganisationUnitGroupSet typeGroupSet = organisationUnitGroupService - .getOrganisationUnitGroupSetByName( OrganisationUnitGroupSetPopulator.NAME_TYPE ); - - for ( OrganisationUnit organisationUnit : object ) - { - if ( organisationUnit.getFeatureType() != null - && organisationUnit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) ) - { - organisationUnit.setType( organisationUnit.getGroupNameInGroupSet( typeGroupSet ) ); - } - } - } - - return returnType; + Collection organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level, + parent ); + + FilterUtils.filter( organisationUnits, new OrganisationUnitWithCoordinatesFilter() ); + + FilterUtils.filter( organisationUnits, new OrganisationUnitWithValidPointCoordinateFilter() ); + + OrganisationUnitGroupSet typeGroupSet = organisationUnitGroupService + .getOrganisationUnitGroupSetByName( OrganisationUnitGroupSetPopulator.NAME_TYPE ); + + object = new ArrayList(); + + for ( OrganisationUnit unit : organisationUnits ) + { + if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) ) + { + unit.setType( unit.getGroupNameInGroupSet( typeGroupSet ) ); + } + + else + { + object.add( unit ); + } + + } + + for ( OrganisationUnit unit : organisationUnits ) + { + if ( unit.getFeatureType().equals( OrganisationUnit.FEATURETYPE_POINT ) ) + { + object.add( unit ); + } + } + + return SUCCESS; } } === removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByLevelAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByLevelAction.java 2011-04-03 10:19:50 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByLevelAction.java 1970-01-01 00:00:00 +0000 @@ -1,97 +0,0 @@ -package org.hisp.dhis.mapping.action; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; - -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.system.filter.OrganisationUnitWithCoordinatesFilter; -import org.hisp.dhis.system.util.FilterUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author Jan Henrik Overland - * @version $Id$ - */ -public class GetGeoJsonByLevelAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer level; - - public void setLevel( Integer level ) - { - this.level = level; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Collection object; - - public Collection getObject() - { - return object; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - object = organisationUnitService.getOrganisationUnitsAtLevel( level ); - - FilterUtils.filter( object, new OrganisationUnitWithCoordinatesFilter() ); - - if ( object != null && object.size() > 0 ) - { - return object.iterator().next().getFeatureType(); - } - - return NONE; - } -} === removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByParentAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByParentAction.java 2010-10-29 11:24:12 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonByParentAction.java 1970-01-01 00:00:00 +0000 @@ -1,95 +0,0 @@ -package org.hisp.dhis.mapping.action; - -/* - * Copyright (c) 2004-2010, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import java.util.Collection; -import java.util.HashSet; - -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.system.filter.OrganisationUnitWithCoordinatesFilter; -import org.hisp.dhis.system.util.FilterUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author Jan Henrik Overland - * @version $Id$ - */ -public class GetGeoJsonByParentAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer parentId; - - public void setParentId( Integer id ) - { - this.parentId = id; - } - - // ------------------------------------------------------------------------- - // Output - // ------------------------------------------------------------------------- - - private Collection object; - - public Collection getObject() - { - return object; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId ); - - object = new HashSet( parent.getChildren() ); - - FilterUtils.filter( object, new OrganisationUnitWithCoordinatesFilter() ); - - return parent.getChildrenFeatureType(); - } -} === 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-11-10 20:57:29 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2011-11-12 12:54:31 +0000 @@ -304,22 +304,6 @@ ref="org.hisp.dhis.organisationunit.OrganisationUnitService" /> - - - - - - - - - - /dhis-web-mapping/geojsonPoint.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm - - - - /dhis-web-mapping/geojsonPoint.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm - - - - /dhis-web-mapping/geojsonPoint.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm - /dhis-web-mapping/geojsonPolygon.vm + /dhis-web-mapping/geojson.vm