← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 344: Work in progress on mapview in dashboard

 

------------------------------------------------------------
revno: 344
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-05-29 16:06:39 +0200
message:
  Work in progress on mapview in dashboard
added:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveMapViewAction.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/map_view.vm
modified:
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveDocumentAction.java
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveDocumentAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveDocumentAction.java	2009-03-08 06:36:12 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveDocumentAction.java	2009-05-29 14:06:39 +0000
@@ -43,7 +43,7 @@
 public class RemoveDocumentAction
     implements Action
 {
- // -------------------------------------------------------------------------
+    // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
     

=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveMapViewAction.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveMapViewAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveMapViewAction.java	2009-05-29 14:06:39 +0000
@@ -0,0 +1,73 @@
+package org.hisp.dhis.dashboard.action;
+
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.mapping.MappingService;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserStore;
+
+import com.opensymphony.xwork.Action;
+
+public class RemoveMapViewAction
+    implements Action
+{
+ // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+    
+    private CurrentUserService currentUserService;
+    
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+    
+    private UserStore userStore;
+    
+    public void setUserStore( UserStore userStore )
+    {
+        this.userStore = userStore;
+    }
+    
+    private MappingService mappingService;
+
+    public void setMappingService( MappingService mappingService )
+    {
+        this.mappingService = mappingService;
+    }
+
+    // -------------------------------------------------------------------------
+    // Input
+    // -------------------------------------------------------------------------
+
+    private Integer id;
+
+    public void setId( Integer id )
+    {
+        this.id = id;
+    }
+    
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    public String execute()
+    {
+        User user = currentUserService.getCurrentUser();
+        
+        if ( user != null )
+        {
+            UserCredentials credentials = userStore.getUserCredentials( user );
+            
+            MapView mapView = mappingService.getMapView( id );
+            
+            if ( credentials.getDashboardMapViews().remove( mapView ) )
+            {
+                userStore.updateUserCredentials( credentials );
+            }
+        }
+        
+        return SUCCESS;
+    }
+}

=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/provider/MapViewContentProvider.java	2009-05-29 14:06:39 +0000
@@ -0,0 +1,93 @@
+package org.hisp.dhis.dashboard.provider;
+
+/*
+ * 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.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.hisp.dhis.mapping.MapView;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
+import org.hisp.dhis.user.UserCredentials;
+import org.hisp.dhis.user.UserStore;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class MapViewContentProvider
+    implements ContentProvider
+{
+    // -------------------------------------------------------------------------
+    // Dependencies
+    // -------------------------------------------------------------------------
+
+    private CurrentUserService currentUserService;
+
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
+    
+    private UserStore userStore;
+
+    public void setUserStore( UserStore userStore )
+    {
+        this.userStore = userStore;
+    }
+    
+    private String key;
+    
+    public void setKey( String key )
+    {
+        this.key = key;
+    }
+
+    // -------------------------------------------------------------------------
+    // ContentProvider implementation
+    // -------------------------------------------------------------------------
+
+    public Map<String, Object> provide()
+    {
+        Map<String, Object> content = new HashMap<String, Object>();
+
+        User user = currentUserService.getCurrentUser();
+        
+        if ( user != null )
+        {
+            UserCredentials credentials = userStore.getUserCredentials( user );
+            
+            List<MapView> mapViews = credentials.getDashboardMapViews();
+            
+            content.put( key, mapViews );
+        }
+        
+        return content;
+    }
+}

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2009-05-19 15:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/META-INF/dhis/beans.xml	2009-05-29 14:06:39 +0000
@@ -35,6 +35,13 @@
     <property name="key" value="reportTables"/>
   </bean>
     
+  <bean id="mapViewContentProvider"
+    class="org.hisp.dhis.dashboard.provider.MapViewContentProvider">
+    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+    <property name="userStore" ref="org.hisp.dhis.user.UserStore"/>
+    <property name="key" value="mapViews"/>
+  </bean>
+  
   <bean id="olapUrlContentProvider"
     class="org.hisp.dhis.dashboard.provider.OlapUrlContentProvider">
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
@@ -72,6 +79,10 @@
           <ref local="reportTableContentProvider"/>
         </entry>
         <entry>
+          <key><value>map_view</value></key>
+          <ref local="mapViewContentProvider"/>
+        </entry>
+        <entry>
           <key><value>olap_url</value></key>
           <ref local="olapUrlContentProvider"/>
         </entry>
@@ -150,4 +161,12 @@
     <property name="reportTableService" ref="org.hisp.dhis.reporttable.ReportTableService"/>
   </bean>
   
+  <bean id="org.hisp.dhis.dashboard.action.RemoveMapViewAction"
+    class="org.hisp.dhis.dashboard.action.RemoveMapViewAction"
+    scope="prototype">
+    <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService"/>
+    <property name="userStore" ref="org.hisp.dhis.user.UserStore"/>
+    <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService"/>
+  </bean>
+  
 </beans>

=== modified file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2009-05-19 15:32:14 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/resources/org/hisp/dhis/dashboard/i18n_module.properties	2009-05-29 14:06:39 +0000
@@ -12,6 +12,7 @@
 data_mart_export= Data mart exports
 report_table= Report tables
 olap_url= OLAP URLs
+map_view = Map views
 
 this_is_a_link_area = This is a link area
 this_is_a_chart_area = This is a chart area
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/map_view.vm'
--- dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/map_view.vm	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/webapp/dhis-web-dashboard-integration/map_view.vm	2009-05-29 14:06:39 +0000
@@ -0,0 +1,17 @@
+
+<table class="contentProviderTable">
+    <tr>
+        <th colspan="2">$i18n.getString( "map_view" )</th>
+    </tr>
+    #foreach ( $view in $mapViews )
+    <tr>
+        <td>
+            <a href="javascript:window.location.href='../dhis-web-mapping/geostat/index.html?view=$view.id'">$encoder.htmlEncode( $view.name )</a>
+        </td>
+        <td style="width:16px">
+            <a href="javascript:window.location.href='removeMapView.action?id=$view.id'" title="$i18n.getString( 'remove' )">
+            <img src="../images/close.png" alt="$i18n.getString( 'remove' )"></a>
+        </td>
+    </tr>
+    #end
+</table>



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