=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2010-04-21 14:32:54 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditService.java 2010-06-09 10:37:45 +0000 @@ -30,6 +30,8 @@ import java.util.Collection; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.period.Period; import org.hisp.dhis.source.Source; /** @@ -54,4 +56,8 @@ Collection getDataValueAuditByDataValue( DataValue dataValue ); Collection getAll(); + + public void deleteByPeriod( Period period ); + + public void deleteByDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datavalue/DataValueAuditStore.java 2010-06-09 10:37:45 +0000 @@ -30,6 +30,8 @@ import java.util.Collection; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.period.Period; import org.hisp.dhis.source.Source; /** @@ -53,4 +55,8 @@ Collection getDataValueAuditByDataValue( DataValue dataValue ); Collection getAll(); + + int deleteByPeriod( Period period ); + + int deleteByDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java 2010-06-01 13:36:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DataValueAuditDeletionHandler.java 2010-06-09 10:37:45 +0000 @@ -27,6 +27,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.source.Source; import org.hisp.dhis.system.deletion.DeletionHandler; /** @@ -59,6 +63,28 @@ } @Override + public void deleteSource( Source source ) + { + dataValueAuditService.deleteDataValueAuditBySource( source ); + } + + @Override + public void deleteDataElement( DataElement dataElement ) + { + dataValueAuditService.deleteDataValueAuditByDataElement( dataElement ); + } + + @Override + public void deletePeriod( Period period ) + { + dataValueAuditService.deleteByPeriod( period ); + } + + @Override + public void deleteDataElementCategoryOptionCombo( DataElementCategoryOptionCombo categoryOptionCombo) + { + dataValueAuditService.deleteByDataElementCategoryOptionCombo( categoryOptionCombo ); + } public void deleteDataValue( DataValue dataValue ) { dataValueAuditService.deleteDataValueAuditByDataValue( dataValue ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2010-04-21 12:14:08 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/DefaultDataValueAuditService.java 2010-06-09 10:37:45 +0000 @@ -30,6 +30,8 @@ import java.util.Collection; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.period.Period; import org.hisp.dhis.source.Source; /** @@ -89,4 +91,13 @@ dataValueAuditStore.deleteDataValueAuditByDataElement( dataElement ); } + public void deleteByDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo ) + { + dataValueAuditStore.deleteByDataElementCategoryOptionCombo( optionCombo ); + } + + public void deleteByPeriod( Period period ) + { + dataValueAuditStore.deleteByPeriod( period ); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2010-05-18 15:42:54 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datavalue/hibernate/HibernateDataValueAuditStore.java 2010-06-09 10:37:45 +0000 @@ -35,9 +35,11 @@ import org.hibernate.SessionFactory; import org.hibernate.criterion.Restrictions; import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.datavalue.DataValueAudit; import org.hisp.dhis.datavalue.DataValueAuditStore; +import org.hisp.dhis.period.Period; import org.hisp.dhis.source.Source; import org.springframework.beans.factory.annotation.Autowired; @@ -126,5 +128,27 @@ } } } + + public int deleteByPeriod( Period period ) + { + Session session = sessionFactory.getCurrentSession(); + + Query query = session.createQuery( "delete DataValueAudit where period = :period" ); + query.setEntity( "period", period ); + + return query.executeUpdate(); + + + } + + public int deleteByDataElementCategoryOptionCombo( DataElementCategoryOptionCombo optionCombo ) + { + Session session = sessionFactory.getCurrentSession(); + + Query query = session.createQuery( "delete DataValueAudit where optionCombo = :optionCombo" ); + query.setEntity( "optionCombo", optionCombo ); + + return query.executeUpdate(); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java 2010-04-21 19:45:12 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/user/UserDeletionHandler.java 2010-06-09 10:37:45 +0000 @@ -27,6 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import java.util.Collection; + import org.hisp.dhis.source.Source; import org.hisp.dhis.system.deletion.DeletionHandler; @@ -69,4 +71,24 @@ } } } + + @Override + public boolean allowDeleteUserAuthorityGroup( UserAuthorityGroup authorityGroup ) + { + Collection userCredentials = userStore.getAllUserCredentials(); + for( UserCredentials uc : userCredentials ) + { + if( uc != null && uc.getUserAuthorityGroups() != null ) + { + for( UserAuthorityGroup role : uc.getUserAuthorityGroups()) + { + if( role.getId() == authorityGroup.getId()) + { + return false; + } + } + } + } + return true; + } } === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2010-04-23 13:37:06 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/deletion/DeletionHandler.java 2010-06-09 10:37:45 +0000 @@ -46,6 +46,7 @@ import org.hisp.dhis.datavalue.DataValue; import org.hisp.dhis.document.Document; import org.hisp.dhis.expression.Expression; +import org.hisp.dhis.gis.Legend; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorGroup; import org.hisp.dhis.indicator.IndicatorGroupSet; @@ -491,4 +492,9 @@ { return true; } + + public boolean allowDeleteLegend( Legend legend ) + { + return true; + } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/RemoveRoleAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/RemoveRoleAction.java 2010-04-12 21:23:33 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-user/src/main/java/org/hisp/dhis/user/action/RemoveRoleAction.java 2010-06-09 10:37:45 +0000 @@ -27,11 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.DeleteNotAllowedException; import org.hisp.dhis.i18n.I18n; import org.hisp.dhis.user.UserAuthorityGroup; +import org.hisp.dhis.user.UserService; import org.hisp.dhis.user.UserStore; -import org.hisp.dhis.user.UserService; -import org.springframework.dao.DataIntegrityViolationException; import com.opensymphony.xwork2.Action; @@ -110,7 +110,7 @@ userStore.deleteUserAuthorityGroup( authorityGroup ); } } - catch ( DataIntegrityViolationException e ) + catch ( DeleteNotAllowedException e ) { message = i18n.getString( "user_use_group" ); === modified file 'local/vn/dhis-service-gis/pom.xml' --- local/vn/dhis-service-gis/pom.xml 2010-04-12 10:13:41 +0000 +++ local/vn/dhis-service-gis/pom.xml 2010-06-09 10:37:45 +0000 @@ -23,7 +23,7 @@ org.hisp.dhis - dhis-service-jdbc + dhis-support-jdbc org.hisp.dhis === modified file 'local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultFeatureService.java' --- local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultFeatureService.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/DefaultFeatureService.java 2010-06-09 10:37:45 +0000 @@ -123,4 +123,14 @@ this.featureStore.updateMapFile( arg0 ); } + + public void deleteFeatureByOrganisationUnit( int arg0 ) + { + featureStore.deleteFeatureByOrganisationUnit( arg0 ); + } + + public void deleteMapFileByOrganisationUnit( int arg0 ) + { + featureStore.deleteMapFileByOrganisationUnit( arg0 ); + } } === modified file 'local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureService.java' --- local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureService.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureService.java 2010-06-09 10:37:45 +0000 @@ -60,4 +60,8 @@ public Collection getAllMapFile(); public MapFile getMapFile( OrganisationUnit organisationUnit ); + + public void deleteFeatureByOrganisationUnit( int arg0 ); + + public void deleteMapFileByOrganisationUnit( int arg0 ); } === modified file 'local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureStore.java' --- local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureStore.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/FeatureStore.java 2010-06-09 10:37:45 +0000 @@ -63,4 +63,8 @@ public Collection getAllMapFile(); public MapFile getMapFile( OrganisationUnit organisationUnit ); + + public void deleteFeatureByOrganisationUnit( int arg0 ); + + public void deleteMapFileByOrganisationUnit( int arg0 ); } === removed file 'local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/Legend.java' --- local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/Legend.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/Legend.java 1970-01-01 00:00:00 +0000 @@ -1,196 +0,0 @@ -package org.hisp.dhis.gis; - - -/* - * Copyright (c) 2004-2010, 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. - */ - -/** - * @author Tran Thanh Tri - * @version $Id: Feature.java 28-01-2008 16:06:00 $ - */ -public class Legend implements Comparable -{ - public static final int AUTO_CREATE_MAX = 1; - - public static final int NO_AUTO_CREATE_MAX = 0; - - private int id; - - private String name; - - private String color; - - private double min; - - private double max; - - private int autoCreateMax; - - public Legend( String color, double min, double max ) - { - this.color = color; - this.min = min; - this.max = max; - } - - public Legend( String name, String color, double min, double max ) - { - this.name = name; - this.color = color; - this.min = min; - this.max = max; - } - - public Legend( int id, String name, String color, double min, double max ) - { - this.id = id; - this.name = name; - this.color = color; - this.min = min; - this.max = max; - } - - - - - public int getAutoCreateMax() { - return autoCreateMax; - } - - public void setAutoCreateMax(int autoCreateMax) { - this.autoCreateMax = autoCreateMax; - } - - public boolean in( double value ) - { - if ( value >= min && value <= max ) - { - return true; - } - return false; - } - - public String getName() - { - return name; - } - - public void setName( String name ) - { - this.name = name; - } - - public int getId() - { - return id; - } - - public double getAverage() - { - return (max - min) / 2 ; - } - - public void setId( int id ) - { - this.id = id; - } - - public Legend() - { - super(); - } - - public String getColor() - { - return color; - } - - public void setColor( String color ) - { - this.color = color; - } - - public double getMin() - { - return min; - } - - public void setMin( double min ) - { - this.min = min; - } - - public double getMax() - { - return max; - } - - public void setMax( double max ) - { - this.max = max; - } - - @Override - public int hashCode() - { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals( Object obj ) - { - if ( this == obj ) - return true; - if ( obj == null ) - return false; - if ( getClass() != obj.getClass() ) - return false; - - final Legend other = (Legend) obj; - - if ( name == null ) - { - if ( other.name != null ) - return false; - } - else if ( !name.equals( other.name ) ) - return false; - - return true; - } - - - public int compareTo ( Legend legend ) { - if(this.getMin() > legend.getMin()){ - return 1; - }else if(this.getMin() < legend.getMin()){ - return -1; - }else{ - return 0; - } - - } -} === modified file 'local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateFeatureStore.java' --- local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateFeatureStore.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-service-gis/src/main/java/org/hisp/dhis/gis/hibernate/HibernateFeatureStore.java 2010-06-09 10:37:45 +0000 @@ -175,4 +175,17 @@ session.update( arg0 ); } + + public void deleteFeatureByOrganisationUnit( int arg0 ) + { + Session session = sessionFactory.getCurrentSession(); + session.createQuery( "delete Feature as f where f.organisationUnit.id = ?" ).setInteger( 0, arg0 ).executeUpdate(); + + } + + public void deleteMapFileByOrganisationUnit( int arg0 ) + { + Session session = sessionFactory.getCurrentSession(); + session.createQuery( "delete MapFile as m where m.organisationUnit.id = ?" ).setInteger( 0, arg0 ).executeUpdate(); + } } === modified file 'local/vn/dhis-service-gis/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-service-gis/src/main/resources/META-INF/dhis/beans.xml 2009-06-10 22:25:07 +0000 +++ local/vn/dhis-service-gis/src/main/resources/META-INF/dhis/beans.xml 2010-06-09 10:37:45 +0000 @@ -1,8 +1,10 @@ +http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd +http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> @@ -44,4 +46,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'local/vn/dhis-web-gis/src/main/java/org/hisp/dhis/gis/action/legend/DeleteLegendAction.java' --- local/vn/dhis-web-gis/src/main/java/org/hisp/dhis/gis/action/legend/DeleteLegendAction.java 2010-04-12 21:23:33 +0000 +++ local/vn/dhis-web-gis/src/main/java/org/hisp/dhis/gis/action/legend/DeleteLegendAction.java 2010-06-09 10:37:45 +0000 @@ -27,8 +27,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hisp.dhis.common.DeleteNotAllowedException; import org.hisp.dhis.gis.Legend; import org.hisp.dhis.gis.LegendService; +import org.hisp.dhis.i18n.I18n; import com.opensymphony.xwork2.Action; @@ -54,13 +56,39 @@ { this.legendId = legendId; } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + private String message; + + public String getMessage() + { + return message; + } public String execute() throws Exception { Legend legend = legendService.getLegend( legendId.intValue() ); - legendService.deleteLegend( legend ); + try { + + legendService.deleteLegend( legend ); + + }catch ( DeleteNotAllowedException ex ) + { + if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) ) + { + message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getClassName(); + + return ERROR; + } + } return SUCCESS; } === modified file 'local/vn/dhis-web-gis/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-gis/src/main/resources/META-INF/dhis/beans.xml 2009-06-14 19:43:19 +0000 +++ local/vn/dhis-web-gis/src/main/resources/META-INF/dhis/beans.xml 2010-06-09 10:37:45 +0000 @@ -46,7 +46,7 @@ - @@ -55,7 +55,7 @@ - +--> === modified file 'local/vn/dhis-web-gis/src/main/resources/org/hisp/dhis/gis/i18n_module.properties' --- local/vn/dhis-web-gis/src/main/resources/org/hisp/dhis/gis/i18n_module.properties 2009-03-13 11:44:39 +0000 +++ local/vn/dhis-web-gis/src/main/resources/org/hisp/dhis/gis/i18n_module.properties 2010-06-09 10:37:45 +0000 @@ -97,6 +97,6 @@ file_null = Please select svg file ! confirm_delete = Do you want delete ? assign_success = Assign Success - +object_not_deleted_associated_by_objects = Object not deleted becuause it is associated by objects of type === modified file 'local/vn/dhis-web-gis/src/main/resources/struts.xml' --- local/vn/dhis-web-gis/src/main/resources/struts.xml 2009-08-21 10:34:49 +0000 +++ local/vn/dhis-web-gis/src/main/resources/struts.xml 2010-06-09 10:37:45 +0000 @@ -195,8 +195,9 @@ - listLegends.action - F_GIS_CONFIGURATION_UPDATE + /dhis-web-gis/responseSuccess.vm + /dhis-web-gis/responseError.vm + F_GIS_CONFIGURATION_UPDATE OpenSessionInViewFilter org.springframework.orm.hibernate3.support.OpenSessionInViewFilter - - SecurityFilterChain - org.acegisecurity.util.FilterToBeanProxy - - targetBean - org.acegisecurity.util.FilterChainProxy - + + filterChainProxy + org.springframework.web.filter.DelegatingFilterProxy Struts @@ -47,7 +43,7 @@ *.action - SecurityFilterChain + filterChainProxy /* === modified file 'local/vn/dhis-web-gis/src/main/webapp/dhis-web-gis/listLegend.vm' --- local/vn/dhis-web-gis/src/main/webapp/dhis-web-gis/listLegend.vm 2009-03-13 11:44:39 +0000 +++ local/vn/dhis-web-gis/src/main/webapp/dhis-web-gis/listLegend.vm 2010-06-09 10:37:45 +0000 @@ -42,7 +42,27 @@ #end - + + + + + + + @@ -50,10 +70,36 @@