← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12924: Null checks for enrollment

 

------------------------------------------------------------
revno: 12924
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-11-12 09:56:05 +0100
message:
  Null checks for enrollment
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.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-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2013-11-04 04:13:54 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/enrollment/AbstractEnrollmentService.java	2013-11-12 08:56:05 +0000
@@ -225,7 +225,9 @@
     @Override
     public Enrollment getEnrollment( String id )
     {
-        return getEnrollment( programInstanceService.getProgramInstance( id ) );
+        ProgramInstance pi = programInstanceService.getProgramInstance( id );
+        
+        return pi != null ? getEnrollment( pi ) : null;
     }
 
     @Override
@@ -290,9 +292,9 @@
     @Override
     public ImportSummary updateEnrollment( Enrollment enrollment )
     {
-        if ( enrollment.getEnrollment() == null )
+        if ( enrollment == null || enrollment.getEnrollment() == null )
         {
-            ImportSummary importSummary = new ImportSummary( ImportStatus.ERROR, "No enrollment ID was supplied" );
+            ImportSummary importSummary = new ImportSummary( ImportStatus.ERROR, "No enrollment or enrollment ID was supplied" );
             importSummary.getImportCount().incrementIgnored();
 
             return importSummary;