dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #01187
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 343: Work in progress on mapview in dashboard
------------------------------------------------------------
revno: 343
committer: Lars Helge Oeverland larshelge@xxxxxxxxx
branch nick: trunk
timestamp: Fri 2009-05-29 15:31:05 +0200
message:
Work in progress on mapview in dashboard
added:
gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewToDashboardAction.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java
dhis-2/dhis-services/dhis-service-user-hibernate/pom.xml
dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/org/hisp/dhis/user/hibernate/UserCredentials.hbm.xml
gis/dhis-web-mapping/pom.xml
gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml
gis/dhis-web-mapping/src/main/resources/xwork.xml
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2009-05-19 15:32:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/UserCredentials.java 2009-05-29 13:31:05 +0000
@@ -35,6 +35,7 @@
import org.hisp.dhis.datamart.DataMartExport;
import org.hisp.dhis.document.Document;
+import org.hisp.dhis.mapping.MapView;
import org.hisp.dhis.olap.OlapURL;
import org.hisp.dhis.report.Report;
import org.hisp.dhis.reporttable.ReportTable;
@@ -77,6 +78,8 @@
private List<ReportTable> dashboardReportTables = new ArrayList<ReportTable>();
+ private List<MapView> dashboardMapViews = new ArrayList<MapView>();
+
// -------------------------------------------------------------------------
// Logic
// -------------------------------------------------------------------------
@@ -146,6 +149,19 @@
}
}
+ public void addMapView( MapView mapView )
+ {
+ if ( !dashboardMapViews.contains( mapView ) )
+ {
+ dashboardMapViews.add( 0, mapView );
+
+ while ( dashboardMapViews.size() > MAX_DASHBOARD_ELEMENTS )
+ {
+ dashboardReportTables.remove( MAX_DASHBOARD_ELEMENTS );
+ }
+ }
+ }
+
// -------------------------------------------------------------------------
// hashCode and equals
// -------------------------------------------------------------------------
@@ -282,4 +298,14 @@
{
this.dashboardReportTables = dashboardReportTables;
}
+
+ public List<MapView> getDashboardMapViews()
+ {
+ return dashboardMapViews;
+ }
+
+ public void setDashboardMapViews( List<MapView> dashboardMapViews )
+ {
+ this.dashboardMapViews = dashboardMapViews;
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-user-hibernate/pom.xml'
--- dhis-2/dhis-services/dhis-service-user-hibernate/pom.xml 2009-04-22 21:31:10 +0000
+++ dhis-2/dhis-services/dhis-service-user-hibernate/pom.xml 2009-05-29 13:31:05 +0000
@@ -40,7 +40,11 @@
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-reporting</artifactId>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-mapping</artifactId>
+ </dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
<artifactId>dhis-support-hibernate</artifactId>
=== modified file 'dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/org/hisp/dhis/user/hibernate/UserCredentials.hbm.xml'
--- dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/org/hisp/dhis/user/hibernate/UserCredentials.hbm.xml 2009-05-19 15:32:14 +0000
+++ dhis-2/dhis-services/dhis-service-user-hibernate/src/main/resources/org/hisp/dhis/user/hibernate/UserCredentials.hbm.xml 2009-05-29 13:31:05 +0000
@@ -66,5 +66,12 @@
class="org.hisp.dhis.reporttable.ReportTable"/>
</list>
+ <list name="dashboardMapViews" table="userrole_mapviews">
+ <key column="userid"/>
+ <list-index column="sort_order" base="0"/>
+ <many-to-many column="mapviewid"
+ class="org.hisp.dhis.mapping.MapView"/>
+ </list>
+
</class>
</hibernate-mapping>
=== modified file 'gis/dhis-web-mapping/pom.xml'
--- gis/dhis-web-mapping/pom.xml 2009-05-25 18:28:22 +0000
+++ gis/dhis-web-mapping/pom.xml 2009-05-29 13:31:05 +0000
@@ -43,6 +43,10 @@
</dependency>
<dependency>
<groupId>org.hisp.dhis</groupId>
+ <artifactId>dhis-service-user-hibernate</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hisp.dhis</groupId>
<artifactId>dhis-service-datamart-default</artifactId>
</dependency>
<dependency>
=== added file 'gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewToDashboardAction.java'
--- gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewToDashboardAction.java 1970-01-01 00:00:00 +0000
+++ gis/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddMapViewToDashboardAction.java 2009-05-29 13:31:05 +0000
@@ -0,0 +1,113 @@
+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 org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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;
+
+/**
+ * @author Lars Helge Overland
+ * @version $Id$
+ */
+public class AddMapViewToDashboardAction
+ implements Action
+{
+ private static final Log log = LogFactory.getLog( AddMapViewToDashboardAction.class );
+
+ // -------------------------------------------------------------------------
+ // 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 );
+
+ credentials.addMapView( mapView );
+
+ userStore.updateUserCredentials( credentials );
+
+ log.info( "Added mapview '" + mapView.getName() + "' to dashboard for user '" + credentials.getUsername() + "'" );
+ }
+ else
+ {
+ log.warn( "Could not add mapview to dashboard, no current user" );
+ }
+
+ return SUCCESS;
+ }
+}
=== modified file 'gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml'
--- gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-05-29 12:05:15 +0000
+++ gis/dhis-web-mapping/src/main/resources/META-INF/dhis/beans.xml 2009-05-29 13:31:05 +0000
@@ -169,7 +169,18 @@
scope="prototype">
<property name="mappingService"
ref="org.hisp.dhis.mapping.MappingService"/>
- </bean>
+ </bean>
+
+ <bean id="org.hisp.dhis.mapping.action.AddMapViewToDashboardAction"
+ class="org.hisp.dhis.mapping.action.AddMapViewToDashboardAction"
+ 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>
<!-- Indicator -->
=== modified file 'gis/dhis-web-mapping/src/main/resources/xwork.xml'
--- gis/dhis-web-mapping/src/main/resources/xwork.xml 2009-05-29 12:05:15 +0000
+++ gis/dhis-web-mapping/src/main/resources/xwork.xml 2009-05-29 13:31:05 +0000
@@ -106,6 +106,10 @@
<action name="getAllMapViewsMin" class="org.hisp.dhis.mapping.action.GetAllMapViewsAction">
<result name="success" type="velocity-json">/dhis-web-mapping/jsonminMapViews.vm</result>
</action>
+
+ <action name="addMapViewToDashboard" class="org.hisp.dhis.mapping.action.AddMapViewToDashboardAction">
+ <result name="success" type="velocity-json">/dhis-web-mapping/void.vm</result>
+ </action>
<!-- Indicator -->
--
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.