2 * Copyright (C) 2014 EBay Software Foundation
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
8 * Authors : Ashwin Raveendran
10 package org.opendaylight.ovsdb.lib.operations;
15 import org.opendaylight.ovsdb.lib.notation.OvsDBMap;
16 import org.opendaylight.ovsdb.lib.notation.OvsDBSet;
17 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
18 import org.opendaylight.ovsdb.lib.schema.TableSchema;
20 import com.fasterxml.jackson.annotation.JsonProperty;
21 import com.google.common.collect.Maps;
24 public class Insert<E extends TableSchema<E>> extends Operation<E> {
26 public static final String INSERT = "insert";
30 @JsonProperty("uuid-name")
31 private String uuidName;
33 private Map<String, Object> row = Maps.newHashMap();
35 public Insert<E> on(TableSchema schema){
36 this.setTableSchema(schema);
40 public Insert<E> withId(String name) {
47 public Insert(TableSchema<E> schema) {
48 super(schema, INSERT);
51 public <D, C extends TableSchema<C>> Insert<E> value(ColumnSchema<C, D> columnSchema, D value) {
52 Object untypedValue = null;
53 if (columnSchema.getType().isMultiValued()) {
54 if (value instanceof Set) {
55 untypedValue = OvsDBSet.fromSet((Set) value);
56 } else if (value instanceof Map) {
57 untypedValue = OvsDBMap.fromMap((Map)value);
62 row.put(columnSchema.getName(), untypedValue);
66 public String getUuid() {
70 public void setUuid(String uuid) {
74 public String getUuidName() {
78 public void setUuidName(String uuidName) {
79 this.uuidName = uuidName;
82 public Map<String, Object> getRow() {
86 public void setRow(Map<String, Object> row) {