← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4505: Implemented getOrgUnitByCode in orgunit service

 

------------------------------------------------------------
revno: 4505
committer: Bob Jolliffe bobjolliffe@xxxxxxxxx
branch nick: dhis2
timestamp: Fri 2011-09-02 13:06:29 +0100
message:
  Implemented getOrgUnitByCode in orgunit service
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.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/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.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/common/GenericIdentifiableObjectStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2010-11-23 18:25:34 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/GenericIdentifiableObjectStore.java	2011-09-02 12:06:29 +0000
@@ -46,7 +46,7 @@
     
     /**
      * Retrieves the object with the given name.
-     * 
+     *
      * @param name the name.
      * @return the object with the given name.
      */

=== 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	2011-07-22 20:43:53 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java	2011-09-02 12:06:29 +0000
@@ -101,6 +101,14 @@
     OrganisationUnit getOrganisationUnit( String uuid );
 
     /**
+     * Returns the OrganisationUnit with the given code.
+     *
+     * @param code the code of the OrganisationUnit to return.
+     * @return the OrganisationUnit with the given code, or null if no match.
+     */
+    OrganisationUnit getOrganisationUnitByCode( String code );
+
+    /**
      * Returns all OrganisationUnits.
      * 
      * @return a collection of all OrganisationUnits, or an empty collection if

=== 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	2011-08-13 10:41:20 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java	2011-09-02 12:06:29 +0000
@@ -191,6 +191,11 @@
         return organisationUnitStore.getByName( name );
     }
 
+    public OrganisationUnit getOrganisationUnitByCode( String code )
+    {
+        return organisationUnitStore.getByCode( code );
+    }
+
     public OrganisationUnit getOrganisationUnitByNameIgnoreCase( String name )
     {
         return organisationUnitStore.getOrganisationUnitByNameIgnoreCase( name );
@@ -680,4 +685,5 @@
             versionService.updateVersion( orgUnitVersion );
         }
     }
+
 }

=== 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	2011-03-17 20:59:33 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/organisationunit/OrganisationUnitServiceTest.java	2011-09-02 12:06:29 +0000
@@ -178,6 +178,14 @@
 
         OrganisationUnit unit4 = organisationUnitService.getOrganisationUnitByName( "foo" );
         assertNull( unit4 );
+
+        unit1 = organisationUnitService.getOrganisationUnitByCode( oU1Code );
+        assertEquals( unit1.getName(), oU1Name );
+
+        unit4 = organisationUnitService.getOrganisationUnitByCode( "foo" );
+        assertNull( unit4 );
+
+
     }
 
     @Test