dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #04460
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1486: (GIS) Map position and zoom level are now captured and stored when creating a map view and applie...
------------------------------------------------------------
revno: 1486
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: trunk
timestamp: Wed 2010-02-24 15:11:32 +0100
message:
(GIS) Map position and zoom level are now captured and stored when creating a map view and applied to the map when a stored map view is selected. Blueprint: https://blueprints.launchpad.net/dhis2/+spec/gis-zoom-center-mapview
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.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/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
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/MappingStoreTest.java
dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm
dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/config.js
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/resources/mapfish/widgets/geostat/Choropleth.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/mapping/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2009-09-29 16:17:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java 2010-02-24 14:11:32 +0000
@@ -66,12 +66,18 @@
private String colorHigh;
+ private String longitude;
+
+ private String latitude;
+
+ private int zoom;
+
public MapView()
{
}
public MapView( String name, IndicatorGroup indicatorGroup, Indicator indicator, PeriodType periodType, Period period, String mapSourceType, String mapSource,
- int method, int classes, String colorLow, String colorHigh )
+ int method, int classes, String colorLow, String colorHigh, String longitude, String latitude, int zoom )
{
this.name = name;
this.indicatorGroup = indicatorGroup;
@@ -84,6 +90,10 @@
this.classes = classes;
this.colorLow = colorLow;
this.colorHigh = colorHigh;
+ this.longitude = longitude;
+ this.latitude = latitude;
+ this.zoom = zoom;
+
}
// -------------------------------------------------------------------------
@@ -242,4 +252,28 @@
{
this.colorHigh = colorHigh;
}
+
+ public String getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(String longitude) {
+ this.longitude = longitude;
+ }
+
+ public String getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(String latitude) {
+ this.latitude = latitude;
+ }
+
+ public int getZoom() {
+ return zoom;
+ }
+
+ public void setZoom(int zoom) {
+ this.zoom = zoom;
+ }
}
\ No newline at end of file
=== 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-10-06 00:48:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2010-02-24 14:11:32 +0000
@@ -343,12 +343,12 @@
int addMapView( MapView mapView );
int addMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh );
+ String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude, String latitude, int zoom );
void updateMapView( MapView mapView );
void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSource, int method, int classes, String colorLow, String colorHigh );
+ String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude, String latitude, int zoom );
void deleteMapView( MapView view );
=== 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-12-02 13:19:53 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2010-02-24 14:11:32 +0000
@@ -590,7 +590,7 @@
}
public int addMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName, int periodId,
- String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh )
+ String mapSourceType, String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude, String latitude, int zoom )
{
MapView mapView = new MapView();
@@ -614,6 +614,9 @@
mapView.setClasses( classes );
mapView.setColorLow( colorLow );
mapView.setColorHigh( colorHigh );
+ mapView.setLongitude( longitude );
+ mapView.setLatitude( latitude );
+ mapView.setZoom( zoom );
return mappingStore.addMapView( mapView );
}
@@ -624,7 +627,7 @@
}
public void addOrUpdateMapView( String name, int indicatorGroupId, int indicatorId, String periodTypeName,
- int periodId, String mapSource, int method, int classes, String colorLow, String colorHigh )
+ int periodId, String mapSource, int method, int classes, String colorLow, String colorHigh, String longitude, String latitude, int zoom )
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( indicatorGroupId );
@@ -652,13 +655,16 @@
mapView.setClasses( classes );
mapView.setColorLow( colorLow );
mapView.setColorHigh( colorHigh );
+ mapView.setLongitude( longitude );
+ mapView.setLatitude( latitude );
+ mapView.setZoom( zoom );
updateMapView( mapView );
}
else
{
mapView = new MapView( name, indicatorGroup, indicator, periodType, period, mapSourceType, mapSource,
- method, classes, colorLow, colorHigh );
+ method, classes, colorLow, colorHigh, longitude, latitude, zoom );
addMapView( mapView );
}
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2009-07-13 20:00:15 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml 2010-02-24 14:11:32 +0000
@@ -35,7 +35,13 @@
<property name="colorLow"/>
- <property name="colorHigh"/>
+ <property name="colorHigh"/>
+
+ <property name="longitude"/>
+
+ <property name="latitude"/>
+
+ <property name="zoom"/>
</class>
=== 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 2009-07-13 20:00:15 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java 2010-02-24 14:11:32 +0000
@@ -49,163 +49,171 @@
* @author Lars Helge Overland
* @version $Id$
*/
-public class MappingServiceTest
- extends DhisSpringTest
-{
- private MappingService mappingService;
-
- private OrganisationUnit organisationUnit;
-
- private OrganisationUnitLevel organisationUnitLevel;
-
- private IndicatorGroup indicatorGroup;
- private IndicatorType indicatorType;
- private Indicator indicator;
-
- private PeriodType periodType;
- private Period period;
-
- private Map mapA;
- private Map mapB;
-
- private MapOrganisationUnitRelation mapOrganisationUnitRelationA;
- private MapOrganisationUnitRelation mapOrganisationUnitRelationB;
-
- // -------------------------------------------------------------------------
- // Fixture
- // -------------------------------------------------------------------------
-
- @Override
- public void setUpTest()
- {
- mappingService = (MappingService) getBean( MappingService.ID );
-
- organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
- indicatorService = (IndicatorService) getBean( IndicatorService.ID );
-
- periodService = (PeriodService) getBean( PeriodService.ID );
-
- organisationUnit = createOrganisationUnit( 'A' );
- organisationUnitLevel = new OrganisationUnitLevel( 1, "Level" );
-
- organisationUnitService.addOrganisationUnit( organisationUnit );
- organisationUnitService.addOrganisationUnitLevel( organisationUnitLevel );
-
- mapA = createMap( 'A', organisationUnit, organisationUnitLevel );
- mapB = createMap( 'B', organisationUnit, organisationUnitLevel );
-
- mapOrganisationUnitRelationA = new MapOrganisationUnitRelation( mapA, organisationUnit, "Feature" );
- mapOrganisationUnitRelationB = new MapOrganisationUnitRelation( mapB, organisationUnit, "Feature" );
-
- indicatorGroup = createIndicatorGroup( 'A' );
- indicatorService.addIndicatorGroup( indicatorGroup );
-
- indicatorType = createIndicatorType( 'A' );
- indicatorService.addIndicatorType( indicatorType );
-
- indicator = createIndicator( 'A', indicatorType );
- indicatorService.addIndicator( indicator );
-
- periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
- period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
- periodService.addPeriod( period );
- }
-
- // -------------------------------------------------------------------------
- // Map tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testAddGetMap()
- {
- int idA = mappingService.addMap( mapA );
- int idB = mappingService.addMap( mapB );
-
- assertEquals( mapA, mappingService.getMap( idA ) );
- assertEquals( mapB, mappingService.getMap( idB ) );
- }
-
- @Test
- public void testDeleteMap()
- {
- int idA = mappingService.addMap( mapA );
- int idB = mappingService.addMap( mapB );
-
- mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationA );
- mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationB );
-
- assertNotNull( mappingService.getMap( idA ) );
- assertNotNull( mappingService.getMap( idB ) );
-
- mappingService.deleteMap( mapA );
-
- assertNull( mappingService.getMap( idA ) );
- assertNotNull( mappingService.getMap( idB ) );
-
- mappingService.deleteMap( mapB );
-
- assertNull( mappingService.getMap( idA ) );
- assertNull( mappingService.getMap( idB ) );
- }
-
- // -------------------------------------------------------------------------
- // MapOrganisationUnitRelation tests
- // -------------------------------------------------------------------------
-
- @Test
- public void addGetMapOrganisationUnitRelation()
- {
- mappingService.addMap( mapA );
- mappingService.addMap( mapB );
-
- int idA = mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationA );
- int idB = mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationB );
-
- assertEquals( mappingService.getMapOrganisationUnitRelation( idA ), mapOrganisationUnitRelationA );
- assertEquals( mappingService.getMapOrganisationUnitRelation( idB ), mapOrganisationUnitRelationB );
- }
-
- @Test
- public void deleteMapOrganisationUnitRelation()
- {
- mappingService.addMap( mapA );
- mappingService.addMap( mapB );
-
- int idA = mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationA );
- int idB = mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelationB );
-
- assertNotNull( mappingService.getMapOrganisationUnitRelation( idA ) );
- assertNotNull( mappingService.getMapOrganisationUnitRelation( idB ) );
-
- mappingService.deleteMapOrganisationUnitRelation( mapOrganisationUnitRelationA );
-
- assertNull( mappingService.getMapOrganisationUnitRelation( idA ) );
- assertNotNull( mappingService.getMapOrganisationUnitRelation( idB ) );
-
- mappingService.deleteMapOrganisationUnitRelation( mapOrganisationUnitRelationB );
-
- assertNull( mappingService.getMapOrganisationUnitRelation( idA ) );
- assertNull( mappingService.getMapOrganisationUnitRelation( idB ) );
- }
-
- // -------------------------------------------------------------------------
- // MapView tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testAddGetMapView()
- {
- mappingService.addMap( mapA );
-
- MapView mapView = new MapView( "MapViewA", indicatorGroup, indicator, periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE, "sl_districts", 1, 1, "A", "B" );
-
- int idA = mappingService.addMapView( mapView );
-
- assertEquals( mapView, mappingService.getMapView( idA ) );
- assertEquals( indicatorGroup, mappingService.getMapView( idA ).getIndicatorGroup() );
- assertEquals( indicator, mappingService.getMapView( idA ).getIndicator() );
- assertEquals( periodType, mappingService.getMapView( idA ).getPeriodType() );
- assertEquals( period, mappingService.getMapView( idA ).getPeriod() );
- }
+public class MappingServiceTest extends DhisSpringTest {
+ private MappingService mappingService;
+
+ private OrganisationUnit organisationUnit;
+
+ private OrganisationUnitLevel organisationUnitLevel;
+
+ private IndicatorGroup indicatorGroup;
+ private IndicatorType indicatorType;
+ private Indicator indicator;
+
+ private PeriodType periodType;
+ private Period period;
+
+ private Map mapA;
+ private Map mapB;
+
+ private MapOrganisationUnitRelation mapOrganisationUnitRelationA;
+ private MapOrganisationUnitRelation mapOrganisationUnitRelationB;
+
+ // -------------------------------------------------------------------------
+ // Fixture
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void setUpTest() {
+ mappingService = (MappingService) getBean(MappingService.ID);
+
+ organisationUnitService = (OrganisationUnitService) getBean(OrganisationUnitService.ID);
+
+ indicatorService = (IndicatorService) getBean(IndicatorService.ID);
+
+ periodService = (PeriodService) getBean(PeriodService.ID);
+
+ organisationUnit = createOrganisationUnit('A');
+ organisationUnitLevel = new OrganisationUnitLevel(1, "Level");
+
+ organisationUnitService.addOrganisationUnit(organisationUnit);
+ organisationUnitService.addOrganisationUnitLevel(organisationUnitLevel);
+
+ mapA = createMap('A', organisationUnit, organisationUnitLevel);
+ mapB = createMap('B', organisationUnit, organisationUnitLevel);
+
+ mapOrganisationUnitRelationA = new MapOrganisationUnitRelation(mapA,
+ organisationUnit, "Feature");
+ mapOrganisationUnitRelationB = new MapOrganisationUnitRelation(mapB,
+ organisationUnit, "Feature");
+
+ indicatorGroup = createIndicatorGroup('A');
+ indicatorService.addIndicatorGroup(indicatorGroup);
+
+ indicatorType = createIndicatorType('A');
+ indicatorService.addIndicatorType(indicatorType);
+
+ indicator = createIndicator('A', indicatorType);
+ indicatorService.addIndicator(indicator);
+
+ periodType = periodService.getPeriodTypeByName(MonthlyPeriodType.NAME);
+ period = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 2,
+ 1));
+ periodService.addPeriod(period);
+ }
+
+ // -------------------------------------------------------------------------
+ // Map tests
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testAddGetMap() {
+ int idA = mappingService.addMap(mapA);
+ int idB = mappingService.addMap(mapB);
+
+ assertEquals(mapA, mappingService.getMap(idA));
+ assertEquals(mapB, mappingService.getMap(idB));
+ }
+
+ @Test
+ public void testDeleteMap() {
+ int idA = mappingService.addMap(mapA);
+ int idB = mappingService.addMap(mapB);
+
+ mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationA);
+ mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationB);
+
+ assertNotNull(mappingService.getMap(idA));
+ assertNotNull(mappingService.getMap(idB));
+
+ mappingService.deleteMap(mapA);
+
+ assertNull(mappingService.getMap(idA));
+ assertNotNull(mappingService.getMap(idB));
+
+ mappingService.deleteMap(mapB);
+
+ assertNull(mappingService.getMap(idA));
+ assertNull(mappingService.getMap(idB));
+ }
+
+ // -------------------------------------------------------------------------
+ // MapOrganisationUnitRelation tests
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void addGetMapOrganisationUnitRelation() {
+ mappingService.addMap(mapA);
+ mappingService.addMap(mapB);
+
+ int idA = mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationA);
+ int idB = mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationB);
+
+ assertEquals(mappingService.getMapOrganisationUnitRelation(idA),
+ mapOrganisationUnitRelationA);
+ assertEquals(mappingService.getMapOrganisationUnitRelation(idB),
+ mapOrganisationUnitRelationB);
+ }
+
+ @Test
+ public void deleteMapOrganisationUnitRelation() {
+ mappingService.addMap(mapA);
+ mappingService.addMap(mapB);
+
+ int idA = mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationA);
+ int idB = mappingService
+ .addMapOrganisationUnitRelation(mapOrganisationUnitRelationB);
+
+ assertNotNull(mappingService.getMapOrganisationUnitRelation(idA));
+ assertNotNull(mappingService.getMapOrganisationUnitRelation(idB));
+
+ mappingService
+ .deleteMapOrganisationUnitRelation(mapOrganisationUnitRelationA);
+
+ assertNull(mappingService.getMapOrganisationUnitRelation(idA));
+ assertNotNull(mappingService.getMapOrganisationUnitRelation(idB));
+
+ mappingService
+ .deleteMapOrganisationUnitRelation(mapOrganisationUnitRelationB);
+
+ assertNull(mappingService.getMapOrganisationUnitRelation(idA));
+ assertNull(mappingService.getMapOrganisationUnitRelation(idB));
+ }
+
+ // -------------------------------------------------------------------------
+ // MapView tests
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testAddGetMapView() {
+ mappingService.addMap(mapA);
+
+ MapView mapView = new MapView("MapViewA", indicatorGroup, indicator,
+ periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE,
+ "sl_districts", 1, 1, "A", "B", "1", "1", 1);
+
+ int idA = mappingService.addMapView(mapView);
+
+ assertEquals(mapView, mappingService.getMapView(idA));
+ assertEquals(indicatorGroup, mappingService.getMapView(idA)
+ .getIndicatorGroup());
+ assertEquals(indicator, mappingService.getMapView(idA).getIndicator());
+ assertEquals(periodType, mappingService.getMapView(idA).getPeriodType());
+ assertEquals(period, mappingService.getMapView(idA).getPeriod());
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java 2009-08-12 21:06:37 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java 2010-02-24 14:11:32 +0000
@@ -49,114 +49,112 @@
* @author Lars Helge Overland
* @version $Id$
*/
-public class MappingStoreTest
- extends DhisSpringTest
-{
- private MappingStore mappingStore;
-
- private OrganisationUnit organisationUnit;
-
- private OrganisationUnitLevel organisationUnitLevel;
-
- private IndicatorGroup indicatorGroup;
- private IndicatorType indicatorType;
- private Indicator indicator;
-
- private PeriodType periodType;
- private Period period;
-
- private Map mapA;
- private Map mapB;
-
- // -------------------------------------------------------------------------
- // Fixture
- // -------------------------------------------------------------------------
-
- @Override
- public void setUpTest()
- {
- mappingStore = (MappingStore) getBean( MappingStore.ID );
-
- organisationUnitService = (OrganisationUnitService) getBean( OrganisationUnitService.ID );
-
- indicatorService = (IndicatorService) getBean( IndicatorService.ID );
-
- periodService = (PeriodService) getBean( PeriodService.ID );
-
- organisationUnit = createOrganisationUnit( 'A' );
- organisationUnitLevel = new OrganisationUnitLevel( 1, "Level" );
-
- organisationUnitService.addOrganisationUnit( organisationUnit );
- organisationUnitService.addOrganisationUnitLevel( organisationUnitLevel );
-
- mapA = createMap( 'A', organisationUnit, organisationUnitLevel );
- mapB = createMap( 'B', organisationUnit, organisationUnitLevel );
-
- indicatorGroup = createIndicatorGroup( 'A' );
- indicatorService.addIndicatorGroup( indicatorGroup );
-
- indicatorType = createIndicatorType( 'A' );
- indicatorService.addIndicatorType( indicatorType );
-
- indicator = createIndicator( 'A', indicatorType );
- indicatorService.addIndicator( indicator );
-
- periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME );
- period = createPeriod( periodType, getDate( 2000, 1, 1 ), getDate( 2000, 2, 1 ) );
- periodService.addPeriod( period );
- }
-
- // -------------------------------------------------------------------------
- // Map tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testAddGetMap()
- {
- int idA = mappingStore.addMap( mapA );
- int idB = mappingStore.addMap( mapB );
-
- assertEquals( mapA, mappingStore.getMap( idA ) );
- assertEquals( mapB, mappingStore.getMap( idB ) );
- }
-
- @Test
- public void testDeleteMap()
- {
- int idA = mappingStore.addMap( mapA );
- int idB = mappingStore.addMap( mapB );
-
- assertNotNull( mappingStore.getMap( idA ) );
- assertNotNull( mappingStore.getMap( idB ) );
-
- mappingStore.deleteMap( mapA );
-
- assertNull( mappingStore.getMap( idA ) );
- assertNotNull( mappingStore.getMap( idB ) );
-
- mappingStore.deleteMap( mapB );
-
- assertNull( mappingStore.getMap( idA ) );
- assertNull( mappingStore.getMap( idB ) );
- }
-
- // -------------------------------------------------------------------------
- // MapView tests
- // -------------------------------------------------------------------------
-
- @Test
- public void testAddGetMapView()
- {
- mappingStore.addMap( mapA );
-
- MapView mapView = new MapView( "MapViewA", indicatorGroup, indicator, periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE, "sl_districts", 1, 1, "A", "B" );
-
- int idA = mappingStore.addMapView( mapView );
-
- assertEquals( mapView, mappingStore.getMapView( idA ) );
- assertEquals( indicatorGroup, mappingStore.getMapView( idA ).getIndicatorGroup() );
- assertEquals( indicator, mappingStore.getMapView( idA ).getIndicator() );
- assertEquals( periodType, mappingStore.getMapView( idA ).getPeriodType() );
- assertEquals( period, mappingStore.getMapView( idA ).getPeriod() );
- }
-}
+public class MappingStoreTest extends DhisSpringTest {
+ private MappingStore mappingStore;
+
+ private OrganisationUnit organisationUnit;
+
+ private OrganisationUnitLevel organisationUnitLevel;
+
+ private IndicatorGroup indicatorGroup;
+ private IndicatorType indicatorType;
+ private Indicator indicator;
+
+ private PeriodType periodType;
+ private Period period;
+
+ private Map mapA;
+ private Map mapB;
+
+ // -------------------------------------------------------------------------
+ // Fixture
+ // -------------------------------------------------------------------------
+
+ @Override
+ public void setUpTest() {
+ mappingStore = (MappingStore) getBean(MappingStore.ID);
+
+ organisationUnitService = (OrganisationUnitService) getBean(OrganisationUnitService.ID);
+
+ indicatorService = (IndicatorService) getBean(IndicatorService.ID);
+
+ periodService = (PeriodService) getBean(PeriodService.ID);
+
+ organisationUnit = createOrganisationUnit('A');
+ organisationUnitLevel = new OrganisationUnitLevel(1, "Level");
+
+ organisationUnitService.addOrganisationUnit(organisationUnit);
+ organisationUnitService.addOrganisationUnitLevel(organisationUnitLevel);
+
+ mapA = createMap('A', organisationUnit, organisationUnitLevel);
+ mapB = createMap('B', organisationUnit, organisationUnitLevel);
+
+ indicatorGroup = createIndicatorGroup('A');
+ indicatorService.addIndicatorGroup(indicatorGroup);
+
+ indicatorType = createIndicatorType('A');
+ indicatorService.addIndicatorType(indicatorType);
+
+ indicator = createIndicator('A', indicatorType);
+ indicatorService.addIndicator(indicator);
+
+ periodType = periodService.getPeriodTypeByName(MonthlyPeriodType.NAME);
+ period = createPeriod(periodType, getDate(2000, 1, 1), getDate(2000, 2,
+ 1));
+ periodService.addPeriod(period);
+ }
+
+ // -------------------------------------------------------------------------
+ // Map tests
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testAddGetMap() {
+ int idA = mappingStore.addMap(mapA);
+ int idB = mappingStore.addMap(mapB);
+
+ assertEquals(mapA, mappingStore.getMap(idA));
+ assertEquals(mapB, mappingStore.getMap(idB));
+ }
+
+ @Test
+ public void testDeleteMap() {
+ int idA = mappingStore.addMap(mapA);
+ int idB = mappingStore.addMap(mapB);
+
+ assertNotNull(mappingStore.getMap(idA));
+ assertNotNull(mappingStore.getMap(idB));
+
+ mappingStore.deleteMap(mapA);
+
+ assertNull(mappingStore.getMap(idA));
+ assertNotNull(mappingStore.getMap(idB));
+
+ mappingStore.deleteMap(mapB);
+
+ assertNull(mappingStore.getMap(idA));
+ assertNull(mappingStore.getMap(idB));
+ }
+
+ // -------------------------------------------------------------------------
+ // MapView tests
+ // -------------------------------------------------------------------------
+
+ @Test
+ public void testAddGetMapView() {
+ mappingStore.addMap(mapA);
+
+ MapView mapView = new MapView("MapViewA", indicatorGroup, indicator,
+ periodType, period, MapView.MAP_SOURCE_TYPE_SHAPEFILE,
+ "sl_districts", 1, 1, "A", "B", "1", "1", 1);
+
+ int idA = mappingStore.addMapView(mapView);
+
+ assertEquals(mapView, mappingStore.getMapView(idA));
+ assertEquals(indicatorGroup, mappingStore.getMapView(idA)
+ .getIndicatorGroup());
+ assertEquals(indicator, mappingStore.getMapView(idA).getIndicator());
+ assertEquals(periodType, mappingStore.getMapView(idA).getPeriodType());
+ assertEquals(period, mappingStore.getMapView(idA).getPeriod());
+ }
+}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java 2009-09-29 16:17:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java 2010-02-24 14:11:32 +0000
@@ -122,6 +122,24 @@
{
this.colorHigh = colorHigh;
}
+
+ 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
@@ -131,7 +149,7 @@
throws Exception
{
mappingService.addOrUpdateMapView( name, indicatorGroupId, indicatorId, periodTypeId, periodId, mapSource,
- method, classes, colorLow, colorHigh );
+ method, classes, colorLow, colorHigh, longitude, latitude, zoom );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm 2009-09-30 12:16:29 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm 2010-02-24 14:11:32 +0000
@@ -11,6 +11,9 @@
"method": "$!{object.method}",
"classes": "$!{object.classes}",
"colorLow": "$!encoder.jsEncode( ${object.colorLow} )",
- "colorHigh": "$!encoder.jsEncode( ${object.colorHigh} )"
+ "colorHigh": "$!encoder.jsEncode( ${object.colorHigh} )",
+ "longitude": "$!encoder.jsEncode( ${object.longitude} )",
+ "latitude": "$!encoder.jsEncode( ${object.latitude} )",
+ "zoom": "$!{object.zoom}"
}]
}
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm 2009-07-13 20:00:15 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm 2010-02-24 14:11:32 +0000
@@ -13,7 +13,10 @@
"method": $!{mapView.method},
"classes": $!{mapView.classes},
"colorLow": "$!encoder.jsEncode( ${mapView.colorLow} )",
- "colorHigh": "$!encoder.jsEncode( ${mapView.colorHigh} )"
+ "colorHigh": "$!encoder.jsEncode( ${mapView.colorHigh} )",
+ "longitude": "$!encoder.jsEncode( ${mapView.longitude} )",
+ "latitude": "$!encoder.jsEncode( ${mapView.latitude} )",
+ "zoom": "$!{mapView.zoom}"
}#if( $velocityCount < $size ),#end
#end
] }
\ No newline at end of file
=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/config.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/config.js 2009-12-06 14:21:44 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/config.js 2010-02-24 14:11:32 +0000
@@ -4,7 +4,12 @@
// MapFish print module
- printConfigUrl = '../../../print-servlet-1.2-SNAPSHOT/pdf/info.json';
+ var layerOverrides = {
+ "World": {overview: true},
+ Countries: { format: 'image/svg+xml' }
+ };
+
+ var printConfigUrl = '../../pdf/info.json';
// Ajax requests
=== 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 2010-02-23 14:22:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js 2010-02-24 14:11:32 +0000
@@ -387,6 +387,9 @@
var c = Ext.getCmp('numClasses').getValue();
var ca = Ext.getCmp('colorA_cf').getValue();
var cb = Ext.getCmp('colorB_cf').getValue();
+ var lon = MAP.getCenter().lon;
+ var lat = MAP.getCenter().lat;
+ var zoom = parseInt(MAP.getZoom());
if (!vn) {
Ext.messageRed.msg('New map view', 'Map view form is not complete.');
@@ -419,7 +422,7 @@
Ext.Ajax.request({
url: path + 'addOrUpdateMapView' + type,
method: 'POST',
- params: { name: vn, indicatorGroupId: ig, indicatorId: ii, periodTypeId: pt, periodId: p, mapSource: ms, method: 2, classes: c, colorLow: ca, colorHigh: cb },
+ params: { name: vn, indicatorGroupId: ig, indicatorId: ii, periodTypeId: pt, periodId: p, mapSource: ms, method: 2, classes: c, colorLow: ca, colorHigh: cb, longitude: lon, latitude: lat, zoom: zoom },
success: function( responseObject ) {
Ext.messageBlack.msg('New map view', 'The view ' + msg_highlight_start + vn + msg_highlight_end + ' was registered.');
@@ -2780,13 +2783,6 @@
}
});
- var layerOverrides={
- "OpenLayers WMS": {overview: true},
- Countries: { format: 'image/svg+xml' }
- };
-
- var printConfigUrl = '../../pdf/info.json';
-
var mapToolbar = new Ext.Toolbar({
id: 'map_tb',
items: [
=== 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 2010-02-16 17:59:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js 2010-02-24 14:11:32 +0000
@@ -158,17 +158,16 @@
params: { id: PARAMETER },
success: function( responseObject ) {
- PARAMETER = null;
+ PARAMETER = false;
MAPVIEW = Ext.util.JSON.decode(responseObject.responseText).mapView[0];
MAPSOURCE = MAPVIEW.mapSourceType;
Ext.getCmp('mapsource_cb').setValue(MAPSOURCE);
-
Ext.getCmp('mapview_cb').setValue(MAPVIEW.id);
-
Ext.getCmp('numClasses').setValue(MAPVIEW.classes);
Ext.getCmp('colorA_cf').setValue(MAPVIEW.colorLow);
Ext.getCmp('colorB_cf').setValue(MAPVIEW.colorHigh);
+ MAP.setCenter(new OpenLayers.LonLat(MAPVIEW.longitude, MAPVIEW.latitude), MAPVIEW.zoom);
Ext.getCmp('indicatorgroup_cb').setValue(MAPVIEW.indicatorGroupId);
@@ -286,8 +285,8 @@
fn: function() {
if (MAPVIEW) {
Ext.getCmp('map_cb').setValue(MAPVIEW.mapSource);
- MAPVIEW = null;
- choropleth.classify(false);
+ choropleth.classify(false, true);
+ MAPVIEW = false;
}
}
}
@@ -325,6 +324,7 @@
success: function( responseObject ) {
MAPVIEW = Ext.util.JSON.decode(responseObject.responseText).mapView[0];
+ MAP.setCenter(new OpenLayers.LonLat(MAPVIEW.longitude, MAPVIEW.latitude), MAPVIEW.zoom);
MAPSOURCE = MAPVIEW.mapSourceType;
@@ -715,7 +715,7 @@
* the widget isn't ready, or no indicator is specified, or no
* method is specified.
*/
- classify: function(exception) {
+ classify: function(exception, position) {
if (!this.ready) {
Ext.MessageBox.alert('Error', 'Component init not complete');
return;
@@ -753,7 +753,7 @@
MASK.msg = 'Loading data...';
MASK.show();
- loadMapData('choropleth');
+ loadMapData('choropleth', position);
},
/**