=== 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 2012-10-25 14:58:43 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2012-10-31 18:29:46 +0000 @@ -138,12 +138,6 @@ int addMapView( MapView mapView ); - void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId, Integer indicatorId, - Integer dataElementGroupId, Integer dataElementId, String periodTypeName, Integer periodId, - Integer parentOrganisationUnitId, Integer organisationUnitLevel, String mapLegendType, Integer method, - Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId, Integer radiusLow, - Integer radiusHigh, String longitude, String latitude, int zoom ); - void updateMapView( MapView mapView ); void deleteMapView( MapView view ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2012-11-01 05:33:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2012-11-01 08:22:08 +0000 @@ -444,45 +444,7 @@ { return mapViewStore.save( mapView ); } - - public void addMapView( String name, boolean system, String mapValueType, Integer indicatorGroupId, - Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName, - Integer periodId, Integer parentOrganisationUnitId, Integer organisationUnitLevel, String mapLegendType, - Integer method, Integer classes, String bounds, String colorLow, String colorHigh, Integer mapLegendSetId, - Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom ) - { - IndicatorGroup indicatorGroup = null; - - Indicator indicator = null; - - DataElementGroup dataElementGroup = null; - - DataElement dataElement = null; - - if ( mapValueType.equals( MapView.VALUE_TYPE_INDICATOR ) ) - { - indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId ); - indicator = indicatorService.getIndicator( indicatorId ); - } - else - { - dataElementGroup = dataElementService.getDataElementGroup( dataElementGroupId ); - dataElement = dataElementService.getDataElement( dataElementId ); - } - - Period period = periodId != null ? periodService.getPeriod( periodId ) : null; - - OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentOrganisationUnitId ); - - OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevelByLevel( organisationUnitLevel ); - - MapLegendSet mapLegendSet = mapLegendSetId != null ? getMapLegendSet( mapLegendSetId ) : null; - - addMapView( new MapView( MapView.LAYER_THEMATIC1, name, mapValueType, indicatorGroup, indicator, dataElementGroup, dataElement, - period, parent, level, mapLegendType, method, classes, colorLow, colorHigh, - mapLegendSet, radiusLow, radiusHigh, 1.0 ) ); - } - + public void updateMapView( MapView mapView ) { mapViewStore.update( mapView ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-11-01 05:57:43 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2012-11-01 14:25:50 +0000 @@ -146,8 +146,9 @@ executeSql( "ALTER TABLE mapview RENAME COLUMN mapvaluetype TO valuetype" ); executeSql( "ALTER TABLE mapview RENAME COLUMN maplegendtype TO legendtype" ); executeSql( "ALTER TABLE mapview RENAME COLUMN maplegendsetid TO legendsetid" ); + executeSql( "ALTER TABLE mapview ALTER COLUMN opacity TYPE double precision" ); + executeSql( "ALTER TABLE maplegend DROP CONSTRAINT maplegend_name_key" ); - executeSql( "ALTER TABLE mapview ALTER COLUMN opacity TYPE double precision" ); executeSql( "UPDATE mapview SET layer = 'thematic1' WHERE layer IS NULL" ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2012-11-01 05:33:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2012-11-01 08:22:08 +0000 @@ -256,46 +256,6 @@ mappingService.addMapLegendSet( legendSet3 ); assertTrue( mappingService.getAllMapLegendSets().containsAll( mapLegendSets ) ); - - } - - // ------------------------------------------------------------------------- - // MapView tests - // ------------------------------------------------------------------------- - - @Test - public void testAddGetMapView() - { - MapView mapView = new MapView( LAYER_THEMATIC1, "MapViewA", VALUE_TYPE_INDICATOR, indicatorGroup, - indicator, dataElementGroup, dataElement, period, - organisationUnit, organisationUnitLevel, LEGEND_TYPE_AUTOMATIC, 1, 1, "A", "B", - mapLegendSet, 5, 20, 1.0 ); - - int idA = mappingService.addMapView( mapView ); - - assertEquals( mapView, mappingService.getMapView( idA ) ); - assertEquals( indicatorGroup, mappingService.getMapView( idA ).getIndicatorGroup() ); - assertEquals( indicator, mappingService.getMapView( idA ).getIndicator() ); - assertEquals( period, mappingService.getMapView( idA ).getPeriod() ); - } - - @Test - public void testGetAllMapViews() - { - MapView mapView1 = new MapView( LAYER_THEMATIC1, "MapViewA", VALUE_TYPE_INDICATOR, indicatorGroup, - indicator, dataElementGroup, dataElement, period, - organisationUnit, organisationUnitLevel, LEGEND_TYPE_AUTOMATIC, 1, 1, "A", "B", - mapLegendSet, 5, 20, 1.0 ); - - MapView mapView2 = new MapView( LAYER_THEMATIC1, "MapViewB", VALUE_TYPE_INDICATOR, indicatorGroup, - indicator, dataElementGroup, dataElement, period, - organisationUnit, organisationUnitLevel, LEGEND_TYPE_AUTOMATIC, 1, 1, "A", "B", - mapLegendSet, 5, 20, 1.0 ); - - mappingService.addMapView( mapView1 ); - mappingService.addMapView( mapView2 ); - - assertEquals( 2, mappingService.getAllMapViews().size() ); } // ------------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java 2012-09-12 18:01:24 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapValueController.java 2012-10-31 12:40:43 +0000 @@ -39,6 +39,7 @@ import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.mapping.MappingService; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; @@ -79,7 +80,7 @@ @RequestParam String in, @RequestParam String pe, @RequestParam String ou, - @RequestParam Integer level, + @RequestParam String le, Model model, HttpServletResponse response ) throws Exception { @@ -109,7 +110,15 @@ return null; } - Collection mapValues = mappingService.getIndicatorMapValues( indicator.getId(), period.getId(), organisationUnit.getId(), level ); + OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevel( le ); + + if ( level == null ) + { + ContextUtils.conflictResponse( response, "Invalid organisation unit level identifier" ); + return null; + } + + Collection mapValues = mappingService.getIndicatorMapValues( indicator.getId(), period.getId(), organisationUnit.getId(), level.getLevel() ); model.addAttribute( "model", mapValues ); @@ -121,7 +130,7 @@ @RequestParam String de, @RequestParam String pe, @RequestParam String ou, - @RequestParam Integer level, + @RequestParam String le, Model model, HttpServletResponse response ) throws Exception { @@ -151,7 +160,15 @@ return null; } - Collection mapValues = mappingService.getDataElementMapValues( dataElement.getId(), period.getId(), organisationUnit.getId(), level ); + OrganisationUnitLevel level = organisationUnitService.getOrganisationUnitLevel( le ); + + if ( level == null ) + { + ContextUtils.conflictResponse( response, "Invalid organisation unit level identifier" ); + return null; + } + + Collection mapValues = mappingService.getDataElementMapValues( dataElement.getId(), period.getId(), organisationUnit.getId(), level.getLevel() ); model.addAttribute( "model", mapValues ); === removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewAction.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewAction.java 1970-01-01 00:00:00 +0000 @@ -1,231 +0,0 @@ -package org.hisp.dhis.mapping.action; - -/* - * Copyright (c) 2004-2012, 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 org.hisp.dhis.mapping.MappingService; - -import com.opensymphony.xwork2.Action; - -/** - * @author Jan Henrik Overland - * @version $Id$ - */ -public class AddMapViewAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private MappingService mappingService; - - public void setMappingService( MappingService mappingService ) - { - this.mappingService = mappingService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private String name; - - public void setName( String name ) - { - this.name = name; - } - - private boolean system; - - public void setSystem( boolean system ) - { - this.system = system; - } - - private String mapValueType; - - public void setMapValueType( String mapValueType ) - { - this.mapValueType = mapValueType; - } - - private Integer indicatorGroupId; - - public void setIndicatorGroupId( Integer indicatorGroupId ) - { - this.indicatorGroupId = indicatorGroupId; - } - - private Integer indicatorId; - - public void setIndicatorId( Integer indicatorId ) - { - this.indicatorId = indicatorId; - } - - private Integer dataElementGroupId; - - public void setDataElementGroupId( Integer dataElementGroupId ) - { - this.dataElementGroupId = dataElementGroupId; - } - - private Integer dataElementId; - - public void setDataElementId( Integer dataElementId ) - { - this.dataElementId = dataElementId; - } - - private String periodTypeId; - - public void setPeriodTypeId( String periodTypeId ) - { - this.periodTypeId = periodTypeId; - } - - private Integer periodId; - - public void setPeriodId( Integer periodId ) - { - this.periodId = periodId; - } - - private Integer parentOrganisationUnitId; - - public void setParentOrganisationUnitId( Integer parentOrganisationUnitId ) - { - this.parentOrganisationUnitId = parentOrganisationUnitId; - } - - private Integer organisationUnitLevel; - - public void setOrganisationUnitLevel( Integer organisationUnitLevel ) - { - this.organisationUnitLevel = organisationUnitLevel; - } - - private String mapLegendType; - - public void setMapLegendType( String mapLegendType ) - { - this.mapLegendType = mapLegendType; - } - - private Integer method; - - public void setMethod( Integer method ) - { - this.method = method; - } - - private Integer classes; - - public void setClasses( Integer classes ) - { - this.classes = classes; - } - - private String bounds; - - public void setBounds( String bounds ) - { - this.bounds = bounds; - } - - private String colorLow; - - public void setColorLow( String colorLow ) - { - this.colorLow = colorLow; - } - - private String colorHigh; - - public void setColorHigh( String colorHigh ) - { - this.colorHigh = colorHigh; - } - - private Integer mapLegendSetId; - - public void setMapLegendSetId( Integer mapLegendSetId ) - { - this.mapLegendSetId = mapLegendSetId; - } - - private Integer radiusLow; - - public void setRadiusLow( Integer radiusLow ) - { - this.radiusLow = radiusLow; - } - - private Integer radiusHigh; - - public void setRadiusHigh( Integer radiusHigh ) - { - this.radiusHigh = radiusHigh; - } - - private String longitude; - - public void setLongitude( String longitude ) - { - this.longitude = longitude; - } - - private String latitude; - - public void setLatitude( String latitude ) - { - this.latitude = latitude; - } - - private int zoom; - - public void setZoom( int zoom ) - { - this.zoom = zoom; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - mappingService.addMapView( name, system, mapValueType, indicatorGroupId, indicatorId, - dataElementGroupId, dataElementId, periodTypeId, periodId, parentOrganisationUnitId, - organisationUnitLevel, mapLegendType, method, classes, bounds, colorLow, colorHigh, mapLegendSetId, - radiusLow, radiusHigh, longitude, latitude, zoom ); - - return SUCCESS; - } -} \ No newline at end of file === 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 2012-10-15 12:51:32 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java 2012-10-31 12:40:43 +0000 @@ -34,6 +34,7 @@ import org.apache.struts2.ServletActionContext; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.system.filter.OrganisationUnitWithValidCoordinatesFilter; import org.hisp.dhis.system.util.FilterUtils; @@ -68,9 +69,9 @@ this.parentId = parentId; } - private Integer level; + private String level; - public void setLevel( Integer level ) + public void setLevel( String level ) { this.level = level; } @@ -108,10 +109,21 @@ { parent = organisationUnitService.getOrganisationUnit( Integer.parseInt( parentId ) ); } - - level = level == null ? organisationUnitService.getLevelOfOrganisationUnit( parent.getId() ) : level; - - Collection organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level, parent ); + + OrganisationUnitLevel orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( level ); + + if ( orgUnitLevel == null ) + { + orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( Integer.parseInt( level ) ); + } + + if ( orgUnitLevel == null ) + { + orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( parent.getOrganisationUnitLevel() ); + } + + Collection organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( + orgUnitLevel.getLevel(), parent ); FilterUtils.filter( organisationUnits, new OrganisationUnitWithValidCoordinatesFilter() ); @@ -136,7 +148,7 @@ } } - Collection organisationUnitsUp = organisationUnitService.getOrganisationUnitsAtLevel( level - 1 ); + Collection organisationUnitsUp = organisationUnitService.getOrganisationUnitsAtLevel( orgUnitLevel.getLevel() - 1 ); FilterUtils.filter( organisationUnitsUp, new OrganisationUnitWithValidCoordinatesFilter() ); === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java 2012-10-25 12:07:10 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFacilitiesAction.java 2012-10-31 12:40:43 +0000 @@ -34,6 +34,7 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; +import org.hisp.dhis.organisationunit.OrganisationUnitLevel; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.system.filter.OrganisationUnitWithValidCoordinatesFilter; import org.hisp.dhis.system.util.FilterUtils; @@ -76,9 +77,9 @@ this.parentId = parentId; } - private Integer level; + private String level; - public void setLevel( Integer level ) + public void setLevel( String level ) { this.level = level; } @@ -110,10 +111,25 @@ { OrganisationUnit parent = organisationUnitService.getOrganisationUnit( parentId ); - level = level == null ? organisationUnitService.getLevelOfOrganisationUnit( parent.getId() ) : level; - - Collection organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( level, - parent ); + if ( parent == null ) + { + parent = organisationUnitService.getOrganisationUnit( Integer.parseInt( parentId ) ); + } + + OrganisationUnitLevel orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( level ); + + if ( orgUnitLevel == null ) + { + orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( Integer.parseInt( level ) ); + } + + if ( orgUnitLevel == null ) + { + orgUnitLevel = organisationUnitService.getOrganisationUnitLevel( parent.getOrganisationUnitLevel() ); + } + + Collection organisationUnits = organisationUnitService.getOrganisationUnitsAtLevel( + orgUnitLevel.getLevel(), parent ); FilterUtils.filter( organisationUnits, new OrganisationUnitWithValidCoordinatesFilter() ); === 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 2012-04-20 09:52:17 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2012-10-31 18:29:46 +0000 @@ -187,11 +187,6 @@ - - - - === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml 2012-08-13 10:41:31 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml 2012-10-31 18:29:46 +0000 @@ -200,12 +200,6 @@ - - /dhis-web-mapping/void.vm - - - /dhis-web-mapping/void.vm === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html 2012-10-24 15:00:24 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/app/index.html 2012-11-01 09:34:58 +0000 @@ -32,7 +32,9 @@ document.getElementById('slow').innerHTML = "SLOW CONNECTION?"; +