dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #00665
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 182: Moving methods from map adapter to map service.
------------------------------------------------------------
revno: 182
committer: Jan Henrik Overland janhenrik.overland@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-04-16 16:10:22 +0200
message:
Moving methods from map adapter to map service.
modified:
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/META-INF/dhis/beans.xml
webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml
=== 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-04-06 18:55:31 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2009-04-16 14:10:22 +0000
@@ -29,6 +29,7 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Set;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
@@ -46,6 +47,13 @@
// Dependencies
// -------------------------------------------------------------------------
+ private MappingService mappingService;
+
+ public void setMappingService( MappingService mappingService )
+ {
+ this.mappingService = mappingService;
+ }
+
private MappingStore mappingStore;
public void setMappingStore( MappingStore mappingStore )
@@ -103,6 +111,62 @@
return mappingStore.getMapsAtLevel( organisationUnitLevel );
}
+ public int addMap( String mapLayerPath, int organisationUnitId, int organisationUnitLevelId, String uniqueColumn,
+ String nameColumn, String longitude, String latitude, int zoom )
+ {
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ OrganisationUnitLevel organisationUnitLevel = organisationUnitService
+ .getOrganisationUnitLevel( organisationUnitLevelId );
+
+ Set<String> staticMapLayerPaths = null;
+
+ Map map = new Map( mapLayerPath, organisationUnit, organisationUnitLevel, uniqueColumn, nameColumn, longitude,
+ latitude, zoom, staticMapLayerPaths );
+
+ return mappingService.addMap( map );
+ }
+
+ public void addOrUpdateMap( String mapLayerPath, int organisationUnitId, int organisationUnitLevelId,
+ String uniqueColumn, String nameColumn, String longitude, String latitude, int zoom )
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ OrganisationUnitLevel organisationUnitLevel = organisationUnitService
+ .getOrganisationUnitLevel( organisationUnitLevelId );
+
+ Set<String> staticMapLayerPaths = null;
+
+ if ( map != null )
+ {
+ map.setOrganisationUnit( organisationUnit );
+ map.setOrganisationUnitLevel( organisationUnitLevel );
+ map.setUniqueColumn( uniqueColumn );
+ map.setNameColumn( nameColumn );
+ map.setLongitude( longitude );
+ map.setLatitude( latitude );
+ map.setZoom( zoom );
+
+ mappingService.updateMap( map );
+ }
+ else
+ {
+ map = new Map( mapLayerPath, organisationUnit, organisationUnitLevel, uniqueColumn, nameColumn, longitude,
+ latitude, zoom, staticMapLayerPaths );
+
+ mappingService.addMap( map );
+ }
+ }
+
+ public void deleteMapByMapLayerPath( String mapLayerPath )
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ mappingService.deleteMap( map );
+ }
+
// -------------------------------------------------------------------------
// MapOrganisationUnitRelation
// -------------------------------------------------------------------------
@@ -157,4 +221,46 @@
return relations;
}
+
+ public int addMapOrganisationUnitRelation( String mapLayerPath, int organisationUnitId, String featureId )
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ MapOrganisationUnitRelation mapOrganisationUnitRelation = new MapOrganisationUnitRelation( map,
+ organisationUnit, featureId );
+
+ return mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelation );
+ }
+
+ public void addOrUpdateMapOrganisationUnitRelation( String mapLayerPath, int organisationUnitId, String featureId )
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitId );
+
+ MapOrganisationUnitRelation mapOrganisationUnitRelation = mappingService.getMapOrganisationUnitRelation( map,
+ organisationUnit );
+
+ if ( mapOrganisationUnitRelation != null )
+ {
+ mapOrganisationUnitRelation.setFeatureId( featureId );
+
+ mappingService.updateMapOrganisationUnitRelation( mapOrganisationUnitRelation );
+ }
+ else
+ {
+ mapOrganisationUnitRelation = new MapOrganisationUnitRelation( map, organisationUnit, featureId );
+
+ mappingService.addMapOrganisationUnitRelation( mapOrganisationUnitRelation );
+ }
+ }
+
+ public Collection<MapOrganisationUnitRelation> getAvailableMapOrganisationUnitRelations( String mapLayerPath )
+ {
+ Map map = mappingService.getMapByMapLayerPath( mapLayerPath );
+
+ return mappingService.getAvailableMapOrganisationUnitRelations( map );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-04-06 18:55:31 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-04-16 14:10:22 +0000
@@ -9,7 +9,9 @@
<bean id="org.hisp.dhis.mapping.MappingService"
class="org.hisp.dhis.mapping.DefaultMappingService">
- <property name="mappingStore"
+ <property name="mappingService"
+ ref="org.hisp.dhis.mapping.MappingService"/>
+ <property name="mappingStore"
ref="org.hisp.dhis.mapping.MappingStore"/>
<property name="organisationUnitService"
ref="org.hisp.dhis.organisationunit.OrganisationUnitService"/>
=== modified file 'webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml'
--- webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml 2009-04-15 15:26:19 +0000
+++ webservice/dhis-webservice-expoze/src/main/resources/dispatcher.xml 2009-04-16 14:10:22 +0000
@@ -1012,7 +1012,7 @@
<request>
<name>addOrUpdateMap</name>
<type>void</type>
- <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>
+ <bean>org.hisp.dhis.mapping.MappingServiceAdapter</bean>
<method>addOrUpdateMap</method>
<parameters>
<parameter>
@@ -1092,7 +1092,7 @@
<request>
<name>deleteMapByMapLayerPath</name>
<type>void</type>
- <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>
+ <bean>org.hisp.dhis.mapping.MappingService</bean>
<method>deleteMapByMapLayerPath</method>
<parameters>
<parameter>
@@ -1105,7 +1105,7 @@
<request>
<name>addOrUpdateMapOrganisationUnitRelation</name>
<type>void</type>
- <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>
+ <bean>org.hisp.dhis.mapping.MappingService</bean>
<method>addOrUpdateMapOrganisationUnitRelation</method>
<parameters>
<parameter>
@@ -1125,7 +1125,7 @@
<request>
<name>getAvailableMapOrganisationUnitRelations</name>
- <bean>org.hisp.dhis.webservice.adapter.mapping.MappingServiceAdapter</bean>
+ <bean>org.hisp.dhis.mapping.MappingService</bean>
<method>getAvailableMapOrganisationUnitRelations</method>
<parameters>
<parameter>
--
Trunk
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.