← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21610: minor bugfix, make sure that query filters are run on program data element controller

 

------------------------------------------------------------
revno: 21610
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-01-06 09:52:09 +0700
message:
  minor bugfix, make sure that query filters are run on program data element controller
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/program/ProgramDataElementController.java	2016-01-06 02:52:09 +0000
@@ -28,11 +28,11 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-import java.util.List;
-
 import org.hisp.dhis.program.ProgramDataElement;
 import org.hisp.dhis.program.ProgramService;
 import org.hisp.dhis.query.Order;
+import org.hisp.dhis.query.Query;
+import org.hisp.dhis.query.QueryParserException;
 import org.hisp.dhis.webapi.controller.AbstractCrudController;
 import org.hisp.dhis.webapi.webdomain.WebMetaData;
 import org.hisp.dhis.webapi.webdomain.WebOptions;
@@ -40,6 +40,8 @@
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import java.util.List;
+
 /**
  * @author Lars Helge Overland
  */
@@ -50,12 +52,24 @@
 {
     @Autowired
     private ProgramService programService;
-    
+
     @Override
-    protected List<ProgramDataElement> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders )
+    @SuppressWarnings( "unchecked" )
+    protected List<ProgramDataElement> getEntityList( WebMetaData metaData, WebOptions options, List<String> filters, List<Order> orders ) throws QueryParserException
     {
-        String programUid = options.get( "program" );
-        
-        return programService.getGeneratedProgramDataElements( programUid );        
+        List<ProgramDataElement> programDataElements;
+        Query query = queryService.getQueryFromUrl( ProgramDataElement.class, filters, orders );
+        query.setDefaultOrder();
+
+        if ( options.contains( "program" ) )
+        {
+            String programUid = options.get( "program" );
+            programDataElements = programService.getGeneratedProgramDataElements( programUid );
+            query.setObjects( programDataElements );
+        }
+
+        programDataElements = (List<ProgramDataElement>) queryService.query( query );
+
+        return programDataElements;
     }
 }