← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16629: Minor fix

 

------------------------------------------------------------
revno: 16629
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-09-05 10:07:24 +0700
message:
  Minor fix
modified:
  dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.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-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java'
--- dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2014-09-04 13:03:35 +0000
+++ dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/HibernateGenericStore.java	2014-09-05 03:07:24 +0000
@@ -38,7 +38,6 @@
 import org.hibernate.criterion.Criterion;
 import org.hibernate.criterion.DetachedCriteria;
 import org.hibernate.criterion.Disjunction;
-import org.hibernate.criterion.Projections;
 import org.hibernate.criterion.Property;
 import org.hibernate.criterion.Restrictions;
 import org.hibernate.criterion.Subqueries;
@@ -278,14 +277,18 @@
     @Override
     public int save( T object )
     {
-        BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;
-        identifiableObject.setPublicAccess( AccessStringHelper.newInstance().build() );
-        identifiableObject.setUserGroupAccesses( new HashSet<UserGroupAccess>() );
+        if ( IdentifiableObject.class.isAssignableFrom( object.getClass() ) )
+        {
+            ((BaseIdentifiableObject) object).setPublicAccess( AccessStringHelper.newInstance().build() );
+            ((BaseIdentifiableObject) object).setUserGroupAccesses( new HashSet<UserGroupAccess>() );
+        }
 
         User currentUser = currentUserService.getCurrentUser();
 
         if ( !Interpretation.class.isAssignableFrom( clazz ) && currentUser != null && aclService.isShareable( clazz ) )
         {
+            BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object;
+
             // TODO we might want to allow setting sharing props on save, but for now we null them out
 
             if ( identifiableObject.getUser() == null )