dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14295
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4807: Made the code property of DataElement, Indicator and OrganisationUnit unique
Merge authors:
Lars Helge Øverland (larshelge)
------------------------------------------------------------
revno: 4807 [merge]
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-10-03 17:14:41 +0200
message:
Made the code property of DataElement, Indicator and OrganisationUnit unique
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java
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/dataelement/hibernate/DataElement.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml
dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ValidateDataElementAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ValidateIndicatorAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/ValidateDataSetAction.java
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ValidateOrganisationUnitAction.java
--
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-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-07-14 10:31:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2011-10-03 15:14:41 +0000
@@ -60,6 +60,8 @@
Indicator getIndicatorByShortName( String shortName );
Indicator getIndicatorByAlternativeName( String alternativeName );
+
+ Indicator getIndicatorByCode( String code );
Collection<Indicator> getIndicatorsWithGroupSets();
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java 2011-07-14 10:31:16 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorStore.java 2011-10-03 15:14:41 +0000
@@ -54,6 +54,8 @@
Indicator getIndicatorByShortName( String shortName );
Indicator getIndicatorByAlternativeName( String alternativeName );
+
+ Indicator getIndicatorByCode( String code );
Collection<Indicator> getIndicatorsWithGroupSets();
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-07-14 10:31:16 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2011-10-03 15:14:41 +0000
@@ -165,6 +165,11 @@
{
return i18n( i18nService, indicatorStore.getIndicatorByAlternativeName( alternativeName ) );
}
+
+ public Indicator getIndicatorByCode( String code )
+ {
+ return i18n( i18nService, indicatorStore.getIndicatorByCode( code ) );
+ }
public Collection<Indicator> getIndicatorsWithGroupSets()
{
=== 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 2011-09-24 11:35:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java 2011-10-03 14:50:57 +0000
@@ -185,11 +185,6 @@
// minmaxdataelement query index
executeSql( "CREATE INDEX index_minmaxdataelement ON minmaxdataelement( sourceid, dataelementid, categoryoptioncomboid )" );
- // drop code unique constraints
- executeSql( "ALTER TABLE dataelement DROP CONSTRAINT dataelement_code_key" );
- executeSql( "ALTER TABLE indicator DROP CONSTRAINT indicator_code_key" );
- executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT organisationunit_code_key" );
-
// add mandatory boolean field to patientattribute
executeSql( "ALTER TABLE patientattribute ADD mandatory bool" );
@@ -290,6 +285,12 @@
executeSql( "ALTER TABLE message DROP COLUMN messagesubject" );
executeSql( "ALTER TABLE usermessage DROP COLUMN messagedate" );
executeSql( "DROP TABLE message_usermessages" );
+
+ // create code unique constraints
+
+ executeSql( "ALTER TABLE dataelement ADD CONSTRAINT dataelement_code_key UNIQUE(code)" );
+ executeSql( "ALTER TABLE indicator ADD CONSTRAINT indicator_code_key UNIQUE(code)" );
+ executeSql( "ALTER TABLE organisationunit ADD CONSTRAINT organisationunit_code_key UNIQUE(code)" );
log.info( "Tables updated" );
}
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2011-09-21 14:43:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml 2011-10-03 14:27:32 +0000
@@ -12,25 +12,15 @@
<generator class="native" />
</id>
- <property name="uuid">
- <column name="uuid" length="40" />
- </property>
-
- <property name="name">
- <column name="name" not-null="true" unique="true" length="230" />
- </property>
-
- <property name="alternativeName">
- <column name="alternativename" not-null="false" unique="true" length="230" />
- </property>
-
- <property name="shortName">
- <column name="shortname" not-null="true" unique="true" length="50" />
- </property>
-
- <property name="code">
- <column name="code" not-null="false" unique="false" length="50" />
- </property>
+ <property name="uuid" column="uuid" length="40" />
+
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
+
+ <property name="alternativeName" column="alternativename" not-null="false" unique="true" length="230" />
+
+ <property name="shortName" column="shortname" not-null="true" unique="true" length="50" />
+
+ <property name="code" column="code" not-null="false" unique="true" length="50" />
<property name="description" type="text" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2011-07-13 09:35:32 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataset/hibernate/DataSet.hbm.xml 2011-10-03 14:27:32 +0000
@@ -20,7 +20,7 @@
<property name="shortName" unique="true" length="50" />
- <property name="code" unique="true" length="50" />
+ <property name="code" not-null="false" unique="true" length="50" />
<many-to-one name="periodType" lazy="false" class="org.hisp.dhis.period.PeriodType" column="periodtypeid"
not-null="true" foreign-key="fk_dataset_periodtypeid" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml 2011-09-24 11:35:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/indicator/hibernate/Indicator.hbm.xml 2011-10-03 14:27:32 +0000
@@ -12,25 +12,15 @@
<generator class="native" />
</id>
- <property name="uuid">
- <column name="uuid" length="40" />
- </property>
-
- <property name="name">
- <column name="name" not-null="true" unique="true" length="230" />
- </property>
-
- <property name="alternativeName">
- <column name="alternativename" not-null="false" unique="true" length="230" />
- </property>
-
- <property name="shortName">
- <column name="shortname" not-null="true" unique="true" length="50" />
- </property>
-
- <property name="code">
- <column name="code" not-null="false" unique="false" length="50" />
- </property>
+ <property name="uuid" column="uuid" length="40" />
+
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
+
+ <property name="alternativeName" column="alternativename" not-null="false" unique="true" length="230" />
+
+ <property name="shortName" column="shortname" not-null="true" unique="true" length="50" />
+
+ <property name="code" column="code" not-null="false" unique="true" length="50" />
<property name="description" type="text" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml 2011-09-21 14:43:36 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml 2011-10-03 14:27:32 +0000
@@ -12,13 +12,9 @@
<generator class="native" />
</id>
- <property name="uuid">
- <column name="uuid" length="40" />
- </property>
+ <property name="uuid" column="uuid" length="40" />
- <property name="name">
- <column name="name" not-null="true" unique="true" length="230" />
- </property>
+ <property name="name" column="name" not-null="true" unique="true" length="230" />
<set name="children" inverse="true">
<cache usage="read-write" />
@@ -29,13 +25,9 @@
<many-to-one name="parent" class="org.hisp.dhis.organisationunit.OrganisationUnit" column="parentid"
foreign-key="fk_parentid" index="in_parentid" />
- <property name="shortName">
- <column name="shortname" not-null="true" unique="false" length="50" />
- </property>
+ <property name="shortName" column="shortname" not-null="true" unique="false" length="50" />
- <property name="code">
- <column name="code" not-null="false" unique="false" length="50" />
- </property>
+ <property name="code" column="code" not-null="false" unique="true" length="50" />
<property name="openingDate" column="openingdate" type="date" />
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java 2011-09-14 14:35:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/dataelement/DataElementServiceTest.java 2011-10-03 14:50:57 +0000
@@ -32,7 +32,6 @@
import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
import java.util.Collection;
import java.util.HashSet;
@@ -179,19 +178,15 @@
{
DataElement dataElementA = createDataElement( 'A' );
DataElement dataElementB = createDataElement( 'B' );
- DataElement dataElementC1 = createDataElement( 'C' );
- DataElement dataElementC2 = createDataElement( 'D' );
+ DataElement dataElementC = createDataElement( 'C' );
dataElementA.setCode( "codeA");
dataElementB.setCode( "codeB");
- dataElementC1.setCode( "codeC");
- dataElementC2.setCode( "codeC");
-
+ dataElementC.setCode( "codeC");
int idA = dataElementService.addDataElement( dataElementA );
int idB = dataElementService.addDataElement( dataElementB );
- dataElementService.addDataElement( dataElementC1 );
- dataElementService.addDataElement( dataElementC2 );
+ dataElementService.addDataElement( dataElementC );
dataElementA = dataElementService.getDataElementByCode( "codeA" );
assertNotNull( dataElementA );
@@ -202,15 +197,6 @@
assertNotNull( dataElementB );
assertEquals( idB, dataElementB.getId() );
assertEquals( "DataElementB", dataElementB.getName() );
-
- try
- {
- dataElementService.getDataElementByCode( "codeC" );
- fail( "Should have thrown exception" );
- }
- catch ( Exception ex )
- {
- }
DataElement dataElementE = dataElementService.getDataElementByCode( "codeE" );
assertNull( dataElementE );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ValidateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ValidateDataElementAction.java 2011-01-25 19:27:15 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/ValidateDataElementAction.java 2011-10-03 15:14:41 +0000
@@ -35,9 +35,6 @@
/**
* @author Torgeir Lorange Ostby
- * @author Hans S. Toemmerholt
- * @version $Id: ValidateDataElementAction.java 2869 2007-02-20 14:26:09Z
- * andegje $
*/
public class ValidateDataElementAction
implements Action
@@ -90,7 +87,14 @@
public void setShortName( String shortName )
{
this.shortName = shortName;
- }
+ }
+
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
// -------------------------------------------------------------------------
// Output
@@ -115,7 +119,6 @@
if ( name != null )
{
-
DataElement match = dataElementService.getDataElementByName( name );
if ( match != null && (id == null || match.getId() != id) )
@@ -128,7 +131,6 @@
if ( shortName != null )
{
-
DataElement match = dataElementService.getDataElementByShortName( shortName );
if ( match != null && (id == null || match.getId() != id) )
@@ -139,7 +141,7 @@
}
}
- if ( alternativeName != null && alternativeName.trim().length() != 0 )
+ if ( alternativeName != null && !alternativeName.trim().isEmpty() )
{
DataElement match = dataElementService.getDataElementByAlternativeName( alternativeName );
@@ -149,8 +151,19 @@
return ERROR;
}
- }
-
+ }
+
+ if ( code != null && !code.trim().isEmpty() )
+ {
+ DataElement match = dataElementService.getDataElementByCode( code );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "code_in_use" );
+
+ return ERROR;
+ }
+ }
// ---------------------------------------------------------------------
// Validation success
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ValidateIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ValidateIndicatorAction.java 2011-08-19 07:40:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/indicator/ValidateIndicatorAction.java 2011-10-03 15:14:41 +0000
@@ -35,8 +35,6 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: ValidateIndicatorAction.java 4015 2007-11-15 14:46:04Z larshelg
- * $
*/
public class ValidateIndicatorAction
implements Action
@@ -90,7 +88,14 @@
{
this.alternativeName = alternativeName;
}
-
+
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -132,7 +137,7 @@
}
}
- if ( alternativeName != null )
+ if ( alternativeName != null && !alternativeName.trim().isEmpty() )
{
Indicator match = indicatorService.getIndicatorByAlternativeName( alternativeName );
@@ -142,11 +147,22 @@
return ERROR;
}
- }
+ }
+
+ if ( code != null && !code.trim().isEmpty() )
+ {
+ Indicator match = indicatorService.getIndicatorByCode( code );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "code_in_use" );
+
+ return ERROR;
+ }
+ }
message = i18n.getString( "everything_is_ok" );
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm 2011-09-20 14:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm 2011-10-03 15:14:41 +0000
@@ -18,6 +18,7 @@
checkValueIsExist( "name", "validateDataElement.action" );
checkValueIsExist( "shortName", "validateDataElement.action" );
checkValueIsExist( "alternativeName", "validateDataElement.action" );
+ checkValueIsExist( "code", "validateDataElement.action" );
} );
var previousName = '';
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js 2011-09-30 06:17:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/javascript/dataElement.js 2011-10-03 15:14:41 +0000
@@ -110,56 +110,6 @@
});
}
-function getDataElements( dataElementGroupId, type, filterCalculated )
-{
- var url = "getDataElementGroupMembers.action?";
-
- if ( dataElementGroupId == '[select]' )
- {
- return;
- }
-
- if ( dataElementGroupId != null )
- {
- url += "dataElementGroupId=" + dataElementGroupId;
- }
-
- if ( type != null )
- {
- url += "&type=" + type;
- }
-
- if ( filterCalculated )
- {
- url += "&filterCalculated=on";
- }
-
- var request = new Request();
- request.setResponseTypeXML( 'operand' );
- request.setCallbackSuccess( getDataElementsReceived );
- request.send( url );
-}
-
-function getDataElementsReceived( xmlObject )
-{
- var availableDataElements = document.getElementById( "availableDataElements" );
-
- clearList( availableDataElements );
-
- var operands = xmlObject.getElementsByTagName( "operand" );
-
- for ( var i = 0; i < operands.length; i++ )
- {
- var id = operands[i].getElementsByTagName( "operandId" )[0].firstChild.nodeValue;
- var dataElementName = operands[i].getElementsByTagName( "operandName" )[0].firstChild.nodeValue;
-
- var option = document.createElement( "option" );
- option.value = id;
- option.text = dataElementName;
- option.title = dataElementName;
- availableDataElements.add( option, null );
- }
-}
// -----------------------------------------------------------------------------
// Remove data element
// -----------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm 2011-09-20 14:48:24 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm 2011-10-03 15:14:41 +0000
@@ -17,6 +17,7 @@
checkValueIsExist( "name", "validateDataElement.action", {id:getFieldValue('id')});
checkValueIsExist( "shortName", "validateDataElement.action", {id:getFieldValue('id')});
checkValueIsExist( "alternativeName", "validateDataElement.action", {id:getFieldValue('id')});
+ checkValueIsExist( "code", "validateDataElement.action", {id:getFieldValue('id')});
updateAggreationOperation( getFieldValue('valueType') );
});
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/ValidateDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/ValidateDataSetAction.java 2010-08-25 09:31:57 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/java/org/hisp/dhis/dataset/action/ValidateDataSetAction.java 2011-10-03 15:14:41 +0000
@@ -113,8 +113,7 @@
// ---------------------------------------------------------------------
if ( name != null )
- {
-
+ {
DataSet match = dataSetService.getDataSetByName( name );
if ( match != null && (dataSetId == null || match.getId() != dataSetId) )
@@ -128,7 +127,6 @@
// ---------------------------------------------------------------------
// Short name
// ---------------------------------------------------------------------
-
if ( shortName != null )
{
@@ -146,7 +144,7 @@
// Code
// ---------------------------------------------------------------------
- if ( code != null && code.trim().length() != 0 )
+ if ( code != null && !code.trim().isEmpty() )
{
DataSet match = dataSetService.getDataSetByCode( code );
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ValidateOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ValidateOrganisationUnitAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ValidateOrganisationUnitAction.java 2011-10-03 15:14:41 +0000
@@ -69,7 +69,14 @@
{
this.name = name;
}
-
+
+ private String code;
+
+ public void setCode( String code )
+ {
+ this.code = code;
+ }
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
@@ -108,7 +115,19 @@
return ERROR;
}
- }
+ }
+
+ if ( code != null && !code.trim().isEmpty() )
+ {
+ OrganisationUnit match = organisationUnitService.getOrganisationUnitByCode( code );
+
+ if ( match != null && (id == null || match.getId() != id) )
+ {
+ message = i18n.getString( "code_in_use" );
+
+ return ERROR;
+ }
+ }
message = "OK";