Added more ignorable files to .gitignore
[ovsdb.git] / library / src / main / java / org / opendaylight / ovsdb / lib / database / OVSBridge.java
1 /*
2  * [[ Authors will Fill in the Copyright header ]]
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 : Brent Salisbury, Evan Zeller
9  */
10 package org.opendaylight.ovsdb.lib.database;
11
12
13 import java.util.ArrayList;
14 import java.util.Arrays;
15 import java.util.HashMap;
16 import java.util.List;
17 import java.util.Map;
18
19 public class OVSBridge {
20
21     private String uuid;
22     private String name;
23
24     public OVSBridge(String uuid, String name){
25         this.uuid = uuid;
26         this.name = name;
27     }
28
29     public String getUuid(){
30         return this.uuid;
31     }
32
33     public String getName(){
34         return this.name;
35     }
36
37     @SuppressWarnings("unchecked")
38     public static Map<String, OVSBridge> monitorBridge(){
39         List<String> columns = new ArrayList<String>();
40         columns.add("_uuid");
41         columns.add("name");
42
43         Map<String, List<String>> row = new HashMap<String, List<String>>();
44         row.put("columns", columns);
45
46         Map<String, Map> tables = new HashMap<String, Map>();
47         tables.put("Bridge", row);
48
49         Object[] params = {"Open_vSwitch", null, tables};
50
51         Map<String, Object> monitorResponse = new HashMap<String, Object>();
52         Map<String, Object> bridgeTable = (Map) monitorResponse.get("Bridge");
53
54         Object[] uuidObjects = bridgeTable.keySet().toArray();
55         String[] uuids = Arrays.copyOf(uuidObjects, uuidObjects.length, String[].class);
56
57         Map<String, OVSBridge> result = new HashMap<String, OVSBridge>();
58
59         for(String uuid : uuids){
60             Map<String, Object> newRow = (Map) bridgeTable.get(uuid);
61             Map<String, Object> newColumns = (Map) newRow.get("new");
62             String name = (String) newColumns.get("name");
63             result.put(name, new OVSBridge(uuid, name));
64         }
65
66         return result;
67     }
68 }