← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 654: Added function for retrieving files in external GIS folder.

 

------------------------------------------------------------
revno: 654
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Wed 2009-09-09 17:59:40 +0200
message:
  Added function for retrieving files in external GIS folder.
added:
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFilesAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonGeoJsonFiles.vm
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLegendSetAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapsByTypeAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml


--
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/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-09-08 20:33:48 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2009-09-09 15:59:40 +0000
@@ -40,6 +40,8 @@
 {
     final String ID = MappingService.class.getName();
 
+    final String GIS_DIR = "gis";
+
     final String KEY_MAP_SOURCE_TYPE = "mapSource";
 
     final String MAP_SOURCE_TYPE_DATABASE = "database";

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLegendSetAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLegendSetAction.java	2009-09-08 20:33:48 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapLegendSetAction.java	2009-09-09 15:59:40 +0000
@@ -27,9 +27,6 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.Collection;
-import java.util.HashSet;
-
 import org.hisp.dhis.mapping.MappingService;
 
 import com.opensymphony.xwork2.Action;

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java	2009-09-09 10:25:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonAction.java	2009-09-09 15:59:40 +0000
@@ -30,6 +30,7 @@
 import java.io.InputStream;
 
 import org.hisp.dhis.external.location.LocationManager;
+import org.hisp.dhis.mapping.MappingService;
 
 import com.opensymphony.xwork2.Action;
 
@@ -40,8 +41,6 @@
 public class GetGeoJsonAction
     implements Action
 {
-    private static final String GIS_DIR = "gis";
-
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
@@ -82,7 +81,7 @@
     public String execute()
         throws Exception
     {        
-        inputStream = locationManager.getInputStream( name, GIS_DIR );
+        inputStream = locationManager.getInputStream( name, MappingService.GIS_DIR );
         
         return SUCCESS;
     }

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFilesAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFilesAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetGeoJsonFilesAction.java	2009-09-09 15:59:40 +0000
@@ -0,0 +1,84 @@
+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.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+import org.hisp.dhis.external.location.LocationManager;
+import org.hisp.dhis.mapping.MappingService;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class GetGeoJsonFilesAction
+    implements Action
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private LocationManager locationManager;
+
+    public void setLocationManager( LocationManager locationManager )
+    {
+        this.locationManager = locationManager;
+    }
+
+    // -------------------------------------------------------------------------
+    // Output
+    // -------------------------------------------------------------------------
+
+    private List<String> object;
+
+    public List<String> getObject()
+    {
+        return object;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+        throws Exception
+    {
+        File dir = locationManager.getFileForWriting( MappingService.GIS_DIR );
+        
+        if ( dir != null && dir.list() != null )
+        {
+            object = Arrays.asList( dir.list() );
+        }
+        
+        return SUCCESS;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapsByTypeAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapsByTypeAction.java	2009-09-06 10:39:18 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetMapsByTypeAction.java	2009-09-09 15:59:40 +0000
@@ -28,7 +28,7 @@
  */
 
 import java.util.ArrayList;
-import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import org.hisp.dhis.mapping.Map;
@@ -37,8 +37,6 @@
 
 import com.opensymphony.xwork2.Action;
 
-import java.util.Collections;
-
 /**
  * @author Jan Henrik Overland
  * @version $Id$

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-09-09 10:25:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml	2009-09-09 15:59:40 +0000
@@ -313,4 +313,11 @@
       ref="org.hisp.dhis.external.location.LocationManager"/>  
   </bean>
   
+  <bean id="org.hisp.dhis.mapping.action.GetGeoJsonFilesAction"
+    class="org.hisp.dhis.mapping.action.GetGeoJsonFilesAction"
+    scope="prototype">
+    <property name="locationManager"
+      ref="org.hisp.dhis.external.location.LocationManager"/>  
+  </bean>
+  
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2009-09-09 10:27:22 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2009-09-09 15:59:40 +0000
@@ -199,5 +199,9 @@
       </result>
     </action>    
       
+    <action name="getGeoJsonFiles" class="org.hisp.dhis.mapping.action.GetGeoJsonFilesAction">
+      <result name="success" type="velocity">/dhis-web-mapping/jsonGeoJsonFiles.vm</result>
+    </action>
+      
   </package>
 </struts>

=== added file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonGeoJsonFiles.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonGeoJsonFiles.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonGeoJsonFiles.vm	2009-09-09 15:59:40 +0000
@@ -0,0 +1,6 @@
+#set( $size = $object.size() )
+{ "files": [
+#foreach ( $file in $object )
+  "$!{file}"#if( $velocityCount < $size ),#end
+#end
+] }
\ No newline at end of file