Added Security Rule for Custom ICMP
[ovsdb.git] / northbound / src / main / java / org / opendaylight / ovsdb / northbound / OvsdbRow.java
index ca4a56b9f259ff2eaad277ee0d9fd44906231d87..977bbbd9725e4f94f9cba49bd5e53d35399a56d8 100644 (file)
@@ -1,20 +1,17 @@
 /*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (c) 2013, 2015 Red Hat, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Authors : Madhu Venugopal, Brent Salisbury
  */
+
 package org.opendaylight.ovsdb.northbound;
 
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.concurrent.ExecutionException;
 
-import javax.xml.bind.annotation.XmlElement;
-
 import org.opendaylight.ovsdb.lib.OvsdbClient;
 import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
@@ -24,18 +21,17 @@ import com.fasterxml.jackson.core.JsonParseException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
-@Deprecated
 public class OvsdbRow {
     private static final String PARENTUUID = "parent_uuid";
+    private static final String PARENTTABLE = "parent_table";
+    private static final String PARENTCOLUMN = "parent_column";
     private static final String ROW = "row";
 
-    @XmlElement(name=PARENTUUID)
-    String parentUuid;
-
-    String tableName;
-
-    @XmlElement(name=ROW)
-    Row<GenericTableSchema> row;
+    private String parentUuid;
+    private String parentTable;
+    private String parentColumn;
+    private String tableName;
+    private Row<GenericTableSchema> row;
 
     public OvsdbRow() {
     }
@@ -46,13 +42,34 @@ public class OvsdbRow {
         this.row = row;
     }
 
+    public OvsdbRow(String parentTable, String parentUuid, String parentColumn, String tableName, Row<GenericTableSchema> row) {
+        this.parentTable = parentTable;
+        this.parentColumn = parentColumn;
+        this.parentUuid = parentUuid;
+        this.tableName = tableName;
+        this.row = row;
+    }
+
     public static OvsdbRow fromJsonNode(OvsdbClient client, String dbName, JsonNode json) {
         JsonNode parentUuidNode = json.get(PARENTUUID);
         String parentUuid = null;
-        if (parentUuidNode != null) parentUuid = parentUuidNode.asText();
-
+        if (parentUuidNode != null) {
+           parentUuid = parentUuidNode.asText();
+        }
+        JsonNode parentTableNode = json.get(PARENTTABLE);
+        String parentTable = null;
+        if (parentTableNode != null) {
+            parentTable = parentTableNode.asText();
+        }
+        JsonNode parentColumnNode = json.get(PARENTCOLUMN);
+        String parentColumn = null;
+        if (parentColumnNode != null) {
+            parentColumn = parentColumnNode.asText();
+        }
         JsonNode rowNode = json.get(ROW);
-        if (rowNode == null) return null;
+        if (rowNode == null) {
+            return null;
+        }
         for(Iterator<String> fieldNames = rowNode.fieldNames(); fieldNames.hasNext();) {
             String tableName = fieldNames.next();
             Row<GenericTableSchema> row = null;
@@ -62,7 +79,7 @@ public class OvsdbRow {
                 e.printStackTrace();
                 return null;
             }
-            return new OvsdbRow(parentUuid, tableName, row);
+            return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row);
         }
         return null;
     }
@@ -73,10 +90,18 @@ public class OvsdbRow {
         return schema.createRow((ObjectNode)rowJson);
     }
 
+    public String getParentTable() {
+        return parentTable;
+    }
+
     public String getParentUuid() {
         return parentUuid;
     }
 
+    public String getParentColumn() {
+        return parentColumn;
+    }
+
     public String getTableName() {
         return tableName;
     }
@@ -84,10 +109,4 @@ public class OvsdbRow {
     public Row<GenericTableSchema> getRow() {
         return row;
     }
-
-    @Override
-    public String toString() {
-        return "OVSDBRow [parentUuid=" + parentUuid + ", tableName="
-                + tableName + ", row=" + row + "]";
-    }
 }