=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2010-09-14 09:03:41 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/DefineDataSetAssociationsAction.java 2010-09-29 07:05:04 +0000 @@ -34,6 +34,7 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.source.Source; @@ -66,6 +67,13 @@ this.dataSetService = dataSetService; } + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + // ------------------------------------------------------------------------- // Input & Output // ------------------------------------------------------------------------- @@ -89,18 +97,18 @@ Set unitsInTheTree = new HashSet(); - getUnitsInTheTree( rootUnits, unitsInTheTree ); + organisationUnitService.getUnitsInTheTree( rootUnits, unitsInTheTree ); DataSet dataSet = dataSetService.getDataSet( dataSetId ); Set assignedSources = dataSet.getSources(); - assignedSources.removeAll( convert( unitsInTheTree ) ); + assignedSources.removeAll( organisationUnitService.convert( unitsInTheTree ) ); Collection selectedOrganisationUnits = selectionTreeManager .getReloadedSelectedOrganisationUnits(); - assignedSources.addAll( convert( selectedOrganisationUnits ) ); + assignedSources.addAll( organisationUnitService.convert( selectedOrganisationUnits ) ); dataSet.setSources( assignedSources ); @@ -108,26 +116,4 @@ return SUCCESS; } - - // ------------------------------------------------------------------------- - // Supportive methods - // ------------------------------------------------------------------------- - - private Set convert( Collection organisationUnits ) - { - Set sources = new HashSet(); - - sources.addAll( organisationUnits ); - - return sources; - } - - private void getUnitsInTheTree( Collection rootUnits, Set unitsInTheTree ) - { - for ( OrganisationUnit root : rootUnits ) - { - unitsInTheTree.add( root ); - getUnitsInTheTree( root.getChildren(), unitsInTheTree ); - } - } } === added file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/MergeAssignedOrgunitsAction.java 2010-09-29 07:05:04 +0000 @@ -0,0 +1,129 @@ +package org.hisp.dhis.dataset.action.editor; + +/* + * 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. + */ + +import java.util.Collection; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.dataset.DataSetService; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.oust.manager.SelectionTreeManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class MergeAssignedOrgunitsAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private SelectionTreeManager selectionTreeManager; + + public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager ) + { + this.selectionTreeManager = selectionTreeManager; + } + + private DataSetService dataSetService; + + public void setDataSetService( DataSetService dataSetService ) + { + this.dataSetService = dataSetService; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private Collection selectedDataSets = new HashSet(); + + public void setSelectedDataSets( Collection selectedDataSets ) + { + this.selectedDataSets = selectedDataSets; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private Set selectedUnits = new HashSet(); + + public Set getSelectedUnits() + { + return selectedUnits; + } + + // ------------------------------------------------------------------------- + // Action + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + Set tempUnits = new HashSet(); + + if ( selectedDataSets.size() >= 1 ) + { + Iterator iterator = selectedDataSets.iterator(); + + if ( iterator.hasNext() ) + { + DataSet dataSet = dataSetService.getDataSet( Integer.valueOf( iterator.next() ) ); + selectedUnits.addAll( dataSet.getOrganisationUnis() ); + + iterator.remove(); + } + } + + for ( String dataSetId : selectedDataSets ) + { + DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) ); + tempUnits = dataSet.getOrganisationUnis(); + + if ( !(tempUnits.size() == selectedUnits.size() && tempUnits.containsAll( selectedUnits )) ) + { + selectedUnits.clear(); + selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); + + return SUCCESS; + } + } + + selectionTreeManager.setSelectedOrganisationUnits( selectedUnits ); + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/SaveAssignMultiDataSetForOrgunitAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/SaveAssignMultiDataSetForOrgunitAction.java 2010-09-27 08:17:04 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/editor/SaveAssignMultiDataSetForOrgunitAction.java 2010-09-29 07:05:04 +0000 @@ -34,6 +34,7 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.oust.manager.SelectionTreeManager; import org.hisp.dhis.source.Source; @@ -64,8 +65,15 @@ this.dataSetService = dataSetService; } + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + // ------------------------------------------------------------------------- - // Input & Output + // Input // ------------------------------------------------------------------------- private Collection selectedDataSets = new HashSet(); @@ -75,6 +83,13 @@ this.selectedDataSets = selectedDataSets; } + private boolean assignStatus; + + public void setAssignStatus( boolean assignStatus ) + { + this.assignStatus = assignStatus; + } + // ------------------------------------------------------------------------- // Action // ------------------------------------------------------------------------- @@ -82,15 +97,26 @@ public String execute() throws Exception { - Set selectedOrganisationUnits = convert( selectionTreeManager + Collection rootUnits = selectionTreeManager.getRootOrganisationUnits(); + + Set unitsInTheTree = new HashSet(); + + organisationUnitService.getUnitsInTheTree( rootUnits, unitsInTheTree ); + + Set selectedOrganisationUnits = organisationUnitService.convert( selectionTreeManager .getReloadedSelectedOrganisationUnits() ); for ( String dataSetId : selectedDataSets ) { - DataSet dataSet = dataSetService.getDataSet( Integer.parseInt( dataSetId ) ); + DataSet dataSet = dataSetService.getDataSet( Integer.valueOf( dataSetId ) ); Set assignedSources = dataSet.getSources(); + if ( !assignStatus ) + { + assignedSources.removeAll( organisationUnitService.convert( unitsInTheTree ) ); + } + assignedSources.addAll( selectedOrganisationUnits ); dataSet.setSources( assignedSources ); @@ -100,17 +126,4 @@ return SUCCESS; } - - // ------------------------------------------------------------------------- - // Supportive methods - // ------------------------------------------------------------------------- - - private Set convert( Collection organisationUnits ) - { - Set sources = new HashSet(); - - sources.addAll( organisationUnits ); - - return sources; - } } === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2010-09-16 05:35:12 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/META-INF/dhis/beans.xml 2010-09-29 07:05:04 +0000 @@ -148,6 +148,9 @@ + + + - + @@ -494,4 +496,18 @@ + + + + + + + + + + + + \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2010-09-28 04:02:31 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module.properties 2010-09-29 07:05:04 +0000 @@ -148,4 +148,7 @@ org_units = Organisation Units data = Data pivot = Pivot -please_select_dataset_or_categorycombo = Please select a dataset/category combo \ No newline at end of file +please_select_dataset_or_categorycombo = Please select a dataset/category combo +confirm_save = This operation will change the old orgunits assigned to these datasets.\nAre you sure to save this? +not_change_old_but_assign_new_only = Do not change the old assignment but assign new only. +datasets_different_orgunitlist = These selected datasets are not the same the list of organsation unit. \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module_vi_VN.properties' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module_vi_VN.properties 2010-09-07 05:24:21 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/org/hisp/dhis/dataset/i18n_module_vi_VN.properties 2010-09-29 07:05:04 +0000 @@ -81,4 +81,7 @@ delete_success = X\u00f3a th\u00e0nh c\u00f4ng rename_success = \u0110\u1ed5i t\u00ean th\u00e0nh c\u00f4ng rename_failed = \u0110\u1ed5i t\u00ean kh\u00f4ng th\u00e0nh c\u00f4ng -please_select_dataset_or_categorycombo = H\u00e3y ch\u1ecdn t\u1eadp d\u1eef li\u1ec7u v\u00e0 category combo t\u01b0\u01a1ng \u1ee9ng \ No newline at end of file +please_select_dataset_or_categorycombo = H\u00e3y ch\u1ecdn t\u1eadp d\u1eef li\u1ec7u v\u00e0 category combo t\u01b0\u01a1ng \u1ee9ng +confirm_save = H\u00e0nh \u0111\u1ed9ng n\u00e0y s\u1ebd thay \u0111\u1ed5i nh\u1eefng \u0111\u01a1n v\u1ecb \u0111\u00e3 \u0111\u01b0\u1ee3c g\u00e1n tr\u01b0\u1edbc \u0111\u00f3 cho c\u00e1c t\u1eadp d\u1eef li\u1ec7u l\u1ef1a ch\u1ecdn tr\u00ean.\nB\u1ea1n c\u00f3 mu\u1ed1n ti\u1ebfp t\u1ee5c? +not_change_old_but_assign_new_only = Kh\u00f4ng thay \u0111\u1ed5i vi\u1ec7c g\u00e1n c\u0169 ch\u1ec9 g\u00e1n th\u00eam m\u1edbi. +datasets_different_orgunitlist = C\u00e1c t\u1eadp d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c ch\u1ecdn tr\u00ean kh\u00e1c nhau v\u1ec1 danh s\u00e1ch c\u00e1c \u0111\u01a1n v\u1ecb g\u00e1n. \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-09-14 09:03:41 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/resources/struts.xml 2010-09-29 07:05:04 +0000 @@ -311,11 +311,7 @@ /main.vm /dhis-web-maintenance-dataset/showAssignMultiDataSetForm.vm /dhis-web-maintenance-dataset/menu.vm - ../dhis-web-commons/oust/oust.js, - javascript/shortName.js, - javascript/dataSet.js, - javascript/multiDataSet.js - + ../dhis-web-commons/oust/oust.js /dhis-web-maintenance-dataset/responseSuccess.vm F_DATASET_DELETE + + + + /dhis-web-commons/ouwt/responseSelect.vm + plainTextError + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/showAssignMultiDataSetForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/showAssignMultiDataSetForm.vm 2010-09-25 20:13:04 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/showAssignMultiDataSetForm.vm 2010-09-29 07:05:04 +0000 @@ -1,7 +1,15 @@ + +

$i18n.getString( "dataset_assignment_editor" )

-
- + @@ -13,7 +21,7 @@
$i18n.getString( "available_datasets" )$i18n.getString( "selected_datasets" )
- #foreach( $dataSet in $availableDataSets ) #end @@ -21,19 +29,29 @@ -
-
-
- +
+
+
+
-

-#organisationUnitSelectionTree( true, true, false) +#organisationUnitSelectionTree( true, true, false ) +
+ + + + + + +
$i18n.getString( "optional" )
+ $i18n.getString( "not_change_old_but_assign_new_only" ) +

@@ -41,71 +59,6 @@

- - - - - - -