dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01185
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 341: addOrUpdateMapLegendSet added + maplegendset and mapview bugs fixed.
------------------------------------------------------------
revno: 341
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-05-29 14:05:15 +0200
message:
addOrUpdateMapLegendSet added + maplegendset and mapview bugs fixed.
removed:
gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java
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/hibernate/HibernateMappingStore.java
gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
gis/dhis-web-mapping/src/main/resources/xwork.xml
gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js
gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js
=== 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 2009-05-27 10:26:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2009-05-29 12:05:15 +0000
@@ -283,10 +283,15 @@
void updateMapLegendSet( MapLegendSet legendSet );
+ void addOrUpdateMapLegendSet( String name, int method, int classes, String colorLow, String colorHigh,
+ Collection<String> indicators );
+
void deleteMapLegendSet( MapLegendSet legendSet );
MapLegendSet getMapLegendSet( int id );
+ MapLegendSet getMapLegendSetByName( String name );
+
MapLegendSet getMapLegendSetByIndicator( int indicatorId );
Collection<MapLegendSet> getAllMapLegendSets();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java 2009-05-27 10:26:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java 2009-05-29 12:05:15 +0000
@@ -202,6 +202,8 @@
MapLegendSet getMapLegendSet( int id );
+ MapLegendSet getMapLegendSetByName( String name );
+
Collection<MapLegendSet> getAllMapLegendSets();
// -------------------------------------------------------------------------
=== 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 2009-05-27 10:26:48 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2009-05-29 12:05:15 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Set;
import org.hisp.dhis.indicator.Indicator;
@@ -292,19 +293,49 @@
// MapLegendSet
// -------------------------------------------------------------------------
- public int addMapLegendSet( MapLegendSet legendSet )
- {
- return mappingStore.addMapLegendSet( legendSet );
- }
-
- public void updateMapLegendSet( MapLegendSet legendSet )
- {
- mappingStore.updateMapLegendSet( legendSet );
- }
-
- public void deleteMapLegendSet( MapLegendSet legendSet )
- {
- mappingStore.deleteMapLegendSet( legendSet );
+ public int addMapLegendSet( MapLegendSet mapLegendSet )
+ {
+ return mappingStore.addMapLegendSet( mapLegendSet );
+ }
+
+ public void updateMapLegendSet( MapLegendSet mapLegendSet )
+ {
+ mappingStore.updateMapLegendSet( mapLegendSet );
+ }
+
+ public void addOrUpdateMapLegendSet( String name, int method, int classes, String colorLow, String colorHigh,
+ Collection<String> indicators )
+ {
+ MapLegendSet mapLegendSet = getMapLegendSetByName( name );
+
+ Set<Indicator> indicatorSet = new HashSet<Indicator>();
+
+ for ( String indicator : indicators )
+ {
+ indicatorSet.add( indicatorService.getIndicator( Integer.parseInt( indicator ) ) );
+ }
+
+ if ( mapLegendSet != null )
+ {
+ mapLegendSet.setMethod( method );
+ mapLegendSet.setClasses( classes );
+ mapLegendSet.setColorLow( colorLow );
+ mapLegendSet.setColorHigh( colorHigh );
+ mapLegendSet.setIndicators( indicatorSet );
+
+ mappingStore.updateMapLegendSet( mapLegendSet );
+ }
+ else
+ {
+ mapLegendSet = new MapLegendSet( name, method, classes, colorLow, colorHigh, indicatorSet );
+
+ mappingStore.addMapLegendSet( mapLegendSet );
+ }
+ }
+
+ public void deleteMapLegendSet( MapLegendSet mapLegendSet )
+ {
+ mappingStore.deleteMapLegendSet( mapLegendSet );
}
public MapLegendSet getMapLegendSet( int id )
@@ -312,17 +343,22 @@
return mappingStore.getMapLegendSet( id );
}
+ public MapLegendSet getMapLegendSetByName( String name )
+ {
+ return mappingStore.getMapLegendSetByName( name );
+ }
+
public MapLegendSet getMapLegendSetByIndicator( int indicatorId )
{
Indicator indicator = indicatorService.getIndicator( indicatorId );
- Collection<MapLegendSet> legendSets = mappingStore.getAllMapLegendSets();
+ Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
- for ( MapLegendSet legendSet : legendSets )
+ for ( MapLegendSet mapLegendSet : mapLegendSets )
{
- if ( legendSet.getIndicators().contains( indicator ) )
+ if ( mapLegendSet.getIndicators().contains( indicator ) )
{
- return legendSet;
+ return mapLegendSet;
}
}
@@ -338,11 +374,11 @@
{
Indicator indicator = indicatorService.getIndicator( indicatorId );
- Collection<MapLegendSet> legendSets = mappingStore.getAllMapLegendSets();
+ Collection<MapLegendSet> mapLegendSets = mappingStore.getAllMapLegendSets();
- for ( MapLegendSet legendSet : legendSets )
+ for ( MapLegendSet mapLegendSet : mapLegendSets )
{
- if ( legendSet.getIndicators().contains( indicator ) )
+ if ( mapLegendSet.getIndicators().contains( indicator ) )
{
return true;
}
@@ -359,7 +395,7 @@
{
return mappingStore.addMapView( mapView );
}
-
+
public int addMapView( String name, int indicatorGroupId, int indicatorId, int periodTypeId, int periodId,
String mapLayerPath, int method, int classes, String colorLow, String colorHigh )
{
@@ -397,7 +433,7 @@
String mapLayerPath, int method, int classes, String colorLow, String colorHigh )
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
-
+
Indicator indicator = indicatorService.getIndicator( indicatorId );
PeriodType periodType = periodService.getPeriodType( periodTypeId );
@@ -405,7 +441,7 @@
Period period = periodService.getPeriod( periodId );
Map map = mappingStore.getMapByMapLayerPath( mapLayerPath );
-
+
MapView mapView = mappingStore.getMapViewByName( name );
if ( mapView != null )
@@ -419,13 +455,14 @@
mapView.setClasses( classes );
mapView.setColorLow( colorLow );
mapView.setColorHigh( colorHigh );
-
+
updateMapView( mapView );
}
else
{
- mapView = new MapView( name, indicatorGroup, indicator, periodType, period, map, method, classes, colorLow, colorHigh );
-
+ mapView = new MapView( name, indicatorGroup, indicator, periodType, period, map, method, classes, colorLow,
+ colorHigh );
+
addMapView( mapView );
}
}
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2009-05-27 10:26:48 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java 2009-05-29 12:05:15 +0000
@@ -253,6 +253,17 @@
return (MapLegendSet) session.get( MapLegendSet.class, id );
}
+
+ public MapLegendSet getMapLegendSetByName( String name )
+ {
+ Session session = sessionManager.getCurrentSession();
+
+ Criteria criteria = session.createCriteria( MapLegendSet.class );
+
+ criteria.add( Restrictions.eq( "name", name ) );
+
+ return (MapLegendSet) criteria.uniqueResult();
+ }
@SuppressWarnings( "unchecked" )
public Collection<MapLegendSet> getAllMapLegendSets()
=== removed file 'gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java'
--- gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java 2009-05-25 17:49:30 +0000
+++ gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapLegendSetAction.java 1970-01-01 00:00:00 +0000
@@ -1,138 +0,0 @@
-package org.hisp.dhis.mapping.action;
-
-/*
- * Copyright (c) 2004-2007, 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.indicator.Indicator;
-import org.hisp.dhis.indicator.IndicatorService;
-import org.hisp.dhis.mapping.MapLegendSet;
-import org.hisp.dhis.mapping.MappingService;
-
-import com.opensymphony.xwork.Action;
-
-/**
- * @author Lars Helge Overland
- * @version $Id$
- */
-public class AddMapLegendSetAction
- implements Action
-{
- // -------------------------------------------------------------------------
- // Dependencies
- // -------------------------------------------------------------------------
-
- private MappingService mappingService;
-
- public void setMappingService( MappingService mappingService )
- {
- this.mappingService = mappingService;
- }
-
- private IndicatorService indicatorService;
-
- public void setIndicatorService( IndicatorService indicatorService )
- {
- this.indicatorService = indicatorService;
- }
-
- // -------------------------------------------------------------------------
- // Input
- // -------------------------------------------------------------------------
-
- private String name;
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- private int method;
-
- public void setMethod( int method )
- {
- this.method = method;
- }
-
- private int classes;
-
- public void setClasses( int classes )
- {
- this.classes = classes;
- }
-
- private String colorLow;
-
- public void setColorLow( String colorLow )
- {
- this.colorLow = colorLow;
- }
-
- private String colorHigh;
-
- public void setColorHigh( String colorHigh )
- {
- this.colorHigh = colorHigh;
- }
-
- private Collection<String> indicators;
-
- public void setIndicators( Collection<String> indicators )
- {
- this.indicators = indicators;
- }
-
- // -------------------------------------------------------------------------
- // Action implementation
- // -------------------------------------------------------------------------
-
- public String execute()
- {
- MapLegendSet legendSet = new MapLegendSet();
-
- legendSet.setName( name );
- legendSet.setMethod( method );
- legendSet.setClasses( classes );
- legendSet.setColorLow( colorLow );
- legendSet.setColorHigh( colorHigh );
- legendSet.setIndicators( new HashSet<Indicator>() );
-
- if ( indicators != null )
- {
- for ( String indicator : indicators )
- {
- legendSet.getIndicators().add( indicatorService.getIndicator( Integer.valueOf( indicator ) ) );
- }
- }
-
- mappingService.addMapLegendSet( legendSet );
-
- return SUCCESS;
- }
-}
=== modified file 'gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-05-27 10:26:48 +0000
+++ gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-05-29 12:05:15 +0000
@@ -112,6 +112,13 @@
<property name="indicatorService"
ref="org.hisp.dhis.indicator.IndicatorService"/>
</bean>
+
+ <bean id="org.hisp.dhis.mapping.action.AddOrUpdateMapLegendSetAction"
+ class="org.hisp.dhis.mapping.action.AddOrUpdateMapLegendSetAction"
+ scope="prototype">
+ <property name="mappingService"
+ ref="org.hisp.dhis.mapping.MappingService"/>
+ </bean>
<bean id="org.hisp.dhis.mapping.action.DeleteMapLegendSetAction"
class="org.hisp.dhis.mapping.action.DeleteMapLegendSetAction"
=== modified file 'gis/dhis-web-mapping/src/main/resources/xwork.xml'
--- gis/dhis-web-mapping/src/main/resources/xwork.xml 2009-05-27 10:26:48 +0000
+++ gis/dhis-web-mapping/src/main/resources/xwork.xml 2009-05-29 12:05:15 +0000
@@ -69,7 +69,7 @@
<!-- MapLegendSet -->
- <action name="addMapLegendSet" class="org.hisp.dhis.mapping.action.AddMapLegendSetAction">
+ <action name="addOrUpdateMapLegendSet" class="org.hisp.dhis.mapping.action.AddOrUpdateMapLegendSetAction">
<result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
</action>
=== modified file 'gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js'
--- gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js 2009-05-27 17:21:20 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mapping/geostat/geostat.js 2009-05-29 12:05:15 +0000
@@ -832,7 +832,7 @@
Ext.Ajax.request(
{
- url: path + 'addMapLegendSet.action' + params,
+ url: path + 'addOrUpdateMapLegendSet.action' + params,
method: 'POST',
params: { name: ln, method: 2, classes: lc, colorLow: llc, colorHigh: lhc },
@@ -1046,7 +1046,7 @@
{
Ext.Msg.show({
title:'Register legend sets',
- msg: '<p style="padding-top:8px">The legend set <b>' + vn + '</b> was successfully registered!</b></p>',
+ msg: '<p style="padding-top:8px">The view <b>' + vn + '</b> was successfully registered!</b></p>',
buttons: Ext.Msg.OK,
animEl: 'elId',
minWidth: 400,
=== modified file 'gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js'
--- gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js 2009-05-27 17:21:20 +0000
+++ gis/dhis-web-mapping/src/main/webapp/mfbase/mapfish/widgets/geostat/Choropleth.js 2009-05-29 12:05:15 +0000
@@ -666,6 +666,9 @@
{
xtype: 'button',
+ isFormField: true,
+ fieldLabel: '',
+ labelStyle: 'color:#dfe8f6;',
text: 'Refresh colors',
handler: function()
{
--
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.