dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #20912
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9764: added back uniqueness on OrgUnitGroup/GroupSet
------------------------------------------------------------
revno: 9764
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-02-07 19:38:00 +0700
message:
added back uniqueness on OrgUnitGroup/GroupSet
modified:
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/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroup.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnitGroupSet.hbm.xml
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/organisationunitgroupset/ValidateGroupSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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 @@
</id>
&identifiableProperties;
- <property name="name" column="name" not-null="true" unique="false" length="230" />
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
<property name="symbol" />
=== 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 @@
</id>
&identifiableProperties;
- <property name="name" column="name" not-null="true" unique="false" length="230" />
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
<property name="description" />
<property name="compulsory" not-null="true" />
=== 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<OrganisationUnitGroup> 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<OrganisationUnitGroupSet> 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 )