Merge "Fix for Bug 3"
[controller.git] / opendaylight / northbound / switchmanager / src / main / java / org / opendaylight / controller / switchmanager / northbound / NodeProperties.java
index 979a8e9776c6faa1ef798cd36a8557e0aa6f73fc..51e96c49eaf4cd7ac39803c1bde77abe96c821cc 100644 (file)
@@ -9,14 +9,19 @@
 
 package org.opendaylight.controller.switchmanager.northbound;
 
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import org.opendaylight.controller.sal.core.Node;
 import org.opendaylight.controller.sal.core.Property;
 
@@ -31,6 +36,7 @@ public class NodeProperties {
     private Node node;
     @XmlElementRef
     @XmlElementWrapper
+    @JsonIgnore
     private Set<Property> properties;
 
     // JAXB required constructor
@@ -44,6 +50,19 @@ public class NodeProperties {
         this.properties = properties;
     }
 
+    @JsonProperty(value="properties")
+    public Map<String, Property> getMapProperties() {
+        Map<String, Property> map = new HashMap<String, Property>();
+        for (Property p : properties) {
+            map.put(p.getName(), p);
+        }
+        return map;
+    }
+
+    public void setMapProperties(Map<String, Property> propertiesMap) {
+        this.properties = new HashSet<Property>(propertiesMap.values());
+    }
+
     public Set<Property> getProperties() {
         return properties;
     }