+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.controller.md.sal.dom.xsql;
import java.io.DataInputStream;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
+/**
+ * @author Sharon Aicler(saichler@gmail.com)
+ **/
public class XSQLBluePrint implements DatabaseMetaData, Serializable {
private static final long serialVersionUID = 1L;
public static final String CACHE_FILE_NAME = "./BluePrintCache.dat";
- private Map<String, XSQLBluePrintNode> tableNameToBluePrint = new HashMap<String, XSQLBluePrintNode>();
- private Map<String, Map<String, XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<String, Map<String, XSQLBluePrintNode>>();
+ private Map<String, XSQLBluePrintNode> tableNameToBluePrint = new HashMap<>();
+ private Map<String, Map<String, XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<>();
private boolean cacheLoadedSuccessfuly = false;
private DatabaseMetaData myProxy = null;
return result;
}
- public void addToBluePrintCache(XSQLBluePrintNode blNode) {
- this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode);
- Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode
- .getODLTableName());
- if (map == null) {
- map = new HashMap<String, XSQLBluePrintNode>();
- this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
+ public XSQLBluePrintNode addToBluePrintCache(XSQLBluePrintNode blNode,XSQLBluePrintNode parent) {
+ XSQLBluePrintNode existingNode = this.tableNameToBluePrint.get(blNode.getBluePrintNodeName());
+ if(existingNode!=null){
+ existingNode.mergeAugmentation(blNode);
+ return existingNode;
+ }else{
+ this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode);
+ Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint.get(blNode.getODLTableName());
+ if (map == null) {
+ map = new HashMap<>();
+ this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
+ }
+ map.put(blNode.getBluePrintNodeName(), blNode);
+ if(parent!=null)
+ parent.addChild(blNode);
+ return blNode;
}
- map.put(blNode.getBluePrintNodeName(), blNode);
}
public Class<?> getGenericType(ParameterizedType type) {
}
public List<String> getAllTableNames() {
- List<String> names = new ArrayList<String>();
+ List<String> names = new ArrayList<>();
for (XSQLBluePrintNode n : this.tableNameToBluePrint.values()) {
if (!n.isModule() && !n.getColumns().isEmpty()) {
names.add(n.getBluePrintNodeName());
public List<String> getInterfaceNames(XSQLBluePrintNode node) {
Set<XSQLBluePrintNode> children = node.getChildren();
- List<String> names = new ArrayList<String>();
+ List<String> names = new ArrayList<>();
for (XSQLBluePrintNode n : children) {
if (!n.isModule() && !n.getColumns().isEmpty()) {
names.add(n.toString());