← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9786: bugfix for getMatching in ouLevel importer

 

------------------------------------------------------------
revno: 9786
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-02-12 14:37:16 +0700
message:
  bugfix for getMatching in ouLevel importer
modified:
  dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitLevelImporter.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-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitLevelImporter.java'
--- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitLevelImporter.java	2013-02-04 14:57:16 +0000
+++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/importer/OrganisationUnitLevelImporter.java	2013-02-12 07:37:16 +0000
@@ -33,6 +33,8 @@
 import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
 import org.hisp.dhis.organisationunit.OrganisationUnitService;
 
+import java.util.List;
+
 /**
  * @author Lars Helge Overland
  * @version $Id$
@@ -45,12 +47,12 @@
     public OrganisationUnitLevelImporter()
     {
     }
-    
+
     public OrganisationUnitLevelImporter( OrganisationUnitService organisationUnitService )
     {
         this.organisationUnitService = organisationUnitService;
     }
-    
+
     @Override
     public void importObject( OrganisationUnitLevel object, ImportParams params )
     {
@@ -68,7 +70,7 @@
     {
         match.setLevel( object.getLevel() );
         match.setName( object.getName() );
-        
+
         organisationUnitService.updateOrganisationUnitLevel( match );
     }
 
@@ -76,12 +78,13 @@
     protected OrganisationUnitLevel getMatching( OrganisationUnitLevel object )
     {
         OrganisationUnitLevel match = organisationUnitService.getOrganisationUnitLevelByLevel( object.getLevel() );
-        
+
         if ( match == null )
         {
-            match = organisationUnitService.getOrganisationUnitLevelByName( object.getName() ).get( 0 );
+            List<OrganisationUnitLevel> organisationUnitLevelByName = organisationUnitService.getOrganisationUnitLevelByName( object.getName() );
+            match = organisationUnitLevelByName.isEmpty() ? null : organisationUnitLevelByName.get( 0 );
         }
-        
+
         return match;
     }
 
@@ -96,7 +99,7 @@
         {
             return false;
         }
-        
+
         return true;
     }
 }