X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-xsql%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fdom%2Fxsql%2FXSQLBluePrint.java;h=76152966d06e8448f0056ed363ec564d761295ec;hp=7b51d03a97aaa6c9a9d1592eb5ba963ec63e6d8c;hb=2801b4929e60938cdac4c84dff6422e24e93d11d;hpb=b06d2c5bbffa48b1e219ac92cf0be60528aff34a diff --git a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java index 7b51d03a97..76152966d0 100644 --- a/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java +++ b/opendaylight/md-sal/sal-dom-xsql/src/main/java/org/opendaylight/controller/md/sal/dom/xsql/XSQLBluePrint.java @@ -1,3 +1,10 @@ +/* + * 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; @@ -23,7 +30,9 @@ import java.util.HashSet; 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; @@ -114,8 +123,9 @@ public class XSQLBluePrint implements DatabaseMetaData, Serializable { String odlTableName) { Map map = this.odlNameToBluePrint .get(odlTableName); - if (map == null) + if (map == null) { return null; + } return map.values().toArray(new XSQLBluePrintNode[map.size()]); } @@ -163,23 +173,23 @@ public class XSQLBluePrint implements DatabaseMetaData, Serializable { return cacheLoadedSuccessfuly; } - private static Map> superClassMap = new HashMap>(); + private static Map, Set>> superClassMap = new HashMap<>(); - public static Set getInheritance(Class myObjectClass, - Class returnType) { + public static Set> getInheritance(Class myObjectClass, + Class returnType) { if (returnType != null && myObjectClass.equals(returnType)) { - return new HashSet(); + return new HashSet<>(); } - Set result = superClassMap.get(myObjectClass); + Set> result = superClassMap.get(myObjectClass); if (result != null) { return result; } - result = new HashSet(); + result = new HashSet<>(); superClassMap.put(myObjectClass, result); if (returnType != null) { if (!returnType.equals(myObjectClass)) { - Class mySuperClass = myObjectClass.getSuperclass(); + Class mySuperClass = myObjectClass.getSuperclass(); while (mySuperClass != null) { result.add(mySuperClass); mySuperClass = mySuperClass.getSuperclass(); @@ -190,11 +200,11 @@ public class XSQLBluePrint implements DatabaseMetaData, Serializable { return result; } - public static Set collectInterfaces(Class cls) { - Set result = new HashSet(); - Class myInterfaces[] = cls.getInterfaces(); + public static Set> collectInterfaces(Class cls) { + Set> result = new HashSet<>(); + Class myInterfaces[] = cls.getInterfaces(); if (myInterfaces != null) { - for (Class in : myInterfaces) { + for (Class in : myInterfaces) { result.add(in); result.addAll(collectInterfaces(in)); } @@ -202,31 +212,39 @@ public class XSQLBluePrint implements DatabaseMetaData, Serializable { return result; } - public void addToBluePrintCache(XSQLBluePrintNode blNode) { - this.tableNameToBluePrint.put(blNode.getBluePrintNodeName(), blNode); - Map map = this.odlNameToBluePrint.get(blNode - .getODLTableName()); - if (map == null) { - map = new HashMap(); - 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 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 Class getGenericType(ParameterizedType type) { Type[] typeArguments = type.getActualTypeArguments(); for (Type typeArgument : typeArguments) { if (typeArgument instanceof ParameterizedType) { ParameterizedType pType = (ParameterizedType) typeArgument; - return (Class) pType.getRawType(); + return (Class) pType.getRawType(); } else if (typeArgument instanceof Class) { - return (Class) typeArgument; + return (Class) typeArgument; } } return null; } - public Class getMethodReturnTypeFromGeneric(Method m) { + public Class getMethodReturnTypeFromGeneric(Method m) { Type rType = m.getGenericReturnType(); if (rType instanceof ParameterizedType) { return getGenericType((ParameterizedType) rType);