=== 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 2010-12-09 15:11:24 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2011-01-10 14:35:40 +0000 @@ -32,6 +32,7 @@ import java.util.Set; import org.hisp.dhis.aggregation.AggregatedMapValue; +import org.hisp.dhis.period.Period; /** * @author Jan Henrik Overland @@ -69,21 +70,8 @@ // IndicatorMapValue // ------------------------------------------------------------------------- - Collection getIndicatorMapValues( int indicatorId, int periodId, int parentOrganisationUnitId ); - - Collection getIndicatorMapValues( int indicatorId, Date startDate, Date endDate, - int parentOrganisationUnitId ); - - Collection getIndicatorMapValues( int indicatorId, int periodId, int parentOrganisationUnitId, - int level ); - - Collection getIndicatorMapValues( int indicatorId, Date startDate, Date endDate, - int parentOrganisationUnitId, int level ); - - Collection getIndicatorMapValuesByLevel( int dataElementId, int periodId, int level ); - - Collection getIndicatorMapValuesByLevel( int dataElementId, Date startDate, Date endDate, - int level ); + Collection getIndicatorMapValues( Integer indicatorId, Period period, Date startDate, Date endDate, + Integer parentOrganisationUnitId, Integer level ); // ------------------------------------------------------------------------- // DataMapValue === 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-01-07 12:59:06 +0000 +++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2011-01-10 14:35:40 +0000 @@ -137,48 +137,7 @@ // ------------------------------------------------------------------------- // IndicatorMapValues // ------------------------------------------------------------------------- - - public Collection getIndicatorMapValues( int indicatorId, int periodId, - int parentOrganisationUnitId ) - { - Period period = periodService.getPeriod( periodId ); - - return getIndicatorMapValuesInternal( indicatorId, period, null, null, parentOrganisationUnitId, null ); - } - - public Collection getIndicatorMapValues( int indicatorId, Date startDate, Date endDate, - int parentOrganisationUnitId ) - { - return getIndicatorMapValuesInternal( indicatorId, null, startDate, endDate, parentOrganisationUnitId, null ); - } - - public Collection getIndicatorMapValues( int indicatorId, int periodId, - int parentOrganisationUnitId, int level ) - { - Period period = periodService.getPeriod( periodId ); - - return getIndicatorMapValuesInternal( indicatorId, period, null, null, parentOrganisationUnitId, level ); - } - - public Collection getIndicatorMapValues( int indicatorId, Date startDate, Date endDate, - int parentOrganisationUnitId, int level ) - { - return getIndicatorMapValuesInternal( indicatorId, null, startDate, endDate, parentOrganisationUnitId, level ); - } - - public Collection getIndicatorMapValuesByLevel( int indicatorId, int periodId, int level ) - { - Period period = periodService.getPeriod( periodId ); - - return getIndicatorMapValuesInternal( indicatorId, period, null, null, null, level ); - } - public Collection getIndicatorMapValuesByLevel( int indicatorId, Date startDate, Date endDate, - int level ) - { - return getIndicatorMapValuesInternal( indicatorId, null, startDate, endDate, null, level ); - } - /** * Generates a collection AggregatedMapValues. Only one of Period and start/end * date can be specified. At least one of parent organisation unit and level @@ -193,18 +152,24 @@ * @param level the OrganisationUnit level. Ignored if null. * @return a collection of AggregatedMapValues. */ - private Collection getIndicatorMapValuesInternal( Integer indicatorId, Period period, Date startDate, Date endDate, + public Collection getIndicatorMapValues( Integer indicatorId, Period period, Date startDate, Date endDate, Integer parentOrganisationUnitId, Integer level ) { 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( !( parentOrganisationUnitId == null && level == null ) ); + Assert.isTrue( !( indicatorId == null || parentOrganisationUnitId == null || level == null ) ); Collection values = new HashSet(); Indicator indicator = indicatorService.getIndicator( indicatorId ); + + if ( period != null ) + { + startDate = period.getStartDate(); + endDate = period.getEndDate(); + } for ( OrganisationUnit organisationUnit : getOrganisationUnits( parentOrganisationUnitId, level ) ) { @@ -225,7 +190,7 @@ } } - return values; + return values; } /** === modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java' --- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-06 04:19:59 +0000 +++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2011-01-10 14:35:40 +0000 @@ -34,6 +34,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Date; import java.util.HashSet; import java.util.List; @@ -520,7 +521,6 @@ public void testMapValues() { mappingService.getDataElementMapValues( dataElement.getId(), period.getId(), organisationUnit.getId() ); - mappingService.getIndicatorMapValues( indicator.getId(), period.getId(), organisationUnit.getId() ); + mappingService.getIndicatorMapValues( indicator.getId(), period, new Date(), new Date(), organisationUnit.getId(), 1 ); } - } === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java 2010-11-19 16:04:04 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesAction.java 2011-01-10 14:35:40 +0000 @@ -32,6 +32,8 @@ import org.hisp.dhis.aggregation.AggregatedMapValue; import org.hisp.dhis.mapping.MappingService; import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.system.util.DateUtils; import com.opensymphony.xwork2.Action; @@ -54,11 +56,11 @@ this.mappingService = mappingService; } - private OrganisationUnitService organisationUnitService; + private PeriodService periodService; - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + public void setPeriodService( PeriodService periodService ) { - this.organisationUnitService = organisationUnitService; + this.periodService = periodService; } // ------------------------------------------------------------------------- @@ -117,7 +119,7 @@ { return object; } - + // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- @@ -125,16 +127,10 @@ public String execute() throws Exception { - if ( periodId != null ) // Period - { - object = mappingService.getIndicatorMapValues( id, periodId, parentId, level ); - } - else - // Start and end date - { - object = mappingService.getIndicatorMapValues( id, DateUtils.getMediumDate( startDate ), - DateUtils.getMediumDate( endDate ), parentId, level ); - } + Period period = periodService.getPeriod( periodId ); + + object = mappingService.getIndicatorMapValues( id, period, DateUtils.getMediumDate( startDate ), DateUtils + .getMediumDate( endDate ), parentId, level ); return SUCCESS; } === removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByLevelAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByLevelAction.java 2010-11-03 14:39:18 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByLevelAction.java 1970-01-01 00:00:00 +0000 @@ -1,124 +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.aggregation.AggregatedMapValue; -import org.hisp.dhis.mapping.MappingService; -import org.hisp.dhis.system.util.DateUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author Jan Henrik Overland - * @version $Id$ - */ -public class GetIndicatorMapValuesByLevelAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private MappingService mappingService; - - public void setMappingService( MappingService mappingService ) - { - this.mappingService = mappingService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - public void setId( Integer id ) - { - this.id = id; - } - - private Integer periodId; - - public void setPeriodId( Integer periodId ) - { - this.periodId = periodId; - } - - private String startDate; - - public void setStartDate( String startDate ) - { - this.startDate = startDate; - } - - private String endDate; - - public void setEndDate( String endDate ) - { - this.endDate = endDate; - } - - private Integer level; - - public void setLevel( Integer level ) - { - this.level = level; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Collection object; - - public Collection getObject() - { - return object; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - if ( periodId != null ) // Period - { - object = mappingService.getIndicatorMapValuesByLevel( id, periodId, level ); - } - else // Start and end date - { - object = mappingService.getIndicatorMapValuesByLevel( id, DateUtils.getMediumDate( startDate ), DateUtils.getMediumDate( endDate ), level ); - } - - return SUCCESS; - } -} === removed file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByParentAction.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByParentAction.java 2010-10-29 11:24:12 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetIndicatorMapValuesByParentAction.java 1970-01-01 00:00:00 +0000 @@ -1,124 +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.aggregation.AggregatedMapValue; -import org.hisp.dhis.mapping.MappingService; -import org.hisp.dhis.system.util.DateUtils; - -import com.opensymphony.xwork2.Action; - -/** - * @author Jan Henrik Overland - * @version $Id$ - */ -public class GetIndicatorMapValuesByParentAction - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private MappingService mappingService; - - public void setMappingService( MappingService mappingService ) - { - this.mappingService = mappingService; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Integer id; - - public void setId( Integer id ) - { - this.id = id; - } - - private Integer periodId; - - public void setPeriodId( Integer periodId ) - { - this.periodId = periodId; - } - - private String startDate; - - public void setStartDate( String startDate ) - { - this.startDate = startDate; - } - - private String endDate; - - public void setEndDate( String endDate ) - { - this.endDate = endDate; - } - - private Integer parentId; - - public void setParentId( Integer parentId ) - { - this.parentId = parentId; - } - - // ------------------------------------------------------------------------- - // Input - // ------------------------------------------------------------------------- - - private Collection object; - - public Collection getObject() - { - return object; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - throws Exception - { - if ( periodId != null ) // Period - { - object = mappingService.getIndicatorMapValues( id, periodId, parentId ); - } - else // Start and end date - { - object = mappingService.getIndicatorMapValues( id, DateUtils.getMediumDate( startDate ), DateUtils.getMediumDate( endDate ), parentId ); - } - - return SUCCESS; - } -} === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java' --- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java 2010-12-09 20:23:56 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/export/SVGDocument.java 2011-01-10 14:35:40 +0000 @@ -31,10 +31,6 @@ import net.sf.json.JSONSerializer; import org.apache.commons.lang.StringEscapeUtils; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.indicator.Indicator; - -import sun.rmi.runtime.Log; /** * @author Tran Thanh Tri === 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 2010-12-01 12:16:51 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2011-01-10 14:35:40 +0000 @@ -67,16 +67,7 @@ - - - - - - - - + - - - /dhis-web-mapping/jsonminAggregatedMapValues.vm - - - - - /dhis-web-mapping/jsonminAggregatedMapValues.vm - - === 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-01-07 10:58:35 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2011-01-10 14:35:40 +0000 @@ -394,7 +394,7 @@ }) }); - overlay.events.register('loadstart', null, loadStart); + overlay.events.register('loadstart', null, loadStart); overlay.events.register('loadend', null, loadEnd); overlay.isOverlay = true; G.vars.map.addLayer(overlay); === modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js' --- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-01-07 10:58:35 +0000 +++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2011-01-10 14:35:40 +0000 @@ -1432,7 +1432,7 @@ } if (this.updateValues) { - var dataUrl = this.valueType.isIndicator() ? 'getIndicatorMapValues' : 'getDataElementMapValues'; + var dataUrl = this.valueType.isIndicator() ? 'getIndicatorMapValues' : 'getDataElementMapValues'; var params = { id: this.valueType.isIndicator() ? this.form.findField('indicator').getValue() : this.form.findField('dataelement').getValue(), periodId: G.vars.mapDateType.isFixed() ? this.form.findField('period').getValue() : null,