import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
+import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* @author Sharon Aicler(saichler@gmail.com)
**/
*/
@Deprecated
public class XSQLAdapter extends Thread implements SchemaContextListener {
+ private static final Logger LOG = LoggerFactory.getLogger(XSQLAdapter.class);
private static final int SLEEP = 10000;
private static XSQLAdapter a = new XSQLAdapter();
private static String tmpDir = null;
private static File xqlLog = null;
public boolean stopped = false;
- private List<String> elementHosts = new ArrayList<>();
private String username;
private String password;
- private String transport = "tcp";
+ private final String transport = "tcp";
private int reconnectTimeout;
private int nThreads;
private int qsize;
- private String applicationName = "NQL Adapter";
- private Map<String, NEEntry> elements = new ConcurrentHashMap<>();
+ private final String applicationName = "NQL Adapter";
private StringBuffer lastInputString = new StringBuffer();
- private XSQLBluePrint bluePrint = new XSQLBluePrint();
private boolean toCsv = false;
private String exportToFileName = null;
- private XSQLThreadPool threadPool = new XSQLThreadPool(1, "Tasks", 2000);
- private JDBCServer jdbcServer = new JDBCServer(this);
+ private final XSQLThreadPool threadPool = new XSQLThreadPool(1, "Tasks", 2000);
+ private final JDBCServer jdbcServer = new JDBCServer(this);
private String pinningFile;
private ServerSocket serverSocket = null;
private DOMDataBroker domDataBroker = null;
private static final String REFERENCE_FIELD_NAME = "reference";
+ @GuardedBy("this")
+ private SchemaContext context;
+ @GuardedBy("this")
+ private XSQLBluePrint bluePrint = new XSQLBluePrint();
+
private XSQLAdapter() {
XSQLAdapter.log("Starting Adapter");
this.setDaemon(true);
}
- public void loadBluePrint(){
+ public synchronized void loadBluePrint(){
try{
InputStream in = this.getClass().getClassLoader().getResourceAsStream("BluePrintCache.dat");
if(in!=null){
- this.bluePrint = XSQLBluePrint.load(in);
+ this.bluePrint = XSQLBluePrint.load(in);
+ in.close();
}
- in.close();
}catch(Exception err){
err.printStackTrace();
}
return xqlLog;
}
- public static void main(String args[]) {
+ public static void main(final String args[]) {
XSQLAdapter adapter = new XSQLAdapter();
adapter.start();
}
- public static void log(String str) {
+ public static void log(final String str) {
try {
if (l == null) {
synchronized (XSQLAdapter.class) {
}
}
- public static void log(Exception e) {
+ public static void log(final Exception e) {
try {
if (l == null) {
synchronized (XSQLAdapter.class) {
}
@Override
- public void onGlobalContextUpdated(SchemaContext context) {
- Set<Module> modules = context.getModules();
- for (Module m : modules) {
- if (XSQLODLUtils.createOpenDaylightCache(this.bluePrint, m)) {
- this.addRootElement(m);
- }
- }
+ public synchronized void onGlobalContextUpdated(final SchemaContext context) {
+ this.bluePrint = null;
+ this.context = context;
}
- public void setDataBroker(DOMDataBroker ddb) {
+ public void setDataBroker(final DOMDataBroker ddb) {
this.domDataBroker = ddb;
}
- public XSQLBluePrint getBluePrint() {
- return this.bluePrint;
+ public synchronized XSQLBluePrint getBluePrint() {
+ if (bluePrint == null) {
+ LOG.warn("XSQL is not supported in production environments and will be removed in a future release");
+ bluePrint = XSQLBluePrint.create(context);
+ }
+
+ return bluePrint;
}
- public List<Object> collectModuleRoots(XSQLBluePrintNode table,LogicalDatastoreType type) {
+ public List<Object> collectModuleRoots(final XSQLBluePrintNode table,final LogicalDatastoreType type) {
if (table.getParent().isModule()) {
try {
List<Object> result = new LinkedList<>();
return null;
}
- public void execute(JDBCResultSet rs) {
+ public void execute(final JDBCResultSet rs) {
if(this.domDataBroker==null){
rs.setFinished(true);
return;
List<NETask> tasks = new LinkedList<>();
for (Object entry : roots) {
- NETask task = new NETask(rs, entry, main, bluePrint);
+ NETask task = new NETask(rs, entry, main, getBluePrint());
rs.numberOfTasks++;
tasks.add(task);
}
}
}
+ @Override
public void run() {
while (!stopped) {
try {
}
}
- public void addRootElement(Object o) {
- NEEntry entry = new NEEntry(o);
- elements.put(o.toString(), entry);
-
- }
-
- public void processCommand(StringBuffer inputString, PrintStream sout) {
+ public void processCommand(StringBuffer inputString, final PrintStream sout) {
if (inputString.toString().trim().equals("r")) {
sout.println(lastInputString);
inputString = lastInputString;
// sout.println("Excel Path="+excelPath01);
} else if (input.startsWith("list vrel")) {
String substr = input.substring("list vrel".length()).trim();
- XSQLBluePrintNode node = bluePrint
- .getBluePrintNodeByTableName(substr);
+ XSQLBluePrintNode node = getBluePrint().getBluePrintNodeByTableName(substr);
if (node == null) {
sout.println("Unknown Interface " + substr);
return;
for (XSQLBluePrintRelation r : node.getRelations()) {
fld.add(r.toString());
}
- String p[] = (String[]) fld.toArray(new String[fld.size()]);
+ String p[] = fld.toArray(new String[fld.size()]);
Arrays.sort(p);
- for (int i = 0; i < p.length; i++) {
- sout.println(p[i]);
+ for (String element : p) {
+ sout.println(element);
}
} else if (input.startsWith("list vfields")) {
String substr = input.substring("list vfields".length()).trim();
- XSQLBluePrintNode node = bluePrint
- .getBluePrintNodeByTableName(substr);
+ XSQLBluePrintNode node = getBluePrint().getBluePrintNodeByTableName(substr);
if (node == null) {
sout.println("Unknown Interface " + substr);
return;
for (XSQLColumn c : node.getColumns()) {
fld.add(c.getName());
}
- String p[] = (String[]) fld.toArray(new String[fld.size()]);
+ String p[] = fld.toArray(new String[fld.size()]);
Arrays.sort(p);
- for (int i = 0; i < p.length; i++) {
- sout.println(p[i]);
+ for (String element : p) {
+ sout.println(element);
}
} else if (input.startsWith("jdbc")) {
String addr = input.substring(5).trim();
// fetchSize = Integer.parseInt(input.substring(6).trim());
} else if (input.startsWith("list vtables")) {
- String iNames[] = bluePrint.getAllTableNames().toArray(
+ String iNames[] = getBluePrint().getAllTableNames().toArray(
new String[0]);
Arrays.sort(iNames);
sout.println();
- for (int i = 0; i < iNames.length; i++) {
- sout.println(iNames[i]);
+ for (String iName : iNames) {
+ sout.println(iName);
}
} else if (input.equals("help") || input.equals("?")) {
// sout.println(getLongDescription());
} catch (Exception err) {
}
} else if (input.equals("save")) {
- XSQLBluePrint.save(this.bluePrint);
+ getBluePrint().save();
} else if (input.equals("tocsv")) {
toCsv = !toCsv;
sout.println("to csv file is " + toCsv);
sout.println();
}
- public void executeSql(String sql, PrintStream out) {
+ public void executeSql(final String sql, final PrintStream out) {
JDBCResultSet rs = new JDBCResultSet(sql);
try {
int count = 0;
private XSQLBluePrintNode main = null;
private XSQLBluePrint bluePrint = null;
- public NETask(JDBCResultSet _rs, Object _modelRoot,
- XSQLBluePrintNode _main, XSQLBluePrint _bluePrint) {
+ public NETask(final JDBCResultSet _rs, final Object _modelRoot,
+ final XSQLBluePrintNode _main, final XSQLBluePrint _bluePrint) {
this.rs = _rs;
this.modelRoot = _modelRoot;
this.main = _main;
this.bluePrint = _bluePrint;
}
+ @Override
public void run() {
rs.addRecords(modelRoot, main, true, main.getBluePrintNodeName(),
bluePrint);
}
}
- private static class NEEntry {
- private Object ne = null;
-
- public NEEntry(Object _ne) {
- this.ne = _ne;
- }
-
- public String toString() {
- Module m = (Module) ne;
- return m.getName() + " [" + m.getNamespace().toString() + "]";
- }
- }
-
private class TelnetConnection extends Thread {
private Socket socket = null;
private InputStream in = null;
private PrintStream out = null;
- private Module currentModule = null;
+ private final Module currentModule = null;
- public TelnetConnection(Socket s) {
+ public TelnetConnection(final Socket s) {
this.socket = s;
try {
this.in = s.getInputStream();
}
}
+ @Override
public void run() {
StringBuffer inputString = new StringBuffer();
String prompt = "XSQL>";
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
/**
* @author Sharon Aicler(saichler@gmail.com)
**/
public static final String CACHE_FILE_NAME = "./BluePrintCache.dat";
- private Map<String, XSQLBluePrintNode> tableNameToBluePrint = new HashMap<>();
- private Map<String, Map<String, XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<>();
+ private final Map<String, XSQLBluePrintNode> tableNameToBluePrint = new HashMap<>();
+ private final Map<String, Map<String, XSQLBluePrintNode>> odlNameToBluePrint = new HashMap<>();
- private boolean cacheLoadedSuccessfuly = false;
+ private final boolean cacheLoadedSuccessfuly = false;
private DatabaseMetaData myProxy = null;
- public static final String replaceAll(String source, String toReplace,
- String withThis) {
+ public static final String replaceAll(final String source, final String toReplace,
+ final String withThis) {
int index = source.indexOf(toReplace);
int index2 = 0;
StringBuffer result = new StringBuffer();
return result.toString();
}
- public XSQLBluePrint() {
+ XSQLBluePrint() {
+
}
- public static void save(XSQLBluePrint bp) {
+ public void save() {
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(new DataOutputStream(
new FileOutputStream(CACHE_FILE_NAME)));
- out.writeObject(bp);
+ out.writeObject(this);
} catch (Exception err) {
err.printStackTrace();
} finally {
}
}
- public static XSQLBluePrint load(InputStream ins) {
+ static XSQLBluePrint create(final SchemaContext context) {
+ final XSQLBluePrint ret = new XSQLBluePrint();
+ for (Module m : context.getModules()) {
+ XSQLODLUtils.createOpenDaylightCache(ret, m);
+ }
+
+ return ret;
+ }
+
+ public static XSQLBluePrint load(final InputStream ins) {
ObjectInputStream in = null;
try {
in = new ObjectInputStream(new DataInputStream(ins));
}
private class NQLBluePrintProxy implements InvocationHandler {
- public Object invoke(Object proxy, Method method, Object[] args)
+ @Override
+ public Object invoke(final Object proxy, final Method method, final Object[] args)
throws Throwable {
System.out.println("Method " + method);
return method.invoke(XSQLBluePrint.this, args);
}
public XSQLBluePrintNode[] getBluePrintNodeByODLTableName(
- String odlTableName) {
+ final String odlTableName) {
Map<String, XSQLBluePrintNode> map = this.odlNameToBluePrint
.get(odlTableName);
if (map == null) {
private static Map<Class<?>, Set<Class<?>>> superClassMap = new HashMap<>();
- public static Set<Class<?>> getInheritance(Class<?> myObjectClass,
- Class<?> returnType) {
+ public static Set<Class<?>> getInheritance(final Class<?> myObjectClass,
+ final Class<?> returnType) {
if (returnType != null && myObjectClass.equals(returnType)) {
return new HashSet<>();
return result;
}
- public static Set<Class<?>> collectInterfaces(Class<?> cls) {
+ public static Set<Class<?>> collectInterfaces(final Class<?> cls) {
Set<Class<?>> result = new HashSet<>();
Class<?> myInterfaces[] = cls.getInterfaces();
if (myInterfaces != null) {
return result;
}
- public XSQLBluePrintNode addToBluePrintCache(XSQLBluePrintNode blNode,XSQLBluePrintNode parent) {
+ public XSQLBluePrintNode addToBluePrintCache(final XSQLBluePrintNode blNode,final XSQLBluePrintNode parent) {
XSQLBluePrintNode existingNode = this.tableNameToBluePrint.get(blNode.getBluePrintNodeName());
if(existingNode!=null){
existingNode.mergeAugmentation(blNode);
this.odlNameToBluePrint.put(blNode.getODLTableName(), map);
}
map.put(blNode.getBluePrintNodeName(), blNode);
- if(parent!=null)
+ if(parent!=null) {
parent.addChild(blNode);
+ }
return blNode;
}
}
- public Class<?> getGenericType(ParameterizedType type) {
+ public Class<?> getGenericType(final ParameterizedType type) {
Type[] typeArguments = type.getActualTypeArguments();
for (Type typeArgument : typeArguments) {
if (typeArgument instanceof ParameterizedType) {
return null;
}
- public Class<?> getMethodReturnTypeFromGeneric(Method m) {
+ public Class<?> getMethodReturnTypeFromGeneric(final Method m) {
Type rType = m.getGenericReturnType();
if (rType instanceof ParameterizedType) {
return getGenericType((ParameterizedType) rType);
}
- public List<String> getInterfaceNames(XSQLBluePrintNode node) {
+ public List<String> getInterfaceNames(final XSQLBluePrintNode node) {
Set<XSQLBluePrintNode> children = node.getChildren();
List<String> names = new ArrayList<>();
for (XSQLBluePrintNode n : children) {
}
@Override
- public boolean deletesAreDetected(int type) throws SQLException {
+ public boolean deletesAreDetected(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
@Override
- public ResultSet getAttributes(String catalog, String schemaPattern,
- String typeNamePattern, String attributeNamePattern)
+ public ResultSet getAttributes(final String catalog, final String schemaPattern,
+ final String typeNamePattern, final String attributeNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getBestRowIdentifier(String catalog, String schema,
- String table, int scope, boolean nullable) throws SQLException {
+ public ResultSet getBestRowIdentifier(final String catalog, final String schema,
+ final String table, final int scope, final boolean nullable) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getColumnPrivileges(String catalog, String schema,
- String table, String columnNamePattern) throws SQLException {
+ public ResultSet getColumnPrivileges(final String catalog, final String schema,
+ final String table, final String columnNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getColumns(String catalog, String schemaPattern,
- String tableNamePattern, String columnNamePattern)
+ public ResultSet getColumns(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String columnNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getCrossReference(String parentCatalog,
- String parentSchema, String parentTable, String foreignCatalog,
- String foreignSchema, String foreignTable) throws SQLException {
+ public ResultSet getCrossReference(final String parentCatalog,
+ final String parentSchema, final String parentTable, final String foreignCatalog,
+ final String foreignSchema, final String foreignTable) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getExportedKeys(String catalog, String schema, String table)
+ public ResultSet getExportedKeys(final String catalog, final String schema, final String table)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getFunctionColumns(String catalog, String schemaPattern,
- String functionNamePattern, String columnNamePattern)
+ public ResultSet getFunctionColumns(final String catalog, final String schemaPattern,
+ final String functionNamePattern, final String columnNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getFunctions(String catalog, String schemaPattern,
- String functionNamePattern) throws SQLException {
+ public ResultSet getFunctions(final String catalog, final String schemaPattern,
+ final String functionNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getImportedKeys(String catalog, String schema, String table)
+ public ResultSet getImportedKeys(final String catalog, final String schema, final String table)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getIndexInfo(String catalog, String schema, String table,
- boolean unique, boolean approximate) throws SQLException {
+ public ResultSet getIndexInfo(final String catalog, final String schema, final String table,
+ final boolean unique, final boolean approximate) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getPrimaryKeys(String catalog, String schema, String table)
+ public ResultSet getPrimaryKeys(final String catalog, final String schema, final String table)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getProcedureColumns(String catalog, String schemaPattern,
- String procedureNamePattern, String columnNamePattern)
+ public ResultSet getProcedureColumns(final String catalog, final String schemaPattern,
+ final String procedureNamePattern, final String columnNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getProcedures(String catalog, String schemaPattern,
- String procedureNamePattern) throws SQLException {
+ public ResultSet getProcedures(final String catalog, final String schemaPattern,
+ final String procedureNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getSchemas(String catalog, String schemaPattern)
+ public ResultSet getSchemas(final String catalog, final String schemaPattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getSuperTables(String catalog, String schemaPattern,
- String tableNamePattern) throws SQLException {
+ public ResultSet getSuperTables(final String catalog, final String schemaPattern,
+ final String tableNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getSuperTypes(String catalog, String schemaPattern,
- String typeNamePattern) throws SQLException {
+ public ResultSet getSuperTypes(final String catalog, final String schemaPattern,
+ final String typeNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getTablePrivileges(String catalog, String schemaPattern,
- String tableNamePattern) throws SQLException {
+ public ResultSet getTablePrivileges(final String catalog, final String schemaPattern,
+ final String tableNamePattern) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getTables(String catalog, String schemaPattern,
- String tableNamePattern, String[] types) throws SQLException {
+ public ResultSet getTables(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String[] types) throws SQLException {
return new TablesResultSet(this);
}
}
@Override
- public ResultSet getUDTs(String catalog, String schemaPattern,
- String typeNamePattern, int[] types) throws SQLException {
+ public ResultSet getUDTs(final String catalog, final String schemaPattern,
+ final String typeNamePattern, final int[] types) throws SQLException {
// TODO Auto-generated method stub
return null;
}
}
@Override
- public ResultSet getVersionColumns(String catalog, String schema,
- String table) throws SQLException {
+ public ResultSet getVersionColumns(final String catalog, final String schema,
+ final String table) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public boolean insertsAreDetected(int type) throws SQLException {
+ public boolean insertsAreDetected(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
@Override
- public boolean othersDeletesAreVisible(int type) throws SQLException {
+ public boolean othersDeletesAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean othersInsertsAreVisible(int type) throws SQLException {
+ public boolean othersInsertsAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean othersUpdatesAreVisible(int type) throws SQLException {
+ public boolean othersUpdatesAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean ownDeletesAreVisible(int type) throws SQLException {
+ public boolean ownDeletesAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean ownInsertsAreVisible(int type) throws SQLException {
+ public boolean ownInsertsAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean ownUpdatesAreVisible(int type) throws SQLException {
+ public boolean ownUpdatesAreVisible(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
@Override
- public boolean supportsConvert(int fromType, int toType)
+ public boolean supportsConvert(final int fromType, final int toType)
throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean supportsResultSetConcurrency(int type, int concurrency)
+ public boolean supportsResultSetConcurrency(final int type, final int concurrency)
throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean supportsResultSetHoldability(int holdability)
+ public boolean supportsResultSetHoldability(final int holdability)
throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean supportsResultSetType(int type) throws SQLException {
+ public boolean supportsResultSetType(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
@Override
- public boolean supportsTransactionIsolationLevel(int level)
+ public boolean supportsTransactionIsolationLevel(final int level)
throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public boolean updatesAreDetected(int type) throws SQLException {
+ public boolean updatesAreDetected(final int type) throws SQLException {
// TODO Auto-generated method stub
return false;
}
}
@Override
- public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ public boolean isWrapperFor(final Class<?> iface) throws SQLException {
// TODO Auto-generated method stub
return false;
}
@Override
- public <T> T unwrap(Class<T> iface) throws SQLException {
+ public <T> T unwrap(final Class<T> iface) throws SQLException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ResultSet getPseudoColumns(String catalog, String schemaPattern,
- String tableNamePattern, String columnNamePattern)
+ public ResultSet getPseudoColumns(final String catalog, final String schemaPattern,
+ final String tableNamePattern, final String columnNamePattern)
throws SQLException {
// TODO Auto-generated method stub
return null;
// TODO Auto-generated method stub
return false;
}
-
}
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
types.put(Status.class, Status.class);
}
- public static boolean isColumnType(Class<?> cls) {
+ public static boolean isColumnType(final Class<?> cls) {
return types.containsKey(cls);
}
- public static String getTableName(Object odlNode) {
+ public static String getTableName(final Object odlNode) {
if (odlNode instanceof Module) {
return ((Module) odlNode).getNamespace().toString();
} else if (odlNode instanceof DataSchemaNode) {
return null;
}
- public static String extractTableName(SchemaPath path) {
+ public static String extractTableName(final SchemaPath path) {
List<QName> lst = path.getPath();
StringBuffer name = new StringBuffer();
int i = 0;
return name.toString();
}
- public static String getBluePrintName(Object odlNode){
+ public static String getBluePrintName(final Object odlNode){
if (odlNode instanceof Module) {
return ((Module) odlNode).getNamespace().toString();
} else if (odlNode instanceof DataSchemaNode) {
return null;
}
- public static String getODLNodeName(Object odlNode) {
+ public static String getODLNodeName(final Object odlNode) {
if (odlNode instanceof Module) {
return ((Module) odlNode).getNamespace().toString();
} else if (odlNode instanceof DataSchemaNode) {
return null;
}
- public static List<QName> getPath(Object odlNode) {
+ public static List<QName> getPath(final Object odlNode) {
return ((DataSchemaNode) odlNode).getPath().getPath();
}
- public static String getODLTableName(Object odlNode) {
+ public static String getODLTableName(final Object odlNode) {
if (odlNode instanceof Module) {
return ((Module) odlNode).getNamespace().toString();
} else if (odlNode instanceof DataSchemaNode) {
return null;
}
- public static String getNodeNameFromDSN(Object o) {
+ public static String getNodeNameFromDSN(final Object o) {
DataSchemaNode node = (DataSchemaNode) o;
String nodeName = node.getQName().toString();
int index = nodeName.lastIndexOf(")");
return nodeName.substring(index + 1);
}
- public static boolean isModule(Object o) {
+ public static boolean isModule(final Object o) {
if (o instanceof Module) {
return true;
}
return false;
}
- public static boolean createOpenDaylightCache(XSQLBluePrint bluePrint,Object module) {
+ public static boolean createOpenDaylightCache(final XSQLBluePrint bluePrint, final Module module) {
XSQLBluePrintNode node = new XSQLBluePrintNode(module, 0,null);
bluePrint.addToBluePrintCache(node,null);
- collectODL(bluePrint, node, ((Module) module).getChildNodes(), 1);
+ collectODL(bluePrint, node, module.getChildNodes(), 1);
return true;
}
- private static void collectODL(XSQLBluePrint bluePrint,
- XSQLBluePrintNode parent, Collection<DataSchemaNode> nodes, int level) {
+ private static void collectODL(final XSQLBluePrint bluePrint,
+ final XSQLBluePrintNode parent, final Collection<DataSchemaNode> nodes, int level) {
if (nodes == null) {
return;
}
public static Map<String, Field> refFieldsCache =
new HashMap<>();
- public static Field findField(Class<?> c, String name) {
+ public static Field findField(final Class<?> c, final String name) {
if (c == null) {
return null;
}
}
- public static Object get(Object o, String name) {
+ public static Object get(final Object o, final String name) {
try {
Class<?> c = o.getClass();
Field f = findField(c, name);
return null;
}
- public static List<Object> getMChildren(Object o) {
+ public static List<Object> getMChildren(final Object o) {
Map<?, ?> children = getChildren(o);
List<Object> result = new LinkedList<>();
for (Object val : children.values()) {
- result.add((Object) val);
+ result.add(val);
}
return result;
}
- public static Map<?, ?> getChildren(Object o) {
+ public static Map<?, ?> getChildren(final Object o) {
return (Map<?, ?>) get(o, "children");
}
- public static Collection<?> getChildrenCollection(Object o) {
+ public static Collection<?> getChildrenCollection(final Object o) {
Object value = get(o, "children");
- if(value==null)
+ if(value==null) {
return Collections.emptyList();
- if(value instanceof Map)
+ }
+ if(value instanceof Map) {
return ((Map<?,?>)value).values();
- else
+ } else
if(value instanceof Collection){
return (Collection<?>)value;
}else{
}
}
- public static Object getValue(Object o) {
+ public static Object getValue(final Object o) {
return get(o, "value");
}
- public static String getNodeIdentiofier(Object o) {
+ public static String getNodeIdentiofier(final Object o) {
try{
return ((PathArgument) get(o, "nodeIdentifier")).getNodeType().toString();
}catch(Exception err){
}
}
- public static String getNodeName(Object o) {
+ public static String getNodeName(final Object o) {
Object nodeID = get(o, "nodeIdentifier");
if (nodeID != null) {
String nodeName = nodeID.toString();
return "NULL";
}
- public static Class<?> getTypeForODLColumn(Object odlNode){
+ public static Class<?> getTypeForODLColumn(final Object odlNode){
final Object o = get(odlNode,"type");
if (o instanceof TypeDefinition) {
final TypeDefinition<?> type = (TypeDefinition<?>)o;