Added more ignorable files to .gitignore
[ovsdb.git] / ovsdb / src / test / java / org / opendaylight / ovsdb / lib / schema / temp / SchemaObjs.java
1 /*
2  * Copyright (C) 2014 EBay Software Foundation
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 : Ashwin Raveendran
9  */
10 package org.opendaylight.ovsdb.lib.schema.temp;
11
12 import org.opendaylight.ovsdb.lib.OvsDBClient;
13 import org.opendaylight.ovsdb.lib.OvsDBClientImpl;
14 import org.opendaylight.ovsdb.lib.schema.DatabaseSchema;
15 import org.opendaylight.ovsdb.lib.schema.ColumnSchema;
16 import org.opendaylight.ovsdb.lib.schema.TableSchema;
17
18 import java.util.concurrent.ExecutionException;
19
20
21 public class SchemaObjs {
22
23     public static class Bridge extends TableSchema<Bridge> {
24         public static String NAME = "Bridge";
25         TableSchema target;
26
27         ColumnSchema<Bridge, String> name;
28         ColumnSchema<Bridge, Boolean> flood_vlans;
29
30
31         public Bridge(TableSchema<Bridge> target) {
32             this.target = target;
33             name = target.column("name", String.class);
34             flood_vlans = target.column("statistics", Boolean.class);
35         }
36
37     }
38
39     public static class Port extends TableSchema<Port> {
40         public static String NAME = "Port";
41         TableSchema target;
42
43         ColumnSchema<Port, String> name;
44         ColumnSchema<Port, String> statistics;
45
46         public Port(TableSchema<Port> target) {
47             this.target = target;
48             name = target.column("name", String.class);
49             statistics = target.column("statistics", String.class);
50         }
51
52     }
53
54     public static void main(String[] args) throws ExecutionException, InterruptedException {
55
56         OvsDBClientImpl ovs = new OvsDBClientImpl(null, null);
57         DatabaseSchema db = ovs.getSchema(OvsDBClient.OPEN_VSWITCH_SCHEMA, true).get();
58         Bridge bridge = db.table(Bridge.NAME, Bridge.class);
59         Port port = db.table(Port.NAME, Port.class);
60
61         db.beginTransaction()
62                 .add(bridge.insert()
63                         .value(bridge.flood_vlans, true)
64                         .value(bridge.name, "br-int"))
65                 .add(port.insert()
66                         .value(port.statistics, "stats")
67                         //.value(port.statistics, 2) ## will not type check as stats is a string
68                         .value(port.name, "newport")
69                 )
70                 .execute();
71
72         //todo untyped version
73
74     }
75 }