← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15549: simplifications to Nodes, removed 'hinting' for now

 

------------------------------------------------------------
revno: 15549
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-06-04 12:49:04 +0200
message:
  simplifications to Nodes, removed 'hinting' for now
removed:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/NodeHint.java
added:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportCollection.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportComplex.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportRoot.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportSimple.java
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/Node.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/JacksonJsonNodeSerializer.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/CollectionNode.java
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/SimpleNode.java
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java
  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/AbstractCrudController.java
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.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/node/AbstractNode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java	2014-06-03 09:14:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/AbstractNode.java	2014-06-04 10:49:04 +0000
@@ -29,25 +29,25 @@
  */
 
 import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
 import org.hisp.dhis.node.exception.InvalidTypeException;
 
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
  */
 public abstract class AbstractNode implements Node
 {
-    private final String name;
+    private String name;
 
     private final NodeType nodeType;
 
+    private String namespace;
+
+    private String comment;
+
     private final List<Node> nodes = Lists.newArrayList();
 
-    private final Map<NodeHint.Type, NodeHint> nodeHints = Maps.newHashMap();
-
     protected AbstractNode( String name, NodeType nodeType )
     {
         this.name = name;
@@ -60,6 +60,11 @@
         return name;
     }
 
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
     @Override
     public NodeType getType()
     {
@@ -67,59 +72,51 @@
     }
 
     @Override
-    public <T extends Node> T addNode( T node ) throws InvalidTypeException
-    {
-        if ( node == null )
+    public String getNamespace()
+    {
+        return namespace;
+    }
+
+    public void setNamespace( String namespace )
+    {
+        this.namespace = namespace;
+    }
+
+    @Override
+    public String getComment()
+    {
+        return comment;
+    }
+
+    public void setComment( String comment )
+    {
+        this.comment = comment;
+    }
+
+    @Override
+    public <T extends Node> T addChild( T child ) throws InvalidTypeException
+    {
+        if ( child == null )
         {
             return null;
         }
 
-        nodes.add( node );
-        return node;
+        nodes.add( child );
+        return child;
     }
 
     @Override
-    public <T extends Node> void addNodes( List<T> nodes )
+    public <T extends Node> void addChildren( Iterable<T> children )
     {
-        for ( Node node : nodes )
+        for ( Node node : children )
         {
-            addNode( node );
+            addChild( node );
         }
     }
 
     @Override
-    public List<Node> getNodes()
+    public List<Node> getChildren()
     {
         return nodes;
     }
-
-    @Override
-    public NodeHint addHint( NodeHint.Type type, Object value )
-    {
-        return addHint( new NodeHint( type, value ) );
-    }
-
-    @Override
-    public NodeHint addHint( NodeHint nodeHint )
-    {
-        nodeHints.put( nodeHint.getType(), nodeHint );
-        return nodeHint;
-    }
-
-    @Override
-    public NodeHint getHint( NodeHint.Type type )
-    {
-        if ( haveHint( type ) )
-        {
-            return nodeHints.get( type );
-        }
-
-        return null;
-    }
-
-    @Override
-    public boolean haveHint( NodeHint.Type type )
-    {
-        return nodeHints.containsKey( type );
-    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/Node.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/Node.java	2014-06-03 09:14:08 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/Node.java	2014-06-04 10:49:04 +0000
@@ -35,21 +35,53 @@
  */
 public interface Node
 {
+    /**
+     * Name of this node.
+     *
+     * @return current name of node
+     */
     String getName();
 
+    /**
+     * Type specifier for this node.
+     *
+     * @return Node type
+     * @see org.hisp.dhis.node.NodeType
+     */
     NodeType getType();
 
-    <T extends Node> T addNode( T node );
-
-    <T extends Node> void addNodes( List<T> nodes );
-
-    List<Node> getNodes();
-
-    NodeHint addHint( NodeHint.Type type, Object value );
-
-    NodeHint addHint( NodeHint nodeHint );
-
-    NodeHint getHint( NodeHint.Type type );
-
-    boolean haveHint( NodeHint.Type type );
+    /**
+     * Namespace for this node. Not all serializers support this, and its up to the
+     * NodeSerializer implementation to decide what to do with this.
+     *
+     * @return namespace
+     * @see org.hisp.dhis.node.NodeSerializer
+     */
+    String getNamespace();
+
+    /**
+     * Comment for this node. Not all serializers support this, and its up to the
+     * NodeSerializer implementation to decide what to do with this.
+     *
+     * @return namespace
+     * @see org.hisp.dhis.node.NodeSerializer
+     */
+    String getComment();
+
+    /**
+     * Adds a child to this node.
+     *
+     * @param child Child node to add
+     * @return Child node that was added
+     */
+    <T extends Node> T addChild( T child );
+
+    /**
+     * Adds a collection of children to this node.
+     *
+     * @param children Child nodes to add
+     */
+    <T extends Node> void addChildren( Iterable<T> children );
+
+    List<Node> getChildren();
 }

=== removed file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/NodeHint.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/NodeHint.java	2014-06-03 08:43:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/NodeHint.java	1970-01-01 00:00:00 +0000
@@ -1,80 +0,0 @@
-package org.hisp.dhis.node;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
- */
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-final public class NodeHint
-{
-    public enum Type
-    {
-        /**
-         * If the serializer supports namespacing, this hint can be used to set the namespace.
-         */
-        NAMESPACE,
-
-        /**
-         * If the serializer supports attributes, this hint can be used to hint that this
-         * node is a attribute or not.
-         */
-        ATTRIBUTE,
-
-        /**
-         * If the serializer has a notion of wrapping collection (like XML), this hint can be used to
-         * turn this feature on or off.
-         */
-        WRAP_COLLECTION,
-
-        /**
-         * If the serializer supports comments, this hint can be used to set a comment for a node.
-         */
-        COMMENT
-    }
-
-    private final Type type;
-
-    private final Object value;
-
-    public NodeHint( Type type, Object value )
-    {
-        this.type = type;
-        this.value = value;
-    }
-
-    public Type getType()
-    {
-        return type;
-    }
-
-    public Object getValue()
-    {
-        return value;
-    }
-}

=== added directory 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation'
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportCollection.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportCollection.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportCollection.java	2014-06-04 10:49:04 +0000
@@ -0,0 +1,54 @@
+package org.hisp.dhis.node.annotation;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Target( { ElementType.FIELD, ElementType.METHOD } )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface ExportCollection
+{
+    String value() default "";
+
+    String namespace() default "";
+
+    String itemName() default "";
+
+    String itemNamespace() default "";
+
+    boolean owner() default false;
+
+    boolean useWrapping() default true;
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportComplex.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportComplex.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportComplex.java	2014-06-04 10:49:04 +0000
@@ -0,0 +1,46 @@
+package org.hisp.dhis.node.annotation;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Target( { ElementType.FIELD, ElementType.METHOD } )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface ExportComplex
+{
+    String value() default "";
+
+    String namespace() default "";
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportRoot.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportRoot.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportRoot.java	2014-06-04 10:49:04 +0000
@@ -0,0 +1,46 @@
+package org.hisp.dhis.node.annotation;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Target( { ElementType.TYPE } )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface ExportRoot
+{
+    String value() default "";
+
+    String namespace() default "";
+}

=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportSimple.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportSimple.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/annotation/ExportSimple.java	2014-06-04 10:49:04 +0000
@@ -0,0 +1,48 @@
+package org.hisp.dhis.node.annotation;
+
+/*
+ * Copyright (c) 2004-2014, University of Oslo
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * Neither the name of the HISP project nor the names of its contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
+ */
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Target( { ElementType.FIELD, ElementType.METHOD } )
+@Retention( RetentionPolicy.RUNTIME )
+public @interface ExportSimple
+{
+    String value() default "";
+
+    boolean isAttribute() default false;
+
+    String namespace() default "";
+}

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/JacksonJsonNodeSerializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/JacksonJsonNodeSerializer.java	2014-06-02 22:47:30 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/JacksonJsonNodeSerializer.java	2014-06-04 10:49:04 +0000
@@ -81,7 +81,7 @@
     {
         generator.writeStartObject();
 
-        for ( Node node : rootNode.getNodes() )
+        for ( Node node : rootNode.getChildren() )
         {
             dispatcher( node, generator, true );
             generator.flush();
@@ -118,7 +118,7 @@
             generator.writeStartObject();
         }
 
-        for ( Node node : complexNode.getNodes() )
+        for ( Node node : complexNode.getChildren() )
         {
             dispatcher( node, generator, true );
         }
@@ -137,7 +137,7 @@
             generator.writeStartArray();
         }
 
-        for ( Node node : collectionNode.getNodes() )
+        for ( Node node : collectionNode.getChildren() )
         {
             dispatcher( node, generator, false );
         }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java	2014-06-03 08:43:56 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/serializers/StAXNodeSerializer.java	2014-06-04 10:49:04 +0000
@@ -29,13 +29,13 @@
  */
 
 import org.hisp.dhis.node.Node;
-import org.hisp.dhis.node.NodeHint;
 import org.hisp.dhis.node.NodeSerializer;
 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.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
 
 import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
@@ -80,14 +80,14 @@
     {
         writer.writeStartDocument( "UTF-8", "1.0" );
 
-        if ( rootNode.haveHint( NodeHint.Type.COMMENT ) )
+        if ( !StringUtils.isEmpty( rootNode.getComment() ) )
         {
-            writer.writeComment( (String) rootNode.getHint( NodeHint.Type.COMMENT ).getValue() );
+            writer.writeComment( rootNode.getComment() );
         }
 
         writeStartElement( rootNode, writer );
 
-        for ( Node node : rootNode.getNodes() )
+        for ( Node node : rootNode.getChildren() )
         {
             dispatcher( node, writer );
             writer.flush();
@@ -120,9 +120,9 @@
 
         String value = String.format( "%s", simpleNode.getValue() );
 
-        if ( simpleNode.haveHint( NodeHint.Type.NAMESPACE ) )
+        if ( !StringUtils.isEmpty( simpleNode.getNamespace() ) )
         {
-            writer.writeAttribute( "", String.valueOf( simpleNode.getHint( NodeHint.Type.NAMESPACE ).getValue() ), simpleNode.getName(), value );
+            writer.writeAttribute( "", simpleNode.getNamespace(), simpleNode.getName(), value );
         }
         else
         {
@@ -134,7 +134,7 @@
     {
         writeStartElement( complexNode, writer );
 
-        for ( Node node : complexNode.getNodes() )
+        for ( Node node : complexNode.getChildren() )
         {
             dispatcher( node, writer );
         }
@@ -149,7 +149,7 @@
             writeStartElement( collectionNode, writer );
         }
 
-        for ( Node node : collectionNode.getNodes() )
+        for ( Node node : collectionNode.getChildren() )
         {
             dispatcher( node, writer );
         }
@@ -162,16 +162,15 @@
 
     private void dispatcher( Node node, XMLStreamWriter writer ) throws IOException, XMLStreamException
     {
-        if ( node.haveHint( NodeHint.Type.COMMENT ) )
+        if ( !StringUtils.isEmpty( node.getComment() ) )
         {
-            writer.writeComment( (String) node.getHint( NodeHint.Type.COMMENT ).getValue() );
+            writer.writeComment( node.getComment() );
         }
 
         switch ( node.getType() )
         {
             case SIMPLE:
-                if ( node.haveHint( NodeHint.Type.ATTRIBUTE ) &&
-                    (boolean) node.getHint( NodeHint.Type.ATTRIBUTE ).getValue() )
+                if ( ((SimpleNode) node).isAttribute() )
                 {
                     renderSimpleNodeAttribute( (SimpleNode) node, writer );
                 }
@@ -184,13 +183,7 @@
                 renderComplexNode( (ComplexNode) node, writer );
                 break;
             case COLLECTION:
-                boolean useWrapping = true;
-
-                if ( node.haveHint( NodeHint.Type.WRAP_COLLECTION ) )
-                {
-                    useWrapping = (boolean) node.getHint( NodeHint.Type.WRAP_COLLECTION ).getValue();
-                }
-
+                boolean useWrapping = ((CollectionNode) node).isWrapping();
                 renderCollectionNode( (CollectionNode) node, writer, useWrapping );
                 break;
         }
@@ -198,9 +191,9 @@
 
     private void writeStartElement( Node node, XMLStreamWriter writer ) throws XMLStreamException
     {
-        if ( node.haveHint( NodeHint.Type.NAMESPACE ) )
+        if ( !StringUtils.isEmpty( node.getNamespace() ) )
         {
-            writer.writeStartElement( "", node.getName(), String.valueOf( node.getHint( NodeHint.Type.NAMESPACE ).getValue() ) );
+            writer.writeStartElement( "", node.getName(), node.getNamespace() );
         }
         else
         {

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/CollectionNode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/CollectionNode.java	2014-05-31 23:48:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/CollectionNode.java	2014-06-04 10:49:04 +0000
@@ -36,8 +36,23 @@
  */
 public class CollectionNode extends AbstractNode
 {
+    /**
+     * Should this collection act as a wrapper around its children.
+     */
+    boolean wrapping = true;
+
     public CollectionNode( String name )
     {
         super( name, NodeType.COLLECTION );
     }
+
+    public boolean isWrapping()
+    {
+        return wrapping;
+    }
+
+    public void setWrapping( boolean wrapping )
+    {
+        this.wrapping = wrapping;
+    }
 }

=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/SimpleNode.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/SimpleNode.java	2014-05-31 23:53:24 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/node/types/SimpleNode.java	2014-06-04 10:49:04 +0000
@@ -40,10 +40,19 @@
 {
     private final Object value;
 
+    private boolean attribute;
+
     public SimpleNode( String name, Object value )
     {
         super( name, NodeType.SIMPLE );
         this.value = value;
+        this.attribute = false;
+    }
+
+    public SimpleNode( String name, NodeType nodeType, Object value, boolean attribute )
+    {
+        super( name, nodeType );
+        this.value = value;
     }
 
     public Object getValue()
@@ -51,9 +60,25 @@
         return value;
     }
 
-    @Override
-    public <T extends Node> T addNode( T node ) throws InvalidTypeException
-    {
-        throw new InvalidTypeException( "Adding nodes to a node of type simple is not allowed." );
+    public boolean isAttribute()
+    {
+        return attribute;
+    }
+
+    public void setAttribute( boolean attribute )
+    {
+        this.attribute = attribute;
+    }
+
+    @Override
+    public <T extends Node> T addChild( T child ) throws InvalidTypeException
+    {
+        throw new InvalidTypeException( "Adding children to a node of type simple is not allowed." );
+    }
+
+    @Override
+    public <T extends Node> void addChildren( Iterable<T> children )
+    {
+        throw new InvalidTypeException( "Adding children to a node of type simple is not allowed." );
     }
 }

=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-06-03 09:14:08 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/datavalueset/DefaultDataValueSetService.java	2014-06-04 10:49:04 +0000
@@ -55,7 +55,6 @@
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
 import org.hisp.dhis.importexport.ImportStrategy;
 import org.hisp.dhis.jdbc.batchhandler.DataValueBatchHandler;
-import org.hisp.dhis.node.NodeHint;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.ComplexNode;
 import org.hisp.dhis.node.types.RootNode;
@@ -243,18 +242,18 @@
         boolean writeComments, String ouScheme, String deScheme )
     {
         RootNode rootNode = new RootNode( "dataValueSet" );
-        rootNode.addHint( NodeHint.Type.NAMESPACE, DxfNamespaces.DXF_2_0 );
-        rootNode.addHint( NodeHint.Type.COMMENT, "Data set: " + dataSet.getDisplayName() + " (" + dataSet.getUid() + ")" );
+        rootNode.setNamespace( DxfNamespaces.DXF_2_0 );
+        rootNode.setComment( "Data set: " + dataSet.getDisplayName() + " (" + dataSet.getUid() + ")" );
 
-        CollectionNode collectionNode = rootNode.addNode( new CollectionNode( "dataValues" ) );
-        collectionNode.addHint( NodeHint.Type.WRAP_COLLECTION, false );
+        CollectionNode collectionNode = rootNode.addChild( new CollectionNode( "dataValues" ) );
+        collectionNode.setWrapping( false );
 
         if ( orgUnits.isEmpty() )
         {
             for ( DataElement dataElement : dataSet.getDataElements() )
             {
                 CollectionNode collection = getDataValueTemplate( dataElement, deScheme, null, ouScheme, period, writeComments );
-                collectionNode.addNodes( collection.getNodes() );
+                collectionNode.addChildren( collection.getChildren() );
             }
         }
         else
@@ -271,7 +270,7 @@
                 for ( DataElement dataElement : dataSet.getDataElements() )
                 {
                     CollectionNode collection = getDataValueTemplate( dataElement, deScheme, organisationUnit, ouScheme, period, writeComments );
-                    collectionNode.addNodes( collection.getNodes() );
+                    collectionNode.addChildren( collection.getChildren() );
                 }
             }
         }
@@ -282,11 +281,11 @@
     private CollectionNode getDataValueTemplate( DataElement dataElement, String deScheme, OrganisationUnit organisationUnit, String ouScheme, Period period, boolean comment )
     {
         CollectionNode collectionNode = new CollectionNode( "dataValues" );
-        collectionNode.addHint( NodeHint.Type.WRAP_COLLECTION, false );
+        collectionNode.setWrapping( false );
 
         for ( DataElementCategoryOptionCombo categoryOptionCombo : dataElement.getCategoryCombo().getSortedOptionCombos() )
         {
-            ComplexNode complexNode = collectionNode.addNode( new ComplexNode( "dataValue" ) );
+            ComplexNode complexNode = collectionNode.addChild( new ComplexNode( "dataValue" ) );
 
             String label = dataElement.getDisplayName();
 
@@ -297,42 +296,42 @@
 
             if ( comment )
             {
-                complexNode.addHint( NodeHint.Type.COMMENT, "Data element: " + label );
+                complexNode.setComment( "Data element: " + label );
             }
 
             if ( IdentifiableObject.IdentifiableProperty.CODE.toString().toLowerCase().equals( deScheme.toLowerCase() ) )
             {
-                SimpleNode simpleNode = complexNode.addNode( new SimpleNode( "dataElement", dataElement.getCode() ) );
-                simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+                SimpleNode simpleNode = complexNode.addChild( new SimpleNode( "dataElement", dataElement.getCode() ) );
+                simpleNode.setAttribute( true );
             }
             else
             {
-                SimpleNode simpleNode = complexNode.addNode( new SimpleNode( "dataElement", dataElement.getUid() ) );
-                simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+                SimpleNode simpleNode = complexNode.addChild( new SimpleNode( "dataElement", dataElement.getUid() ) );
+                simpleNode.setAttribute( true );
             }
 
-            SimpleNode simpleNode = complexNode.addNode( new SimpleNode( "categoryOptionCombo", categoryOptionCombo.getUid() ) );
-            simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+            SimpleNode simpleNode = complexNode.addChild( new SimpleNode( "categoryOptionCombo", categoryOptionCombo.getUid() ) );
+            simpleNode.setAttribute( true );
 
-            simpleNode = complexNode.addNode( new SimpleNode( "period", period != null ? period.getIsoDate() : "" ) );
-            simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+            simpleNode = complexNode.addChild( new SimpleNode( "period", period != null ? period.getIsoDate() : "" ) );
+            simpleNode.setAttribute( true );
 
             if ( organisationUnit != null )
             {
                 if ( IdentifiableObject.IdentifiableProperty.CODE.toString().toLowerCase().equals( ouScheme.toLowerCase() ) )
                 {
-                    simpleNode = complexNode.addNode( new SimpleNode( "orgUnit", organisationUnit.getCode() == null ? "" : organisationUnit.getCode() ) );
-                    simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+                    simpleNode = complexNode.addChild( new SimpleNode( "orgUnit", organisationUnit.getCode() == null ? "" : organisationUnit.getCode() ) );
+                    simpleNode.setAttribute( true );
                 }
                 else
                 {
-                    simpleNode = complexNode.addNode( new SimpleNode( "orgUnit", organisationUnit.getUid() == null ? "" : organisationUnit.getUid() ) );
-                    simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+                    simpleNode = complexNode.addChild( new SimpleNode( "orgUnit", organisationUnit.getUid() == null ? "" : organisationUnit.getUid() ) );
+                    simpleNode.setAttribute( true );
                 }
             }
 
-            simpleNode = complexNode.addNode( new SimpleNode( "value", "" ) );
-            simpleNode.addHint( NodeHint.Type.ATTRIBUTE, true );
+            simpleNode = complexNode.addChild( new SimpleNode( "value", "" ) );
+            simpleNode.setAttribute( true );
         }
 
         return collectionNode;

=== 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-03 14:33:29 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/filter/DefaultFilterService.java	2014-06-04 10:49:04 +0000
@@ -120,7 +120,7 @@
 
         for ( Object object : objects )
         {
-            collectionNode.addNode( buildObjectOutput( fieldMap, object ) );
+            collectionNode.addChild( buildObjectOutput( fieldMap, object ) );
         }
 
         return collectionNode;
@@ -158,30 +158,30 @@
             {
                 if ( !property.isIdentifiableObject() )
                 {
-                    complexNode.addNode( new SimpleNode( fieldKey, returnValue ) );
+                    complexNode.addChild( new SimpleNode( fieldKey, returnValue ) );
                 }
                 else if ( !property.isCollection() )
                 {
-                    complexNode.addNode( getIdentifiableObjectProperties( returnValue, IDENTIFIABLE_PROPERTIES ) );
+                    complexNode.addChild( getIdentifiableObjectProperties( returnValue, IDENTIFIABLE_PROPERTIES ) );
                 }
                 else
                 {
-                    complexNode.addNode( getIdentifiableObjectCollectionProperties( returnValue, IDENTIFIABLE_PROPERTIES, fieldKey ) );
+                    complexNode.addChild( getIdentifiableObjectCollectionProperties( returnValue, IDENTIFIABLE_PROPERTIES, fieldKey ) );
                 }
             }
             else
             {
                 if ( property.isCollection() )
                 {
-                    CollectionNode collectionNode = complexNode.addNode( new CollectionNode( property.getCollectionName() ) );
+                    CollectionNode collectionNode = complexNode.addChild( new CollectionNode( property.getCollectionName() ) );
 
                     for ( Object collectionObject : (Collection<?>) returnValue )
                     {
                         ComplexNode node = buildObjectOutput( fieldValue, collectionObject );
 
-                        if ( !node.getNodes().isEmpty() )
+                        if ( !node.getChildren().isEmpty() )
                         {
-                            collectionNode.addNode( node );
+                            collectionNode.addChild( node );
                         }
                     }
                 }
@@ -189,9 +189,9 @@
                 {
                     ComplexNode node = buildObjectOutput( fieldValue, returnValue );
 
-                    if ( !node.getNodes().isEmpty() )
+                    if ( !node.getChildren().isEmpty() )
                     {
-                        complexNode.addNode( node );
+                        complexNode.addChild( node );
                     }
                 }
             }
@@ -228,7 +228,7 @@
 
         for ( IdentifiableObject identifiableObject : identifiableObjects )
         {
-            collectionNode.addNode( getIdentifiableObjectProperties( identifiableObject, fields ) );
+            collectionNode.addChild( getIdentifiableObjectProperties( identifiableObject, fields ) );
         }
 
         return collectionNode;
@@ -263,7 +263,7 @@
 
             if ( o != null )
             {
-                complexNode.addNode( new SimpleNode( field, o ) );
+                complexNode.addChild( new SimpleNode( field, o ) );
             }
         }
 

=== 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	2014-06-03 14:33:29 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java	2014-06-04 10:49:04 +0000
@@ -202,15 +202,15 @@
 
         if ( hasPaging )
         {
-            ComplexNode pagerNode = rootNode.addNode( new ComplexNode( "pager" ) );
-            pagerNode.addNode( new SimpleNode( "page", metaData.getPager().getPage() ) );
-            pagerNode.addNode( new SimpleNode( "pageCount", metaData.getPager().getPageCount() ) );
-            pagerNode.addNode( new SimpleNode( "total", metaData.getPager().getTotal() ) );
-            pagerNode.addNode( new SimpleNode( "nextPage", metaData.getPager().getNextPage() ) );
-            pagerNode.addNode( new SimpleNode( "prevPage", metaData.getPager().getPrevPage() ) );
+            ComplexNode pagerNode = rootNode.addChild( new ComplexNode( "pager" ) );
+            pagerNode.addChild( new SimpleNode( "page", metaData.getPager().getPage() ) );
+            pagerNode.addChild( new SimpleNode( "pageCount", metaData.getPager().getPageCount() ) );
+            pagerNode.addChild( new SimpleNode( "total", metaData.getPager().getTotal() ) );
+            pagerNode.addChild( new SimpleNode( "nextPage", metaData.getPager().getNextPage() ) );
+            pagerNode.addChild( new SimpleNode( "prevPage", metaData.getPager().getPrevPage() ) );
         }
 
-        rootNode.addNode( filterService.filterProperties( getEntityClass(), entityList, include, exclude ) );
+        rootNode.addChild( filterService.filterProperties( getEntityClass(), entityList, include, exclude ) );
 
         // response.setContentType( MediaType.APPLICATION_XML_VALUE );
         // nodeService.serialize( rootNode, MediaType.APPLICATION_XML_VALUE, response.getOutputStream() );

=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java	2014-06-03 09:14:08 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SystemController.java	2014-06-04 10:49:04 +0000
@@ -31,7 +31,6 @@
 import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.dxf2.metadata.ImportSummary;
 import org.hisp.dhis.dxf2.utils.JacksonUtils;
-import org.hisp.dhis.node.NodeHint;
 import org.hisp.dhis.node.exception.InvalidTypeException;
 import org.hisp.dhis.node.types.CollectionNode;
 import org.hisp.dhis.node.types.RootNode;
@@ -96,12 +95,12 @@
         }
 
         RootNode rootNode = new RootNode( "codes" );
-        CollectionNode collectionNode = rootNode.addNode( new CollectionNode( "codes" ) );
-        collectionNode.addHint( NodeHint.Type.WRAP_COLLECTION, false );
+        CollectionNode collectionNode = rootNode.addChild( new CollectionNode( "codes" ) );
+        collectionNode.setWrapping( false );
 
         for ( int i = 0; i < n; i++ )
         {
-            collectionNode.addNode( new SimpleNode( "code", CodeGenerator.generateCode() ) );
+            collectionNode.addChild( new SimpleNode( "code", CodeGenerator.generateCode() ) );
         }
 
         return rootNode;