Add the OVSDB Delete Operation 42/6842/3
authorDave Tucker <dave@dtucker.co.uk>
Fri, 9 May 2014 21:56:52 +0000 (22:56 +0100)
committerDave Tucker <djt@redhat.com>
Fri, 16 May 2014 17:33:24 +0000 (18:33 +0100)
Add the OVSDB Delete Operation to the new library

Change-Id: Ie16c193cca74184e79f1e8462dcc11bf8632a9d4
Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
library/src/main/java/org/opendaylight/ovsdb/lib/operations/Delete.java [new file with mode: 0644]
library/src/main/java/org/opendaylight/ovsdb/lib/operations/Operations.java
library/src/test/java/org/opendaylight/ovsdb/lib/OvsDBClientTestIT.java

diff --git a/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Delete.java b/library/src/main/java/org/opendaylight/ovsdb/lib/operations/Delete.java
new file mode 100644 (file)
index 0000000..0067212
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Red Hat Inc,
+ *
+ * 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 : Dave Tucker
+ *
+ */
+
+package org.opendaylight.ovsdb.lib.operations;
+
+import com.google.common.collect.Lists;
+import org.opendaylight.ovsdb.lib.notation.Condition;
+import org.opendaylight.ovsdb.lib.schema.TableSchema;
+
+import java.util.List;
+
+public class Delete<E extends TableSchema<E>> extends Operation<E> implements ConditionalOperation {
+
+    public static final String DELETE = "delete";
+    List<Condition> where = Lists.newArrayList();
+    Integer count;
+
+    public Delete(TableSchema<E> schema) {
+        super(schema, DELETE);
+    }
+
+    public Delete<E> on(TableSchema schema){
+        return this;
+    }
+
+    public Where where(Condition condition) {
+        return new Where(this);
+    }
+
+    @Override
+    public void addCondition(Condition condition) {
+        this.where.add(condition);
+    }
+
+    public List<Condition> getWhere() {
+        return where;
+    }
+
+    public void setWhere(List<Condition> where) {
+        this.where = where;
+    }
+
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+}
index 18b07c73dbe009ec838f17fc5282d8afaa4781ce..4e84de23be20e4631d6a5e3aefa38299df400887 100644 (file)
@@ -25,5 +25,8 @@ public class Operations {
         return new Update<>(schema);
     }
 
+    public  <E extends TableSchema<E>> Delete<E> delete(TableSchema<E> schema) {
+        return new Delete<>(schema);
+    }
 
-}
+}
\ No newline at end of file
index 0d2a3191ac72a44c03a50588384e83d90edd04c6..40a2356a8a4916b9af99f15354d624d82b2ae8a3 100644 (file)
@@ -65,6 +65,9 @@ public class OvsDBClientTestIT extends OvsdbTestBase {
                         .where(name.opEqual("br-int"))
                         //.and(name.opEqual("br-int"))
                         .operation())
+                .add(op.delete(bridge)
+                        .where(name.opEqual("br-int"))
+                        .operation())
                 .execute();
 
         List<OperationResult> operationResults = results.get();