=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2013-02-07 12:38:00 +0000 @@ -508,8 +508,8 @@ // remove name/shortName uniqueness executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT organisationunit_name_key" ); - executeSql( "ALTER TABLE orgunitgroup DROP CONSTRAINT orgunitgroup_name_key" ); - executeSql( "ALTER TABLE orgunitgroupset DROP CONSTRAINT orgunitgroupset_name_key" ); + executeSql( "ALTER TABLE orgunitgroup ADD CONSTRAINT orgunitgroup_name_key UNIQUE (name)" ); + executeSql( "ALTER TABLE orgunitgroupset ADD CONSTRAINT orgunitgroupset_name_key UNIQUE (name)" ); executeSql( "ALTER TABLE indicator DROP CONSTRAINT indicator_name_key" ); executeSql( "ALTER TABLE indicator DROP CONSTRAINT indicator_shortname_key" ); === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml 2013-02-07 12:38:00 +0000 @@ -15,7 +15,7 @@ &identifiableProperties; - + === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml' --- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml 2013-02-07 10:25:34 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml 2013-02-07 12:38:00 +0000 @@ -15,7 +15,7 @@ &identifiableProperties; - + === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/ValidateOrganisationUnitGroupAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/ValidateOrganisationUnitGroupAction.java 2013-02-04 14:57:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroup/ValidateOrganisationUnitGroupAction.java 2013-02-07 12:38:00 +0000 @@ -103,31 +103,12 @@ { List organisationUnitGroups = organisationUnitGroupService.getOrganisationUnitGroupByName( name ); - if ( !organisationUnitGroups.isEmpty() && id == null ) + if ( !organisationUnitGroups.isEmpty() && (id == null || organisationUnitGroups.get( 0 ).getId() != id) ) { - message = i18n.getString( "name_exists" ); + message = i18n.getString( "name_in_use" ); return ERROR; } - else if ( !organisationUnitGroups.isEmpty() ) - { - boolean found = false; - - for ( OrganisationUnitGroup organisationUnitGroup : organisationUnitGroups ) - { - if ( organisationUnitGroup.getId() == id ) - { - found = true; - } - } - - if ( !found ) - { - message = i18n.getString( "name_exists" ); - - return ERROR; - } - } } message = "OK"; === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java 2013-02-04 14:57:16 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunitgroupset/ValidateGroupSetAction.java 2013-02-07 12:38:00 +0000 @@ -32,7 +32,6 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupSetPopulator; import org.hisp.dhis.system.util.ListUtils; import java.util.ArrayList; @@ -116,31 +115,12 @@ { List organisationUnitGroupSets = organisationUnitGroupService.getOrganisationUnitGroupSetByName( name ); - if ( !organisationUnitGroupSets.isEmpty() && id == null ) + if ( !organisationUnitGroupSets.isEmpty() && (id == null || organisationUnitGroupSets.get( 0 ).getId() != id) ) { - message = i18n.getString( "name_exists" ); + message = i18n.getString( "name_in_use" ); return ERROR; } - else if ( !organisationUnitGroupSets.isEmpty() ) - { - boolean found = false; - - for ( OrganisationUnitGroupSet organisationUnitGroupSet : organisationUnitGroupSets ) - { - if ( organisationUnitGroupSet.getId() == id ) - { - found = true; - } - } - - if ( !found ) - { - message = i18n.getString( "name_exists" ); - - return ERROR; - } - } } // --------------------------------------------------------------------- === modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm' --- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2013-02-03 10:13:17 +0000 +++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm 2013-02-07 12:38:00 +0000 @@ -12,7 +12,7 @@ 'rules' : getValidationRules("organisationUnit") }); - checkValueIsExist( "name", "validateOrganisationUnit.action", { id : $organisationUnit.id } ); + // checkValueIsExist( "name", "validateOrganisationUnit.action", { id : $organisationUnit.id } ); checkValueIsExist( "code", "validateOrganisationUnit.action", { id : $organisationUnit.id } ); #if ( $numberOfChildren == 0 )