dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19672
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8682: Web api, impl POST of map legend sets
------------------------------------------------------------
revno: 8682
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-10-24 11:11:47 +0200
message:
Web api, impl POST of map legend sets
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.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-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java
--
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/MapLegendSet.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-10-21 14:18:05 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapLegendSet.java 2012-10-24 09:11:47 +0000
@@ -52,6 +52,8 @@
public class MapLegendSet
extends BaseIdentifiableObject
{
+ //TODO remove type, move indicator/data element to respective objects
+
private String type;
private String symbolizer;
=== 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-05 16:00:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2012-10-24 09:11:47 +0000
@@ -90,6 +90,8 @@
void addOrUpdateMapLegend( String name, Double startValue, Double endValue, String color, String image );
+ int addMapLegend( MapLegend mapLegend );
+
void deleteMapLegend( MapLegend legend );
MapLegend getMapLegend( int id );
=== 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 2012-10-05 16:00:19 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2012-10-24 09:11:47 +0000
@@ -299,6 +299,11 @@
}
}
+ public int addMapLegend( MapLegend mapLegend )
+ {
+ return mapLegendStore.save( mapLegend );
+ }
+
public void deleteMapLegend( MapLegend mapLegend )
{
mapLegendStore.delete( mapLegend );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java 2012-10-24 08:31:40 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapLegendSetController.java 2012-10-24 09:11:47 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.api.controller.AbstractCrudController;
import org.hisp.dhis.api.utils.ContextUtils;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
+import org.hisp.dhis.mapping.MapLegend;
import org.hisp.dhis.mapping.MapLegendSet;
import org.hisp.dhis.mapping.MappingService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -58,13 +59,18 @@
@Override
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
- @PreAuthorize( "hasRole('F_GIS_ADMIN')" )
+ @PreAuthorize( "hasRole('F_GIS_ADMIN') or hasRole('ALL')" )
public void postJsonObject( HttpServletResponse response, HttpServletRequest request, InputStream input ) throws Exception
{
MapLegendSet legendSet = JacksonUtils.fromJson( input, MapLegendSet.class );
+ for ( MapLegend legend : legendSet.getMapLegends() )
+ {
+ mappingService.addMapLegend( legend );
+ }
+
mappingService.addMapLegendSet( legendSet );
- ContextUtils.createdResponse( response, "Mal legend set created", RESOURCE_PATH + "/" + legendSet.getUid() );
+ ContextUtils.createdResponse( response, "Map legend set created", RESOURCE_PATH + "/" + legendSet.getUid() );
}
}