← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21850: switch to sharing accessible objects only for PreheatMode.ALL, also switches from id object manag...

 

------------------------------------------------------------
revno: 21850
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2016-02-02 16:16:43 +0700
message:
  switch to sharing accessible objects only for PreheatMode.ALL, also switches from id object manager to query service
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.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/preheat/DefaultPreheatService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java	2016-02-01 10:27:53 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/preheat/DefaultPreheatService.java	2016-02-02 09:16:43 +0000
@@ -30,7 +30,9 @@
 
 import com.google.common.collect.Sets;
 import org.hisp.dhis.common.IdentifiableObject;
-import org.hisp.dhis.common.IdentifiableObjectManager;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryService;
+import org.hisp.dhis.query.Restrictions;
 import org.hisp.dhis.schema.Property;
 import org.hisp.dhis.schema.PropertyType;
 import org.hisp.dhis.schema.Schema;
@@ -57,7 +59,7 @@
     private SchemaService schemaService;
 
     @Autowired
-    private IdentifiableObjectManager manager;
+    private QueryService queryService;
 
     @Override
     @SuppressWarnings( "unchecked" )
@@ -75,7 +77,8 @@
 
             for ( Class<? extends IdentifiableObject> klass : params.getClasses() )
             {
-                List<? extends IdentifiableObject> objects = manager.getAllNoAcl( klass ); // should we use getAll here? are we allowed to reference unshared objects?
+                Query query = Query.from( schemaService.getDynamicSchema( klass ) );
+                List<? extends IdentifiableObject> objects = queryService.query( query );
 
                 if ( PreheatIdentifier.UID == params.getPreheatIdentifier() || PreheatIdentifier.AUTO == params.getPreheatIdentifier() )
                 {
@@ -98,7 +101,9 @@
                 for ( Class<? extends IdentifiableObject> klass : uidMap.keySet() )
                 {
                     Collection<String> identifiers = uidMap.get( klass );
-                    List<? extends IdentifiableObject> objects = manager.getByUid( klass, identifiers );
+                    Query query = Query.from( schemaService.getDynamicSchema( klass ) );
+                    query.add( Restrictions.in( "id", identifiers ) );
+                    List<? extends IdentifiableObject> objects = queryService.query( query );
                     preheat.put( PreheatIdentifier.UID, objects );
                 }
             }
@@ -108,7 +113,9 @@
                 for ( Class<? extends IdentifiableObject> klass : codeMap.keySet() )
                 {
                     Collection<String> identifiers = codeMap.get( klass );
-                    List<? extends IdentifiableObject> objects = manager.getByCode( klass, identifiers );
+                    Query query = Query.from( schemaService.getDynamicSchema( klass ) );
+                    query.add( Restrictions.in( "code", identifiers ) );
+                    List<? extends IdentifiableObject> objects = queryService.query( query );
                     preheat.put( PreheatIdentifier.CODE, objects );
                 }
             }