← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 2760: (GIS) Impl user/system map views.

 

Merge authors:
  Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 2760 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2011-01-26 11:58:22 +0100
message:
  (GIS) Impl user/system map views.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java
  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-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java
  dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java
  dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js
  dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js


--
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/MapView.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2010-11-30 13:04:58 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapView.java	2011-01-26 00:07:38 +0000
@@ -35,6 +35,7 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.User;
 
 /**
  * @author Jan Henrik Overland
@@ -45,6 +46,8 @@
     private int id;
 
     private String name;
+    
+    private User user;
 
     private String featureType;
 
@@ -100,7 +103,7 @@
     {
     }
 
-    public MapView( String name, String featureType, String mapValueType, IndicatorGroup indicatorGroup,
+    public MapView( String name, User user, String featureType, String mapValueType, IndicatorGroup indicatorGroup,
         Indicator indicator, DataElementGroup dataElementGroup, DataElement dataElement, String mapDateType,
         PeriodType periodType, Period period, String startDate, String endDate,
         OrganisationUnit parentOrganisationUnit, OrganisationUnitLevel organisationUnitLevel, String mapLegendType,
@@ -108,6 +111,7 @@
         Integer radiusLow, Integer radiusHigh, String longitude, String latitude, int zoom )
     {
         this.name = name;
+        this.user = user;
         this.featureType = featureType;
         this.mapValueType = mapValueType;
         this.indicatorGroup = indicatorGroup;
@@ -201,6 +205,16 @@
         this.name = name;
     }
 
+    public User getUser()
+    {
+        return user;
+    }
+
+    public void setUser( User user )
+    {
+        this.user = user;
+    }
+
     public String getFeatureType()
     {
         return featureType;

=== 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	2011-01-10 16:07:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2011-01-26 00:07:38 +0000
@@ -129,7 +129,7 @@
 
     void updateMapView( MapView mapView );
 
-    void addOrUpdateMapView( String name, String featureType, String mapValueType, Integer indicatorGroupId,
+    void addOrUpdateMapView( String name, boolean system, String featureType, String mapValueType, Integer indicatorGroupId,
         Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName,
         Integer periodId, String startDate, String endDate, Integer parentOrganisationUnitId,
         Integer organisationUnitLevelId, String mapLegendType, Integer method, Integer classes, String bounds,

=== 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	2010-11-29 15:44:01 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingStore.java	2011-01-26 00:07:38 +0000
@@ -29,6 +29,8 @@
 
 import java.util.Collection;
 
+import org.hisp.dhis.user.User;
+
 /**
  * @author Jan Henrik Overland
  * @version $Id$
@@ -85,9 +87,9 @@
 
     MapView getMapViewByName( String name );
 
-    Collection<MapView> getAllMapViews();
+    Collection<MapView> getAllMapViews( User user );
 
-    Collection<MapView> getMapViewsByFeatureType( String featureType );
+    Collection<MapView> getMapViewsByFeatureType( String featureType, User user );
 
     // -------------------------------------------------------------------------
     // MapLayer

=== 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	2011-01-10 16:07:53 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2011-01-26 00:07:38 +0000
@@ -49,6 +49,8 @@
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
 import org.hisp.dhis.system.util.MathUtils;
+import org.hisp.dhis.user.CurrentUserService;
+import org.hisp.dhis.user.User;
 import org.hisp.dhis.user.UserSettingService;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.Assert;
@@ -129,6 +131,13 @@
     {
         this.systemSettingManager = systemSettingManager;
     }
+    
+    private CurrentUserService currentUserService;
+    
+    public void setCurrentUserService( CurrentUserService currentUserService )
+    {
+        this.currentUserService = currentUserService;
+    }
 
     // -------------------------------------------------------------------------
     // MappingService implementation
@@ -137,7 +146,7 @@
     // -------------------------------------------------------------------------
     // OrganisationUnits
     // -------------------------------------------------------------------------
-    
+
     /**
      * Returns the relevant OrganisationUnits for the given parent identifier
      * and / or level.
@@ -464,13 +473,15 @@
         mappingStore.updateMapView( mapView );
     }
 
-    public void addOrUpdateMapView( String name, String featureType, String mapValueType, Integer indicatorGroupId,
+    public void addOrUpdateMapView( String name, boolean system, String featureType, String mapValueType, Integer indicatorGroupId,
         Integer indicatorId, Integer dataElementGroupId, Integer dataElementId, String periodTypeName,
         Integer periodId, String startDate, String endDate, Integer parentOrganisationUnitId,
         Integer organisationUnitLevel, String mapLegendType, Integer method, Integer classes, String bounds,
         String colorLow, String colorHigh, Integer mapLegendSetId, Integer radiusLow, Integer radiusHigh,
         String longitude, String latitude, int zoom )
     {
+        User user = system ? null : currentUserService.getCurrentUser();
+        
         IndicatorGroup indicatorGroup = null;
 
         Indicator indicator = null;
@@ -508,6 +519,7 @@
         if ( mapView != null )
         {
             mapView.setName( name );
+            mapView.setUser( user );
             mapView.setFeatureType( featureType );
             mapView.setMapValueType( mapValueType );
             mapView.setIndicatorGroup( indicatorGroup );
@@ -538,7 +550,7 @@
         }
         else
         {
-            mapView = new MapView( name, featureType, mapValueType, indicatorGroup, indicator, dataElementGroup,
+            mapView = new MapView( name, user, featureType, mapValueType, indicatorGroup, indicator, dataElementGroup,
                 dataElement, mapDateType, periodType, period, startDate, endDate, parent, level, mapLegendType, method,
                 classes, bounds, colorLow, colorHigh, mapLegendSet, radiusLow, radiusHigh, longitude, latitude, zoom );
 
@@ -571,7 +583,9 @@
 
     public Collection<MapView> getAllMapViews()
     {
-        Collection<MapView> mapViews = mappingStore.getAllMapViews();
+        User user = currentUserService.getCurrentUser();
+        
+        Collection<MapView> mapViews = mappingStore.getAllMapViews( user );
 
         if ( mapViews.size() > 0 )
         {
@@ -587,7 +601,9 @@
 
     public Collection<MapView> getMapViewsByFeatureType( String featureType )
     {
-        Collection<MapView> mapViews = mappingStore.getMapViewsByFeatureType( featureType );
+        User user = currentUserService.getCurrentUser();
+        
+        Collection<MapView> mapViews = mappingStore.getMapViewsByFeatureType( featureType, user );
 
         for ( MapView mapView : mapViews )
         {

=== 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	2011-01-06 04:10:29 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMappingStore.java	2011-01-26 00:07:38 +0000
@@ -38,6 +38,7 @@
 import org.hisp.dhis.mapping.MapLegendSet;
 import org.hisp.dhis.mapping.MapView;
 import org.hisp.dhis.mapping.MappingStore;
+import org.hisp.dhis.user.User;
 
 /**
  * @author Jan Henrik Overland
@@ -231,23 +232,27 @@
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<MapView> getAllMapViews()
+    public Collection<MapView> getAllMapViews( User user )
     {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( MapView.class );
+        
+        criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
 
         return criteria.list();
     }
 
     @SuppressWarnings( "unchecked" )
-    public Collection<MapView> getMapViewsByFeatureType( String featureType )
+    public Collection<MapView> getMapViewsByFeatureType( String featureType, User user )
     {
         Session session = sessionFactory.getCurrentSession();
 
         Criteria criteria = session.createCriteria( MapView.class );
 
         criteria.add( Restrictions.eq( "featureType", featureType ) );
+        
+        criteria.add( Restrictions.or( Restrictions.eq( "user", user ), Restrictions.isNull( "user" ) ) );
 
         return criteria.list();
     }

=== 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	2011-01-07 12:59:06 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2011-01-26 00:07:38 +0000
@@ -28,6 +28,8 @@
 	  ref="org.hisp.dhis.options.SystemSettingManager"/>
 	<property name="aggregatedDataValueService"
 	  ref="org.hisp.dhis.aggregation.AggregatedDataValueService"/>
+    <property name="currentUserService"
+      ref="org.hisp.dhis.user.CurrentUserService"/>
   </bean>
 		
   <!-- Store definitions -->

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2010-11-30 13:04:58 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/org/hisp/dhis/mapping/hibernate/MapView.hbm.xml	2011-01-26 00:07:38 +0000
@@ -11,7 +11,10 @@
 			<generator class="native"/>
 		</id>
 	
-		<property name="name" unique="true"/>
+		<property name="name"/>
+        
+        <many-to-one name="user" class="org.hisp.dhis.user.User" 
+            column="userid" foreign-key="fk_mapview_userid"/>
 		
 		<property name="featureType"/>
 		

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-01-14 16:18:27 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingServiceTest.java	2011-01-26 00:07:38 +0000
@@ -52,6 +52,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.User;
 import org.junit.Test;
 
 /**
@@ -334,7 +335,7 @@
     @Test
     public void testAddGetMapView()
     {
-        MapView mapView = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
@@ -351,7 +352,7 @@
     @Test
     public void testGetDeleteMapViewByName()
     {
-        MapView mapView = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
@@ -368,12 +369,12 @@
     @Test
     public void testGetAllMapViews()
     {
-        MapView mapView1 = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
 
-        MapView mapView2 = new MapView( "MapViewB", OrganisationUnit.FEATURETYPE_POLYGON,
+        MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
@@ -388,18 +389,18 @@
     @Test
     public void testGetMapViewsByFeatureType()
     {
-        MapView mapView1 = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView1 = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "", organisationUnit, organisationUnitLevel,
             MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20, "1", "1", 1 );
 
-        MapView mapView2 = new MapView( "MapViewB", OrganisationUnit.FEATURETYPE_POLYGON,
+        MapView mapView2 = new MapView( "MapViewB", new User(), OrganisationUnit.FEATURETYPE_POLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,
             "2", "2", 1 );
 
-        MapView mapView3 = new MapView( "MapViewC", OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
+        MapView mapView3 = new MapView( "MapViewC", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON,
             MappingService.MAP_VALUE_TYPE_DATAELEMENT, indicatorGroup, indicator, dataElementGroup, dataElement,
             MappingService.MAP_DATE_TYPE_START_END, periodType, period, "", "", organisationUnit,
             organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B", mapLegendSet, 5, 20,

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java	2010-11-30 13:04:58 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/test/java/org/hisp/dhis/mapping/MappingStoreTest.java	2011-01-26 00:07:38 +0000
@@ -43,6 +43,7 @@
 import org.hisp.dhis.period.Period;
 import org.hisp.dhis.period.PeriodService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.user.User;
 import org.junit.Test;
 
 /**
@@ -115,7 +116,7 @@
     @Test
     public void testAddGetMapView()
     {
-        MapView mapView = new MapView( "MapViewA", OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator,
+        MapView mapView = new MapView( "MapViewA", new User(), OrganisationUnit.FEATURETYPE_MULTIPOLYGON, MappingService.MAP_VALUE_TYPE_INDICATOR, indicatorGroup, indicator,
             new DataElementGroup(), new DataElement(), MappingService.MAP_DATE_TYPE_FIXED, periodType, period, "", "",
             organisationUnit, organisationUnitLevel, MappingService.MAPLEGENDSET_TYPE_AUTOMATIC, 1, 1, "", "A", "B",
             mapLegendSet, 5, 20, "1", "1", 1 );

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java	2010-11-30 13:04:58 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/AddOrUpdateMapViewAction.java	2011-01-26 00:07:38 +0000
@@ -59,6 +59,13 @@
     {
         this.name = name;
     }
+    
+    private boolean system;
+
+    public void setSystem( boolean system )
+    {
+        this.system = system;
+    }
 
     private String featureType;
 
@@ -235,7 +242,7 @@
     public String execute()
         throws Exception
     {
-        mappingService.addOrUpdateMapView( name, featureType, mapValueType, indicatorGroupId, indicatorId,
+        mappingService.addOrUpdateMapView( name, system, featureType, mapValueType, indicatorGroupId, indicatorId,
             dataElementGroupId, dataElementId, periodTypeId, periodId, startDate, endDate, parentOrganisationUnitId,
             organisationUnitLevel, mapLegendType, method, classes, bounds, colorLow, colorHigh, mapLegendSetId,
             radiusLow, radiusHigh, longitude, latitude, zoom );

=== 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	2011-01-10 16:07:53 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/resources/struts.xml	2011-01-26 10:26:19 +0000
@@ -178,13 +178,11 @@
 			class="org.hisp.dhis.mapping.action.AddOrUpdateMapViewAction">
 			<result name="success" type="velocity-json">/dhis-web-mapping/void.vm
 			</result>
-            <param name="requiredAuthorities">F_GIS_ADMIN</param>
 		</action>
 
 		<action name="deleteMapView" class="org.hisp.dhis.mapping.action.DeleteMapViewAction">
 			<result name="success" type="velocity-json">/dhis-web-mapping/void.vm
 			</result>
-            <param name="requiredAuthorities">F_GIS_ADMIN</param>
 		</action>
 
 		<action name="getMapView" class="org.hisp.dhis.mapping.action.GetMapViewAction">

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm	2010-11-29 15:44:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapView.vm	2011-01-26 00:07:38 +0000
@@ -2,6 +2,7 @@
   [{
     "id": "$!{object.id}",
     "name": "$!encoder.jsonEncode( ${object.name} )",
+    "userId": "$!{object.user.id}",
     "featureType": "$!encoder.jsonEncode( ${object.featureType} )",
     "mapValueType": "$!encoder.jsonEncode( ${object.mapValueType} )",
     "indicatorGroupId": "$!{object.indicatorGroup.id}",

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm	2010-11-29 15:44:01 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/jsonMapViews.vm	2011-01-26 00:07:38 +0000
@@ -4,6 +4,7 @@
   {
     "id": "$!{mapView.id}",
     "name": "$!encoder.jsonEncode( ${mapView.name} )",
+    "userId": "$!{mapView.user.id}",
     "featureType": "$!encoder.jsonEncode( ${mapView.featureType} )",
     "mapValueType": "$!encoder.jsonEncode( ${mapView.mapValueType} )",
     "indicatorGroupId": "$!{mapView.indicatorGroup.id}",

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-01-24 15:20:31 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/global.js	2011-01-26 00:07:38 +0000
@@ -55,6 +55,8 @@
     map_feature_type_multipolygon: 'MultiPolygon',
     map_feature_type_polygon: 'Polygon',
     map_feature_type_point: 'Point',
+    map_view_access_level_user: 'user',
+    map_view_access_level_system: 'system',
     aggregation_strategy_real_time: 'real_time',
     aggregation_strategy_batch: 'batch',
     

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2011-01-24 15:20:31 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/mapping/script/index.js	2011-01-26 10:56:54 +0000
@@ -30,13 +30,14 @@
     var mapViewStore = new Ext.data.JsonStore({
         url: G.conf.path_mapping + 'getAllMapViews' + G.conf.type,
         root: 'mapViews',
-        fields: [ 'id', 'name', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
+        fields: [ 'id', 'name', 'userId', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
             'mapDateType', 'periodTypeId', 'periodId', 'startDate', 'endDate', 'parentOrganisationUnitId', 'parentOrganisationUnitName',
             'parentOrganisationUnitLevel', 'organisationUnitLevel', 'organisationUnitLevelName', 'mapLegendType', 'method', 'classes',
             'bounds', 'colorLow', 'colorHigh', 'mapLegendSetId', 'radiusLow', 'radiusHigh', 'longitude', 'latitude', 'zoom'
         ],
         autoLoad: false,
         isLoaded: false,
+        sortInfo: {field: 'userId', direction: 'ASC'},
         listeners: {
             'load': G.func.storeLoadListener
         }
@@ -46,12 +47,12 @@
         url: G.conf.path_mapping + 'getMapViewsByFeatureType' + G.conf.type,
         baseParams: {featureType: G.conf.map_feature_type_multipolygon},
         root: 'mapViews',
-        fields: [ 'id', 'name', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
+        fields: [ 'id', 'name', 'userId', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
             'mapDateType', 'periodTypeId', 'periodId', 'startDate', 'endDate', 'parentOrganisationUnitId', 'parentOrganisationUnitName',
             'parentOrganisationUnitLevel', 'organisationUnitLevel', 'organisationUnitLevelName', 'mapLegendType', 'method', 'classes',
             'bounds', 'colorLow', 'colorHigh', 'mapLegendSetId', 'longitude', 'latitude', 'zoom'
         ],
-        sortInfo: {field: 'name', direction: 'ASC'},
+        sortInfo: {field: 'userId', direction: 'ASC'},
         autoLoad: false,
         isLoaded: false,
         listeners: {
@@ -63,12 +64,12 @@
         url: G.conf.path_mapping + 'getMapViewsByFeatureType' + G.conf.type,
         baseParams: {featureType: G.conf.map_feature_type_point},
         root: 'mapViews',
-        fields: [ 'id', 'name', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
+        fields: [ 'id', 'name', 'userId', 'featureType', 'mapValueType', 'indicatorGroupId', 'indicatorId', 'dataElementGroupId', 'dataElementId',
             'mapDateType', 'periodTypeId', 'periodId', 'startDate', 'endDate', 'parentOrganisationUnitId', 'parentOrganisationUnitName',
             'parentOrganisationUnitLevel', 'organisationUnitLevel', 'organisationUnitLevelName', 'mapLegendType', 'method', 'classes',
             'bounds', 'colorLow', 'colorHigh', 'mapLegendSetId', 'radiusLow', 'radiusHigh', 'longitude', 'latitude', 'zoom'
         ],
-        sortInfo: {field: 'name', direction: 'ASC'},
+        sortInfo: {field: 'userId', direction: 'ASC'},
         autoLoad: false,
         isLoaded: false,
         listeners: {
@@ -418,7 +419,7 @@
 		layout: 'fit',
         closeAction: 'hide',
 		width: G.conf.window_width,
-        height: 180,
+        height: 207,
         items: [
             {
                 xtype: 'form',
@@ -434,6 +435,15 @@
                         width: G.conf.combo_width_fieldset,
                         autoCreate: {tag: 'input', type: 'text', size: '20', autocomplete: 'off', maxlength: '35'}
                     },
+                    {
+                        xtype: 'checkbox',
+                        id: 'favoritesystem_chb',
+                        disabled: !G.user.isAdmin,
+                        fieldLabel: 'System',
+                        labelSeparator: G.conf.labelseparator,
+                        editable: false
+                    },
+                        
                     {html: '<div class="window-p"></div>'},
                     {html: '<div class="window-info">Delete / Add favorite to dashboard</div>'},
                     {
@@ -466,25 +476,24 @@
 				text: G.i18n.register,
 				handler: function() {
 					var vn = Ext.getCmp('favoritename_tf').getValue();
+                    var params;
                     
                     if (!vn) {
 						Ext.message.msg(false, G.i18n.form_is_not_complete);
 						return;
 					}
                     
-                    var formValues;
-                    
                     if (G.vars.activePanel.isPolygon()) {
                         if (!choropleth.formValidation.validateForm(true)) {
                             return;
                         }
-                        formValues = choropleth.formValues.getAllValues.call(choropleth);
+                        params = choropleth.formValues.getAllValues.call(choropleth);
                     }
                     else if (G.vars.activePanel.isPoint()) {
                         if (!symbol.formValidation.validateForm(true)) {
                             return;
                         }
-                        formValues = symbol.formValues.getAllValues.call(symbol);
+                        params = symbol.formValues.getAllValues.call(symbol);
                     }
                     
                     if (G.stores.mapView.findExact('name', vn) !== -1) {
@@ -492,46 +501,24 @@
                         return;
                     }
                     
+                    params.name = vn;
+                    params.system = Ext.getCmp('favoritesystem_chb').getValue();
+                    
                     Ext.Ajax.request({
                         url: G.conf.path_mapping + 'addOrUpdateMapView' + G.conf.type,
                         method: 'POST',
-                        params: {
-                            name: vn,
-							featureType: formValues.featureType,
-                            mapValueType: formValues.mapValueType,
-                            indicatorGroupId: formValues.indicatorGroupId,
-                            indicatorId: formValues.indicatorId,
-                            dataElementGroupId: formValues.dataElementGroupId,
-                            dataElementId: formValues.dataElementId,
-                            periodTypeId: formValues.periodTypeId,
-                            periodId: formValues.periodId,
-                            startDate: formValues.startDate,
-                            endDate: formValues.endDate,
-                            parentOrganisationUnitId: formValues.parentOrganisationUnitId,
-                            organisationUnitLevel: formValues.organisationUnitLevel,
-                            mapLegendType: formValues.mapLegendType,
-                            method: formValues.method,
-                            classes: formValues.classes,
-                            bounds: formValues.bounds,
-                            colorLow: formValues.colorLow,
-                            colorHigh: formValues.colorHigh,
-                            mapLegendSetId: formValues.mapLegendSetId,
-                            radiusLow: formValues.radiusLow,
-                            radiusHigh: formValues.radiusHigh,
-                            longitude: formValues.longitude,
-                            latitude: formValues.latitude,
-                            zoom: formValues.zoom
-                        },
+                        params: params,
                         success: function(r) {
                             Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + vn + '</span> ' + G.i18n.registered);
                             G.stores.mapView.load();
-                            if (formValues.featureType == G.conf.map_feature_type_multipolygon) {
+                            if (params.featureType == G.conf.map_feature_type_multipolygon) {
 								G.stores.polygonMapView.load();
 							}
-							else if (formValues.featureType == G.conf.map_feature_type_multipolygon) {
+							else if (params.featureType == G.conf.map_feature_type_multipolygon) {
 								G.stores.pointMapView.load();
 							}
                             Ext.getCmp('favoritename_tf').reset();
+                            Ext.getCmp('favoritesystem_chb').reset();
                         }
                     });
 				}
@@ -545,29 +532,44 @@
 				handler: function() {
 					var v = Ext.getCmp('favorite_cb').getValue();
 					var rw = Ext.getCmp('favorite_cb').getRawValue();
-					
-                    if (!v) {
-						Ext.message.msg(false, G.i18n.please_select_a_map_view);
-						return;
-					}
-					
-					Ext.Ajax.request({
-						url: G.conf.path_mapping + 'deleteMapView' + G.conf.type,
-						method: 'POST',
-						params: {id: v},
-						success: function(r) {
-							Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + rw + '</span> ' + G.i18n.deleted);
-                            G.stores.polygonMapView.load();
-							G.stores.pointMapView.load();
-                            Ext.getCmp('favorite_cb').clearValue();
-                            if (v == choropleth.form.findField('mapview').getValue()) {
-                                choropleth.form.findField('mapview').clearValue();
-                            }
-                            if (v == symbol.form.findField('mapview').getValue()) {
-                                symbol.form.findField('mapview').clearValue();
-                            }
-						}
-					});
+                    var userId = G.stores.mapView.getAt(G.stores.mapView.findExact('id', v)).data.userId;
+                    
+                    if (userId || G.user.isAdmin) {
+                        if (!v) {
+                            Ext.message.msg(false, G.i18n.please_select_a_map_view);
+                            return;
+                        }
+                        
+                        Ext.Ajax.request({
+                            url: G.conf.path_mapping + 'deleteMapView' + G.conf.type,
+                            method: 'POST',
+                            params: {id: v},
+                            success: function(r) {
+                                Ext.message.msg(true, G.i18n.favorite + ' <span class="x-msg-hl">' + rw + '</span> ' + G.i18n.deleted);
+                                Ext.getCmp('favorite_cb').clearValue();
+                                
+                                var featureType = G.stores.mapView.getAt(G.stores.mapView.findExact('id', v)).data.featureType;
+                                if (featureType == G.conf.map_feature_type_multipolygon) {
+                                    G.stores.polygonMapView.load();
+                                }
+                                else if (featureType == G.conf.map_feature_type_point) {
+                                    G.stores.pointMapView.load();
+                                }
+                                
+                                G.stores.mapView.load();
+                                
+                                if (v == choropleth.form.findField('mapview').getValue()) {
+                                    choropleth.form.findField('mapview').clearValue();
+                                }
+                                if (v == symbol.form.findField('mapview').getValue()) {
+                                    symbol.form.findField('mapview').clearValue();
+                                }
+                            }
+                        });
+                    }
+                    else {
+                        Ext.message.msg(false, 'Access denied');
+                    }
 				}
 			},
             {
@@ -2313,7 +2315,6 @@
 	var favoritesButton = new Ext.Button({
 		iconCls: 'icon-favorite',
 		tooltip: G.i18n.favorite_map_views,
-		disabled: !G.user.isAdmin,
 		handler: function() {
 			var x = Ext.getCmp('center').x + 15;
 			var y = Ext.getCmp('center').y + 41;    

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-01-20 23:18:16 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Choropleth.js	2011-01-26 00:07:38 +0000
@@ -96,7 +96,7 @@
 					classes: this.mapView.classes || this.legend.classes
 				};
 				
-				G.vars.parameter = false;
+				G.vars.parameter.id = false;
 				G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
 				
 				function mapViewStoreCallback() {

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-01-21 04:30:30 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/webapp/dhis-web-mapping/resources/mapfish/widgets/geostat/Symbol.js	2011-01-26 00:07:38 +0000
@@ -95,7 +95,8 @@
 					method: this.mapView.method || this.legend.method,
 					classes: this.mapView.classes || this.legend.classes
 				};
-
+                
+                G.vars.parameter.id = false;
 				G.vars.map.setCenter(new OpenLayers.LonLat(this.mapView.longitude, this.mapView.latitude), this.mapView.zoom);
 				
 				function mapViewStoreCallback() {