------------------------------------------------------------ revno: 10034 committer: Hieu <hieu.hispviet...@gmail.com> branch nick: dhis2 timestamp: Thu 2013-03-07 16:36:38 +0700 message: local vn - Improved in the department management feature removed: local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/organisationunit/action/ShowAddDepartmentFormAction.java added: 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/GetDepartmentAction.java 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/RemoveDepartmentAction.java modified: 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/organisationunit/action/RenameOrganisationUnitAction.java local/vn/dhis-web-spreadsheet-reporting/src/main/resources/META-INF/dhis/beans.xml local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 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/javascript/department.js
-- 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
=== 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<String> selectedGroups = new ArrayList<String>(); + + public void setSelectedGroups( List<String> selectedGroups ) + { + this.selectedGroups = selectedGroups; + } + + private List<String> orgUnitGroupSets = new ArrayList<String>(); + + public void setOrgUnitGroupSets( List<String> 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<OrganisationUnit> +{ + // ------------------------------------------------------------------------- + // 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<OrganisationUnitGroupSet> groupSets; + + public List<OrganisationUnitGroupSet> getGroupSets() + { + return groupSets; + } + + private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>(); + + public List<OrganisationUnit> 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<OrganisationUnitGroupSet>( organisationUnitGroupService + .getCompulsoryOrganisationUnitGroupSetsWithMembers() ); + + Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE ); + + Collection<OrganisationUnit> 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<OrganisationUnit> -{ - // ------------------------------------------------------------------------- - // 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<OrganisationUnitGroupSet> groupSets; - - public List<OrganisationUnitGroupSet> getGroupSets() - { - return groupSets; - } - - private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>(); - - public List<OrganisationUnit> 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<OrganisationUnitGroupSet>( organisationUnitGroupService - .getCompulsoryOrganisationUnitGroupSetsWithMembers() ); - - Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE ); - - // - - Collection<OrganisationUnit> 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 @@ <!-- OrganisationUnit --> <bean - id="org.hisp.dhis.reportsheet.organisationunit.action.ShowAddDepartmentFormAction" - class="org.hisp.dhis.reportsheet.organisationunit.action.ShowAddDepartmentFormAction" + id="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentAction" + class="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentAction" + scope="prototype"> + <property name="organisationUnitService"> + <ref + bean="org.hisp.dhis.organisationunit.OrganisationUnitService" /> + </property> + </bean> + + <bean + id="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentListAction" + class="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentListAction" scope="prototype"> <property name="organisationUnitService"> <ref @@ -1837,6 +1847,16 @@ </property> </bean> + <bean + id="org.hisp.dhis.reportsheet.organisationunit.action.RemoveDepartmentAction" + class="org.hisp.dhis.reportsheet.organisationunit.action.RemoveDepartmentAction" + scope="prototype"> + <property name="organisationUnitService"> + <ref + bean="org.hisp.dhis.organisationunit.OrganisationUnitService" /> + </property> + </bean> + <!-- Data Entry module --> <bean === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2013-01-16 05:49:06 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module.properties 2013-03-07 09:36:38 +0000 @@ -403,4 +403,5 @@ registers_date = Registers date default_frame = Default frame extension_frame = Extension frame -user_setting_frame = User setting frame \ No newline at end of file +user_setting_frame = User setting frame +organisation_unit_unavailable= Selected unit is unavailable \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2013-01-16 05:49:06 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/org/hisp/dhis/reportsheet/i18n_module_vi_VN.properties 2013-03-07 09:36:38 +0000 @@ -435,4 +435,5 @@ registers_date = \u0110\u0103ng k\u00ed d\u1eef li\u1ec7u default_frame = Khung c\u01a1 b\u1ea3n extension_frame = Khung m\u1edf r\u1ed9ng -user_setting_frame = Thay \u0111\u1ed5i khung giao di\u1ec7n \ No newline at end of file +user_setting_frame = Thay \u0111\u1ed5i khung giao di\u1ec7n +organisation_unit_unavailable = \u0110\u01a1n v\u1ecb \u0111\u01b0\u1ee3c ch\u1ecdn hi\u1ec7n kh\u00f4ng t\u1ed3n t\u1ea1i \ No newline at end of file === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml' --- local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2013-01-16 05:49:06 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/resources/struts.xml 2013-03-07 09:36:38 +0000 @@ -2559,8 +2559,15 @@ <!-- OrganisationUnit --> + <action name="getDepartment" + class="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentAction"> + <result name="success" type="velocity-json"> + /dhis-web-spreadsheet-reporting/jsonOrganisationUnit.vm + </result> + </action> + <action name="department" - class="org.hisp.dhis.reportsheet.organisationunit.action.ShowAddDepartmentFormAction"> + class="org.hisp.dhis.reportsheet.organisationunit.action.GetDepartmentListAction"> <result name="success" type="velocity">/main.vm</result> <param name="page"> /dhis-web-spreadsheet-reporting/department.vm @@ -2584,7 +2591,7 @@ </param> </action> - <action name="renameOrganisationUnit" + <action name="renameDepartment" class="org.hisp.dhis.reportsheet.organisationunit.action.RenameOrganisationUnitAction"> <result name="success" type="velocity-json"> ../dhis-web-commons/ajax/jsonResponseSuccess.vm @@ -2595,6 +2602,18 @@ <param name="onExceptionReturn">plainTextError</param> <param name="requiredAuthorities">F_ORGANISATIONUNIT_UPDATE</param> </action> + + <action name="removeDepartment" + class="org.hisp.dhis.reportsheet.organisationunit.action.RemoveDepartmentAction"> + <result name="success" type="velocity-json"> + ../dhis-web-commons/ajax/jsonResponseSuccess.vm + </result> + <result name="error" type="velocity-json"> + ../dhis-web-commons/ajax/jsonResponseError.vm + </result> + <param name="onExceptionReturn">plainTextError</param> + <param name="requiredAuthorities">F_ORGANISATIONUNIT_DELETE</param> + </action> <!-- Data Entry module --> === 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 = "<input type='text' style='width:" + name.length + "em'"; - _input += " onkeypress='renameByEnter( event, " + '"' + this.id + '"' + ', "' + name + '"' + ", this.value )'"; - _input += " onblur='renameByBlur( " + '"' + this.id + '"' + ', "' + name + '"' + ", this.value )'/>"; - - 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 @@ </tr> #foreach ( $groupSet in $groupSets ) <tr> - <td style="width:200px">$encoder.htmlEncode( $groupSet.name )</td> - <td> + <td style="width:200px">$encoder.htmlEncode( $groupSet.displayName )</td> + <td id="td${groupSet.id}"> <select id="selectedGroups" name="selectedGroups" style="min-width: 244px;"> <option value="-1">[ $i18n.getString( "select_group" ) ]</option> #foreach ( $group in $groupSet.getSortedGroups() ) - <option value="$group.id">$group.name</option> + <option value="$group.id">$group.displayName</option> #end </select> </td> + <td><input type="hidden" name="orgUnitGroupSets" value="$groupSet.id"/></td> <td> <input type="submit" name="save" value="$i18n.getString( 'add' )" style="width: 10em;" /> </td> @@ -139,8 +89,12 @@ </thead> <tbody id="list"> #foreach( $organisationUnit in $organisationUnits ) - <tr id="tr${organisationUnit.id}"> - <td id="td${organisationUnit.id}" allowRename="true">$encoder.htmlEncode( $organisationUnit.name )</td> + #set( $unitId = ${organisationUnit.uuid} ) + #if( !$unitId ) + $unitId = ${organisationUnit.id} + #end + <tr id="tr${unitId}"> + <td id="td${unitId}" allowRename="true">$encoder.htmlEncode( $organisationUnit.name )</td> <td> <select style="width:190px"> #foreach( $group in $organisationUnit.groups ) @@ -149,11 +103,11 @@ </select> </td> <td style="text-align:right"> - <!--a href="showUpdateOrganisationUnitForm.action?id=$organisationUnit.id" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a--> + <a href="javascript:showUpdateOrganisationUnit( '$unitId' )" title="$i18n.getString( 'edit' )"><img src="../images/edit.png" alt="$i18n.getString( 'edit' )"/></a> #if( $organisationUnit.children.size() == 0 && $auth.hasAccess( "dhis-web-maintenance-organisationunit", "removeOrganisationUnit" ) ) - <a href="javascript:removeOrganisationUnit( $organisationUnit.id, '$encoder.jsEncode( $organisationUnit.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a> + <a href="javascript:removeOrganisationUnit( '$unitId', '$encoder.jsEncode( $organisationUnit.name )' )" title="$i18n.getString( 'remove' )"><img src="../images/delete.png" alt="$i18n.getString( 'remove' )"/></a> #else <img src="../images/delete-denied.png" alt="$i18n.getString( 'remove' )"/> #end - <a href="javascript:showOrganisationUnitDetails( $organisationUnit.id )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a> + <a href="javascript:showOrganisationUnitDetails( '$unitId' )" title="$i18n.getString( 'show_details' )"><img src="../images/information.png" alt="$i18n.getString( 'show_details' )"/></a> </td> </tr> #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 = "<input type='text' style='width:" + name.length + "em'"; + _input += " onkeypress='renameByEnter( event, " + '"' + this.id + '"' + ', "' + name + '"' + ", this.value )'"; + _input += " onblur='renameByBlur( " + '"' + this.id + '"' + ', "' + name + '"' + ", this.value )'/>"; + + 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()
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp