dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #43069
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21898: add field filtering for /api/dimensions/dataSet/ID endpoint
------------------------------------------------------------
revno: 21898
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2016-02-07 16:59:19 +0700
message:
add field filtering for /api/dimensions/dataSet/ID endpoint
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.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/DimensionController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2016-02-02 06:34:22 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2016-02-07 09:59:19 +0000
@@ -156,11 +156,12 @@
}
@RequestMapping( value = "/dataSet/{uid}", method = RequestMethod.GET )
- public String getDimensionsForDataSet( @PathVariable String uid,
+ public @ResponseBody RootNode getDimensionsForDataSet( @PathVariable String uid,
@RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
Model model, HttpServletResponse response ) throws WebMessageException
{
WebMetadata metadata = new WebMetadata();
+ List<String> fields = Lists.newArrayList( contextService.getParameterValues( "fields" ) );
DataSet dataSet = identifiableObjectManager.get( DataSet.class, uid );
@@ -185,13 +186,14 @@
metadata.getDimensions().add( dimensionService.getDimensionalObjectCopy( dim.getUid(), true ) );
}
- model.addAttribute( "model", metadata );
-
if ( links )
{
linkService.generateLinks( metadata, false );
}
- return "dimensions";
+ RootNode rootNode = NodeUtils.createMetadata();
+ rootNode.addChild( fieldFilterService.filter( getEntityClass(), metadata.getDimensions(), fields ) );
+
+ return rootNode;
}
}