← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20399: Fixed issue with upgrade of favorites. Comparing parameter class type on right side of isAssignab...

 

------------------------------------------------------------
revno: 20399
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-09-29 21:17:08 +0200
message:
  Fixed issue with upgrade of favorites. Comparing parameter class type on right side of isAssignableFrom check. Avoids issue with proxying. This works better as proxy is a subclass of real class, and isAssignableFrom checks if this class is the same or a superclass of the compared class.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DataDimensionItem.java
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/FavoriteDataItemUpgrader.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/DataDimensionItem.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DataDimensionItem.java	2015-09-28 09:25:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/DataDimensionItem.java	2015-09-29 19:17:08 +0000
@@ -99,30 +99,34 @@
     {
         DataDimensionItem dimension = new DataDimensionItem();
         
-        if ( object.getClass().isAssignableFrom( Indicator.class ) )
+        if ( Indicator.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setIndicator( (Indicator) object );
         }
-        else if ( object.getClass().isAssignableFrom( DataElement.class ) )
+        else if ( DataElement.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setDataElement( (DataElement) object );
         }
-        else if ( object.getClass().isAssignableFrom( DataElementOperand.class ) )
+        else if ( DataElementOperand.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setDataElementOperand( (DataElementOperand) object );
         }
-        else if ( object.getClass().isAssignableFrom( DataSet.class ) )
+        else if ( DataSet.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setDataSet( (DataSet) object );
         }
-        else if ( object.getClass().isAssignableFrom( ProgramIndicator.class ) )
+        else if ( ProgramIndicator.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setProgramIndicator( (ProgramIndicator) object );
         }
-        else if ( object.getClass().isAssignableFrom( TrackedEntityAttribute.class ) )
+        else if ( TrackedEntityAttribute.class.isAssignableFrom( object.getClass() ) )
         {
             dimension.setTrackedEntityAttribute( (TrackedEntityAttribute) object );
         }
+        else
+        {
+            throw new IllegalArgumentException( "Not a valid data dimension: " + object.getClass().getSimpleName() + ", " + object );
+        }
         
         return dimension;
     }

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/FavoriteDataItemUpgrader.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/FavoriteDataItemUpgrader.java	2015-07-15 13:32:09 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/FavoriteDataItemUpgrader.java	2015-09-29 19:17:08 +0000
@@ -105,7 +105,7 @@
             BaseAnalyticalObject favorite = idObjectManager.get( favoriteClass, rtId );
             NameableObject object = (NameableObject) idObjectManager.get( objectClass, obId );
             DataDimensionItem item = DataDimensionItem.create( object );
-            
+                        
             favorite.getDataDimensionItems().add( item );
             idObjectManager.update( favorite );