dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #24575
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12075: Impl MapDeletionHandler
------------------------------------------------------------
revno: 12075
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-09-13 13:22:35 +0200
message:
Impl MapDeletionHandler
added:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java
dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.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/MappingService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2013-08-23 15:56:19 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/MappingService.java 2013-09-13 11:22:35 +0000
@@ -110,6 +110,8 @@
List<Map> getMapsBetweenLikeName( String name, int first, int max );
+ List<Map> getAllMaps();
+
// -------------------------------------------------------------------------
// MapView
// -------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/DefaultMappingService.java 2013-09-13 11:22:35 +0000
@@ -265,6 +265,11 @@
mapStore.delete( map );
}
+ public List<Map> getAllMaps()
+ {
+ return mapStore.getAll();
+ }
+
public List<Map> getMapsBetweenLikeName( String name, int first, int max )
{
return mapStore.getAllLikeNameOrderedName( name, first, max );
=== added file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/mapping/MapDeletionHandler.java 2013-09-13 11:22:35 +0000
@@ -0,0 +1,84 @@
+package org.hisp.dhis.mapping;
+
+/*
+ * Copyright (c) 2004-2013, 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.Iterator;
+
+import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.hisp.dhis.user.User;
+
+/**
+ * @author Lars Helge Overland
+ */
+public class MapDeletionHandler
+ extends DeletionHandler
+{
+ private MappingService mappingService;
+
+ public void setMappingService( MappingService mappingService )
+ {
+ this.mappingService = mappingService;
+ }
+
+ // -------------------------------------------------------------------------
+ // DeletionHandler implementation
+ // -------------------------------------------------------------------------
+
+ @Override
+ protected String getClassName()
+ {
+ return Map.class.getSimpleName();
+ }
+
+ @Override
+ public void deleteUser( User user )
+ {
+ for ( Map map : mappingService.getAllMaps() )
+ {
+ if ( map.getUser() != null && map.getUser().equals( user ) )
+ {
+ map.setUser( null );
+ mappingService.updateMap( map );
+ }
+ }
+ }
+
+ @Override
+ public void deleteMap( Map map )
+ {
+ Iterator<MapView> views = map.getMapViews().iterator();
+
+ while ( views.hasNext() )
+ {
+ MapView view = views.next();
+ views.remove();
+ mappingService.deleteMapView( view );
+ }
+ }
+}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/DefaultUserService.java 2013-09-13 11:22:35 +0000
@@ -46,6 +46,7 @@
import org.hisp.dhis.system.filter.UserCredentialsCanUpdateFilter;
import org.hisp.dhis.system.util.Filter;
import org.hisp.dhis.system.util.FilterUtils;
+import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -521,6 +522,7 @@
return userStore.getUsersByOrganisationUnits( units );
}
+ @Transactional(propagation=Propagation.REQUIRES_NEW)
public void removeUserSettings( User user )
{
userStore.removeUserSettings( user );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-08 15:32:46 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2013-09-13 11:22:35 +0000
@@ -1067,6 +1067,10 @@
<property name="operandService" ref="org.hisp.dhis.dataelement.DataElementOperandService" />
</bean>
+ <bean id="org.hisp.dhis.mapping.MapDeletionHandler" class="org.hisp.dhis.mapping.MapDeletionHandler">
+ <property name="mappingService" ref="org.hisp.dhis.mapping.MappingService" />
+ </bean>
+
<!-- DeletionManager -->
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
@@ -1139,6 +1143,7 @@
<aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegend(..) )" method="intercept" />
<aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapLegendSet(..) )" method="intercept" />
<aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMapView(..) )" method="intercept" />
+ <aop:before pointcut="execution( * org.hisp.dhis.mapping.MappingService.deleteMap(..) )" method="intercept" />
</aop:aspect>
<!-- <aop:aspect ref="i18nTranslationInterceptor"> <aop:after-returning pointcut="execution( * org.hisp.dhis.dataelement.DataElementService.get*(..)
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/chart/ChartDeletionHandler.java 2013-09-13 11:22:35 +0000
@@ -28,8 +28,6 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.util.Iterator;
-
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataset.DataSet;
@@ -69,6 +67,19 @@
}
@Override
+ public void deleteUser( User user )
+ {
+ for ( Chart chart : chartService.getAllCharts() )
+ {
+ if ( chart.getUser() != null && chart.getUser().equals( user ) )
+ {
+ chart.setUser( null );
+ chartService.updateChart( chart );
+ }
+ }
+ }
+
+ @Override
public String allowDeletePeriod( Period period )
{
for ( Chart chart : chartService.getAllCharts() )
@@ -131,19 +142,6 @@
}
@Override
- public void deleteUser( User user )
- {
- Iterator<Chart> iterator = chartService.getChartsByUser( user ).iterator();
-
- while ( iterator.hasNext() )
- {
- Chart chart = iterator.next();
- iterator.remove();
- chartService.deleteChart( chart );
- }
- }
-
- @Override
public void deleteDataElementGroup( DataElementGroup group )
{
for ( Chart chart : chartService.getAllCharts() )
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2013-08-23 16:05:01 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/ReportTableDeletionHandler.java 2013-09-13 11:22:35 +0000
@@ -36,6 +36,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.deletion.DeletionHandler;
+import org.hisp.dhis.user.User;
/**
* @author Lars Helge Overland
@@ -64,6 +65,19 @@
{
return ReportTable.class.getSimpleName();
}
+
+ @Override
+ public void deleteUser( User user )
+ {
+ for ( ReportTable reportTable : reportTableService.getAllReportTables() )
+ {
+ if ( reportTable.getUser() != null && reportTable.getUser().equals( reportTable ) )
+ {
+ reportTable.setUser( user );
+ reportTableService.updateReportTable( reportTable );
+ }
+ }
+ }
@Override
public void deleteDataElement( DataElement dataElement )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java 2013-09-03 19:11:14 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceTableController.java 2013-09-13 11:22:35 +0000
@@ -71,7 +71,7 @@
//TODO make tasks prototypes to avoid potential concurrency issues?
- @RequestMapping( value = "/analytics", method = RequestMethod.PUT )
+ @RequestMapping( value = "/analytics", method = { RequestMethod.PUT, RequestMethod.POST } )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATA_MART_ADMIN')" )
public void analytics( HttpServletResponse response )
{
@@ -82,7 +82,7 @@
ContextUtils.okResponse( response, "Initiated analytics table update" );
}
- @RequestMapping( value = "/dataMart", method = RequestMethod.PUT )
+ @RequestMapping( value = "/dataMart", method = { RequestMethod.PUT, RequestMethod.POST } )
@PreAuthorize( "hasRole('ALL') or hasRole('F_DATA_MART_ADMIN')" )
public void data( HttpServletResponse response )
{
@@ -93,7 +93,7 @@
ContextUtils.okResponse( response, "Initiated data mart update" );
}
- @RequestMapping( method = RequestMethod.PUT )
+ @RequestMapping( method = { RequestMethod.PUT, RequestMethod.POST } )
@PreAuthorize( "hasRole('ALL') or hasRole('F_PERFORM_MAINTENANCE')" )
public void resourceTables( HttpServletResponse response )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-08-23 16:00:30 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/mapping/MapController.java 2013-09-13 11:22:35 +0000
@@ -188,15 +188,6 @@
return;
}
- Iterator<MapView> views = map.getMapViews().iterator();
-
- while ( views.hasNext() )
- {
- MapView view = views.next();
- views.remove();
- mappingService.deleteMapView( view );
- }
-
mappingService.deleteMap( map );
}