+ private String getTableNameForRowUuid(Node node, String databaseName, UUID rowUuid) {
+ ConcurrentMap<String, ConcurrentMap<String, Row>> cache = ovsdbInventoryService.getCache(node, databaseName);
+ if (cache == null) return null;
+ for (String tableName : cache.keySet()) {
+ ConcurrentMap<String, Row> rows = cache.get(tableName);
+ if (rows.get(rowUuid.toString()) != null) {
+ return tableName;
+ }
+ }
+ return null;
+ }
+
+ private String getReferencingColumn (TableSchema<?> parentTableSchema, String childTableName) throws OvsdbPluginException {
+ Map<String, ColumnSchema> columnSchemas = parentTableSchema.getColumnSchemas();
+ String refColumn = null;
+ for (String columnName : columnSchemas.keySet()) {
+ ColumnSchema columnSchema = columnSchemas.get(columnName);
+ if (columnSchema.getType().getBaseType().getClass().equals(UuidBaseType.class)) {
+ UuidBaseType refType = (UuidBaseType)columnSchema.getType().getBaseType();
+ if (refType.getRefTable() != null && refType.getRefTable().equalsIgnoreCase(childTableName)) {
+ if (refColumn == null) {
+ refColumn = columnName;
+ } else {
+ throw new OvsdbPluginException("Multiple Referencing Columns for "+ childTableName +" on "+ parentTableSchema.getName());
+ }
+ }
+ }
+ }
+ if (refColumn != null) {
+ return refColumn;
+ }
+ throw new OvsdbPluginException("No Referencing Column for "+childTableName+" on "+parentTableSchema.getName());
+ }