← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 237: Added support methods for Map, MapLegendSet

 

------------------------------------------------------------
revno: 237
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Thu 2009-04-23 19:07:39 +0200
message:
  Added support methods for Map, MapLegendSet
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
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java
  dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java
  docs/Technical Architecture DHIS 2.doc
  gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm

=== 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-04-23 13:08:41 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-04-23 17:07:39 +0000
@@ -38,6 +38,8 @@
  */
 public interface MappingService
 {
+    String ID = MappingService.class.getName();
+    
     // -------------------------------------------------------------------------
     // Map
     // -------------------------------------------------------------------------
@@ -251,6 +253,8 @@
     
     int addMapLegendSet( MapLegendSet legendSet );
     
+    void updateMapLegendSet( MapLegendSet legendSet );
+    
     void deleteMapLegendSet( MapLegendSet legendSet );
     
     MapLegendSet getMapLegendSet( int id );

=== 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-04-21 16:40:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2009-04-23 17:07:39 +0000
@@ -38,6 +38,8 @@
  */
 public interface MappingStore
 {
+    String ID = MappingStore.class.getName();
+    
     // -------------------------------------------------------------------------
     // Map
     // -------------------------------------------------------------------------
@@ -168,6 +170,8 @@
     
     int addMapLegendSet( MapLegendSet legendSet );
     
+    void updateMapLegendSet( MapLegendSet legendSet );
+    
     void deleteMapLegendSet( MapLegendSet legendSet );
     
     MapLegendSet getMapLegendSet( 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	2009-04-23 13:58:27 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2009-04-23 17:07:39 +0000
@@ -272,6 +272,11 @@
         return mappingStore.addMapLegendSet( legendSet );
     }
     
+    public void updateMapLegendSet( MapLegendSet legendSet )
+    {
+        mappingStore.updateMapLegendSet( legendSet );
+    }
+    
     public void deleteMapLegendSet( MapLegendSet legendSet )
     {
         mappingStore.deleteMapLegendSet( legendSet );

=== 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-04-21 16:40:40 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2009-04-23 17:07:39 +0000
@@ -45,7 +45,6 @@
  * @author Jan Henrik Overland
  * @version $Id$
  */
-
 public class HibernateMappingStore
     implements MappingStore
 {
@@ -202,6 +201,13 @@
         return (Integer) session.save( legendSet );
     }
     
+    public void updateMapLegendSet( MapLegendSet legendSet )
+    {
+        Session session = sessionManager.getCurrentSession();
+        
+        session.update( legendSet );
+    }
+    
     public void deleteMapLegendSet( MapLegendSet legendSet )
     {
         Session session = sessionManager.getCurrentSession();

=== 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-21 16:52:52 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-04-23 17:07:39 +0000
@@ -2,10 +2,9 @@
 <beans xmlns="http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>
-  
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd";>  
 
-	<!-- Service definitions -->
+  <!-- Service definitions -->
 
   <bean id="org.hisp.dhis.mapping.MappingService"
     class="org.hisp.dhis.mapping.DefaultMappingService">
@@ -17,7 +16,7 @@
       ref="org.hisp.dhis.indicator.IndicatorService"/>
   </bean>
 		
-	<!-- Store definitions -->
+  <!-- Store definitions -->
 
   <bean id="org.hisp.dhis.mapping.MappingStore"
     class="org.hisp.dhis.mapping.hibernate.HibernateMappingStore">
@@ -25,7 +24,7 @@
       ref="org.hisp.dhis.hibernate.HibernateSessionManager"/>
   </bean>
 
-	<!-- AOP transaction definitions -->
+  <!-- AOP transaction definitions -->
 	
   <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
     <property name="advice" ref="readOnlyTransactionInterceptor"/>
@@ -47,7 +46,27 @@
     </property>
   </bean>
 
-	<!-- Deletion AOP definitions -->
+  <!-- DeletionHandlers -->
+    
+  <bean id="org.hisp.dhis.mapping.MapDeletionHandler"
+    class="org.hisp.dhis.mapping.MapDeletionHandler">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+    
+  <bean id="org.hisp.dhis.mapping.MapLegendSetDeletionHandler"
+    class="org.hisp.dhis.mapping.MapLegendSetDeletionHandler">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+    
+  <bean id="org.hisp.dhis.mapping.MapOrganisationUnitRelationDeletionHandler"
+    class="org.hisp.dhis.mapping.MapOrganisationUnitRelationDeletionHandler">
+    <property name="mappingService"
+      ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+    
+  <!-- Deletion AOP definitions -->
   
   <bean class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
     <property name="advice" ref="deletionInterceptor"/>
@@ -58,4 +77,18 @@
     </property>
   </bean>
 
-</beans>
\ No newline at end of file
+  <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
+    <property name="targetObject" ref="org.hisp.dhis.system.deletion.DeletionManager"/>
+    <property name="targetMethod" value="addDeletionHandlers"/>
+    <property name="arguments">
+      <list>
+        <list>
+          <ref local="org.hisp.dhis.mapping.MapDeletionHandler"/>
+          <ref local="org.hisp.dhis.mapping.MapLegendSetDeletionHandler"/>
+          <ref local="org.hisp.dhis.mapping.MapOrganisationUnitRelationDeletionHandler"/>
+        </list>
+      </list>
+    </property>
+  </bean>
+  
+</beans>

=== modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2009-03-07 13:10:38 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java	2009-04-23 17:07:39 +0000
@@ -49,6 +49,8 @@
 import org.hisp.dhis.indicator.Indicator;
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.minmax.MinMaxDataElement;
 import org.hisp.dhis.olap.OlapURL;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
@@ -422,4 +424,22 @@
     {
         return true;
     }
+    
+    public void deleteMap( Map map )
+    {   
+    }
+    
+    public boolean allowDeleteMap( Map map )
+    {
+        return true;
+    }
+    
+    public void deleteMapLegendSet( MapLegendSet mapLegendSet )
+    {   
+    }
+    
+    public boolean allowDeleteMapLegendSet( MapLegendSet mapLegendSet )
+    {
+        return true;
+    }
 }

=== modified file 'dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java'
--- dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2009-03-19 12:56:27 +0000
+++ dhis-2/dhis-support/dhis-support-test/src/main/java/org/hisp/dhis/DhisConvenienceTest.java	2009-04-23 17:07:39 +0000
@@ -62,10 +62,14 @@
 import org.hisp.dhis.indicator.IndicatorGroup;
 import org.hisp.dhis.indicator.IndicatorService;
 import org.hisp.dhis.indicator.IndicatorType;
+import org.hisp.dhis.mapping.Map;
+import org.hisp.dhis.mapping.MapLegendSet;
+import org.hisp.dhis.mapping.MappingService;
 import org.hisp.dhis.organisationunit.OrganisationUnit;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
 import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
+import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
@@ -129,7 +133,9 @@
     protected DataValueService dataValueService;
     
     protected ResourceTableService resourceTableService;
-    
+        
+    protected MappingService mappingService;
+        
     static
     {
         Calendar calendar = Calendar.getInstance();
@@ -641,6 +647,40 @@
         
         return importDataValue;
     }
+    
+    protected static Map createMap( char uniqueCharacter, OrganisationUnit unit, OrganisationUnitLevel level )
+    {
+        Map map = new Map();
+        
+        map.setName( "Map" + uniqueCharacter );
+        map.setOrganisationUnit( unit );
+        map.setOrganisationUnitLevel( level );
+        map.setMapLayerPath( "MapLayerPath" + uniqueCharacter );
+        map.setUniqueColumn( "UniqueColumn" + uniqueCharacter );
+        map.setNameColumn( "NameColumn" + uniqueCharacter );
+        map.setLongitude( "Longitude" + uniqueCharacter );
+        map.setLatitude( "Latitude" + uniqueCharacter );
+        map.setZoom( 1 );
+        map.setStaticMapLayerPaths( new HashSet<String>() );
+        
+        return map;
+    }
+    
+    protected static MapLegendSet createMapLegendSet( char uniqueCharacter, Indicator... indicators )
+    {
+        MapLegendSet legendSet = new MapLegendSet();
+        
+        legendSet.setName( "MapLegendSet" + uniqueCharacter );
+        legendSet.setColorLow( "ColorLow" + uniqueCharacter );
+        legendSet.setColorHigh( "ColorHigh" + uniqueCharacter );
+        
+        for ( Indicator indicator : indicators )
+        {
+            legendSet.getIndicators().add( indicator );
+        }
+        
+        return legendSet;
+    }
 
     // -------------------------------------------------------------------------
     // Supportive methods

=== modified file 'docs/Technical Architecture DHIS 2.doc'
Binary files docs/Technical Architecture DHIS 2.doc	2009-04-03 13:27:40 +0000 and docs/Technical Architecture DHIS 2.doc	2009-04-23 17:07:39 +0000 differ
=== modified file 'gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm'
--- gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm	2009-04-22 16:10:50 +0000
+++ gis/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonminMapLegendSets.vm	2009-04-23 17:07:39 +0000
@@ -3,7 +3,7 @@
 #foreach( $legendSet in $object )
   {
     "id": $!{legendSet.id},
-    "name": "$!encoder.jsEncode( ${legendSet.name} )",
+    "name": "$!encoder.jsEncode( ${legendSet.name} )"
   }#if( $velocityCount < $size ),#end
 #end
 ] }
\ No newline at end of file



--
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.