------------------------------------------------------------ revno: 5891 committer: Morten Olav Hansen <[email protected]> branch nick: dhis2 timestamp: Wed 2012-02-08 20:38:13 +0700 message: update lock exceptions ui removed: dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSets.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriods.java added: dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSetsAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionFormAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriodsAction.java dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/javascript/lockException.js modified: 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/org/hisp/dhis/dataadmin/i18n_module.properties 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/webapp/dhis-web-maintenance-dataadmin/addLockExceptionForm.vm dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateLockExceptionForm.vm
-- 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
=== removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSets.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSets.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/GetDataSets.java 1970-01-01 00:00:00 +0000 @@ -1,119 +0,0 @@ -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.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.user.CurrentUserService; -import org.hisp.dhis.user.UserCredentials; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Morten Olav Hansen <[email protected]> - */ -public class GetDataSets - implements Action -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private CurrentUserService currentUserService; - - public void setCurrentUserService( CurrentUserService currentUserService ) - { - this.currentUserService = currentUserService; - } - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private int id; - - public void setId( int id ) - { - this.id = id; - } - - private List<DataSet> dataSets; - - public List<DataSet> getDataSets() - { - return dataSets; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() throws Exception - { - dataSets = getDataSetsForCurrentUser( id ); - - return SUCCESS; - } - - public List<DataSet> getDataSetsForCurrentUser( int id ) - { - OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id ); - - if ( organisationUnit == null ) - { - return new ArrayList<DataSet>(); - } - - List<DataSet> dataSets = new ArrayList<DataSet>(); - - if ( organisationUnit.getDataSets() != null ) - { - dataSets.addAll( organisationUnit.getDataSets() ); - } - - UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials(); - - if ( !userCredentials.isSuper() ) - { - dataSets.retainAll( userCredentials.getAllDataSets() ); - } - - return dataSets; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSetsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetDataSetsAction.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/GetDataSetsAction.java 2012-02-08 13:38:13 +0000 @@ -0,0 +1,119 @@ +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.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.UserCredentials; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Morten Olav Hansen <[email protected]> + */ +public class GetDataSetsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private int id; + + public void setId( int id ) + { + this.id = id; + } + + private List<DataSet> dataSets; + + public List<DataSet> getDataSets() + { + return dataSets; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + dataSets = getDataSetsForCurrentUser( id ); + + return SUCCESS; + } + + private List<DataSet> getDataSetsForCurrentUser( int id ) + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id ); + + if ( organisationUnit == null ) + { + return new ArrayList<DataSet>(); + } + + List<DataSet> dataSets = new ArrayList<DataSet>(); + + if ( organisationUnit.getDataSets() != null ) + { + dataSets.addAll( organisationUnit.getDataSets() ); + } + + UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials(); + + if ( !userCredentials.isSuper() ) + { + dataSets.retainAll( userCredentials.getAllDataSets() ); + } + + return dataSets; + } +} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionFormAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetLockExceptionFormAction.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/GetLockExceptionFormAction.java 2012-02-08 13:38:13 +0000 @@ -0,0 +1,203 @@ +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.dataset.LockException; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.oust.manager.SelectionTreeManager; +import org.hisp.dhis.period.CalendarPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; +import org.hisp.dhis.system.util.FilterUtils; +import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.UserCredentials; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @author Morten Olav Hansen <[email protected]> + */ +public class GetLockExceptionFormAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private CurrentUserService currentUserService; + + public void setCurrentUserService( CurrentUserService currentUserService ) + { + this.currentUserService = currentUserService; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private I18nFormat format; + + public void setFormat( I18nFormat format ) + { + this.format = format; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private Integer id; + + public void setId( Integer id ) + { + this.id = id; + } + + private LockException lockException; + + public LockException getLockException() + { + return lockException; + } + + private List<DataSet> dataSets; + + public List<DataSet> getDataSets() + { + return dataSets; + } + + private List<Period> periods; + + public List<Period> getPeriods() + { + return periods; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + if ( id != null ) + { + lockException = dataSetService.getLockException( id ); + + if ( lockException == null ) + { + return INPUT; + } + + selectionTreeManager.setSelectedOrganisationUnit( lockException.getOrganisationUnit() ); + dataSets = getDataSetsForCurrentUser( lockException.getOrganisationUnit().getId() ); + periods = getPeriodsForDataSet( lockException.getDataSet().getId() ); + + for ( Period period : periods ) + { + period.setName( format.formatPeriod( period ) ); + } + } + + return SUCCESS; + } + + private List<Period> getPeriodsForDataSet( int id ) + { + DataSet dataSet = dataSetService.getDataSet( id ); + + if ( dataSet == null ) + { + return new ArrayList<Period>(); + } + + CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); + List<Period> periods = periodType.generateLast5Years( new Date() ); + FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); + Collections.reverse( periods ); + + if ( periods.size() > 10 ) + { + periods = periods.subList( 0, 10 ); + } + + return periods; + } + + private List<DataSet> getDataSetsForCurrentUser( int id ) + { + OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( id ); + + if ( organisationUnit == null ) + { + return new ArrayList<DataSet>(); + } + + List<DataSet> dataSets = new ArrayList<DataSet>(); + + if ( organisationUnit.getDataSets() != null ) + { + dataSets.addAll( organisationUnit.getDataSets() ); + } + + UserCredentials userCredentials = currentUserService.getCurrentUser().getUserCredentials(); + + if ( !userCredentials.isSuper() ) + { + dataSets.retainAll( userCredentials.getAllDataSets() ); + } + + return dataSets; + } +} === removed file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriods.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriods.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/GetPeriods.java 1970-01-01 00:00:00 +0000 @@ -1,125 +0,0 @@ -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.CompleteDataSetRegistration; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.i18n.I18nFormat; -import org.hisp.dhis.period.CalendarPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; -import org.hisp.dhis.system.util.FilterUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -/** - * @author Morten Olav Hansen <[email protected]> - */ -public class GetPeriods - 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 int id; - - public void setId( int id ) - { - this.id = id; - } - - private List<Period> periods; - - public List<Period> getPeriods() - { - return periods; - } - - // ------------------------------------------------------------------------- - // Action Implementation - // ------------------------------------------------------------------------- - - @Override - public String execute() throws Exception - { - periods = getPeriodsForDataSet( id ); - - for ( Period period : periods ) - { - period.setName( format.formatPeriod( period ) ); - } - - return SUCCESS; - } - - public List<Period> getPeriodsForDataSet( int id ) - { - DataSet dataSet = dataSetService.getDataSet( id ); - - if ( dataSet == null ) - { - return new ArrayList<Period>(); - } - - CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); - List<Period> periods = periodType.generateLast5Years( new Date() ); - FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); - Collections.reverse( periods ); - - if ( periods.size() > 10 ) - { - periods = periods.subList( 0, 10 ); - } - - return periods; - } -} === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriodsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/java/org/hisp/dhis/dataadmin/action/lockexception/GetPeriodsAction.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/GetPeriodsAction.java 2012-02-08 13:38:13 +0000 @@ -0,0 +1,125 @@ +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.CompleteDataSetRegistration; +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.period.CalendarPeriodType; +import org.hisp.dhis.period.Period; +import org.hisp.dhis.system.filter.PastAndCurrentPeriodFilter; +import org.hisp.dhis.system.util.FilterUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @author Morten Olav Hansen <[email protected]> + */ +public class GetPeriodsAction + 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 int id; + + public void setId( int id ) + { + this.id = id; + } + + private List<Period> periods; + + public List<Period> getPeriods() + { + return periods; + } + + // ------------------------------------------------------------------------- + // Action Implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() throws Exception + { + periods = getPeriodsForDataSet( id ); + + for ( Period period : periods ) + { + period.setName( format.formatPeriod( period ) ); + } + + return SUCCESS; + } + + private List<Period> getPeriodsForDataSet( int id ) + { + DataSet dataSet = dataSetService.getDataSet( id ); + + if ( dataSet == null ) + { + return new ArrayList<Period>(); + } + + CalendarPeriodType periodType = (CalendarPeriodType) dataSet.getPeriodType(); + List<Period> periods = periodType.generateLast5Years( new Date() ); + FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() ); + Collections.reverse( periods ); + + if ( periods.size() > 10 ) + { + periods = periods.subList( 0, 10 ); + } + + return periods; + } +} === 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-08 12:04:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/META-INF/dhis/beans.xml 2012-02-08 13:38:13 +0000 @@ -301,6 +301,14 @@ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" /> </bean> + <bean id="org.hisp.dhis.dataadmin.action.lockexception.GetLockExceptionFormAction" class="org.hisp.dhis.dataadmin.action.lockexception.GetLockExceptionFormAction" + scope="prototype"> + <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" /> + <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" /> + <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" /> + <property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" /> + </bean> + <bean id="org.hisp.dhis.dataadmin.action.lockexception.RemoveLockExceptionAction" class="org.hisp.dhis.dataadmin.action.lockexception.RemoveLockExceptionAction" scope="prototype"> <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" /> @@ -313,13 +321,13 @@ <property name="periodService" ref="org.hisp.dhis.period.PeriodService" /> </bean> - <bean id="org.hisp.dhis.dataadmin.action.lockexception.GetDataSets" class="org.hisp.dhis.dataadmin.action.lockexception.GetDataSets" + <bean id="org.hisp.dhis.dataadmin.action.lockexception.GetDataSetsAction" class="org.hisp.dhis.dataadmin.action.lockexception.GetDataSetsAction" scope="prototype"> <property name="currentUserService" ref="org.hisp.dhis.user.CurrentUserService" /> <property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" /> </bean> - <bean id="org.hisp.dhis.dataadmin.action.lockexception.GetPeriods" class="org.hisp.dhis.dataadmin.action.lockexception.GetPeriods" + <bean id="org.hisp.dhis.dataadmin.action.lockexception.GetPeriodsAction" class="org.hisp.dhis.dataadmin.action.lockexception.GetPeriodsAction" scope="prototype"> <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" /> </bean> === 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 12:39:22 +0000 +++ 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 @@ -107,6 +107,7 @@ organisation_unit_pruning=Organisation Unit Pruning min_max_value_generation=Min-Max Value Generation intro_data_locking=Deny data to be entered or imported for data sets for certain combinations of organisation unit and period. +intro_lock_exception=Add or remove exceptions to the auto-locking feature of datasets intro_data_browser=Browse the database and get an overview of where data exists. View and export counts of data elements as well as raw data. intro_data_integrity=Run data integrity checks and unveil anomalies and problems in the meta data setup. intro_data_archive=Archive data which is not currently relevant to your system in order to improve performance. Data can also be unarchived. === 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-08 12:04:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/resources/struts.xml 2012-02-08 13:38:13 +0000 @@ -493,7 +493,7 @@ <param name="requiredAuthorities">F_DATASET_ADD</param> </action> - <action name="showUpdateLockExceptionForm" class="org.hisp.dhis.dataadmin.action.lockexception.GetLockExceptionAction"> + <action name="showUpdateLockExceptionForm" class="org.hisp.dhis.dataadmin.action.lockexception.GetLockExceptionFormAction"> <result name="success" type="velocity">/main.vm</result> <param name="menu">/dhis-web-maintenance-dataadmin/menu.vm</param> <param name="page">/dhis-web-maintenance-dataadmin/updateLockExceptionForm.vm</param> @@ -520,12 +520,12 @@ <param name="requiredAuthorities">F_DATASET_DELETE</param> </action> - <action name="getDataSets" class="org.hisp.dhis.dataadmin.action.lockexception.GetDataSets"> + <action name="getDataSets" class="org.hisp.dhis.dataadmin.action.lockexception.GetDataSetsAction"> <result name="success" type="velocity-json">jsonDataSets.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> - <action name="getPeriods" class="org.hisp.dhis.dataadmin.action.lockexception.GetPeriods"> + <action name="getPeriods" class="org.hisp.dhis.dataadmin.action.lockexception.GetPeriodsAction"> <result name="success" type="velocity-json">jsonPeriods.vm</result> <param name="onExceptionReturn">plainTextError</param> </action> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addLockExceptionForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addLockExceptionForm.vm 2012-02-08 12:04:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/addLockExceptionForm.vm 2012-02-08 13:38:13 +0000 @@ -1,83 +1,4 @@ -<script type="text/javascript"> - jQuery(document).ready( function() - { - jQuery("body").bind("oust.selected", ouChanged); - jQuery("#dataSets").bind("change", dataSetChanged); - jQuery("#periods").bind("change", periodChanged); - }); - - function ouChanged(e, ou) - { - jQuery("#organisationUnitId").val(ou); - - jQuery.getJSON('getDataSets.action?id=' + ou, function(data) { - jQuery("#dataSets").children().remove(); - - if(data.dataSets.length == 0) { - resetDataSets(); - } else { - for(var n in data.dataSets) - { - var option = jQuery("<option />").attr("value", data.dataSets[n].id).text(data.dataSets[n].name) - jQuery("#dataSets").append(option); - } - - jQuery("#dataSets").removeAttr("disabled"); - } - - jQuery("#dataSets").trigger("change"); - }); - } - - function dataSetChanged(e) - { - var dataSetId = jQuery("#dataSets option:selected").val(); - jQuery("#periods").children().remove(); - - if(!isNaN(dataSetId)) { - jQuery.getJSON('getPeriods.action?id=' + dataSetId, function(data) { - if(data.periods.length == 0) { - resetPeriods(); - } else { - for(var n in data.periods) { - var option = jQuery("<option />").attr("value", data.periods[n].externalId).text(data.periods[n].name); - jQuery("#periods").append(option); - } - - jQuery("#periods").removeAttr("disabled"); - } - - jQuery("#periods").trigger("change"); - }); - } else { - resetPeriods(); - jQuery("#periods").trigger("change"); - } - } - - function periodChanged(e) - { - var periods = jQuery("#periods"); - - if(periods.attr("disabled")) { - jQuery("#submit").attr("disabled", true); - } else { - jQuery("#submit").removeAttr("disabled"); - } - } - - function resetDataSets() { - var option = jQuery("<option>-- Please select an organisation unit with a dataset --</option>"); - jQuery("#dataSets").append(option); - jQuery("#dataSets").attr("disabled", true); - } - - function resetPeriods() { - var option = jQuery("<option>-- Please select a dataset --</option>"); - jQuery("#periods").append(option); - jQuery("#periods").attr("disabled", true); - } -</script> +<script type="text/javascript" src="javascript/lockException.js"></script> <h3>$i18n.getString( "create_new_lock_exception" )</h3> @@ -103,7 +24,7 @@ <tr> <td> <select id="periods" name="periodId" disabled="disabled" style="width: 100%;"> - <option>-- Please select a dataset--</option> + <option>-- Please select a dataset --</option> </select> </td> </tr> === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm 2012-02-08 12:04:46 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/index.vm 2012-02-08 13:38:13 +0000 @@ -19,7 +19,7 @@ #introListImgItem( "displayDuplicateDataEliminationForm.action" "duplicate_data_elimination" "duplicatedataelimination" ) #introListImgItem( "viewStatistics.action" "data_statistics" "datastatistics" ) #introListImgItem( "displayLockingForm.action" "data_locking" "datalocking" ) - #introListImgItem( "lockException.action" "lock_exception" "lockexception" ) + #introListImgItem( "lockException.action" "lock_exception" "datalocking" ) #introListImgItem( "zeroValueStorageManagement.action" "zero_storage_management" "zerovaluestorage" ) #introListImgItem( "displayPruneOrganisationUnitForm.action" "organisation_unit_pruning" "organisationunitpruning" ) #introListImgItem( "getMinMaxValidationParams.action" "min_max_value_generation" "minmaxvaluegeneration" ) === added 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 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/javascript/lockException.js 2012-02-08 13:38:13 +0000 @@ -0,0 +1,73 @@ +jQuery(document).ready(function () { + jQuery("body").bind("oust.selected", ouChanged); + jQuery("#dataSets").bind("change", dataSetChanged); + jQuery("#periods").bind("change", periodChanged); +}); + +function ouChanged( e, ou ) { + jQuery("#organisationUnitId").val(ou); + + jQuery.getJSON('getDataSets.action?id=' + ou, function ( data ) { + jQuery("#dataSets").children().remove(); + + if ( data.dataSets.length == 0 ) { + resetDataSets(); + } else { + for ( var n in data.dataSets ) { + var option = jQuery("<option />").attr("value", data.dataSets[n].id).text(data.dataSets[n].name) + jQuery("#dataSets").append(option); + } + + jQuery("#dataSets").removeAttr("disabled"); + } + + jQuery("#dataSets").trigger("change"); + }); +} + +function dataSetChanged( e ) { + var dataSetId = jQuery("#dataSets option:selected").val(); + jQuery("#periods").children().remove(); + + if ( !isNaN(dataSetId) ) { + jQuery.getJSON('getPeriods.action?id=' + dataSetId, function ( data ) { + if ( data.periods.length == 0 ) { + resetPeriods(); + } else { + for ( var n in data.periods ) { + var option = jQuery("<option />").attr("value", data.periods[n].externalId).text(data.periods[n].name); + jQuery("#periods").append(option); + } + + jQuery("#periods").removeAttr("disabled"); + } + + jQuery("#periods").trigger("change"); + }); + } else { + resetPeriods(); + jQuery("#periods").trigger("change"); + } +} + +function periodChanged( e ) { + var periods = jQuery("#periods"); + + if ( periods.attr("disabled") ) { + jQuery("#submit").attr("disabled", true); + } else { + jQuery("#submit").removeAttr("disabled"); + } +} + +function resetDataSets() { + var option = jQuery("<option>-- Please select an organisation unit with a dataset --</option>"); + jQuery("#dataSets").append(option); + jQuery("#dataSets").attr("disabled", true); +} + +function resetPeriods() { + var option = jQuery("<option>-- Please select a dataset --</option>"); + jQuery("#periods").append(option); + jQuery("#periods").attr("disabled", true); +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateLockExceptionForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateLockExceptionForm.vm 2012-02-08 12:39:22 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/updateLockExceptionForm.vm 2012-02-08 13:38:13 +0000 @@ -1,34 +1,43 @@ -<script type="text/javascript"> - jQuery(document).ready( function() - { - - }); -</script> +<script type="text/javascript" src="javascript/lockException.js"></script> <h3>$i18n.getString( "edit_lock_exception" )</h3> <form id="updateLockExceptionForm" action="updateLockException.action" method="post" > +<input type="hidden" id="lockExceptionId" name="lockExceptionId" value="$lockException.id"/> +<input type="hidden" id="organisationUnitId" name="organisationUnitId" value="$lockException.organisationUnit.id"/> <table> <col style="width: 100px"/> <col/> <tr> - <td>#organisationUnitSelectionTree( true, false, true )</td> + <td>#organisationUnitSelectionTree( false, false, true )</td> </tr> <tr> <td> - <select id="dataSets" name="dataSetId" disabled="disabled" style="width: 100%;"> - <option>-- Please select an organisation unit --</option> + <select id="dataSets" name="dataSetId" style="width: 100%;"> + #foreach( $dataSet in $dataSets ) + #if( $dataSet.id == $lockException.dataSet.id ) + <option selected="selected" value="$dataSet.id">$encoder.htmlEncode( $!dataSet.name )</option> + #else + <option value="$dataSet.id">$encoder.htmlEncode( $!dataSet.name )</option> + #end + #end) </select> </td> </tr> <tr> <td> - <select id="periods" name="periodId" disabled="disabled" style="width: 100%;"> - <option>-- Please select a dataset--</option> + <select id="periods" name="periodId" style="width: 100%;"> + #foreach( $period in $periods ) + #if( $period.externalId == $lockException.period.externalId ) + <option selected="selected" value="$period.externalId">$encoder.htmlEncode( $!period.name )</option> + #else + <option value="$period.externalId">$encoder.htmlEncode( $!period.name )</option> + #end + #end) </select> </td> </tr>
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : [email protected] Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp

