dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30735
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15618: bugfixes for preset expansion in field filtering
------------------------------------------------------------
revno: 15618
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-06-11 11:59:34 +0200
message:
bugfixes for preset expansion in field filtering
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.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-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-06-11 07:43:00 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java 2014-06-11 09:59:34 +0000
@@ -132,7 +132,7 @@
return collectionNode;
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private ComplexNode buildObjectOutput( Map<String, Map> fieldMap, Object object )
{
if ( object == null )
@@ -144,7 +144,7 @@
ComplexNode complexNode = new ComplexNode( schema.getName() );
complexNode.setNamespace( schema.getNamespace() );
- updateFields( fieldMap, object );
+ updateFields( fieldMap, schema.getKlass() );
for ( String fieldKey : fieldMap.keySet() )
{
@@ -164,7 +164,15 @@
}
Map fieldValue = fieldMap.get( fieldKey );
- updateFields( fieldValue, returnValue );
+
+ if ( property.isCollection() )
+ {
+ updateFields( fieldValue, property.getItemKlass() );
+ }
+ else
+ {
+ updateFields( fieldValue, property.getKlass() );
+ }
if ( fieldValue.isEmpty() )
{
@@ -258,22 +266,21 @@
return complexNode;
}
- private void updateFields( Map<String, Map> fieldMap, Object object )
+ private void updateFields( Map<String, Map> fieldMap, Class<?> klass )
{
// we need two run this (at least) two times, since some of the presets might contain other presets
- _updateFields( fieldMap, object, true );
- _updateFields( fieldMap, object, false );
+ _updateFields( fieldMap, klass, true );
+ _updateFields( fieldMap, klass, false );
}
- private void _updateFields( Map<String, Map> fieldMap, Object object, boolean expandOnly )
+ private void _updateFields( Map<String, Map> fieldMap, Class<?> klass, boolean expandOnly )
{
- Schema schema = schemaService.getDynamicSchema( object.getClass() );
-
+ Schema schema = schemaService.getDynamicSchema( klass );
List<String> cleanupFields = Lists.newArrayList();
for ( String fieldKey : Sets.newHashSet( fieldMap.keySet() ) )
{
- if ( fieldKey.equals( "*" ) )
+ if ( "*".equals( fieldKey ) )
{
for ( String mapKey : schema.getPropertyMap().keySet() )
{
@@ -369,7 +376,7 @@
return complexNode;
}
- @SuppressWarnings( "unchecked" )
+ @SuppressWarnings("unchecked")
private <T> boolean evaluateWithFilters( T object, Filters filters )
{
Schema schema = schemaService.getDynamicSchema( object.getClass() );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-06-09 10:37:39 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/DashboardController.java 2014-06-11 09:59:34 +0000
@@ -83,7 +83,6 @@
Dashboard dashboard = JacksonUtils.fromJson( input, Dashboard.class );
dashboardService.mergeDashboard( dashboard );
-
dashboardService.saveDashboard( dashboard );
ContextUtils.createdResponse( response, "Dashboard created", DashboardSchemaDescriptor.API_ENDPOINT + "/" + dashboard.getUid() );
@@ -109,24 +108,6 @@
dashboardService.updateDashboard( dashboard );
}
- @Override
- @RequestMapping(value = "/{uid}", method = RequestMethod.DELETE)
- @ResponseStatus(value = HttpStatus.NO_CONTENT)
- public void deleteObject( HttpServletResponse response, HttpServletRequest request, @PathVariable("uid") String uid ) throws Exception
- {
- Dashboard dashboard = dashboardService.getDashboard( uid );
-
- if ( dashboard == null )
- {
- ContextUtils.notFoundResponse( response, "Dashboard does not exist: " + uid );
- return;
- }
-
- dashboardService.deleteDashboard( dashboard );
-
- ContextUtils.okResponse( response, "Dashboard deleted" );
- }
-
@RequestMapping(value = "/{uid}/items", method = RequestMethod.POST, consumes = "application/json")
public void postJsonItem( HttpServletResponse response, HttpServletRequest request,
InputStream input, @PathVariable String uid ) throws Exception