dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34345
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17630: support filter in /api/dimensions
------------------------------------------------------------
revno: 17630
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-12-01 12:36:11 +0700
message:
support filter in /api/dimensions
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java
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-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2014-11-11 06:54:03 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/BaseIdentifiableObject.java 2014-12-01 05:36:11 +0000
@@ -36,12 +36,12 @@
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import org.apache.commons.lang.Validate;
+import org.hisp.dhis.acl.Access;
import org.hisp.dhis.common.annotation.Description;
import org.hisp.dhis.common.view.DimensionalView;
import org.hisp.dhis.common.view.SharingBasicView;
import org.hisp.dhis.common.view.SharingDetailedView;
import org.hisp.dhis.common.view.SharingExportView;
-import org.hisp.dhis.acl.Access;
import org.hisp.dhis.user.User;
import org.hisp.dhis.user.UserGroupAccess;
@@ -340,21 +340,22 @@
{
this.access = access;
}
-
+
@Override
@JsonView( { DimensionalView.class } )
@JsonProperty
+ @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public String getDisplayName()
{
return displayName != null && !displayName.trim().isEmpty() ? displayName : getName();
}
-
+
@JsonIgnore
public void setDisplayName( String displayName )
{
this.displayName = displayName;
}
-
+
public String getUrn()
{
return "urn:x-dhis:" + getUid();
=== 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 2014-11-11 12:51:06 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DimensionController.java 2014-12-01 05:36:11 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import com.google.common.collect.Lists;
import org.hisp.dhis.common.DimensionService;
import org.hisp.dhis.common.DimensionalObject;
import org.hisp.dhis.common.IdentifiableObjectManager;
@@ -36,6 +37,8 @@
import org.hisp.dhis.common.PagerUtils;
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dxf2.objectfilter.ObjectFilterService;
+import org.hisp.dhis.webapi.service.ContextService;
import org.hisp.dhis.webapi.service.LinkService;
import org.hisp.dhis.webapi.utils.ContextUtils;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
@@ -74,10 +77,38 @@
@Autowired
private LinkService linkService;
+ @Autowired
+ protected ObjectFilterService objectFilterService;
+
+ @Autowired
+ protected ContextService contextService;
+
// -------------------------------------------------------------------------
// Controller
// -------------------------------------------------------------------------
+ @RequestMapping( method = RequestMethod.GET )
+ public String getDimensions( @RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
+ Model model )
+ {
+ List<String> filters = Lists.newArrayList( contextService.getParameterValues( "filter" ) );
+
+ List<DimensionalObject> dimensions = dimensionService.getAllDimensions();
+ dimensions = objectFilterService.filter( dimensions, filters );
+
+ WebMetaData metaData = new WebMetaData();
+ metaData.setDimensions( dimensions );
+
+ model.addAttribute( "model", metaData );
+
+ if ( links )
+ {
+ linkService.generateLinks( metaData, false );
+ }
+
+ return "dimensions";
+ }
+
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
public String getDimension( @PathVariable( "uid" ) String uid,
@RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
@@ -121,24 +152,6 @@
return "items";
}
- @RequestMapping( method = RequestMethod.GET )
- public String getDimensions( @RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
- Model model )
- {
- WebMetaData metaData = new WebMetaData();
-
- metaData.setDimensions( dimensionService.getAllDimensions() );
-
- model.addAttribute( "model", metaData );
-
- if ( links )
- {
- linkService.generateLinks( metaData, false );
- }
-
- return "dimensions";
- }
-
@RequestMapping( value = "/constraints", method = RequestMethod.GET )
public String getDimensionConstraints( @RequestParam( value = "links", defaultValue = "true", required = false ) Boolean links,
Model model )