dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35978
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18425: minor fix, check for empty childrens list when creating root node
------------------------------------------------------------
revno: 18425
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-26 16:27:36 +0700
message:
minor fix, check for empty childrens list when creating root node
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.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/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-02-25 07:31:03 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2015-02-26 09:27:36 +0000
@@ -57,6 +57,7 @@
import org.hisp.dhis.node.NodeUtils;
import org.hisp.dhis.node.config.InclusionStrategy;
import org.hisp.dhis.node.types.CollectionNode;
+import org.hisp.dhis.node.types.ComplexNode;
import org.hisp.dhis.node.types.RootNode;
import org.hisp.dhis.node.types.SimpleNode;
import org.hisp.dhis.query.Order;
@@ -346,7 +347,18 @@
}
else
{
- RootNode rootNode = NodeUtils.createRootNode( collectionNode.getChildren().get( 0 ) );
+ List<Node> children = collectionNode.getChildren();
+ RootNode rootNode;
+
+ if ( !children.isEmpty() )
+ {
+ rootNode = NodeUtils.createRootNode( children.get( 0 ) );
+ }
+ else
+ {
+ rootNode = NodeUtils.createRootNode( new ComplexNode( getSchema().getSingular() ) );
+ }
+
rootNode.getConfig().setInclusionStrategy( getInclusionStrategy( parameters.get( "inclusionStrategy" ) ) );
return rootNode;