Commit operation as per Section 5.2.7 of RFC 7047
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / operations / Operation.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Madhu Venugopal, Ashwin Raveendran
9  */
10 package org.opendaylight.ovsdb.lib.operations;
11
12 import org.opendaylight.ovsdb.lib.schema.TableSchema;
13
14 import com.fasterxml.jackson.annotation.JsonIgnore;
15 import com.fasterxml.jackson.annotation.JsonProperty;
16
17 public abstract class Operation<E extends TableSchema<E>> {
18
19     @JsonIgnore
20     private TableSchema<E> tableSchema;
21
22     private String op;
23
24     @JsonIgnore
25     //todo(Ashwin): remove this
26     // Just a simple way to retain the result of a transact operation which the client can refer to.
27     private OperationResult result;
28
29
30     protected Operation() {
31     }
32
33     protected Operation(TableSchema<E> tableSchema) {
34         this.tableSchema = tableSchema;
35     }
36
37     public Operation(TableSchema<E> schema, String operation) {
38         this.tableSchema = schema;
39         this.op = operation;
40     }
41
42     public String getOp() {
43         return op;
44     }
45
46     public void setOp(String op) {
47         this.op = op;
48     }
49
50     public OperationResult getResult() {
51         return result;
52     }
53
54     public void setResult(OperationResult result) {
55         this.result = result;
56     }
57
58     public TableSchema<E> getTableSchema() {
59         return tableSchema;
60     }
61
62     public void setTableSchema(TableSchema<E> tableSchema) {
63         this.tableSchema = tableSchema;
64     }
65
66     @JsonProperty
67     public String getTable() {
68         return (tableSchema == null) ? null : tableSchema.getName();
69     }
70
71     @Override
72     public String toString() {
73         return "Operation [op=" + op + ", result=" + result + "]";
74     }
75
76 }