← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6810: GIS fixed bug, map view list should only contain system views and views made by current user

 

------------------------------------------------------------
revno: 6810
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2012-04-29 20:04:08 +0200
message:
  GIS fixed bug, map view list should only contain system views and views made by current user
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.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/HibernateMapViewStore.java
  dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml
  dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java


--
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/MapViewStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MapViewStore.java	2012-04-29 18:04:08 +0000
@@ -40,6 +40,8 @@
 {
     String ID = MapViewStore.class.getName();
 
+    Collection<MapView> getSystemAndUserMapViews( User user );
+    
     Collection<MapView> getMapViewsByMapSourceType( String mapSourceType );
 
     Collection<MapView> getMapViewsByFeatureType( String featureType, User user );

=== 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	2012-03-19 22:10:02 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java	2012-04-29 18:04:08 +0000
@@ -152,6 +152,8 @@
     MapView getIndicatorLastYearMapView( String indicatorUid, String organisationUnitUid, int level );
 
     Collection<MapView> getAllMapViews();
+    
+    Collection<MapView> getSystemAndUserMapViews();
 
     Collection<MapView> getMapViewsByFeatureType( String featureType );
 

=== 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	2012-03-26 13:00:42 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java	2012-04-29 18:04:08 +0000
@@ -27,6 +27,10 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
 import org.hisp.dhis.aggregation.AggregatedDataValueService;
 import org.hisp.dhis.aggregation.AggregatedMapValue;
 import org.hisp.dhis.configuration.ConfigurationService;
@@ -47,13 +51,8 @@
 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 java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
 /**
  * @author Jan Henrik Overland
  */
@@ -121,13 +120,6 @@
         this.periodService = periodService;
     }
 
-    private UserSettingService userSettingService;
-
-    public void setUserSettingService( UserSettingService userSettingService )
-    {
-        this.userSettingService = userSettingService;
-    }
-
     private AggregatedDataValueService aggregatedDataValueService;
 
     public void setAggregatedDataValueService( AggregatedDataValueService aggregatedDataValueService )
@@ -569,10 +561,15 @@
         return mapView;
     }
 
+    public Collection<MapView> getSystemAndUserMapViews()
+    {
+        User user = currentUserService.getCurrentUser();
+        
+        return mapViewStore.getSystemAndUserMapViews( user );
+    }
+    
     public Collection<MapView> getAllMapViews()
     {
-        User user = currentUserService.getCurrentUser();
-
         Collection<MapView> mapViews = mapViewStore.getAll();
 
         if ( mapViews.size() > 0 )

=== modified file 'dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java'
--- dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/java/org/hisp/dhis/mapping/hibernate/HibernateMapViewStore.java	2012-04-29 18:04:08 +0000
@@ -45,6 +45,14 @@
     implements MapViewStore
 {
     @SuppressWarnings( "unchecked" )
+    public Collection<MapView> getSystemAndUserMapViews( User user )
+    {
+        return getCriteria( 
+            Restrictions.or( Restrictions.isNull( "user" ), 
+            Restrictions.eq( "user", user ) ) ).list();
+    }
+    
+    @SuppressWarnings( "unchecked" )
     public Collection<MapView> getMapViewsByMapSourceType( String mapSourceType )
     {
         Session session = sessionFactory.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	2012-03-22 12:34:46 +0000
+++ dhis-2/dhis-services/dhis-service-mapping/src/main/resources/META-INF/dhis/beans.xml	2012-04-29 18:04:08 +0000
@@ -14,12 +14,10 @@
     <property name="mapLayerStore" ref="org.hisp.dhis.mapping.MapLayerStore" />
     <property name="mapLegendStore" ref="org.hisp.dhis.mapping.MapLegendStore" />
     <property name="mapLegendSetStore" ref="org.hisp.dhis.mapping.MapLegendSetStore" />
-
     <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
     <property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
     <property name="dataElementService" ref="org.hisp.dhis.dataelement.DataElementService" />
     <property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
-    <property name="userSettingService" ref="org.hisp.dhis.user.UserSettingService" />
     <property name="aggregatedDataValueService" ref="org.hisp.dhis.aggregation.AggregatedDataValueService" />
     <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" />
     <property name="configurationService" ref="org.hisp.dhis.configuration.ConfigurationService" />

=== modified file 'dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java'
--- dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java	2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-mapping/src/main/java/org/hisp/dhis/mapping/action/GetAllMapViewsAction.java	2012-04-29 18:04:08 +0000
@@ -72,7 +72,7 @@
 
     public String execute()
     {
-        object = new ArrayList<MapView>( mappingService.getAllMapViews() );
+        object = new ArrayList<MapView>( mappingService.getSystemAndUserMapViews() );
 
         Collections.sort( object, new MapViewNameComparator() );