← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13677: fixed error with /operands

 

------------------------------------------------------------
revno: 13677
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-01-09 17:03:24 +0100
message:
  fixed error with /operands
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.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/api/controller/dataelement/DataElementGroupController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.java	2014-01-09 15:03:58 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/dataelement/DataElementGroupController.java	2014-01-09 16:03:24 +0000
@@ -148,8 +148,47 @@
         return StringUtils.uncapitalize( getEntitySimpleName() );
     }
 
+    @RequestMapping( value = "/{uid}/operands", method = RequestMethod.GET )
+    public String getOperands( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
+        @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
+        HttpServletResponse response ) throws Exception
+    {
+        WebOptions options = new WebOptions( parameters );
+        DataElementGroup dataElementGroup = getEntity( uid );
+
+        if ( dataElementGroup == null )
+        {
+            ContextUtils.notFoundResponse( response, "DataElementGroup not found for uid: " + uid );
+            return null;
+        }
+
+        WebMetaData metaData = new WebMetaData();
+        List<DataElementOperand> dataElementOperands = Lists.newArrayList( dataElementOperandService.getDataElementOperandByDataElementGroup( dataElementGroup ) );
+
+        metaData.setDataElementOperands( dataElementOperands );
+
+        if ( options.hasPaging() )
+        {
+            Pager pager = new Pager( options.getPage(), dataElementOperands.size(), options.getPageSize() );
+            metaData.setPager( pager );
+            dataElementOperands = PagerUtils.pageCollection( dataElementOperands, pager );
+        }
+
+        metaData.setDataElementOperands( dataElementOperands );
+
+        if ( options.hasLinks() )
+        {
+            WebUtils.generateLinks( metaData );
+        }
+
+        model.addAttribute( "model", metaData );
+        model.addAttribute( "viewClass", options.getViewClass( "basic" ) );
+
+        return StringUtils.uncapitalize( getEntitySimpleName() );
+    }
+
     @RequestMapping( value = "/{uid}/operands/query/{q}", method = RequestMethod.GET )
-    public String getOperands( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
+    public String getOperandsByQuery( @PathVariable( "uid" ) String uid, @PathVariable( "q" ) String q,
         @RequestParam Map<String, String> parameters, Model model, HttpServletRequest request,
         HttpServletResponse response ) throws Exception
     {