--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
+ <fileset name="all" enabled="true" check-config-name="Sun Checks" local="false">
+ <file-match-pattern match-pattern=".*" include-pattern="true"/>
+ </fileset>
+</fileset-config>
--- /dev/null
+/target-ide
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-parent</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <artifactId>sal-dom-xsql</artifactId>
+ <packaging>bundle</packaging>
+ <name>sal-dom-xsql</name>
+ <description>XSQL language</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-binding-config</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-util</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator-plugin</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${yangtools.version}</version>
+ <type>jar</type>
+ </dependency>
+ </dependencies>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <yangFilesRootDir>src/main/yang</yangFilesRootDir>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+ <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+ <additionalConfiguration>
+ <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+ </additionalConfiguration>
+ </generator>
+ <generator>
+ <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+ <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>true</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:XSQL</url>
+ <scm>
+ <developerConnection>Sharon Aicler</developerConnection>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL:XSQL</url>
+ </scm>
+</project>
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+public class TablesResultSet implements ResultSet {
+
+ private String tables[] = null;
+ private int pos = -1;
+
+ public TablesResultSet(XSQLBluePrint cache) {
+ //tables = cache.getInterfaceNames();
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean next() throws SQLException {
+ if (tables == null) {
+ return false;
+ }
+ pos++;
+ if (pos >= tables.length) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void close() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean wasNull() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getString(int columnIndex) throws SQLException {
+ return tables[pos];
+ }
+
+ @Override
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public byte getByte(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public short getShort(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getInt(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getLong(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public float getFloat(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public double getDouble(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex, int scale)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getString(String columnLabel) throws SQLException {
+ return tables[pos];
+ }
+
+ @Override
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public byte getByte(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public short getShort(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getInt(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getLong(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public float getFloat(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public double getDouble(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel, int scale)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getUnicodeStream(String columnLabel)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getCursorName() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSetMetaData getMetaData() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int findColumn(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isAfterLast() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isFirst() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isLast() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void beforeFirst() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void afterLast() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean first() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean last() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int getRow() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean absolute(int row) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean relative(int rows) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean previous() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setFetchDirection(int direction) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getFetchDirection() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public void setFetchSize(int rows) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getFetchSize() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getType() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getConcurrency() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean rowUpdated() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean rowInserted() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean rowDeleted() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void updateNull(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBigDecimal(int columnIndex, BigDecimal x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateString(int columnIndex, String x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTimestamp(int columnIndex, Timestamp x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x, int scaleOrLength)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNull(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBoolean(String columnLabel, boolean x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBigDecimal(String columnLabel, BigDecimal x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateString(String columnLabel, String x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTimestamp(String columnLabel, Timestamp x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x,
+ int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader,
+ int length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x, int scaleOrLength)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void insertRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void refreshRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelRowUpdates() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void moveToInsertRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void moveToCurrentRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Statement getStatement() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(int columnIndex, Map<String, Class<?>> map)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Ref getRef(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Blob getBlob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Clob getClob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Array getArray(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(String columnLabel, Map<String, Class<?>> map)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Ref getRef(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Blob getBlob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Clob getClob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Array getArray(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex, Calendar cal)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel, Calendar cal)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URL getURL(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URL getURL(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public RowId getRowId(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public RowId getRowId(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void updateNString(int columnIndex, String nString)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNString(String columnLabel, String nString)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, NClob nClob)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public NClob getNClob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public NClob getNClob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getNString(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getNString(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x,
+ long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream,
+ long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
+
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+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.controller.md.sal.dom.xsql.jdbc.JDBCResultSet;
+import org.opendaylight.controller.md.sal.dom.xsql.jdbc.JDBCServer;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+
+public class XSQLAdapter extends Thread implements SchemaContextListener {
+
+ private static final int SLEEP = 10000;
+ private static XSQLAdapter a = new XSQLAdapter();
+ private static PrintStream l = null;
+ public boolean stopped = false;
+ private List<String> elementHosts = new ArrayList<String>();
+ private String username;
+ private String password;
+ private String transport = "tcp";
+ private int reconnectTimeout;
+ private int nThreads;
+ private int qsize;
+ private String applicationName = "NQL Adapter";
+ private Map<String, NEEntry> elements = new ConcurrentHashMap<String, XSQLAdapter.NEEntry>();
+ 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 String pinningFile;
+ private ServerSocket serverSocket = null;
+ private DOMDataBroker domDataBroker = null;
+
+ private XSQLAdapter() {
+ XSQLAdapter.log("Starting Adapter");
+ this.setDaemon(true);
+ try {
+ serverSocket = new ServerSocket(34343);
+ } catch (Exception err) {
+ XSQLAdapter.log(err);
+ }
+ this.start();
+ XSQLAdapter.log("Adapter Started!");
+
+ }
+
+ public static XSQLAdapter getInstance() {
+ return a;
+ }
+
+ public static void main(String args[]) {
+ XSQLAdapter adapter = new XSQLAdapter();
+ adapter.start();
+ }
+
+ public static void log(String str) {
+ try {
+ if (l == null) {
+ synchronized (XSQLAdapter.class) {
+ if (l == null) {
+ l = new PrintStream(
+ new FileOutputStream("/tmp/xql.log"));
+ }
+ }
+ }
+ l.print(Calendar.getInstance().getTime());
+ l.print(" - ");
+ l.println(str);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public static void log(Exception e) {
+ try {
+ if (l == null) {
+ synchronized (XSQLAdapter.class) {
+ if (l == null) {
+ l = new PrintStream(
+ new FileOutputStream("/tmp/xql.log"));
+ }
+ }
+ }
+ l.print(Calendar.getInstance().getTime());
+ l.print(" - ");
+ e.printStackTrace(l);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ @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 void setDataBroker(DOMDataBroker ddb) {
+ this.domDataBroker = ddb;
+ }
+
+ public XSQLBluePrint getBluePrint() {
+ return this.bluePrint;
+ }
+
+ public List<Object> collectModuleRoots(XSQLBluePrintNode table) {
+ if (table.getParent().isModule()) {
+ try {
+ List<Object> result = new LinkedList<Object>();
+ InstanceIdentifier instanceIdentifier =
+ InstanceIdentifier.builder()
+ .node(XSQLODLUtils.getPath(table.getODLNode()).get(0))
+ .toInstance();
+ DOMDataReadTransaction t = this.domDataBroker.newReadOnlyTransaction();
+ Object node =
+ t.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier)
+ .get();
+ node = XSQLODLUtils.get(node, "reference");
+ if (node == null) {
+ return result;
+ }
+
+ //XSQLAdapter.log(""+node);
+ Map<?, ?> children = XSQLODLUtils.getChildren(node);
+ for (Object c : children.values()) {
+ Map<?, ?> sons = XSQLODLUtils.getChildren(c);
+ for (Object child : sons.values()) {
+ result.add(child);
+ }
+ }
+
+ return result;
+ } catch (Exception err) {
+ XSQLAdapter.log(err);
+ }
+ } else {
+ return collectModuleRoots(table.getParent());
+ }
+ return null;
+ }
+
+ public void execute(JDBCResultSet rs) {
+ List<XSQLBluePrintNode> tables = rs.getTables();
+ List<Object> roots = collectModuleRoots(tables.get(0));
+ XSQLBluePrintNode main = rs.getMainTable();
+ List<NETask> tasks = new LinkedList<XSQLAdapter.NETask>();
+
+ for (Object entry : roots) {
+ NETask task = new NETask(rs, entry, main,bluePrint);
+ rs.numberOfTasks++;
+ tasks.add(task);
+ }
+ for (NETask task : tasks) {
+ threadPool.addTask(task);
+ }
+ }
+
+ public void run() {
+ while (!stopped) {
+ try {
+ Socket s = serverSocket.accept();
+ new TelnetConnection(s);
+ } catch (Exception err) {
+ err.printStackTrace();
+ try {
+ Thread.sleep(20000);
+ } catch (Exception err2) {
+ }
+ stopped = true;
+ }
+ }
+ }
+
+ public void addRootElement(Object o) {
+ NEEntry entry = new NEEntry(o);
+ elements.put(o.toString(), entry);
+
+ }
+
+ protected void processCommand(StringBuffer inputString, PrintStream sout,
+ TelnetConnection tc) {
+ if (inputString.toString().trim().equals("r")) {
+ sout.println(lastInputString);
+ inputString = lastInputString;
+ }
+ lastInputString = inputString;
+ String input = inputString.toString().trim();
+ if (input.startsWith("setExcel")) {
+ String substr = input.substring("setExcel".length()).trim();
+ if (!substr.equals("")) {
+ //excelPath01 = substr;
+ }
+ //sout.println("Excel Path="+excelPath01);
+ } else if (input.startsWith("list vrel")) {
+ String substr = input.substring("list vrel".length()).trim();
+ XSQLBluePrintNode node = bluePrint.getBluePrintNodeByTableName(substr);
+ if (node == null) {
+ sout.println("Unknown Interface " + substr);
+ return;
+ }
+ List<String> fld = new ArrayList<String>();
+ for (XSQLBluePrintRelation r : node.getRelations()) {
+ fld.add(r.toString());
+ }
+ String p[] = (String[]) fld.toArray(new String[fld.size()]);
+ Arrays.sort(p);
+ for (int i = 0; i < p.length; i++) {
+ sout.println(p[i]);
+ }
+ } else if (input.startsWith("list vfields")) {
+ String substr = input.substring("list vfields".length()).trim();
+ XSQLBluePrintNode node = bluePrint.getBluePrintNodeByTableName(substr);
+ if (node == null) {
+ sout.println("Unknown Interface " + substr);
+ return;
+ }
+ List<String> fld = new ArrayList<String>();
+ for (XSQLColumn c : node.getColumns()) {
+ fld.add(c.getName());
+ }
+ String p[] = (String[]) fld.toArray(new String[fld.size()]);
+ Arrays.sort(p);
+ for (int i = 0; i < p.length; i++) {
+ sout.println(p[i]);
+ }
+ } else if (input.startsWith("jdbc")) {
+ String addr = input.substring(5).trim();
+ jdbcServer.connectToClient(addr);
+ sout.println("Connected To " + addr);
+ } else if (input.startsWith("fetch")) {
+ //fetchSize = Integer.parseInt(input.substring(6).trim());
+ } else if (input.startsWith("list vtables")) {
+
+ String iNames[] =
+ bluePrint.getAllTableNames().toArray(new String[0]);
+ Arrays.sort(iNames);
+ sout.println();
+ for (int i = 0; i < iNames.length; i++) {
+ sout.println(iNames[i]);
+ }
+ } else if (input.startsWith("cd sid")) {
+ String substr = input.substring("cd sid".length()).trim();
+ for (NEEntry e : elements.values()) {
+ if (((Module) e.ne).getName().equals(substr)) {
+ tc.currentModule = (Module) e.ne;
+ }
+ }
+ } else if (input.equals("list sid")) {
+ String arr[] = new String[elements.size()];
+
+ int i = 0;
+ for (NEEntry entry : elements.values()) {
+ arr[i] = entry.toString();
+ i++;
+ }
+ Arrays.sort(arr);
+ for (String s : arr) {
+ sout.println(s);
+ }
+ } else if (input.equals("help") || input.equals("?")) {
+ //sout.println(getLongDescription());
+ } else if (input.equals("avmdata")) {
+ try {
+ //myConnection.getManagedData();
+ } catch (Exception err) {
+ }
+ } else if (input.equals("innerjoin")) {
+ //innerJoin = !innerJoin;
+ //sout.println("Inner Join set to "+innerJoin);
+ } else if (input.equals("exit")) {
+ try {
+ sout.close();
+ } catch (Exception err) {
+ }
+ } else if (input.equals("tocsv")) {
+ toCsv = !toCsv;
+ sout.println("to csv file is " + toCsv);
+ } else if (input.indexOf("filename") != -1) {
+ exportToFileName = input.substring(input.indexOf(" ")).trim();
+ sout.println("Exporting to file:" + exportToFileName);
+ } else if (!input.equals("")) {
+ if (toCsv) {
+ if (exportToFileName != null) {
+ try {
+ PrintStream o =
+ new PrintStream(new File(exportToFileName));
+ executeSql(inputString.toString(), o);
+ o.close();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ } else {
+ try {
+ String fName =
+ "export-" + System.currentTimeMillis() + ".csv";
+ PrintStream o = new PrintStream(new File(fName));
+ executeSql(inputString.toString(), o);
+ o.close();
+ sout.println("Exported to file " + fName);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+
+ }
+ } else {
+ executeSql(inputString.toString(), sout);
+ }
+ }
+ sout.println();
+ }
+
+ public void executeSql(String sql, PrintStream out) {
+ JDBCResultSet rs = new JDBCResultSet(sql);
+ try {
+ int count = 0;
+ jdbcServer.execute(rs, this);
+ boolean isFirst = true;
+ int loc = rs.getFields().size() - 1;
+ int totalWidth = 0;
+ for (XSQLColumn c : rs.getFields()) {
+ if (isFirst) {
+ isFirst = false;
+ if (toCsv) {
+ out.print("\"");
+ }
+ }
+
+ if (!toCsv) {
+ out.print("|");
+ }
+
+ out.print(c.getName());
+
+ if (!toCsv) {
+ int cw = c.getCharWidth();
+ int cnw = c.getName().length();
+ if (cnw > cw) {
+ c.setCharWidth(cnw);
+ }
+ int gap = cw - cnw;
+ for (int i = 0; i < gap; i++) {
+ out.print(" ");
+ }
+ }
+
+ totalWidth += c.getCharWidth() + 1;
+
+ if (loc > 0) {
+ if (toCsv) {
+ out.print("\",\"");
+ }
+ }
+ loc--;
+ }
+
+ if (toCsv) {
+ out.println("\"");
+ } else {
+ totalWidth++;
+ out.println("|");
+ for (int i = 0; i < totalWidth; i++) {
+ out.print("-");
+ }
+ out.println();
+ }
+
+ while (rs.next()) {
+ isFirst = true;
+ loc = rs.getFields().size() - 1;
+ for (XSQLColumn c : rs.getFields()) {
+ if (isFirst) {
+ isFirst = false;
+ if (toCsv) {
+ out.print("\"");
+ }
+ }
+
+
+ if (!toCsv) {
+ out.print("|");
+ }
+
+ Object sValue = rs.getObject(c.toString());
+ if (sValue == null) {
+ sValue = "";
+ }
+ out.print(sValue);
+
+ int cw = c.getCharWidth();
+ int vw = sValue.toString().length();
+ int gap = cw - vw;
+ for (int i = 0; i < gap; i++) {
+ out.print(" ");
+ }
+
+
+ if (loc > 0) {
+ if (toCsv) {
+ out.print("\",\"");
+ }
+ }
+ loc--;
+ }
+ if (toCsv) {
+ out.println("\"");
+ } else {
+ out.println("|");
+ }
+ count++;
+ }
+ out.println("Total Number Of Records=" + count);
+ } catch (Exception err) {
+ err.printStackTrace(out);
+ }
+ }
+
+
+ public static class NETask implements Runnable {
+
+ private JDBCResultSet rs = null;
+ private Object modelRoot = null;
+ private XSQLBluePrintNode main = null;
+ private XSQLBluePrint bluePrint = null;
+
+ public NETask(JDBCResultSet _rs, Object _modelRoot,XSQLBluePrintNode _main,XSQLBluePrint _bluePrint) {
+ this.rs = _rs;
+ this.modelRoot = _modelRoot;
+ this.main = _main;
+ this.bluePrint = _bluePrint;
+ }
+
+ public void run() {
+ rs.addRecords(modelRoot, main, true, main.getBluePrintNodeName(),bluePrint);
+ synchronized (rs) {
+ rs.numberOfTasks--;
+ if (rs.numberOfTasks == 0) {
+ rs.setFinished(true);
+ rs.notifyAll();
+ }
+ }
+ }
+ }
+
+
+ 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;
+
+ public TelnetConnection(Socket s) {
+ this.socket = s;
+ try {
+ this.in = s.getInputStream();
+ this.out = new PrintStream(s.getOutputStream());
+ this.start();
+ } catch (Exception err) {
+ XSQLAdapter.log(err);
+ }
+ }
+
+ public void run() {
+ StringBuffer inputString = new StringBuffer();
+ String prompt = "XSQL>";
+ try {
+ while (!stopped) {
+ if (currentModule != null) {
+ prompt = "XQL/" + currentModule.getName() + ">";
+ }
+ out.print(prompt);
+ char c = 0;
+ byte data[] = new byte[1];
+ while (c != '\n') {
+ try {
+ in.read(data);
+ c = (char) data[0];
+ inputString.append(c);
+ } catch (Exception err) {
+ err.printStackTrace(out);
+ }
+ }
+
+ processCommand(inputString, out, this);
+ inputString = new StringBuffer();
+ }
+ } catch (Exception err) {
+ try {
+ socket.close();
+ } catch (Exception err2) {
+ }
+ }
+ }
+ }
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Proxy;
+import java.lang.reflect.Type;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.RowIdLifetime;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class XSQLBluePrint implements DatabaseMetaData {
+
+ 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 boolean cacheLoadedSuccessfuly = false;
+ private DatabaseMetaData myProxy = null;
+
+ public static final String replaceAll(String source, String toReplace,
+ String withThis) {
+ int index = source.indexOf(toReplace);
+ int index2 = 0;
+ StringBuffer result = new StringBuffer();
+ while (index != -1) {
+ result.append(source.substring(index2, index));
+ result.append(withThis);
+ index2 = index + toReplace.length();
+ index = source.indexOf(toReplace, index2);
+ }
+ if (index2 < source.length()) {
+ result.append(source.substring(index2));
+ }
+ return result.toString();
+ }
+
+ public XSQLBluePrint() {
+ }
+
+ private class NQLBluePrintProxy implements InvocationHandler {
+ public Object invoke(Object proxy, Method method, Object[] args)
+ throws Throwable {
+ System.out.println("Method " + method);
+ return method.invoke(XSQLBluePrint.this, args);
+ }
+ }
+
+ public DatabaseMetaData getProxy() {
+ if (myProxy == null) {
+ try {
+ myProxy = (DatabaseMetaData) Proxy
+ .newProxyInstance(getClass().getClassLoader(),
+ new Class[] {DatabaseMetaData.class},
+ new NQLBluePrintProxy());
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+ return myProxy;
+ }
+
+ /*
+ public void loadBluePrintCache(String hostName) {
+ try {
+ ObjectInputStream in = new ObjectInputStream(
+ new FileInputStream(hostName + "-" + CACHE_FILE_NAME));
+ cache = (Map) in.readObject();
+ in.close();
+ cacheLoadedSuccessfuly = true;
+ } catch (Exception err) {
+ //err.printStackTrace();
+ }
+ }*/
+
+ public XSQLBluePrintNode[] getBluePrintNodeByODLTableName(String odlTableName) {
+ Map<String,XSQLBluePrintNode> map = this.odlNameToBluePrint.get(odlTableName);
+ if(map==null) return null;
+ return map.values().toArray(new XSQLBluePrintNode[map.size()]);
+ }
+
+ public XSQLBluePrintNode getBluePrintNodeByTableName(String tableName) {
+ if (tableName.indexOf(".") != -1) {
+ tableName = tableName.substring(tableName.lastIndexOf(".") + 1);
+ }
+
+ XSQLBluePrintNode node = tableNameToBluePrint.get(tableName);
+
+ if (node != null) {
+ return node;
+ }
+
+ for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
+ if (n.getBluePrintNodeName().endsWith(tableName)) {
+ return n;
+ }
+ }
+
+ for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
+ if (n.getBluePrintNodeName().toLowerCase().endsWith(tableName.toLowerCase())) {
+ return n;
+ }
+ }
+
+ for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
+ if (n.getBluePrintNodeName().toLowerCase().equals(tableName.toLowerCase())) {
+ return n;
+ }
+ }
+
+ for (XSQLBluePrintNode n : tableNameToBluePrint.values()) {
+ if (n.getBluePrintNodeName().toLowerCase().indexOf(tableName.toLowerCase())!= -1) {
+ return n;
+ }
+ }
+ return null;
+ }
+
+
+ public boolean isCacheLoaded() {
+ return cacheLoadedSuccessfuly;
+ }
+
+ private static Map<Class, Set<Class>> superClassMap = new HashMap<Class, Set<Class>>();
+
+ public static Set<Class> getInheritance(Class myObjectClass,
+ Class returnType) {
+
+ if (returnType != null && myObjectClass.equals(returnType)) {
+ return new HashSet<Class>();
+ }
+ Set<Class> result = superClassMap.get(myObjectClass);
+ if (result != null) {
+ return result;
+ }
+ result = new HashSet<Class>();
+ superClassMap.put(myObjectClass, result);
+ if (returnType != null) {
+ if (!returnType.equals(myObjectClass)) {
+ Class mySuperClass = myObjectClass.getSuperclass();
+ while (mySuperClass != null) {
+ result.add(mySuperClass);
+ mySuperClass = mySuperClass.getSuperclass();
+ }
+ result.addAll(collectInterfaces(myObjectClass));
+ }
+ }
+ return result;
+ }
+
+ public static Set<Class> collectInterfaces(Class cls) {
+ Set<Class> result = new HashSet();
+ Class myInterfaces[] = cls.getInterfaces();
+ if (myInterfaces != null) {
+ for (Class in : myInterfaces) {
+ result.add(in);
+ result.addAll(collectInterfaces(in));
+ }
+ }
+ 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);
+ }
+ map.put(blNode.getBluePrintNodeName(), blNode);
+ }
+
+ 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();
+ } else if (typeArgument instanceof Class) {
+ return (Class) typeArgument;
+ }
+ }
+ return null;
+ }
+
+ public Class getMethodReturnTypeFromGeneric(Method m) {
+ Type rType = m.getGenericReturnType();
+ if (rType instanceof ParameterizedType) {
+ return getGenericType((ParameterizedType) rType);
+ }
+ return null;
+ }
+
+ public List<String> getAllTableNames() {
+ List<String> names = new ArrayList<String>();
+ for (XSQLBluePrintNode n : this.tableNameToBluePrint.values()) {
+ if (!n.isModule() && !n.getColumns().isEmpty()) {
+ names.add(n.getBluePrintNodeName());
+ }
+ }
+ return names;
+
+ }
+
+ public List<String> getInterfaceNames(XSQLBluePrintNode node) {
+ Set<XSQLBluePrintNode> children = node.getChildren();
+ List<String> names = new ArrayList<String>();
+ for (XSQLBluePrintNode n : children) {
+ if (!n.isModule() && !n.getColumns().isEmpty()) {
+ names.add(n.toString());
+ }
+ names.addAll(getInterfaceNames(n));
+ }
+ return names;
+ }
+
+ @Override
+ public boolean allProceduresAreCallable() throws SQLException {
+ return false;
+ }
+
+ @Override
+ public boolean allTablesAreSelectable() throws SQLException {
+ return true;
+ }
+
+ @Override
+ public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean deletesAreDetected(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public ResultSet getAttributes(String catalog, String schemaPattern,
+ String typeNamePattern, 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 {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getCatalogs() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getCatalogSeparator() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getCatalogTerm() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getClientInfoProperties() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getColumnPrivileges(String catalog, String schema,
+ String table, String columnNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getColumns(String catalog, String schemaPattern,
+ String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Connection getConnection() 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 {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getDatabaseMajorVersion() throws SQLException {
+ return 0;
+ }
+
+ @Override
+ public int getDatabaseMinorVersion() throws SQLException {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+
+ @Override
+ public String getDatabaseProductName() throws SQLException {
+ return "VNE Query Language";
+ }
+
+ @Override
+ public String getDatabaseProductVersion() throws SQLException {
+ return "0.1";
+ }
+
+ @Override
+ public int getDefaultTransactionIsolation() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getDriverMajorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getDriverMinorVersion() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getDriverName() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getDriverVersion() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getExportedKeys(String catalog, String schema,
+ String table)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getExtraNameCharacters() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getFunctionColumns(String catalog, String schemaPattern,
+ String functionNamePattern, String columnNamePattern)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getFunctions(String catalog, String schemaPattern,
+ String functionNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getIdentifierQuoteString() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getImportedKeys(String catalog, String schema,
+ 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 {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getJDBCMajorVersion() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getJDBCMinorVersion() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxBinaryLiteralLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxCatalogNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxCharLiteralLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInGroupBy() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInIndex() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInOrderBy() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInSelect() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxColumnsInTable() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxConnections() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxCursorNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxIndexLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxProcedureNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxRowSize() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxSchemaNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxStatementLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxStatements() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxTableNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxTablesInSelect() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxUserNameLength() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getNumericFunctions() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getPrimaryKeys(String catalog, String schema, String table)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getProcedureColumns(String catalog, String schemaPattern,
+ String procedureNamePattern, String columnNamePattern)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getProcedures(String catalog, String schemaPattern,
+ String procedureNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getProcedureTerm() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getResultSetHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public RowIdLifetime getRowIdLifetime() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getSchemas() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getSchemas(String catalog, String schemaPattern)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getSchemaTerm() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getSearchStringEscape() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getSQLKeywords() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getSQLStateType() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getStringFunctions() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getSuperTables(String catalog, String schemaPattern,
+ String tableNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getSuperTypes(String catalog, String schemaPattern,
+ String typeNamePattern) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getSystemFunctions() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getTablePrivileges(String catalog, String schemaPattern,
+ 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 {
+ return new TablesResultSet(this);
+ }
+
+ @Override
+ public ResultSet getTableTypes() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTimeDateFunctions() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getTypeInfo() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getUDTs(String catalog, String schemaPattern,
+ String typeNamePattern, int[] types) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getURL() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getUserName() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getVersionColumns(String catalog, String schema,
+ String table) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean insertsAreDetected(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isCatalogAtStart() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean locatorsUpdateCopy() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean nullPlusNonNullIsNull() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedAtEnd() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedAtStart() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedHigh() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean nullsAreSortedLow() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean othersDeletesAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean othersInsertsAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean othersUpdatesAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean ownDeletesAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean ownInsertsAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean ownUpdatesAreVisible(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesLowerCaseIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesMixedCaseIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesUpperCaseIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsAlterTableWithAddColumn() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsAlterTableWithDropColumn() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92FullSQL() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsANSI92IntermediateSQL() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsBatchUpdates() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInDataManipulation() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInPrivilegeDefinitions()
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsColumnAliasing() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsConvert() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsConvert(int fromType, int toType)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCoreSQLGrammar() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsDataDefinitionAndDataManipulationTransactions()
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsDataManipulationTransactionsOnly()
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsDifferentTableCorrelationNames()
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsExpressionsInOrderBy() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsExtendedSQLGrammar() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsGetGeneratedKeys() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupBy() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupByBeyondSelect() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupByUnrelated() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsLikeEscapeClause() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsLimitedOuterJoins() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMinimumSQLGrammar() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMixedCaseIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleOpenResults() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleResultSets() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsMultipleTransactions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsNamedParameters() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsNonNullableColumns() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsPositionedDelete() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsPositionedUpdate() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsResultSetConcurrency(int type, int concurrency)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsResultSetHoldability(int holdability)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsResultSetType(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSavepoints() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInDataManipulation() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInProcedureCalls() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSchemasInTableDefinitions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelectForUpdate() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsStatementPooling() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsStoredFunctionsUsingCallSyntax()
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsStoredProcedures() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInComparisons() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInExists() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInIns() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsTableCorrelationNames() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsTransactionIsolationLevel(int level)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsTransactions() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnion() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnionAll() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean updatesAreDetected(int type) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean usesLocalFilePerTable() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean usesLocalFiles() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResultSet getPseudoColumns(String catalog, String schemaPattern,
+ String tableNamePattern, String columnNamePattern)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean generatedKeyAlwaysReturned() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.Serializable;
+import java.sql.SQLException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+public class XSQLBluePrintNode implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ private Class<?> myInterface = null;
+ private String myInterfaceString = null;
+ private Set<XSQLBluePrintRelation> relations =
+ new HashSet<XSQLBluePrintRelation>();
+ private Set<XSQLBluePrintNode> inheritingNodes =
+ new HashSet<XSQLBluePrintNode>();
+ private Set<XSQLBluePrintNode> children = new HashSet<XSQLBluePrintNode>();
+ private XSQLBluePrintNode parent = null;
+
+ private int level = -1;
+ private transient Set<String> parentHierarchySet = null;
+ private String myInterfaceName = null;
+ private Set<XSQLColumn> columns = new HashSet<XSQLColumn>();
+
+ private transient Object odlNode = null;
+ private boolean module = false;
+ private String bluePrintTableName = null;
+ private String odlTableName = null;
+
+ public XSQLBluePrintNode(Class<?> _myInterface, int _level) {
+ this.myInterface = _myInterface;
+ this.myInterfaceString = _myInterface.getName();
+ this.myInterfaceName = myInterface.getSimpleName();
+ this.level = _level;
+ }
+
+ public XSQLBluePrintNode(Object _odlNode, int _level,XSQLBluePrintNode _parent) {
+ this.odlNode = _odlNode;
+ this.level = _level;
+ this.module = XSQLODLUtils.isModule(_odlNode);
+ this.parent = _parent;
+ this.bluePrintTableName = XSQLODLUtils.getBluePrintName(_odlNode);
+
+ }
+
+ public String getBluePrintNodeName(){
+ return this.bluePrintTableName;
+ }
+
+ public boolean isModule() {
+ return this.module;
+ }
+
+ public Set<XSQLBluePrintNode> getChildren() {
+ return this.children;
+ }
+
+ public String getODLTableName() {
+ if (this.odlTableName == null) {
+ this.odlTableName = XSQLODLUtils.getODLNodeName(this.odlNode);
+ }
+ return this.odlTableName;
+ }
+
+ public Object getODLNode() {
+ return this.odlNode;
+ }
+
+ public void AddChild(XSQLBluePrintNode ch) {
+ this.children.add(ch);
+ }
+
+ public boolean isModelChild(Class p) {
+ if (this.relations.size() == 0) {
+ return false;
+ }
+ for (XSQLBluePrintRelation parentRelation : this.relations) {
+ if (parentRelation.getParent().getInterface().equals(p)) {
+ return true;
+ }
+ }
+ for (XSQLBluePrintRelation dtr : this.relations) {
+ XSQLBluePrintNode parent = dtr.getParent();
+ if (!parent.getInterface().equals(this.getInterface()) && !parent
+ .getInterface().isAssignableFrom(this.getInterface()) &&
+ this.getInterface().isAssignableFrom(parent.getInterface())
+ && parent.isModelChild(p)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public Set<XSQLBluePrintRelation> getRelations() {
+ return this.relations;
+ }
+
+ public String getClassName() {
+ return this.myInterfaceString;
+ }
+
+ public void addInheritingNode(XSQLBluePrintNode node) {
+ this.inheritingNodes.add(node);
+ }
+
+ public Set<XSQLBluePrintNode> getInheritingNodes() {
+ return this.inheritingNodes;
+ }
+
+ public void addColumn(Object node, String tableName) {
+ XSQLColumn c = new XSQLColumn(node,getBluePrintNodeName(), this);
+ this.columns.add(c);
+ }
+
+ public void addColumn(String methodName) {
+ if (methodName.startsWith("get")) {
+ methodName = methodName.substring(3);
+ } else if (methodName.startsWith("is")) {
+ methodName = methodName.substring(2);
+ }
+ XSQLColumn c = new XSQLColumn(methodName, myInterfaceName, null);
+ this.columns.add(c);
+ }
+
+ public Collection<XSQLColumn> getColumns() {
+ return this.columns;
+ }
+
+ public XSQLColumn findColumnByName(String name) throws SQLException {
+
+ XSQLColumn exactMatch = null;
+ XSQLColumn indexOfMatch = null;
+ XSQLColumn exactLowercaseMatch = null;
+ XSQLColumn indexOfLowerCaseMatch = null;
+
+ for (XSQLColumn col : columns) {
+ if (col.getName().equals(name)) {
+ exactMatch = col;
+ }
+ if (col.getName().indexOf(name) != -1) {
+ indexOfMatch = col;
+ }
+ if (col.getName().toLowerCase().equals(name.toLowerCase())) {
+ exactLowercaseMatch = col;
+ }
+ if (col.getName().toLowerCase().indexOf(name.toLowerCase()) != -1) {
+ indexOfLowerCaseMatch = col;
+ }
+ }
+
+ if (exactMatch != null) {
+ return exactMatch;
+ }
+ if (exactLowercaseMatch != null) {
+ return exactLowercaseMatch;
+ }
+ if (indexOfMatch != null) {
+ return indexOfMatch;
+ }
+ if (indexOfLowerCaseMatch != null) {
+ return indexOfLowerCaseMatch;
+ }
+
+ throw new SQLException("Unknown field name '" + name + "'");
+ }
+
+
+ public void addParent(XSQLBluePrintNode parent, String property) {
+ try {
+ if (property.equals("ContainingTPs")) {
+ return;
+ }
+ //Method m = parent.getInterface().getMethod("get"+property, null);
+ //if(!m.getDeclaringClass().equals(parent.getInterface()))
+ //return;
+ XSQLBluePrintRelation rel =
+ new XSQLBluePrintRelation(parent, property, myInterface);
+ relations.add(rel);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public XSQLBluePrintNode getParent() {
+ return this.parent;
+ }
+
+ public Set<XSQLBluePrintRelation> getClonedParents() {
+ Set<XSQLBluePrintRelation> result =
+ new HashSet<XSQLBluePrintRelation>();
+ result.addAll(this.relations);
+ return result;
+ }
+
+ public String toString() {
+ if (myInterfaceName != null) {
+ return myInterfaceName;
+ }
+ if (odlNode != null) {
+ return getBluePrintNodeName();
+ }
+ return "Unknown";
+ }
+
+ public Class getInterface() {
+ return this.myInterface;
+ }
+
+ public int getLevel() {
+ return this.level;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ XSQLBluePrintNode other = (XSQLBluePrintNode) obj;
+ if (odlNode != null) {
+ return getBluePrintNodeName().equals(other.getBluePrintNodeName());
+ } else if (this.odlTableName != null) {
+ return this.odlTableName.equals(other.odlTableName);
+ } else {
+ return other.myInterface.equals(myInterface);
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ if (myInterfaceString != null) {
+ return myInterfaceString.hashCode();
+ } else if (odlNode != null) {
+ return bluePrintTableName.hashCode();
+ }
+ return 0;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class XSQLBluePrintRelation implements Serializable {
+ private static final long serialVersionUID = 2L;
+ private XSQLBluePrintNode parent = null;
+ private String property = null;
+ private Class<?> childClass = null;
+
+ public XSQLBluePrintRelation(XSQLBluePrintNode _parent, String _property,
+ Class<?> _childClass) {
+ this.parent = _parent;
+ this.property = _property;
+ this.childClass = _childClass;
+ }
+
+ public Class<?> getNEClosestClass() {
+ Class<?> p = parent.getInterface();
+ return getNEClosestClass(p);
+ }
+
+
+ public static Class<?> getNEClosestClass(Class<?> p) {
+ while (!p.getInterfaces()[0]
+ .equals(Object.class/*XSQLBluePrint.STOP_INTERFACE*/)) {
+ p = p.getInterfaces()[0];
+ }
+ return p;
+ }
+
+ public XSQLBluePrintNode getParent() {
+ return parent;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ public Class<?> getChildClass() {
+ return this.childClass;
+ }
+
+ public boolean equals(Object obj) {
+ XSQLBluePrintRelation other = (XSQLBluePrintRelation) obj;
+ if (other.parent != null && this.parent == null) {
+ return false;
+ }
+ if (other.parent == null && this.parent != null) {
+ return false;
+ }
+
+ if (other.parent == null && this.parent == null) {
+ return property.equals(other.property);
+ }
+
+ if (other.parent.toString().equals(this.parent.toString())) {
+ return property.equals(other.property);
+ }
+
+ return false;
+ }
+
+ public int hashCode() {
+ if (parent != null) {
+ return parent.toString().hashCode() + property.hashCode();
+ }
+ return property.hashCode();
+ }
+
+ public String toString() {
+ if (parent != null) {
+ return parent.toString() + ":" + property;
+ } else {
+ return property;
+ }
+ }
+
+ public List execute(Object o) {
+ List result = new LinkedList();
+ if (o == null) {
+ return null;
+ }
+
+ if (Set.class.isAssignableFrom(o.getClass())) {
+ Set lst = (Set) o;
+ for (Object oo : lst) {
+ addToResult(result, execute(oo));
+ }
+ return result;
+ } else if (List.class.isAssignableFrom(o.getClass())) {
+ List lst = (List) o;
+ for (Object oo : lst) {
+ addToResult(result, execute(oo));
+ }
+ return result;
+ } else if (Map.class.isAssignableFrom(o.getClass())) {
+ Map map = (Map) o;
+ for (Object oo : map.values()) {
+ addToResult(result, execute(oo));
+ }
+ return result;
+ }
+
+ addToResult(result, XSQLCriteria.getValue(o, this.property));
+
+ return result;
+ }
+
+ public static void addToResult(List result, Object o) {
+ if (o == null) {
+ return;
+ }
+ if (Set.class.isAssignableFrom(o.getClass())) {
+ Set lst = (Set) o;
+ for (Object oo : lst) {
+ result.add(oo);
+ }
+ } else if (List.class.isAssignableFrom(o.getClass())) {
+ List lst = (List) o;
+ for (Object oo : lst) {
+ result.add(oo);
+ }
+ } else if (Map.class.isAssignableFrom(o.getClass())) {
+ Map map = (Map) o;
+ for (Object oo : map.values()) {
+ result.add(oo);
+ }
+ } else {
+ result.add(o);
+ }
+ }
+
+}
+
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.Serializable;
+
+public class XSQLColumn implements Serializable, Comparable {
+ private String name = null;
+ private String tableName = null;
+ private int charWidth = -1;
+ private Class type = null;
+ private transient Object bluePrintNode = null;
+
+ public XSQLColumn(Object odlNode, String _tableName, Object _bluePrintNode) {
+ this.name = XSQLODLUtils.getNodeNameFromDSN(odlNode);
+ this.tableName = _tableName;
+ this.bluePrintNode = _bluePrintNode;
+ this.type = XSQLODLUtils.getTypeForODLColumn(odlNode);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setCharWidth(int i) {
+ if (this.charWidth < i) {
+ this.charWidth = i;
+ }
+ }
+
+ public int getCharWidth() {
+ return this.charWidth;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.name.hashCode() + this.tableName.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof XSQLColumn)) {
+ return false;
+ }
+ XSQLColumn other = (XSQLColumn) obj;
+ return tableName.equals(other.tableName) && name.equals(other.name);
+ }
+
+ public Object getBluePrintNode() {
+ return this.bluePrintNode;
+ }
+
+ @Override
+ public String toString() {
+ return tableName + "." + name;
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ return this.toString().compareTo(o.toString());
+ }
+
+ public Object getResultSetValue(Object obj){
+ if(this.type.equals(String.class)){
+ return obj.toString();
+ }else
+ if(this.type.equals(int.class)){
+ return Integer.parseInt(obj.toString());
+ }else
+ if(this.type.equals(long.class)){
+ return Long.parseLong(obj.toString());
+ }else
+ if(this.type.equals(byte.class)){
+ return Byte.parseByte(obj.toString());
+ }
+ return null;
+ }
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class XSQLCriteria implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private static final String operators[] =
+ new String[] {" and ", " or ", ">=", "<=", "!=", "=", ">", "<", "like",
+ "is null", "not null", "skip"};
+ private static final String STRING_CHAR = "'";
+
+ public static final int OP_CODE_AND = 0;
+ public static final int OP_CODE_OR = 1;
+ public static final int OP_CODE_GTEQ = 2;
+ public static final int OP_CODE_LTEQ = 3;
+ public static final int OP_CODE_NOT_EQ = 4;
+ public static final int OP_CODE_EQUAL = 5;
+ public static final int OP_CODE_GT = 6;
+ public static final int OP_CODE_LT = 7;
+ public static final int OP_CODE_LIKE = 8;
+ public static final int OP_CODE_NULL = 9;
+ public static final int OP_CODE_NOT_NULL = 10;
+ public static final int OP_CODE_SKIP = 11;
+
+ private XSQLCriteria left = null;
+ private XSQLCriteria right = null;
+
+ private int operation = -1;
+
+ private Object leftValue = null;
+ private Object rightValue = null;
+ private String criteria = null;
+
+ private static final Map<Class<?>, Map<String, Method>> methodCache =
+ new ConcurrentHashMap<Class<?>, Map<String, Method>>();
+
+ public XSQLCriteria(final String data, final int parentOperation) {
+ criteria = data;
+ parse(data, parentOperation);
+ }
+
+ private void parse(String data, int parentOperation) {
+
+ data = data.trim();
+
+ int index1 = data.indexOf("(");
+ if (index1 != -1) {
+ String leftCondition = data.substring(0, index1).trim();
+ if (leftCondition.trim().equals("")) {
+ int index2 = data.lastIndexOf(")");
+ if (index2 < data.length() - 1) {
+ String rtValue = data.substring(index2 + 1).trim();
+ if (!rtValue.equals("")) {
+ left =
+ new XSQLCriteria(data.substring(index1 + 1, index2),
+ parentOperation);
+ data = data.substring(index2 + 1);
+ } else {
+ data = data.substring(1, index2);
+ }
+ } else {
+ data = data.substring(1, index2);
+ }
+ } else {
+ right = new XSQLCriteria(
+ data.substring(index1 + 1, data.length() - 1),
+ parentOperation);
+ data = data.substring(0, index1);
+ }
+ }
+
+ for (int i = 0; i < operators.length; i++) {
+ index1 = data.indexOf(operators[i]);
+ if (index1 != -1) {
+ this.operation = i;
+ if (left == null) {
+ left = new XSQLCriteria(data.substring(0, index1),
+ this.operation);
+ }
+ if (left.leftValue != null && left.rightValue == null
+ && left.right == null) {
+ leftValue = left.leftValue;
+ left = null;
+ }
+ if (right == null) {
+ right = new XSQLCriteria(
+ data.substring(index1 + operators[i].length()),
+ this.operation);
+ }
+ if (right.leftValue != null && right.rightValue == null
+ && right.right == null) {
+ rightValue = right.leftValue;
+ right = null;
+ }
+ return;
+ }
+ }
+
+ if (data.startsWith("'") && data.endsWith("'")) {
+ data = data.substring(1, data.length() - 1);
+ }
+
+ if (parentOperation == OP_CODE_LIKE && data.startsWith("%") && data.endsWith("%")
+ && data.substring(1, data.length() - 1).indexOf("%") == -1) {
+ data = data.substring(1, data.length() - 1);
+ }
+
+ leftValue = data;
+ }
+
+ public static Object getValue(Object element, String propertyName) {
+ try {
+ Map<String, Method> cache = methodCache.get(element.getClass());
+ if (cache == null) {
+ cache = new ConcurrentHashMap<String, Method>();
+ methodCache.put(element.getClass(), cache);
+ }
+
+ Method m = cache.get(propertyName);
+ if (m == null) {
+ Method methods[] = element.getClass().getMethods();
+ for (Method mm : methods) {
+ if (mm.getName().equals(propertyName) || mm.getName()
+ .equals("get" + propertyName) || mm.getName()
+ .equals("is" + propertyName)) {
+ m = mm;
+ m.setAccessible(true);
+ cache.put(propertyName, m);
+ break;
+ }
+ }
+ }
+
+ Object value = null;
+ if (m == null) {
+ return null;
+ }
+ if (m.getParameterTypes() == null
+ || m.getParameterTypes().length == 0) {
+ value = m.invoke(element, null);
+ } else {
+ if (String.class.isAssignableFrom(m.getParameterTypes()[0])) {
+ return null;
+ }
+ Object arg = m.getParameterTypes()[0].newInstance();
+ value = m.invoke(element, arg);
+ }
+ return value;
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ return null;
+ }
+
+ public int isObjectFitCriteria(Object element, String propertyName) {
+ Object value = getValue(element, propertyName);
+ if (value != null) {
+ value = value.toString();
+ }
+ return checkValue(value);
+ }
+
+ public int checkValue(Object value) {
+ if (leftValue != null && rightValue != null) {
+ Object aSide = null;
+ Object bSide = null;
+ if (leftValue.equals("?")) {
+ aSide = value;
+ } else {
+ aSide = leftValue;
+ }
+
+ if (rightValue.equals("?")) {
+ bSide = value;
+ } else {
+ bSide = rightValue;
+ }
+ if (operation != OP_CODE_SKIP && operation != OP_CODE_NULL) {
+ if (aSide == null && bSide != null) {
+ return 0;
+ } else if (aSide != null && bSide == null) {
+ return 0;
+ } else if (aSide == null && bSide == null) {
+ return 1;
+ }
+ }
+ switch (operation) {
+ case OP_CODE_EQUAL:
+ if (aSide.equals(bSide)) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_NOT_EQ:
+ if (!aSide.equals(bSide)) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_LIKE:
+ if (aSide.toString().indexOf(bSide.toString()) != -1) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_NULL:
+ if (aSide == null) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_NOT_NULL:
+ if (aSide != null) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_GT:
+ if (aSide == null || bSide == null) {
+ return 0;
+ }
+ if (Double.parseDouble(aSide.toString().trim()) > Double
+ .parseDouble(bSide.toString().trim())) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_GTEQ:
+ if (aSide == null || bSide == null) {
+ return 0;
+ }
+ if (Double.parseDouble(aSide.toString().trim()) >= Double
+ .parseDouble(bSide.toString().trim())) {
+ return 1;
+ } else {
+ return 0;
+ }
+
+ case OP_CODE_LT:
+ if (aSide == null || bSide == null) {
+ return 0;
+ }
+ if (Double.parseDouble(aSide.toString().trim()) < Double
+ .parseDouble(bSide.toString().trim())) {
+ return 1;
+ } else {
+ return 0;
+ }
+ case OP_CODE_LTEQ:
+ if (aSide == null || bSide == null) {
+ return 0;
+ }
+ if (Double.parseDouble(aSide.toString().trim()) <= Double
+ .parseDouble(bSide.toString().trim())) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ int leftResult = 0;
+ if (left != null) {
+ leftResult = left.checkValue(value);
+ }
+
+ int rightResult = 0;
+ if (right != null) {
+ rightResult = right.checkValue(value);
+ }
+
+ if (operation == OP_CODE_SKIP) {
+ if (rightResult == 0) {
+ return 2;
+ } else {
+ return 3;
+ }
+ }
+
+ if (operation == OP_CODE_AND) {
+ if (leftResult == 0) {
+ return 0;
+ }
+ if (rightResult == 0) {
+ return 0;
+ }
+ if (leftResult >= 2) {
+ return leftResult;
+ }
+ if (rightResult >= 2) {
+ return rightResult;
+ }
+
+ return 1;
+ }
+
+ if (operation == OP_CODE_OR) {
+ if (leftResult == 0 && rightResult == 0) {
+ return 0;
+ }
+ if (leftResult >= 2) {
+ return leftResult;
+ }
+ if (rightResult >= 2) {
+ return rightResult;
+ }
+ return 1;
+ }
+
+ return 0;
+ }
+
+ public String toString() {
+ return criteria;
+ }
+
+ public String getCriteriaForProperty(XSQLColumn col) {
+ StringBuffer result = new StringBuffer();
+ if (criteria == null) {
+ return "";
+ }
+
+ if (leftValue != null && rightValue != null) {
+ if (leftValue.toString().toLowerCase().equals(col.getName().toLowerCase()) ||
+ leftValue.toString().toLowerCase().equals(col.toString().toLowerCase()) /*||
+ /*col.getName().toLowerCase().indexOf(leftValue.toString().toLowerCase()) != -1*/) {
+ result.append("? ").append(operators[operation]).append(" ").append(rightValue);
+ }else
+ if (rightValue.toString().toLowerCase().equals(col.getName().toLowerCase()) ||
+ rightValue.toString().toLowerCase().equals(col.toString().toLowerCase()) /*||
+ col.getName().toLowerCase().indexOf(rightValue.toString().toLowerCase()) != -1*/) {
+ result.append("? ").append(operators[operation]).append(" ").append(leftValue);
+ }
+ return result.toString();
+ } else if (left != null && right != null) {
+ String leftString = left.getCriteriaForProperty(col);
+ String rightString = right.getCriteriaForProperty(col);
+ if (!leftString.equals("") && !rightString.equals("")) {
+ return leftString + " " + operators[operation] + " "
+ + rightString;
+ } else if (!leftString.equals("")) {
+ return leftString;
+ } else if (!rightString.equals("")) {
+ return rightString;
+ }
+ return "";
+ } else if (leftValue != null && leftValue.toString().toLowerCase()
+ .equals(col.toString().toLowerCase()) && right != null) {
+ return "? " + operators[operation] + " (" + right
+ .getCriteriaForProperty(col) + ")";
+ } else if (rightValue != null && rightValue.toString().toLowerCase()
+ .equals(col.toString().toLowerCase()) && left != null) {
+ return "(" + left.getCriteriaForProperty(col) + ") "
+ + operators[operation] + " ?";
+ }
+ return "";
+ }
+
+ public static void main(String args[]) {
+ XSQLCriteria p =
+ new XSQLCriteria("ip like '%101%' or (354>=0 or 456>=3)", -1);
+ System.out.println(p.checkValue("192.268.4.4"));
+ p = new XSQLCriteria("? like '%267%'", -1);
+ System.out.println(p.checkValue("192.268.4.4"));
+
+ }
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.lang.reflect.Field;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+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.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.util.Uint16;
+import org.opendaylight.yangtools.yang.model.util.Uint32;
+import org.opendaylight.yangtools.yang.model.util.Uint64;
+import org.opendaylight.yangtools.yang.model.util.Uint8;
+
+public class XSQLODLUtils {
+
+ private static Map<Class<?>, Class<?>> types =
+ new ConcurrentHashMap<Class<?>, Class<?>>();
+
+ static {
+ types.put(QName.class, QName.class);
+ types.put(SchemaPath.class, SchemaPath.class);
+ types.put(Status.class, Status.class);
+ }
+
+ public static boolean isColumnType(Class cls) {
+ return types.containsKey(cls);
+ }
+
+ public static String getTableName(Object odlNode) {
+ if (odlNode instanceof Module) {
+ return ((Module) odlNode).getNamespace().toString();
+ } else if (odlNode instanceof DataSchemaNode) {
+ SchemaPath p = ((DataSchemaNode) odlNode).getPath();
+ return extractTableName(p);
+ } else {
+ int i = 0;
+ }
+ return null;
+ }
+
+ public static String extractTableName(SchemaPath path) {
+ List<QName> lst = path.getPath();
+ StringBuffer name = new StringBuffer();
+ int i = 0;
+ for (QName q : lst) {
+ name.append(q.getLocalName());
+ i++;
+ if (i < lst.size()) {
+ name.append("/");
+ }
+ }
+ return name.toString();
+ }
+
+ public static String getBluePrintName(Object odlNode){
+ if (odlNode instanceof Module) {
+ return ((Module) odlNode).getNamespace().toString();
+ } else if (odlNode instanceof DataSchemaNode) {
+ SchemaPath p = ((DataSchemaNode) odlNode).getPath();
+ return extractTableName(p);
+ }
+ return null;
+ }
+
+ public static String getODLNodeName(Object odlNode) {
+ if (odlNode instanceof Module) {
+ return ((Module) odlNode).getNamespace().toString();
+ } else if (odlNode instanceof DataSchemaNode) {
+ SchemaPath p = ((DataSchemaNode) odlNode).getPath();
+ List<QName> lst = p.getPath();
+ return lst.get(lst.size() - 1).toString();
+ }
+ return null;
+ }
+
+ public static List<QName> getPath(Object odlNode) {
+ return ((DataSchemaNode) odlNode).getPath().getPath();
+ }
+
+
+ public static String getODLTableName(Object odlNode) {
+ if (odlNode instanceof Module) {
+ return ((Module) odlNode).getNamespace().toString();
+ } else if (odlNode instanceof DataSchemaNode) {
+ return ((DataSchemaNode) odlNode).getPath().toString();
+ }
+ return null;
+ }
+
+ public static String getNodeNameFromDSN(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) {
+ if (o instanceof Module) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean createOpenDaylightCache(XSQLBluePrint bluePrint,Object module) {
+ XSQLBluePrintNode node = new XSQLBluePrintNode(module, 0,null);
+ bluePrint.addToBluePrintCache(node);
+ collectODL(bluePrint, node, ((Module) module).getChildNodes(), 1);
+ return true;
+ }
+
+ private static void collectODL(XSQLBluePrint bluePrint,
+ XSQLBluePrintNode parent, Set<DataSchemaNode> nodes, int level) {
+ if (nodes == null) {
+ return;
+ }
+ for (DataSchemaNode n : nodes) {
+ if (n instanceof DataNodeContainer /*|| n instanceof LeafListSchemaNode*/
+ || n instanceof ListSchemaNode) {
+ XSQLBluePrintNode bn = new XSQLBluePrintNode(n, level,parent);
+ bluePrint.addToBluePrintCache(bn);
+ parent.AddChild(bn);
+ if (n instanceof DataNodeContainer) {
+ level++;
+ collectODL(bluePrint, bn,
+ ((DataNodeContainer) n).getChildNodes(), level);
+ level--;
+ } else if (n instanceof ListSchemaNode) {
+ level++;
+ collectODL(bluePrint, bn,
+ ((ListSchemaNode) n).getChildNodes(), level);
+ level--;
+ }
+ } else {
+ if (parent != null) {
+ parent.addColumn(n, parent.getParent().getBluePrintNodeName());
+ } else {
+ XSQLAdapter.log("NO Parent!");
+ }
+ }
+ }
+ }
+
+ public static Map<String, Field> refFieldsCache =
+ new HashMap<String, Field>();
+
+ public static Field findField(Class<?> c, String name) {
+ if (c == null) {
+ return null;
+ }
+ String cacheKey = c.getName() + name;
+ Field f = refFieldsCache.get(cacheKey);
+ if (f != null) {
+ return f;
+ }
+
+ try {
+ f = c.getDeclaredField(name);
+ f.setAccessible(true);
+ refFieldsCache.put(cacheKey, f);
+ return f;
+ } catch (Exception err) {
+ }
+
+ Class<?> s = c.getSuperclass();
+ if (s != null) {
+ f = findField(s, name);
+ if (f != null) {
+ refFieldsCache.put(cacheKey, f);
+ }
+ return f;
+ }
+ return null;
+ }
+
+
+ public static Object get(Object o, String name) {
+ try {
+ Class<?> c = o.getClass();
+ Field f = findField(c, name);
+ return f.get(o);
+ } catch (Exception err) {
+ XSQLAdapter.log(err);
+ }
+ return null;
+ }
+
+ public static List<Object> getMChildren(Object o) {
+ Map<?, ?> children = getChildren(o);
+ List<Object> result = new LinkedList<Object>();
+ for (Object val : children.values()) {
+ result.add((Object) val);
+ }
+ return result;
+ }
+
+ public static Map<?, ?> getChildren(Object o) {
+ return (Map<?, ?>) get(o, "children");
+ }
+
+ public static Object getValue(Object o) {
+ return get(o, "value");
+ }
+
+ public static String getNodeIdentiofier(Object o) {
+ try{
+ return ((PathArgument) get(o, "nodeIdentifier")).getNodeType().toString();
+ }catch(Exception err){
+ return null;
+ }
+ }
+
+ public static String getNodeName(Object o) {
+ Object nodeID = get(o, "nodeIdentifier");
+ if (nodeID != null) {
+ String nodeName = nodeID.toString();
+ int index = nodeName.lastIndexOf(")");
+ return nodeName.substring(index + 1);
+ }
+ return "NULL";
+ }
+
+ public static Class getTypeForODLColumn(Object odlNode){
+ Object type = get(odlNode,"type");
+ if(type instanceof Uint32 || type instanceof Uint64){
+ return long.class;
+ }else
+ if(type instanceof Uint16){
+ return int.class;
+ }else
+ if(type instanceof Uint8){
+ return byte.class;
+ }
+ return String.class;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql;
+
+import java.util.LinkedList;
+
+public class XSQLThreadPool {
+ private LinkedList<Runnable> tasks = new LinkedList<Runnable>();
+ private int threadCount = 0;
+ private int maxThreadCount = 10;
+ private String threadPoolName = "Simple Thread Pool";
+ private int waitTimeForIdle = 10000;
+ private int maxQueueSize = -1;
+ public Object waitForSlotSync = new Object();
+
+ public XSQLThreadPool(int _maxThreadCount, String name,
+ int _waitTimeForIdle) {
+ this.maxThreadCount = _maxThreadCount;
+ this.threadPoolName = name;
+ this.waitTimeForIdle = _waitTimeForIdle;
+ }
+
+ public void addTask(Runnable r) {
+ synchronized (tasks) {
+ tasks.add(r);
+ tasks.notifyAll();
+ if (threadCount < maxThreadCount) {
+ threadCount++;
+ new WorkerThread(threadCount).start();
+ }
+ }
+ }
+
+ private class WorkerThread extends Thread {
+
+ private long lastTimeExecuted = System.currentTimeMillis();
+
+ public WorkerThread(int threadNumber) {
+ super(
+ "Thread #" + threadNumber + " Of Threadpool " + threadPoolName);
+ }
+
+ public void run() {
+ Runnable runthis = null;
+ while (true) {
+ runthis = null;
+ if (maxQueueSize != -1) {
+ synchronized (waitForSlotSync) {
+ if (tasks.size() < maxQueueSize) {
+ waitForSlotSync.notifyAll();
+ }
+ }
+ }
+ synchronized (tasks) {
+ if (tasks.isEmpty()) {
+ try {
+ tasks.wait(2000);
+ } catch (Exception err) {
+ }
+ }
+
+ if (!tasks.isEmpty()) {
+ runthis = tasks.removeFirst();
+ }
+ }
+ if (runthis != null) {
+ try {
+ runthis.run();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ lastTimeExecuted = System.currentTimeMillis();
+ }
+ if (System.currentTimeMillis() - lastTimeExecuted
+ > waitTimeForIdle) {
+ break;
+ }
+ }
+ synchronized (tasks) {
+ threadCount--;
+ }
+ }
+ }
+
+ public int getNumberOfThreads() {
+ return threadCount;
+ }
+
+ public void waitForSlot() {
+ if (tasks.size() > maxQueueSize) {
+ synchronized (waitForSlotSync) {
+ try {
+ waitForSlotSync.wait();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public boolean isEmpty() {
+ if (this.threadCount == 0) {
+ return true;
+ }
+ return false;
+ }
+
+ public void setMaxQueueSize(int size) {
+ this.maxQueueSize = size;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.io.Serializable;
+import java.util.Map;
+
+public class JDBCCommand implements Serializable {
+ public int type = 0;
+ public static final int TYPE_EXECUTE_QUERY = 1;
+ public static final int TYPE_QUERY_REPLY = 2;
+ public static final int TYPE_QUERY_RECORD = 3;
+ public static final int TYPE_QUERY_FINISH = 4;
+ public static final int TYPE_QUERY_ERROR = 5;
+
+ private JDBCResultSet rs = null;
+ private Map record = null;
+ private int rsID = -1;
+ private Exception err = null;
+
+ public JDBCCommand(Exception _err, int _RSID) {
+ this.type = TYPE_QUERY_ERROR;
+ this.err = _err;
+ this.rsID = _RSID;
+ }
+
+ public JDBCCommand(JDBCResultSet _rs, int _type) {
+ this.type = TYPE_EXECUTE_QUERY;
+ this.rs = _rs;
+ this.type = _type;
+ this.rsID = rs.getID();
+ }
+
+ public JDBCCommand(Map _record, int _rsID) {
+ this.record = _record;
+ this.rsID = _rsID;
+ this.type = TYPE_QUERY_RECORD;
+ }
+
+ public JDBCCommand(int _rsID) {
+ this.rsID = _rsID;
+ this.type = TYPE_QUERY_FINISH;
+ }
+
+ public int getType() {
+ return this.type;
+ }
+
+ public JDBCResultSet getRS() {
+ return this.rs;
+ }
+
+ public Map getRecord() {
+ return this.record;
+ }
+
+ public int getRSID() {
+ return this.rsID;
+ }
+
+ public Exception getERROR() {
+ return this.err;
+ }
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+
+public class JDBCConnection extends Thread implements Connection {
+ private Socket socket = null;
+ private DataInputStream in = null;
+ private DataOutputStream out = null;
+ private LinkedList<byte[]> queue = new LinkedList<byte[]>();
+ private XSQLAdapter adapter = null;
+
+ public JDBCConnection(Socket s, XSQLAdapter _a) {
+ this.socket = s;
+ this.adapter = _a;
+ try {
+ in = new DataInputStream(
+ new BufferedInputStream(s.getInputStream()));
+ out = new DataOutputStream(
+ new BufferedOutputStream(s.getOutputStream()));
+ new JDBCObjectReader();
+ this.start();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public JDBCConnection(String addr) throws Exception {
+ socket = new Socket(addr, 40004);
+ try {
+ in = new DataInputStream(
+ new BufferedInputStream(socket.getInputStream()));
+ out = new DataOutputStream(
+ new BufferedOutputStream(socket.getOutputStream()));
+ new JDBCObjectReader();
+ this.start();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public JDBCConnection(boolean server) {
+ try {
+ ServerSocket s = new ServerSocket(50003);
+ socket = s.accept();
+ try {
+ in = new DataInputStream(
+ new BufferedInputStream(socket.getInputStream()));
+ out = new DataOutputStream(
+ new BufferedOutputStream(socket.getOutputStream()));
+ new JDBCObjectReader();
+ this.start();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+
+ private boolean isStopped() {
+ if (adapter != null && adapter.stopped) {
+ return true;
+ }
+ if (socket == null || socket.isClosed()) {
+ return true;
+ }
+ return false;
+ }
+
+ public void run() {
+ byte data[] = null;
+ while (!isStopped()) {
+ try {
+ int len = in.readInt();
+ data = new byte[len];
+ in.readFully(data);
+ addObject(data);
+
+ } catch (Exception err) {
+ System.out.println("Connection Lost or Closed.");
+ try {
+ socket.close();
+ } catch (Exception err2) {
+ }
+ //err.printStackTrace();
+ }
+ }
+ }
+
+ private void addObject(byte[] data) {
+ synchronized (queue) {
+ queue.add(data);
+ queue.notifyAll();
+ }
+ }
+
+ private class JDBCObjectReader extends Thread {
+
+ public JDBCObjectReader() {
+ super("JDBCObjectReader");
+ start();
+ }
+
+ public void run() {
+ while (!isStopped()) {
+ byte data[] = null;
+ synchronized (queue) {
+ if (queue.size() == 0) {
+ try {
+ queue.wait(1000);
+ } catch (Exception err) {
+ }
+ }
+ if (queue.size() > 0) {
+ data = queue.removeFirst();
+ }
+ }
+ if (data != null) {
+ JDBCCommand command = (JDBCCommand) deSerialize(data);
+ processCommand(command);
+ }
+ }
+ }
+
+ private Object deSerialize(byte data[]) {
+ try {
+ ByteArrayInputStream in = new ByteArrayInputStream(data);
+ ObjectInputStream oin = new ObjectInputStream(in);
+ return oin.readObject();
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ return null;
+ }
+ }
+
+ public void processCommand(JDBCCommand cmd) {
+ switch (cmd.getType()) {
+ case JDBCCommand.TYPE_EXECUTE_QUERY:
+ try {
+ JDBCServer.execute(cmd.getRS(), adapter);
+ send(new JDBCCommand(cmd.getRS(),
+ JDBCCommand.TYPE_QUERY_REPLY));
+ QueryUpdater u = new QueryUpdater(cmd.getRS());
+ new Thread(u).start();
+ } catch (Exception err) {
+ send(new JDBCCommand(err, cmd.getRSID()));
+ }
+ break;
+ case JDBCCommand.TYPE_QUERY_REPLY:
+ JDBCResultSet rs1 = JDBCStatement.getQuery(cmd.getRS().getID());
+ rs1.updateData(cmd.getRS());
+ break;
+ case JDBCCommand.TYPE_QUERY_RECORD:
+ JDBCResultSet rs2 = JDBCStatement.getQuery(cmd.getRSID());
+ rs2.addRecord(cmd.getRecord());
+ break;
+ case JDBCCommand.TYPE_QUERY_FINISH:
+ JDBCResultSet rs3 = JDBCStatement.removeQuery(cmd.getRSID());
+ rs3.setFinished(true);
+ break;
+ case JDBCCommand.TYPE_QUERY_ERROR:
+ System.err.println("ERROR Executing Query\n");
+ cmd.getERROR().printStackTrace();
+ JDBCResultSet rs4 = JDBCStatement.removeQuery(cmd.getRSID());
+ rs4.setError(cmd.getERROR());
+ rs4.setFinished(true);
+ synchronized (rs4) {
+ rs4.notifyAll();
+ }
+ }
+ }
+
+ private class QueryUpdater implements Runnable {
+
+ private JDBCResultSet rs = null;
+
+ public QueryUpdater(JDBCResultSet _rs) {
+ this.rs = _rs;
+ }
+
+ public void run() {
+ while (rs.next()) {
+ JDBCCommand rec = new JDBCCommand(rs.getCurrent(), rs.getID());
+ send(rec);
+ }
+ JDBCCommand end = new JDBCCommand(rs.getID());
+ send(end);
+ }
+ }
+
+ public void send(Object o) {
+ try {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream oout = new ObjectOutputStream(bout);
+ oout.writeObject(o);
+ byte data[] = bout.toByteArray();
+ synchronized (socket) {
+ out.writeInt(data.length);
+ out.write(data);
+ out.flush();
+ }
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> arg0) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> arg0) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() throws SQLException {
+ try {
+ socket.close();
+ } catch (Exception err) {
+ }
+ socket = null;
+ }
+
+ @Override
+ public void commit() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Array createArrayOf(String typeName, Object[] elements)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Blob createBlob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Clob createClob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public NClob createNClob() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLXML createSQLXML() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Statement createStatement() throws SQLException {
+ return new JDBCStatement(this);
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Statement createStatement(int resultSetType,
+ int resultSetConcurrency)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Struct createStruct(String typeName, Object[] attributes)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean getAutoCommit() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getCatalog() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Properties getClientInfo() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getClientInfo(String name) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public DatabaseMetaData getMetaData() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getTransactionIsolation() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Map<String, Class<?>> getTypeMap() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isReadOnly() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isValid(int timeout) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String nativeSQL(String sql) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql, int resultSetType,
+ int resultSetConcurrency) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public CallableStatement prepareCall(String sql) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType,
+ int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int resultSetType,
+ int resultSetConcurrency) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql, String[] columnNames)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public PreparedStatement prepareStatement(String sql) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void rollback() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void rollback(Savepoint savepoint) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setAutoCommit(boolean autoCommit) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setCatalog(String catalog) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setClientInfo(Properties properties)
+ throws SQLClientInfoException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setClientInfo(String name, String value)
+ throws SQLClientInfoException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setHoldability(int holdability) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setReadOnly(boolean readOnly) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Savepoint setSavepoint() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Savepoint setSavepoint(String name) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setTransactionIsolation(int level) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setSchema(String schema) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public String getSchema() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void abort(Executor executor) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setNetworkTimeout(Executor executor, int milliseconds)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int getNetworkTimeout() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+}
+
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.DriverPropertyInfo;
+import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
+import java.util.Properties;
+import java.util.logging.Logger;
+
+public class JDBCDriver implements Driver {
+
+ public static JDBCDriver drv = new JDBCDriver();
+
+ public JDBCDriver() {
+ try {
+ DriverManager.registerDriver(this);
+ } catch (SQLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public boolean acceptsURL(String arg0) throws SQLException {
+ return true;
+ }
+
+ @Override
+ public Connection connect(String url, Properties arg1) throws SQLException {
+ System.err.println("JDBC Connection");
+ try {
+ if (url.equals("svr")) {
+ return new JDBCConnection(true);
+ } else {
+ return new JDBCConnection(url);
+ }
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public int getMajorVersion() {
+ return 1;
+ }
+
+ @Override
+ public int getMinorVersion() {
+ return 0;
+ }
+
+ @Override
+ public DriverPropertyInfo[] getPropertyInfo(String arg0, Properties arg1)
+ throws SQLException {
+ DriverPropertyInfo i = new DriverPropertyInfo("NQL", "NQL");
+ return new DriverPropertyInfo[] {i};
+ }
+
+ @Override
+ public boolean jdbcCompliant() {
+ return false;
+ }
+
+ @Override
+ public Logger getParentLogger() throws SQLFeatureNotSupportedException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLODLUtils;
+
+public class JDBCResultSet
+ implements Serializable, ResultSet, ResultSetMetaData {
+ private static final long serialVersionUID = -7450200738431047057L;
+
+ private String sql = null;
+ private List<XSQLBluePrintNode> tablesInQuery =
+ new ArrayList<XSQLBluePrintNode>();
+ private Map<String, XSQLBluePrintNode> tablesInQueryMap =
+ new ConcurrentHashMap<String, XSQLBluePrintNode>();
+ private List<XSQLColumn> fieldsInQuery = new ArrayList<XSQLColumn>();
+ private transient LinkedList<Map> records = new LinkedList<Map>();
+ private transient Map currentRecord = null;
+ private boolean finished = false;
+ private int id = 0;
+ private static Integer nextID = new Integer(0);
+ public int numberOfTasks = 0;
+ private Map<String, Map<XSQLColumn, List<XSQLCriteria>>> criteria =
+ new ConcurrentHashMap<String, Map<XSQLColumn, List<XSQLCriteria>>>();
+ private Exception err = null;
+ private List<Record> EMPTY_RESULT = new LinkedList<Record>();
+
+ public JDBCResultSet(String _sql) {
+ synchronized (JDBCResultSet.class) {
+ nextID++;
+ id = nextID;
+ }
+ this.sql = _sql;
+ }
+
+ public String getSQL() {
+ return this.sql;
+ }
+
+ public void setError(Exception _err) {
+ this.err = _err;
+ }
+
+ public Exception getError() {
+ return this.err;
+ }
+
+ public void updateData(JDBCResultSet rs) {
+ synchronized (this) {
+ this.tablesInQuery = rs.tablesInQuery;
+ this.tablesInQueryMap = rs.tablesInQueryMap;
+ this.fieldsInQuery = rs.fieldsInQuery;
+ this.notifyAll();
+ }
+ }
+
+ public int isObjectFitCriteria(Map objValues, String tableName) {
+ Map<XSQLColumn, List<XSQLCriteria>> tblCriteria = criteria.get(tableName);
+ if (tblCriteria == null) {
+ return 1;
+ }
+ for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
+ .entrySet()) {
+ for (XSQLCriteria c : cc.getValue()) {
+ Object value = objValues.get(cc.getKey().toString());
+ int result = c.checkValue(value);
+ if (result == 0) {
+ return 0;
+ }
+ }
+ }
+ return 1;
+ }
+
+ public int isObjectFitCriteria(Object element, Class cls) {
+ Map<XSQLColumn, List<XSQLCriteria>> tblCriteria =
+ criteria.get(cls.getName());
+ if (tblCriteria == null) {
+ return 1;
+ }
+ for (Map.Entry<XSQLColumn, List<XSQLCriteria>> cc : tblCriteria
+ .entrySet()) {
+ for (XSQLCriteria c : cc.getValue()) {
+ int result =
+ c.isObjectFitCriteria(element, cc.getKey().getName());
+ if (result == 0) {
+ return 0;
+ }
+ }
+ }
+ return 1;
+ }
+
+ public Map<String, Map<XSQLColumn, List<XSQLCriteria>>> getCriteria() {
+ return this.criteria;
+ }
+
+ public int getID() {
+ return this.id;
+ }
+
+ public List<XSQLBluePrintNode> getTables() {
+ return tablesInQuery;
+ }
+
+ public void addTableToQuery(XSQLBluePrintNode node) {
+ if (this.tablesInQueryMap.containsKey(node.getBluePrintNodeName())) {
+ return;
+ }
+ this.tablesInQuery.add(node);
+ this.tablesInQueryMap.put(node.getBluePrintNodeName(), node);
+ }
+
+ public List<XSQLColumn> getFields() {
+ return this.fieldsInQuery;
+ }
+
+ public XSQLBluePrintNode getMainTable() {
+ if (tablesInQuery.size() == 1) {
+ return tablesInQuery.get(0);
+ }
+ XSQLBluePrintNode result = null;
+ for (XSQLBluePrintNode node : tablesInQuery) {
+ if (result == null) {
+ result = node;
+ } else if (result.getLevel() < node.getLevel()) {
+ result = node;
+ }
+ }
+ return result;
+ }
+
+ public boolean isFinished() {
+ return finished;
+ }
+
+ public void setFinished(boolean b) {
+ this.finished = b;
+ }
+
+ public int size() {
+ return this.records.size();
+ }
+
+ public void addRecord(Map r) {
+ synchronized (this) {
+ if (records == null) {
+ records = new LinkedList<Map>();
+ }
+ records.add(r);
+ this.notifyAll();
+ }
+ }
+
+
+ public void addRecord(ArrayList hierarchy) {
+ Map rec = new HashMap();
+ for (int i = hierarchy.size() - 1; i >= 0; i--) {
+ Object element = hierarchy.get(i);
+ for (XSQLColumn c : fieldsInQuery) {
+ if (c.getTableName()
+ .equals(element.getClass().getSimpleName())) {
+ try {
+ Method m = element.getClass().getMethod(c.getName(), null);
+ Object value = m.invoke(element, null);
+ rec.put(c.getName(), value);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+ }
+ }
+ this.records.add(rec);
+ }
+
+ public boolean next() {
+ this.currentRecord = null;
+ if (records == null) {
+ records = new LinkedList<Map>();
+ }
+ while (!finished || records.size() > 0) {
+ synchronized (this) {
+ if (records.size() == 0) {
+ try {
+ this.wait(1000);
+ } catch (Exception err) {
+ }
+ if (records.size() > 0) {
+ try {
+ currentRecord = records.removeFirst();
+ return true;
+ } finally {
+ this.notifyAll();
+ }
+ }
+ } else {
+ try {
+ currentRecord = records.removeFirst();
+ return true;
+ } finally {
+ this.notifyAll();
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public Map getCurrent() {
+ return this.currentRecord;
+ }
+
+ private void createRecord(Object data, XSQLBluePrintNode node) {
+ Map rec = new HashMap();
+ for (XSQLColumn c : this.fieldsInQuery) {
+ if (c.getTableName().equals(node.getBluePrintNodeName())) {
+ try {
+ Method m = node.getInterface().getMethod(c.getName(), null);
+ Object value = m.invoke(data, null);
+ if (value != null) {
+ rec.put(c.getName(), value);
+ } else {
+ rec.put(c.getName(), "");
+ }
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+
+ }
+ }
+ }
+
+ public static class Record {
+ public Map data = new HashMap();
+ public Object element = null;
+
+ public Map getRecord() {
+ return this.data;
+ }
+ }
+
+ private Map collectColumnValues(Object node, XSQLBluePrintNode bpn) {
+ Map subChildren = XSQLODLUtils.getChildren(node);
+ Map result = new HashMap();
+ for (Object stc : subChildren.values()) {
+ if (stc.getClass().getName()
+ .endsWith("ImmutableAugmentationNode")) {
+ Map values = XSQLODLUtils.getChildren(stc);
+ for (Object key : values.keySet()) {
+ Object val = values.get(key);
+ if (val.getClass().getName()
+ .endsWith("ImmutableLeafNode")) {
+ Object value = XSQLODLUtils.getValue(val);
+ String k = XSQLODLUtils.getNodeName(val);
+ if (value != null) {
+ result.put(bpn.getBluePrintNodeName() + "." + k,
+ value.toString());
+ }
+ }
+ }
+ } else if (stc.getClass().getName().endsWith("ImmutableLeafNode")) {
+ String k = XSQLODLUtils.getNodeName(stc);
+ Object value = XSQLODLUtils.getValue(stc);
+ if (value != null) {
+ result.put(bpn.getBluePrintNodeName() + "." + k, value.toString());
+ }
+ }
+ }
+ return result;
+ }
+
+ private void addToData(Record rec, XSQLBluePrintNode bpn, XSQLBluePrint bluePrint, Map fullRecord) {
+ XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(XSQLODLUtils.getNodeIdentiofier(rec.element));
+ if (bpn != null) {
+ for (XSQLColumn c : fieldsInQuery) {
+ for(XSQLBluePrintNode eNode:eNodes){
+ if (((XSQLBluePrintNode) c.getBluePrintNode()).getBluePrintNodeName().equals(eNode.getBluePrintNodeName())) {
+ //Object value = Criteria.getValue(rec.element, c.getName());
+ String columnName = c.toString();
+ Object value = fullRecord.get(columnName);
+ if (value != null) {
+ try {
+ Object rsValue = c.getResultSetValue(value);
+ c.setCharWidth(rsValue.toString().length());
+ rec.data.put(columnName, rsValue);
+ } catch (Exception err) {
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private boolean beenHere(Set<String> beenHereElement, Object element) {
+ if (beenHereElement == null) {
+ beenHereElement = new HashSet<String>();
+ }
+
+ String elementKey = null;
+
+ try {
+ elementKey = element.toString();
+ } catch (Exception err) {
+ elementKey = "Unknown";
+ }
+
+ if (beenHereElement.contains(elementKey)) {
+ return true;
+ }
+
+ beenHereElement.add(elementKey);
+ return false;
+ }
+
+ public List<Object> getChildren(Object node, String tableName,XSQLBluePrint bluePrint) {
+
+ List<Object> children = XSQLODLUtils.getMChildren(node);
+ List<Object> result = new LinkedList<Object>();
+
+ for (Object child : children) {
+
+ String odlNodeName = XSQLODLUtils.getNodeIdentiofier(child);
+ if(odlNodeName==null) continue;
+
+ XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(odlNodeName);
+ if(eNodes==null) continue;
+
+ boolean match = false;
+ for(XSQLBluePrintNode enode:eNodes){
+ if(tableName.startsWith(enode.toString())){
+ match = true;
+ break;
+ }
+ }
+
+ if(!match) continue;
+
+ if (child.getClass().getName().endsWith("ImmutableContainerNode")) {
+ result.add(child);
+ }else
+ if (child.getClass().getName().endsWith("ImmutableAugmentationNode")) {
+ List<Object> _children = XSQLODLUtils.getMChildren(child);
+ for (Object c : _children) {
+ if (c.getClass().getName().endsWith("ImmutableContainerNode")) {
+ result.add(c);
+ }
+ }
+ } else if (child.getClass().getName().endsWith("ImmutableMapNode")) {
+ result.addAll(XSQLODLUtils.getMChildren(child));
+ }
+ }
+ return result;
+ }
+
+ public List<Record> addRecords(Object element, XSQLBluePrintNode node,boolean root, String tableName,XSQLBluePrint bluePrint) {
+
+ List<Record> result = new LinkedList<Record>();
+ String nodeID = XSQLODLUtils.getNodeIdentiofier(element);
+ if (node.getODLTableName().equals(nodeID)) {
+ XSQLBluePrintNode bluePrintNode = bluePrint.getBluePrintNodeByODLTableName(nodeID)[0];
+ Record rec = new Record();
+ rec.element = element;
+ XSQLBluePrintNode bpn = this.tablesInQueryMap.get(bluePrintNode.getBluePrintNodeName());
+ if (this.criteria.containsKey(bluePrintNode.getBluePrintNodeName()) || bpn != null) {
+ Map<?, ?> allKeyValues = collectColumnValues(element, bpn);
+ if (!(isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) {
+ return EMPTY_RESULT;
+ }
+ addToData(rec, bpn, bluePrint,allKeyValues);
+ }
+ if (root) {
+ addRecord(rec.data);
+ } else {
+ result.add(rec);
+ }
+ return result;
+ }
+
+ XSQLBluePrintNode parent = node.getParent();
+ List<Record> subRecords = addRecords(element, parent, false, tableName,bluePrint);
+ for (Record subRec : subRecords) {
+ List<Object> subO = getChildren(subRec.element, tableName,bluePrint);
+ if (subO != null) {
+ for (Object subData : subO) {
+ Record rec = new Record();
+ rec.element = subData;
+ rec.data.putAll(subRec.data);
+
+ String recID = XSQLODLUtils.getNodeIdentiofier(rec.element);
+ XSQLBluePrintNode eNodes[] = bluePrint.getBluePrintNodeByODLTableName(recID);
+ XSQLBluePrintNode bpn = null;
+ for(XSQLBluePrintNode eNode:eNodes){
+ bpn = this.tablesInQueryMap.get(eNode.getBluePrintNodeName());
+ if(bpn!=null)
+ break;
+ }
+ boolean isObjectInCriteria = true;
+ if (bpn != null) {
+ Map allKeyValues = collectColumnValues(rec.element, bpn);
+ if ((isObjectFitCriteria(allKeyValues, bpn.getBluePrintNodeName()) == 1)) {
+ addToData(rec, bpn,bluePrint,allKeyValues);
+ } else {
+ isObjectInCriteria = false;
+ }
+ }
+
+ if (isObjectInCriteria) {
+ if (root) {
+ if(!rec.data.isEmpty())
+ addRecord(rec.data);
+ } else {
+ result.add(rec);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean absolute(int row) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void afterLast() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void beforeFirst() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancelRowUpdates() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void deleteRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public int findColumn(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean first() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Array getArray(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Array getArray(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getAsciiStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getAsciiStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex, int scale)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel, int scale)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getBinaryStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getBinaryStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Blob getBlob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Blob getBlob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean getBoolean(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean getBoolean(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public byte getByte(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public byte getByte(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public byte[] getBytes(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public byte[] getBytes(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getCharacterStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getCharacterStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Clob getClob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Clob getClob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getConcurrency() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getCursorName() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Date getDate(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public double getDouble(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public double getDouble(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getFetchDirection() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getFetchSize() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public float getFloat(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public float getFloat(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getInt(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getInt(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getLong(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public long getLong(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public ResultSetMetaData getMetaData() throws SQLException {
+ return this;
+ }
+
+ @Override
+ public Reader getNCharacterStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Reader getNCharacterStream(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public NClob getNClob(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public NClob getNClob(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getNString(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getNString(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(int columnIndex, Map<String, Class<?>> map)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(int columnIndex) throws SQLException {
+ return currentRecord
+ .get(this.fieldsInQuery.get(columnIndex - 1).toString());
+ }
+
+ @Override
+ public Object getObject(String columnLabel, Map<String, Class<?>> map)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getObject(String columnLabel) throws SQLException {
+ return currentRecord.get(columnLabel);
+ }
+
+ @Override
+ public Ref getRef(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Ref getRef(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getRow() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public RowId getRowId(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public RowId getRowId(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLXML getSQLXML(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLXML getSQLXML(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public short getShort(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public short getShort(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Statement getStatement() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getString(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getString(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Time getTime(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex, Calendar cal)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel, Calendar cal)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Timestamp getTimestamp(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getType() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public URL getURL(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public URL getURL(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public InputStream getUnicodeStream(String columnLabel)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void insertRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isAfterLast() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isBeforeFirst() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isFirst() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isLast() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean last() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void moveToCurrentRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void moveToInsertRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean previous() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void refreshRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean relative(int rows) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean rowDeleted() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean rowInserted() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean rowUpdated() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setFetchDirection(int direction) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setFetchSize(int rows) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateArray(int columnIndex, Array x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateArray(String columnLabel, Array x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x,
+ long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateAsciiStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBigDecimal(int columnIndex, BigDecimal x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBigDecimal(String columnLabel, BigDecimal x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(int columnIndex, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x,
+ int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBinaryStream(String columnLabel, InputStream x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, Blob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream,
+ long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(int columnIndex, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, Blob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBlob(String columnLabel, InputStream inputStream)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBoolean(String columnLabel, boolean x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateByte(int columnIndex, byte x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateByte(String columnLabel, byte x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, int length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader,
+ int length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Clob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(int columnIndex, Reader reader) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Clob x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDate(int columnIndex, Date x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDate(String columnLabel, Date x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDouble(int columnIndex, double x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateDouble(String columnLabel, double x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateFloat(int columnIndex, float x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateFloat(String columnLabel, float x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateInt(int columnIndex, int x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateInt(String columnLabel, int x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateLong(int columnIndex, long x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateLong(String columnLabel, long x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(int columnIndex, Reader x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader,
+ long length) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNCharacterStream(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(int columnIndex, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, NClob nClob)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader, long length)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNClob(String columnLabel, Reader reader)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNString(int columnIndex, String nString)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNString(String columnLabel, String nString)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNull(int columnIndex) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateNull(String columnLabel) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x, int scaleOrLength)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(int columnIndex, Object x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x, int scaleOrLength)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateObject(String columnLabel, Object x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRef(int columnIndex, Ref x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRef(String columnLabel, Ref x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRow() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRowId(int columnIndex, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateRowId(String columnLabel, RowId x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateSQLXML(int columnIndex, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateSQLXML(String columnLabel, SQLXML xmlObject)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateShort(int columnIndex, short x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateShort(String columnLabel, short x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateString(int columnIndex, String x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateString(String columnLabel, String x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTime(int columnIndex, Time x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTime(String columnLabel, Time x) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTimestamp(int columnIndex, Timestamp x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void updateTimestamp(String columnLabel, Timestamp x)
+ throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean wasNull() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public String getCatalogName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getColumnClassName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getColumnCount() throws SQLException {
+ return fieldsInQuery.size();
+ }
+
+ @Override
+ public int getColumnDisplaySize(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getColumnLabel(int column) throws SQLException {
+ return this.fieldsInQuery.get(column - 1).toString();
+ }
+
+ @Override
+ public String getColumnName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getColumnType(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getColumnTypeName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getPrecision(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getScale(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public String getSchemaName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getTableName(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isAutoIncrement(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isCaseSensitive(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isCurrency(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isDefinitelyWritable(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int isNullable(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean isReadOnly(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isSearchable(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isSigned(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isWritable(int column) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <T> T getObject(String columnLabel, Class<T> type)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+
+ ////Metadata
+
+
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrint;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLBluePrintNode;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLColumn;
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLCriteria;
+
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class JDBCServer extends Thread {
+ private ServerSocket socket = null;
+ private XSQLAdapter adapter = null;
+
+ public JDBCServer(XSQLAdapter a) {
+ super("JDBC Server");
+ this.adapter = a;
+ start();
+ }
+
+ public void run() {
+ try {
+ socket = new ServerSocket(40004);
+ while (!adapter.stopped) {
+ Socket s = socket.accept();
+ new JDBCConnection(s, adapter);
+ }
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public void connectToClient(String addr) {
+ try {
+ Socket s = new Socket(addr, 50003);
+ new JDBCConnection(s, adapter);
+ } catch (Exception err) {
+ err.printStackTrace();
+ }
+ }
+
+ public static void execute(JDBCResultSet rs, XSQLAdapter adapter)
+ throws SQLException {
+ parseTables(rs, adapter.getBluePrint());
+ parseFields(rs, adapter.getBluePrint());
+ parseCriteria(rs, adapter.getBluePrint());
+ try {
+ adapter.execute(rs);
+ } catch (Exception err) {
+ throw new SQLException("Error", err);
+ }
+ }
+
+ public static void parseTables(JDBCResultSet rs, XSQLBluePrint bp)
+ throws SQLException {
+ String lowSQL = rs.getSQL().toLowerCase();
+ int from = lowSQL.indexOf("from");
+ int where = lowSQL.indexOf("where");
+ int subQuery = lowSQL.indexOf("select", 2);
+ int fromTo = lowSQL.indexOf(";");
+
+ if (where != -1 && subQuery != -1 && where < subQuery) {
+ fromTo = where;
+ } else if (where != -1 && subQuery != -1 && where > subQuery) {
+ fromTo = subQuery;
+ } else if (where != -1) {
+ fromTo = where;
+ } else if (subQuery != -1) {
+ fromTo = subQuery;
+ }
+
+ if (from == -1) {
+ throw new SQLException("Missing \"from\" statement.");
+ }
+
+ if (fromTo == -1) {
+ throw new SQLException("Missing terminating \";\".");
+ }
+
+ String tableNames = rs.getSQL().substring(from + 4, fromTo).trim();
+ StringTokenizer tokens = new StringTokenizer(tableNames, ",");
+ while (tokens.hasMoreTokens()) {
+ String tableName = tokens.nextToken().trim();
+ XSQLBluePrintNode table = bp.getBluePrintNodeByTableName(tableName);
+ if (table == null) {
+ throw new SQLException(
+ "Unknown table name \"" + tableName + "\"");
+ }
+ rs.addTableToQuery(table);
+ }
+ }
+
+ public static void addCriteria(XSQLColumn col, XSQLCriteria c,
+ JDBCResultSet rs) {
+ Map<XSQLColumn, List<XSQLCriteria>> tblCriteria =
+ rs.getCriteria().get(col.getTableName());
+ if (tblCriteria == null) {
+ tblCriteria =
+ new ConcurrentHashMap<XSQLColumn, List<XSQLCriteria>>();
+ rs.getCriteria().put(col.getTableName(), tblCriteria);
+ }
+ List<XSQLCriteria> lstCriteria = tblCriteria.get(col);
+ if (lstCriteria == null) {
+ lstCriteria = new ArrayList<XSQLCriteria>();
+ tblCriteria.put(col, lstCriteria);
+ }
+ lstCriteria.add(c);
+ }
+
+ public static void parseFields(JDBCResultSet rs, XSQLBluePrint bp)
+ throws SQLException {
+ String lowSQL = rs.getSQL().toLowerCase();
+ if (!lowSQL.startsWith("select")) {
+ throw new SQLException("Missing 'select' statement.");
+ }
+ int from = lowSQL.indexOf("from");
+ if (from == -1) {
+ throw new SQLException("Missing 'from' statement.");
+ }
+ String fields = rs.getSQL().substring(6, from).trim();
+ StringTokenizer tokens = new StringTokenizer(fields, ",");
+ while (tokens.hasMoreTokens()) {
+ String token = tokens.nextToken().trim();
+ if (token.equals("*")) {
+ for (XSQLBluePrintNode table : rs.getTables()) {
+ rs.getFields().addAll(table.getColumns());
+ }
+ return;
+ }
+ if (token.indexOf(".") != -1) {
+ XSQLBluePrintNode tbl = bp.getBluePrintNodeByTableName(
+ token.substring(0, token.indexOf(".")).trim());
+ String p = token.substring(token.indexOf(".") + 1);
+ if (p.equals("*")) {
+ for (XSQLColumn c : tbl.getColumns()) {
+ rs.getFields().add(c);
+ }
+ } else {
+ XSQLColumn col = tbl.findColumnByName(p);
+ rs.getFields().add(col);
+ }
+ } else {
+ XSQLColumn col = null;
+ for (XSQLBluePrintNode table : rs.getTables()) {
+ try {
+ col = table.findColumnByName(token);
+ } catch (Exception err) {
+ }
+ if (col != null) {
+ break;
+ }
+ }
+ if (col == null) {
+ throw new SQLException(
+ "Unknown field name '" + token + "'.");
+ }
+
+ rs.getFields().add(col);
+ }
+ }
+ }
+
+ public static void parseCriteria(JDBCResultSet rs, XSQLBluePrint bp) {
+ String lowSQL = rs.getSQL().toLowerCase();
+ int where = lowSQL.indexOf("where");
+ int order = lowSQL.indexOf("order");
+ int subQuery = lowSQL.indexOf("select", 2);
+ int whereTo = lowSQL.indexOf(";");
+
+ if (where == -1) {
+ return;
+ }
+
+ if (where != -1 && subQuery != -1 && subQuery < where) {
+ return;
+ }
+
+ if (order != -1 && subQuery != -1 && order < subQuery) {
+ whereTo = order;
+ } else if (order != -1 && subQuery != -1 && order > subQuery) {
+ whereTo = subQuery;
+ } else if (order != -1) {
+ whereTo = order;
+ } else if (subQuery != -1) {
+ whereTo = subQuery;
+ }
+ String whereStatement =
+ rs.getSQL().substring(where + 5, whereTo).trim();
+ XSQLCriteria cr = new XSQLCriteria(whereStatement, -1);
+ for (XSQLBluePrintNode tbl : rs.getTables()) {
+ for (XSQLColumn col : tbl.getColumns()) {
+ String colCriteria = cr.getCriteriaForProperty(col);
+ if (colCriteria != null && !colCriteria.trim().equals("")) {
+ addCriteria(col, new XSQLCriteria(colCriteria, -1), rs);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.dom.xsql.jdbc;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class JDBCStatement implements Statement {
+ private JDBCResultSet rs = null;
+ private transient JDBCConnection connection = null;
+ private static Map<Integer, JDBCResultSet> queries =
+ new ConcurrentHashMap<Integer, JDBCResultSet>();
+
+ public JDBCStatement(JDBCConnection con) {
+ this.connection = con;
+ }
+
+ public JDBCStatement() {
+
+ }
+
+ public static JDBCResultSet getQuery(int id) {
+ return queries.get(id);
+ }
+
+ public static JDBCResultSet removeQuery(int id) {
+ return queries.remove(id);
+ }
+
+ @Override
+ public java.sql.ResultSet executeQuery(String _sql) throws SQLException {
+ rs = new JDBCResultSet(_sql);
+ queries.put(rs.getID(), rs);
+ synchronized (rs) {
+ this.connection
+ .send(new JDBCCommand(rs, JDBCCommand.TYPE_EXECUTE_QUERY));
+ try {
+ rs.wait();
+ } catch (Exception err) {
+ }
+ if (rs.getError() != null) {
+ throw ((SQLException) rs.getError());
+ }
+ }
+ return rs;
+ }
+
+ @Override
+ public boolean execute(String _sql) throws SQLException {
+ return true;
+ }
+
+ public void addRecord(ArrayList hierarchy) {
+ rs.addRecord(hierarchy);
+ }
+
+ public int size() {
+ return rs.size();
+ }
+
+ public void setFinished(boolean b) {
+ this.rs.setFinished(b);
+ }
+
+ public JDBCResultSet getRS() {
+ return this.rs;
+ }
+
+ public ResultSet getResultSet() {
+ return this.rs;
+ }
+
+ @Override
+ public boolean isWrapperFor(Class<?> arg0) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public <T> T unwrap(Class<T> arg0) throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void addBatch(String sql) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void cancel() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearBatch() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void clearWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void close() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean execute(String sql, int autoGeneratedKeys)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean execute(String sql, int[] columnIndexes)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean execute(String sql, String[] columnNames)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int[] executeBatch() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int executeUpdate(String sql, int autoGeneratedKeys)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int executeUpdate(String sql, int[] columnIndexes)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int executeUpdate(String sql, String[] columnNames)
+ throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int executeUpdate(String sql) throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getFetchDirection() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getFetchSize() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public java.sql.ResultSet getGeneratedKeys() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public int getMaxFieldSize() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getMaxRows() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public boolean getMoreResults() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean getMoreResults(int current) throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public int getQueryTimeout() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getResultSetConcurrency() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getResultSetHoldability() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getResultSetType() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public int getUpdateCount() throws SQLException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @Override
+ public SQLWarning getWarnings() throws SQLException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isClosed() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isPoolable() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void setCursorName(String name) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setEscapeProcessing(boolean enable) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setFetchDirection(int direction) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setFetchSize(int rows) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setMaxFieldSize(int max) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setMaxRows(int max) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setPoolable(boolean poolable) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setQueryTimeout(int seconds) throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void closeOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isCloseOnCompletion() throws SQLException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+
+}
--- /dev/null
+package org.opendaylight.xsql;
+
+import java.util.concurrent.ExecutionException;
+
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQL;
+import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQLBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Created by root on 6/26/14.
+ */
+public class XSQLProvider implements AutoCloseable {
+
+ public static final InstanceIdentifier<XSQL> ID = InstanceIdentifier.builder(XSQL.class).build();
+ private static final Logger LOG = LoggerFactory.getLogger(XSQLProvider.class);
+
+ public void close() {
+ }
+
+ public XSQL buildXSQL(DataProviderService dps) {
+ XSQLBuilder builder = new XSQLBuilder();
+ builder.setPort("34343");
+ XSQL xsql = builder.build();
+ if (dps != null) {
+ final DataModificationTransaction t = dps.beginTransaction();
+ t.removeOperationalData(ID);
+ t.putOperationalData(ID,xsql);
+
+ try {
+ t.commit().get();
+ } catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Failed to update toaster status, operational otherwise", e);
+ }
+ }
+ return xsql;
+ }
+}
--- /dev/null
+package org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626;
+
+import org.opendaylight.controller.md.sal.dom.xsql.XSQLAdapter;
+import org.opendaylight.xsql.XSQLProvider;
+
+public class XSQLModule extends org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.AbstractXSQLModule {
+ public XSQLModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
+ }
+
+ public XSQLModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.XSQLModule oldModule, java.lang.AutoCloseable oldInstance) {
+ super(identifier, dependencyResolver, oldModule, oldInstance);
+ }
+
+ @Override
+ public void customValidation() {
+ // add custom validation form module attributes here.
+ }
+
+ @Override
+ public java.lang.AutoCloseable createInstance() {
+ XSQLAdapter xsqlAdapter = XSQLAdapter.getInstance();
+ getSchemaServiceDependency().registerSchemaServiceListener(xsqlAdapter);
+ xsqlAdapter.setDataBroker(getAsyncDataBrokerDependency());
+ XSQLProvider p = new XSQLProvider();
+ p.buildXSQL(getDataBrokerDependency());
+ return p;
+ }
+
+}
--- /dev/null
+/*
+* Generated file
+*
+* Generated from: yang module name: XSQL yang module local name: XSQL
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Thu Jun 26 14:56:25 PDT 2014
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626;
+public class XSQLModuleFactory extends org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.xsql.rev140626.AbstractXSQLModuleFactory {
+
+}
--- /dev/null
+<snapshot>
+ <configuration>
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+ <module>
+ <type xmlns:XSQL="http://netconfcentral.org/ns/XSQL">
+ XSQL:XSQL
+ </type>
+ <name>XSQL</name>
+ <data-broker>
+ <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+ <name>binding-data-broker</name>
+ </data-broker>
+ <async-data-broker>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-async-data-broker</type>
+ <name>inmemory-data-broker</name>
+ </async-data-broker>
+ <schema-service>
+ <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
+ <name>yang-schema-service</name>
+ </schema-service>
+ </module>
+ </modules>
+ </data>
+ </configuration>
+ <required-capabilities>
+ <capability>http://netconfcentral.org/ns/XSQL?module=XSQL&revision=2014-06-26</capability>
+ </required-capabilities>
+</snapshot>
--- /dev/null
+module XSQL{
+ yang-version 1;
+ namespace "http://netconfcentral.org/ns/XSQL";
+ prefix XSQL;
+
+ import config { prefix config; revision-date 2013-04-05; }
+ import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+ import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+ import opendaylight-md-sal-dom {prefix sal;}
+ import opendaylight-md-sal-common {prefix common;}
+
+ organization "Netconf Central";
+ contact "Sharon Aicler <saichler@cisco.com>";
+ description "YANG version of the XSQL status";
+
+ revision "2014-06-26" {
+ description "XSQL module initial version";
+ }
+
+ container XSQL {
+ presence "Indicates the XSQL service is available";
+ description "Container to indicate the XSQL availability";
+ leaf port {
+ type string;
+ config false;
+ mandatory true;
+ description "The port the XSQL binds on";
+ }
+ }
+
+ identity XSQL {
+ base config:module-type;
+ config:java-name-prefix XSQL;
+ }
+
+ augment "/config:modules/config:module/config:configuration" {
+ case XSQL {
+ when "/config:modules/config:module/config:type = 'XSQL'";
+
+ container data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity mdsal:binding-data-broker;
+ }
+ }
+ }
+
+ container async-data-broker {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity sal:dom-async-data-broker;
+ }
+ }
+
+ }
+
+ container schema-service {
+ uses config:service-ref {
+ refine type {
+ mandatory false;
+ config:required-identity sal:schema-service;
+ }
+ }
+
+ }
+
+ }
+ }
+
+}