← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22324: Tracked entity instance enrollment validation, using equals instead of == for reliable comparison

 

------------------------------------------------------------
revno: 22324
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-03-15 12:40:54 +0100
message:
  Tracked entity instance enrollment validation, using equals instead of == for reliable comparison
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.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-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2016-03-15 11:22:02 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/program/DefaultProgramInstanceService.java	2016-03-15 11:40:54 +0000
@@ -454,11 +454,9 @@
         // Add program instance
         // ---------------------------------------------------------------------
         
-        if( program.getTrackedEntity() != trackedEntityInstance.getTrackedEntity() )
+        if ( program.getTrackedEntity() != null && !program.getTrackedEntity().equals( trackedEntityInstance.getTrackedEntity() ) )
         {
-            log.warn( "Tracked entitiy instance needs to have the same tracked entity as the program" );
-
-            throw new IllegalQueryException( "Tracked entitiy instance needs to have the same tracked entity as the program" );
+            throw new IllegalQueryException( "Tracked entitiy instance must have same tracked entity as program: " + program.getUid() );
         }
 
         ProgramInstance programInstance = new ProgramInstance();