=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2012-02-08 12:39:22 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSetService.java 2012-02-14 02:58:08 +0000 @@ -29,6 +29,7 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import java.util.Collection; @@ -284,4 +285,21 @@ * @return Collection of LockExceptions withing the range specified */ public Collection getLockExceptionsBetween( int first, int max ); + + /** + * Find all unique dataSet + period combinations + * (mainly used for batch removal) + * + * @return A collection of all unique combinations (only dataSet and period is set) + */ + public Collection getLockExceptionCombinations(); + + /** + * Delete a dataSet + period combination, used for batch removal, e.g. when you + * have a lock exception set on 100 OUs with the same dataSet + period combination. + * + * @param dataSet DataSet part of the combination + * @param period Period part of the combination + */ + public void deleteLockExceptionCombination( DataSet dataSet, Period period ); } === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java 2012-02-05 13:27:40 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/LockExceptionStore.java 2012-02-14 02:58:08 +0000 @@ -28,6 +28,9 @@ */ import org.hisp.dhis.common.GenericStore; +import org.hisp.dhis.period.Period; + +import java.util.Collection; /** * @author Morten Olav Hansen @@ -36,4 +39,8 @@ extends GenericStore { String ID = LockExceptionStore.class.getName(); + + Collection getCombinations(); + + void deleteCombination( DataSet dataSet, Period period ); } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2012-02-08 12:04:46 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2012-02-14 02:58:08 +0000 @@ -34,6 +34,7 @@ import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.util.AuditLogUtil; import org.hisp.dhis.system.util.Filter; @@ -378,4 +379,16 @@ // FIXME extend lockExceptionStore to include HQL query for this return getAllLockExceptions(); } + + @Override + public Collection getLockExceptionCombinations() + { + return lockExceptionStore.getCombinations(); + } + + @Override + public void deleteLockExceptionCombination( DataSet dataSet, Period period ) + { + lockExceptionStore.deleteCombination( dataSet, period ); + } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java 2012-02-05 13:27:40 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/hibernate/HibernateLockExceptionStore.java 2012-02-14 02:58:08 +0000 @@ -27,9 +27,21 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import org.hibernate.Query; +import org.hibernate.Session; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.dataset.LockException; import org.hisp.dhis.dataset.LockExceptionStore; import org.hisp.dhis.hibernate.HibernateGenericStore; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; +import org.springframework.jdbc.core.RowCallbackHandler; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collection; /** * @author Morten Olav Hansen @@ -38,4 +50,70 @@ extends HibernateGenericStore implements LockExceptionStore { + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + // ------------------------------------------------------------------------- + // LockExceptionStore Implementation + // ------------------------------------------------------------------------- + + @Override + public Collection getCombinations() + { + final String sql = "SELECT DISTINCT datasetid, periodid FROM LockException"; + + final Collection lockExceptions = new ArrayList(); + + jdbcTemplate.query( sql, new RowCallbackHandler() + { + @Override + public void processRow( ResultSet rs ) throws SQLException + { + int dataSetId = rs.getInt( 1 ); + int periodId = rs.getInt( 2 ); + + LockException lockException = new LockException(); + Period period = periodService.getPeriod( periodId ); + DataSet dataSet = dataSetService.getDataSet( dataSetId ); + + lockException.setDataSet( dataSet ); + lockException.setPeriod( period ); + + lockExceptions.add( lockException ); + } + } ); + + return lockExceptions; + } + + @Override + public void deleteCombination( DataSet dataSet, Period period ) + { + Session session = sessionFactory.getCurrentSession(); + + final String hql = "DELETE FROM LockException WHERE dataSet=:dataSet AND period=:period"; + Query query = session.createQuery( hql ); + query.setParameter( "dataSet", dataSet ); + query.setParameter( "period", period ); + + query.executeUpdate(); + +// final String sql = "DELETE FROM LockException WHERE dataSetId=? AND periodId=?"; +// jdbcTemplate.update( sql, new Object[]{dataSet.getId(), period.getId()} ); + } } === 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 2012-02-08 12:04:46 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/META-INF/dhis/beans.xml 2012-02-14 02:58:08 +0000 @@ -88,7 +88,10 @@ + + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/BatchRemoveLockExceptionsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/BatchRemoveLockExceptionsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/BatchRemoveLockExceptionsAction.java 2012-02-14 02:58:08 +0000 @@ -0,0 +1,97 @@ +package org.hisp.dhis.dataadmin.action.lockexception; + +/* + * Copyright (c) 2004-2012, 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 com.opensymphony.xwork2.Action; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.period.PeriodService; + +/** + * @author Morten Olav Hansen + */ +public class BatchRemoveLockExceptionsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private int dataSetId; + + public void setDataSetId( int dataSetId ) + { + this.dataSetId = dataSetId; + } + + private int periodId; + + public void setPeriodId( int periodId ) + { + this.periodId = periodId; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + DataSet dataSet = dataSetService.getDataSet( dataSetId ); + Period period = periodService.getPeriod( periodId ); + + if ( dataSet == null || period == null ) + { + return ERROR; + } + + dataSetService.deleteLockExceptionCombination( dataSet, period ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java 2012-02-08 12:04:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionListAction.java 2012-02-14 02:58:08 +0000 @@ -102,6 +102,8 @@ lockExceptions = lockExceptions.subList( paging.getStartPos(), paging.getEndPos() ); } + dataSetService.getLockExceptionCombinations(); + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/PrepareBatchRemovalAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/PrepareBatchRemovalAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/PrepareBatchRemovalAction.java 2012-02-14 02:58:08 +0000 @@ -0,0 +1,90 @@ +package org.hisp.dhis.dataadmin.action.lockexception; + +/* + * Copyright (c) 2004-2012, 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 com.opensymphony.xwork2.Action; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.dataset.LockException; +import org.hisp.dhis.i18n.I18nFormat; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen + */ +public class PrepareBatchRemovalAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List lockExceptions; + + public List getLockExceptions() + { + return lockExceptions; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + lockExceptions = new ArrayList( dataSetService.getLockExceptionCombinations() ); + + for ( LockException lockException : lockExceptions ) + { + lockException.getPeriod().setName( format.formatPeriod( lockException.getPeriod() ) ); + + } + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2012-02-13 04:51:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2012-02-14 02:58:08 +0000 @@ -1,24 +1,27 @@ - + - + - + @@ -26,73 +29,84 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -102,101 +116,117 @@ - + - + - + - + - + - + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - + - + - + - + - + @@ -205,207 +235,256 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + - + - + - + - + - + - - + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2012-02-08 13:38:13 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/org/hisp/dhis/dataadmin/i18n_module.properties 2012-02-14 02:58:08 +0000 @@ -394,9 +394,13 @@ must_include_option = Please include one or more category options edit_option_set = Edit option set number_of_members = The number of members -object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type >>>>>>> MERGE-SOURCE +object_not_deleted_associated_by_objects=Object not deleted because it is associated by objects of type lock_exception_management=Lock Exception Management lock_exception=Lock Exception confirm_delete_lock_exception=Do you want to delete this lock exception? +confirm_delete_lock_exceptions=Do you want to delete lock exceptions with this configuration? create_new_lock_exception=Create new lock exception edit_lock_exception=Edit lock exception +lock_exception_batch_removal=Lock exception batch removal +back_to_lock_exceptions=Back to lock exception +batch_delete=Batch deletion === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2012-02-13 19:27:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2012-02-14 02:58:08 +0000 @@ -496,13 +496,6 @@ F_DATASET_ADD - - /dhis-web-commons/ajax/jsonResponseSuccess.vm - /dhis-web-commons/ajax/jsonResponseError.vm - plainTextError - F_DATASET_DELETE - - jsonDataSets.vm plainTextError @@ -518,6 +511,27 @@ plainTextError + + /main.vm + /dhis-web-maintenance-dataadmin/menu.vm + /dhis-web-maintenance-dataadmin/removeLockExceptionBatch.vm + F_DATASET_DELETE + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + F_DATASET_DELETE + + + + /dhis-web-commons/ajax/jsonResponseSuccess.vm + /dhis-web-commons/ajax/jsonResponseError.vm + plainTextError + F_DATASET_DELETE + + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/lockException.js' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/lockException.js 2012-02-13 04:51:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/lockException.js 2012-02-14 02:58:08 +0000 @@ -55,9 +55,7 @@ } function periodChanged( e ) { - var periods = jQuery("#periods"); - - if ( periods.attr("disabled") ) { + if ( jQuery("#periods").attr("disabled") ) { jQuery("#submit").attr("disabled", true); } else { jQuery("#submit").removeAttr("disabled"); @@ -65,13 +63,9 @@ } function resetDataSets() { - var option = jQuery(""); - jQuery("#dataSets").append(option); - jQuery("#dataSets").attr("disabled", true); + jQuery("#dataSets").append("").attr("disabled", true); } function resetPeriods() { - var option = jQuery(""); - jQuery("#periods").append(option); - jQuery("#periods").attr("disabled", true); + jQuery("#periods").append("").attr("disabled", true); } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm 2012-02-13 04:51:23 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/lockException.vm 2012-02-14 02:58:08 +0000 @@ -32,7 +32,8 @@ #filterDiv( "lockException" ) - + + === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/removeLockExceptionBatch.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/removeLockExceptionBatch.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/removeLockExceptionBatch.vm 2012-02-14 02:58:08 +0000 @@ -0,0 +1,81 @@ + + +

$i18n.getString( "lock_exception_batch_removal" )

+ + + + + + + + +
+ + + + +
+ +
+ + + + + + + + + + + + #foreach( $lockException in $lockExceptions ) + + #set( $name = "$encoder.htmlEncode( $lockException.dataSet.name ) - $encoder.htmlEncode( $lockException.period.name )" ) + + + + #end + + +
$i18n.getString( "name" )$i18n.getString( "operations" )
$name + $i18n.getString( 'remove' ) +
+
+