← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1982: Removed uniqueness constraint on OrganisationUnit shortname

 

------------------------------------------------------------
revno: 1982
committer: Lars <larshelg@larshelg-laptop>
branch nick: trunk
timestamp: Fri 2010-08-27 12:58:42 +0200
message:
  Removed uniqueness constraint on OrganisationUnit shortname
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.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/organisationunit/hibernate/OrganisationUnit.hbm.xml
  dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.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/organisationunit/OrganisationUnitService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2010-06-08 19:47:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2010-08-27 10:58:42 +0000
@@ -122,14 +122,13 @@
     OrganisationUnit getOrganisationUnitByName( String name );
 
     /**
-     * Returns an OrganisationUnit with a given short name.
+     * Returns an OrganisationUnit with a given code.
      * 
-     * @param shortName the short name of the OrganisationUnit to return.
-     * @return the OrganisationUnit with the given short name, or null if no
-     *         match.
+     * @param code the code of the OrganisationUnit to return.
+     * @return the OrganisationUnit with the given code, or null if not match.
      */
-    OrganisationUnit getOrganisationUnitByShortName( String shortName );
-
+    OrganisationUnit getOrganisationUnitByCode( String code );
+    
     /**
      * Returns all root OrganisationUnits. A root OrganisationUnit is an
      * OrganisationUnit with no parent/the parent set to null.

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2010-06-08 19:47:40 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitStore.java	2010-08-27 10:58:42 +0000
@@ -60,14 +60,13 @@
     OrganisationUnit getOrganisationUnitByName( String name );
 
     /**
-     * Returns an OrganisationUnit with a given short name.
+     * Returns an OrganisationUnit with a given code.
      * 
-     * @param shortName the short name of the OrganisationUnit to return.
-     * @return the OrganisationUnit with the given short name, or null if no
-     *         match.
+     * @param code the code of the OrganisationUnit to return.
+     * @return the OrganisationUnit with the given code, or null if not match.
      */
-    OrganisationUnit getOrganisationUnitByShortName( String shortName );
-
+    OrganisationUnit getOrganisationUnitByCode( String code );
+    
     /**
      * Returns all root OrganisationUnits. A root OrganisationUnit is an
      * OrganisationUnit with no parent/has the parent set to null.

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2010-08-25 04:13:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2010-08-27 10:58:42 +0000
@@ -179,9 +179,9 @@
         return organisationUnitStore.getOrganisationUnitByName( name );
     }
 
-    public OrganisationUnit getOrganisationUnitByShortName( String shortName )
+    public OrganisationUnit getOrganisationUnitByCode( String code )
     {
-        return organisationUnitStore.getOrganisationUnitByShortName( shortName );
+        return organisationUnitStore.getOrganisationUnitByCode( code );
     }
 
     public Collection<OrganisationUnit> getRootOrganisationUnits()

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2010-06-08 19:47:40 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/hibernate/HibernateOrganisationUnitStore.java	2010-08-27 10:58:42 +0000
@@ -89,17 +89,6 @@
         return (OrganisationUnit) query.uniqueResult();
     }
 
-    public OrganisationUnit getOrganisationUnitByShortName( String shortName )
-    {
-        Session session = sessionFactory.getCurrentSession();
-
-        Query query = session.createQuery( "from OrganisationUnit o where o.shortName = :shortName" );
-
-        query.setString( "shortName", shortName );
-
-        return (OrganisationUnit) query.uniqueResult();
-    }
-
     public OrganisationUnit getOrganisationUnitByCode( String code )
     {
         Session session = sessionFactory.getCurrentSession();

=== 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	2010-08-18 10:41:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableAlteror.java	2010-08-27 10:58:42 +0000
@@ -163,6 +163,9 @@
         //orgunit coord
         executeSql( "ALTER TABLE organisationunit DROP COLUMN polygoncoordinates" );
         
+        //orgunit shortname uniqueness
+        executeSql( "ALTER TABLE organisationunit DROP CONSTRAINT organisationunit_shortname_key" );
+        
         log.info( "Tables updated" );
     }
 

=== 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	2010-05-25 17:36:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/organisationunit/hibernate/OrganisationUnit.hbm.xml	2010-08-27 10:58:42 +0000
@@ -24,11 +24,11 @@
 		
     <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="true" length="50"/>			
+      <column name="shortname" not-null="true" unique="false" length="50"/>			
     </property>
-		
+	
     <property name="code">
       <column name="code" not-null="false" unique="false" length="25"/>
     </property>

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java'
--- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java	2010-06-22 09:22:00 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java	2010-08-27 10:58:42 +0000
@@ -174,9 +174,6 @@
         OrganisationUnit unit1 = organisationUnitService.getOrganisationUnitByName( oU1Name );
         assertEquals( unit1.getName(), oU1Name );
 
-        OrganisationUnit unit2 = organisationUnitService.getOrganisationUnitByShortName( oU2ShortName );
-        assertEquals( unit2.getShortName(), oU2ShortName );
-
         OrganisationUnit unit4 = organisationUnitService.getOrganisationUnitByName( "foo" );
         assertNull( unit4 );
     }

=== modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java	2010-07-30 14:20:36 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitImporter.java	2010-08-27 10:58:42 +0000
@@ -104,7 +104,7 @@
         
         if ( match == null )
         {
-            match = organisationUnitService.getOrganisationUnitByShortName( object.getShortName() );
+            match = organisationUnitService.getOrganisationUnitByCode( object.getCode() );
         }
         
         return match;

=== 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	2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/java/org/hisp/dhis/oum/action/organisationunit/ValidateOrganisationUnitAction.java	2010-08-27 10:58:42 +0000
@@ -161,19 +161,6 @@
 
             return INPUT;
         }
-        else
-        {
-            shortName = shortName.trim();
-
-            OrganisationUnit match = organisationUnitService.getOrganisationUnitByShortName( shortName );
-
-            if ( match != null && (id == null || match.getId() != id) )
-            {
-                message = i18n.getString( "short_name_in_use" );
-
-                return INPUT;
-            }
-        }
 
         Date oDate;