=== modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2012-11-28 10:16:05 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/exporting/action/ValidateGenerateExportReportAction.java 2013-03-07 09:36:38 +0000 @@ -29,17 +29,12 @@ import java.io.File; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.period.CalendarPeriodType; -import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.reportsheet.ExportReport; import org.hisp.dhis.reportsheet.ExportReportService; import org.hisp.dhis.reportsheet.ReportLocationManager; === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/EditDepartmentAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/EditDepartmentAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/EditDepartmentAction.java 2013-03-07 09:36:38 +0000 @@ -0,0 +1,194 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * 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 java.util.ArrayList; +import java.util.List; + +import org.hisp.dhis.dataset.DataSet; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroup; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class EditDepartmentAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String name; + + public void setName( String name ) + { + this.name = name; + } + + private String shortName; + + public void setShortName( String shortName ) + { + this.shortName = shortName; + } + + private List selectedGroups = new ArrayList(); + + public void setSelectedGroups( List selectedGroups ) + { + this.selectedGroups = selectedGroups; + } + + private List orgUnitGroupSets = new ArrayList(); + + public void setOrgUnitGroupSets( List orgUnitGroupSets ) + { + this.orgUnitGroupSets = orgUnitGroupSets; + } + + private String id; + + public void setId( String id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + // --------------------------------------------------------------------- + // Get parent + // --------------------------------------------------------------------- + + OrganisationUnit parent = selectionManager.getSelectedOrganisationUnit(); + + if ( parent == null ) + { + // ----------------------------------------------------------------- + // If no unit is selected, the parent is the parent of the roots + // ----------------------------------------------------------------- + + parent = selectionManager.getRootOrganisationUnitsParent(); + } + + // --------------------------------------------------------------------- + // Create organization unit + // --------------------------------------------------------------------- + + OrganisationUnit department = organisationUnitService.getOrganisationUnitByUuid( id ); + + if ( department == null ) + { + department = organisationUnitService.getOrganisationUnit( Integer.parseInt( id ) ); + } + + department.setName( name ); + department.setShortName( shortName ); + + // --------------------------------------------------------------------- + // Must persist org-unit before adding data sets because association are + // updated on both sides (and this side is inverse) + // --------------------------------------------------------------------- + + for ( int i = 0; i < orgUnitGroupSets.size(); i++ ) + { + OrganisationUnitGroupSet groupSet = organisationUnitGroupService.getOrganisationUnitGroupSet( Integer + .parseInt( orgUnitGroupSets.get( i ) ) ); + + OrganisationUnitGroup oldGroup = groupSet.getGroup( department ); + + OrganisationUnitGroup newGroup = organisationUnitGroupService.getOrganisationUnitGroup( Integer + .parseInt( selectedGroups.get( i ) ) ); + + if ( oldGroup != null ) + { + oldGroup.removeOrganisationUnit( department ); + + for ( DataSet ds : oldGroup.getDataSets() ) + { + department.removeDataSet( ds ); + } + + organisationUnitGroupService.updateOrganisationUnitGroup( oldGroup ); + } + + if ( newGroup != null ) + { + newGroup.addOrganisationUnit( department ); + + for ( DataSet ds : newGroup.getDataSets() ) + { + department.addDataSet( ds ); + } + + organisationUnitGroupService.updateOrganisationUnitGroup( newGroup ); + } + } + + organisationUnitService.updateOrganisationUnit( department ); + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentAction.java 2013-03-07 09:36:38 +0000 @@ -0,0 +1,93 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.reportsheet.action.ActionSupport; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class GetDepartmentAction + extends ActionSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String id; + + public void setId( String id ) + { + this.id = id; + } + + private OrganisationUnit organisationUnit; + + public OrganisationUnit getOrganisationUnit() + { + return organisationUnit; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + organisationUnit = organisationUnitService.getOrganisationUnitByUuid( id ); + + if ( organisationUnit == null ) + { + organisationUnit = organisationUnitService.getOrganisationUnit( Integer.parseInt( id ) ); + } + + if ( organisationUnit == null ) + { + message = i18n.getString( "organisation_unit_unavailable" ); + + return ERROR; + } + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentListAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentListAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/GetDepartmentListAction.java 2013-03-07 09:36:38 +0000 @@ -0,0 +1,144 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * Copyright (c) 2004-2013, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import static org.apache.commons.lang.StringUtils.isNotBlank; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; +import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; +import org.hisp.dhis.organisationunit.OrganisationUnitService; +import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; +import org.hisp.dhis.paging.ActionPagingSupport; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class GetDepartmentListAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private OrganisationUnitGroupService organisationUnitGroupService; + + public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) + { + this.organisationUnitGroupService = organisationUnitGroupService; + } + + private OrganisationUnitSelectionManager selectionManager; + + public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) + { + this.selectionManager = selectionManager; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private List groupSets; + + public List getGroupSets() + { + return groupSets; + } + + private List organisationUnits = new ArrayList(); + + public List getOrganisationUnits() + { + return organisationUnits; + } + + private String key; + + public String getKey() + { + return key; + } + + public void setKey( String key ) + { + this.key = key; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + { + groupSets = new ArrayList( organisationUnitGroupService + .getCompulsoryOrganisationUnitGroupSetsWithMembers() ); + + Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE ); + + Collection selectedUnits = selectionManager.getSelectedOrganisationUnits(); + + if ( selectedUnits.isEmpty() ) + { + organisationUnits.addAll( selectionManager.getRootOrganisationUnits() ); + } + else + { + for ( OrganisationUnit selectedUnit : selectedUnits ) + { + organisationUnits.addAll( selectedUnit.getChildren() ); + } + } + + Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() ); + + if ( isNotBlank( key ) ) + { + organisationUnitService.searchOrganisationUnitByName( organisationUnits, key ); + } + + this.paging = createPaging( organisationUnits.size() ); + organisationUnits = getBlockElement( organisationUnits, paging.getStartPos(), paging.getPageSize() ); + + return SUCCESS; + } +} === added file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RemoveDepartmentAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RemoveDepartmentAction.java 1970-01-01 00:00:00 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RemoveDepartmentAction.java 2013-03-07 09:36:38 +0000 @@ -0,0 +1,114 @@ +package org.hisp.dhis.reportsheet.organisationunit.action; + +/* + * 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 org.hisp.dhis.common.DeleteNotAllowedException; +import org.hisp.dhis.i18n.I18n; +import org.hisp.dhis.organisationunit.OrganisationUnit; +import org.hisp.dhis.organisationunit.OrganisationUnitService; + +import com.opensymphony.xwork2.Action; + +/** + * @author Dang Duy Hieu + * @version $Id$ + */ +public class RemoveDepartmentAction + implements Action +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private OrganisationUnitService organisationUnitService; + + public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) + { + this.organisationUnitService = organisationUnitService; + } + + private I18n i18n; + + public void setI18n( I18n i18n ) + { + this.i18n = i18n; + } + + // ------------------------------------------------------------------------- + // Input + // ------------------------------------------------------------------------- + + private String id; + + public void setId( String id ) + { + this.id = id; + } + + // ------------------------------------------------------------------------- + // Output + // ------------------------------------------------------------------------- + + private String message; + + public String getMessage() + { + return message; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + OrganisationUnit unit = organisationUnitService.getOrganisationUnitByUuid( id ); + + if ( unit == null ) + { + unit = organisationUnitService.getOrganisationUnit( Integer.parseInt( id ) ); + } + + try + { + organisationUnitService.deleteOrganisationUnit( unit ); + } + catch ( DeleteNotAllowedException ex ) + { + if ( ex.getErrorCode().equals( DeleteNotAllowedException.ERROR_ASSOCIATED_BY_OTHER_OBJECTS ) ) + { + message = i18n.getString( "object_not_deleted_associated_by_objects" ) + " " + ex.getMessage(); + + return ERROR; + } + } + + return SUCCESS; + } +} === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RenameOrganisationUnitAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RenameOrganisationUnitAction.java 2013-01-10 10:13:56 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/RenameOrganisationUnitAction.java 2013-03-07 09:36:38 +0000 @@ -62,9 +62,9 @@ // Input & Output // ------------------------------------------------------------------------- - private Integer id; + private String id; - public void setId( Integer id ) + public void setId( String id ) { this.id = id; } @@ -90,10 +90,15 @@ public String execute() throws Exception { - OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id ); + OrganisationUnit unit = organisationUnitService.getOrganisationUnitByUuid( id ); if ( unit == null ) { + unit = organisationUnitService.getOrganisationUnit( Integer.parseInt( id ) ); + } + + if ( unit == null ) + { message = i18n.getString( "org_unit_not_available" ); return ERROR; === removed file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java 2013-01-03 10:00:51 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java 1970-01-01 00:00:00 +0000 @@ -1,146 +0,0 @@ -package org.hisp.dhis.reportsheet.organisationunit.action; - -/* - * 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 static org.apache.commons.lang.StringUtils.isNotBlank; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.ouwt.manager.OrganisationUnitSelectionManager; -import org.hisp.dhis.paging.ActionPagingSupport; - -/** - * @author Dang Duy Hieu - * @version $Id$ - */ -public class ShowAddDepartmentFormAction - extends ActionPagingSupport -{ - // ------------------------------------------------------------------------- - // Dependencies - // ------------------------------------------------------------------------- - - private OrganisationUnitService organisationUnitService; - - public void setOrganisationUnitService( OrganisationUnitService organisationUnitService ) - { - this.organisationUnitService = organisationUnitService; - } - - private OrganisationUnitGroupService organisationUnitGroupService; - - public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService ) - { - this.organisationUnitGroupService = organisationUnitGroupService; - } - - private OrganisationUnitSelectionManager selectionManager; - - public void setSelectionManager( OrganisationUnitSelectionManager selectionManager ) - { - this.selectionManager = selectionManager; - } - - // ------------------------------------------------------------------------- - // Input & Output - // ------------------------------------------------------------------------- - - private List groupSets; - - public List getGroupSets() - { - return groupSets; - } - - private List organisationUnits = new ArrayList(); - - public List getOrganisationUnits() - { - return organisationUnits; - } - - private String key; - - public String getKey() - { - return key; - } - - public void setKey( String key ) - { - this.key = key; - } - - // ------------------------------------------------------------------------- - // Action implementation - // ------------------------------------------------------------------------- - - public String execute() - { - groupSets = new ArrayList( organisationUnitGroupService - .getCompulsoryOrganisationUnitGroupSetsWithMembers() ); - - Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE ); - - // - - Collection selectedUnits = selectionManager.getSelectedOrganisationUnits(); - - if ( selectedUnits.isEmpty() ) - { - organisationUnits.addAll( selectionManager.getRootOrganisationUnits() ); - } - else - { - for ( OrganisationUnit selectedUnit : selectedUnits ) - { - organisationUnits.addAll( selectedUnit.getChildren() ); - } - } - - Collections.sort( organisationUnits, new IdentifiableObjectNameComparator() ); - - if ( isNotBlank( key ) ) - { - organisationUnitService.searchOrganisationUnitByName( organisationUnits, key ); - } - - this.paging = createPaging( organisationUnits.size() ); - organisationUnits = getBlockElement( organisationUnits, paging.getStartPos(), paging.getPageSize() ); - - return SUCCESS; - } -} === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-01-16 05:49:06 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-03-07 09:36:38 +0000 @@ -1792,8 +1792,18 @@ + + + + + + + + + + + + + + + /dhis-web-spreadsheet-reporting/jsonOrganisationUnit.vm + + + + class="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentListAction"> /main.vm /dhis-web-spreadsheet-reporting/department.vm @@ -2584,7 +2591,7 @@ - ../dhis-web-commons/ajax/jsonResponseSuccess.vm @@ -2595,6 +2602,18 @@ plainTextError F_ORGANISATIONUNIT_UPDATE + + + + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + + + ../dhis-web-commons/ajax/jsonResponseError.vm + + plainTextError + F_ORGANISATIONUNIT_DELETE + === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm 2013-01-10 10:13:56 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/department.vm 2013-03-07 09:36:38 +0000 @@ -9,58 +9,7 @@ jQuery("#name").focus(); jQuery( "table.listTable tbody tr td[allowRename=true]" ).bind( "click", showRename ); }); - - function showRename( event ) - { - var jqsource = jQuery( "#" + this.id ); - var name = jqsource.html(); - _input = ""; - - jqsource.html( _input ); - jqsource.unbind( "click" ); - jqsource.find( "input" ).focus(); - jqsource.find( "input" ).val( name ); - } - - function renameByEnter( event, id, _old, _new ) - { - var key = event.keyCode || event.charCode || event.which; - - if ( key == 13 || key == 1 ) // Enter - { - var jqsource = jQuery( "#" + id ); - jqsource.bind( "click", showRename ); - - if ( _old != _new ) - { - jQuery.postUTF8( "renameOrganisationUnit.action", - { - id: id.substring(2, id.length), - name: _new - }, function( json ) - { - if ( json.response == "success" ) - { - jqsource.html( _new ); - } else { - jqsource.html( _old ); - showWarningMessage( json.message ); - } - } ); - } - else { jqsource.html( _old ); } - } - } - - function renameByBlur( id, _old, _new ) - { - var jqsource = jQuery( "#" + id ); - jqsource.bind( "click", showRename ); - jqsource.html( _old ); - } - + var previousName = ''; var adding_the_org_unit_failed = '$encoder.jsEscape( $i18n.getString( "adding_the_org_unit_failed" ) , "'" )'; var none = '$encoder.jsEscape( $i18n.getString( "none" ) , "'" )'; @@ -93,15 +42,16 @@ #foreach ( $groupSet in $groupSets ) - $encoder.htmlEncode( $groupSet.name ) - + $encoder.htmlEncode( $groupSet.displayName ) + + @@ -139,8 +89,12 @@ #foreach( $organisationUnit in $organisationUnits ) - - $encoder.htmlEncode( $organisationUnit.name ) + #set( $unitId = ${organisationUnit.uuid} ) + #if( !$unitId ) + $unitId = ${organisationUnit.id} + #end + + $encoder.htmlEncode( $organisationUnit.name ) - + $i18n.getString( 'edit' ) #if( $organisationUnit.children.size() == 0 && $auth.hasAccess( "dhis-web-maintenance-organisationunit", "removeOrganisationUnit" ) ) - $i18n.getString( 'remove' ) + $i18n.getString( 'remove' ) #else $i18n.getString( 'remove' ) #end - $i18n.getString( 'show_details' ) + $i18n.getString( 'show_details' ) #end === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js' --- local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js 2013-01-09 07:00:50 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/webapp/dhis-web-spreadsheet-reporting/javascript/department.js 2013-03-07 09:36:38 +0000 @@ -14,6 +14,57 @@ window.location.href = 'department.action'; } +function showRename( event ) +{ + var jqsource = jQuery( "#" + this.id ); + var name = jqsource.html(); + _input = ""; + + jqsource.html( _input ); + jqsource.unbind( "click" ); + jqsource.find( "input" ).focus(); + jqsource.find( "input" ).val( name ); +} + +function renameByEnter( event, id, _old, _new ) +{ + var key = event.keyCode || event.charCode || event.which; + + if ( key == 13 || key == 1 ) // Enter + { + var jqsource = jQuery( "#" + id ); + jqsource.bind( "click", showRename ); + + if ( _old != _new ) + { + jQuery.postUTF8( "renameDepartment.action", + { + id: id.substring(2, id.length), + name: _new + }, function( json ) + { + if ( json.response == "success" ) + { + jqsource.html( _new ); + } else { + jqsource.html( _old ); + showWarningMessage( json.message ); + } + } ); + } + else { jqsource.html( _old ); } + } +} + +function renameByBlur( id, _old, _new ) +{ + var jqsource = jQuery( "#" + id ); + jqsource.bind( "click", showRename ); + jqsource.html( _old ); +} + // ----------------------------------------------------------------------------- // Export to PDF // ----------------------------------------------------------------------------- @@ -31,7 +82,7 @@ function showOrganisationUnitDetails( unitId ) { - jQuery.post( '../dhis-web-commons-ajax-json/getOrganisationUnit.action', + jQuery.post( 'getDepartment.action', { id: unitId }, function ( json ) { setInnerHTML( 'nameField', json.organisationUnit.name ); setInnerHTML( 'shortNameField', json.organisationUnit.shortName ); @@ -60,13 +111,35 @@ }); } +function showUpdateOrganisationUnit( unitId ) +{ + jQuery.get( 'getDepartment.action', { id : unitId }, function( json ) + { + setFieldValue( 'name', json.organisationUnit.name ); + setFieldValue( 'shortName', json.organisationUnit.shortName ); + + var groups = json.organisationUnit.groups; + + if ( groups.length == 0 ) + { + jQuery( "select[name=selectedGroups] option:first-child" ).attr( "selected", "selected" ); + } + else { + for ( var i in groups ) + { + jQuery( "td#td" + groups[i].groupSetId + " select:first" ).val( groups[i].id ); + } + } + } ); +} + // ----------------------------------------------------------------------------- // Remove organisation unit // ----------------------------------------------------------------------------- function removeOrganisationUnit( unitId, unitName ) { - removeItem( unitId, unitName, confirm_to_delete_org_unit, '../dhis-web-maintenance-organisationunit/removeOrganisationUnit.action', subtree.refreshTree ); + removeItem( unitId, unitName, confirm_to_delete_org_unit, 'removeDepartment.action', subtree.refreshTree ); } function nameChanged()