aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--].gitignore0
-rwxr-xr-x[-rw-r--r--].gitreview0
-rwxr-xr-x[-rw-r--r--]INFO.yaml0
-rwxr-xr-x[-rw-r--r--]LICENSE0
-rwxr-xr-x[-rw-r--r--]docs/histo_graph.svg0
-rwxr-xr-x[-rw-r--r--]docs/redo_arch.svg0
-rwxr-xr-x[-rw-r--r--]docs/specs.md0
-rwxr-xr-x[-rw-r--r--]docs/uml.svg0
-rwxr-xr-xmdbc-server/pom.xml6
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/exceptions/MDBCServiceException.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/exceptions/QueryException.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/logging/EELFLoggerDelegate.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/logging/format/AppMessages.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/logging/format/ErrorSeverity.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/logging/format/ErrorTypes.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/ArchiveProcess.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/DatabaseOperations.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/LockId.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcCallableStatement.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcPreparedStatement.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServer.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServerLogic.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/MdbcStatement.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/Range.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/RedoRow.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/configurations/NodeConfiguration.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/configurations/TablesConfiguration.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/configurations/config-0.json0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/configurations/ranges.json0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/configurations/tableConfiguration.json0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/examples/EtdbTestClient.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java0
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/query/Operation.java37
-rw-r--r--mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java245
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/MriReference.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicRangeInformationRow.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicTxDigestId.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/Operation.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/OperationType.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/PartitionInformation.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/StagingTable.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tables/TxCommitProgress.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tests/ConnectionTest.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreateNodeConfigurations.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreatePartition.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/resources/logback.xml0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/resources/mdbc_driver.properties0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/main/resources/music.properties0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/test/java/org/onap/music/mdbc/DatabaseOperationsTest.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/test/java/org/onap/music/mdbc/MDBCUtilsTest.java0
-rwxr-xr-x[-rw-r--r--]mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java0
56 files changed, 288 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index ff3bfdd..ff3bfdd 100644..100755
--- a/.gitignore
+++ b/.gitignore
diff --git a/.gitreview b/.gitreview
index e67571d..e67571d 100644..100755
--- a/.gitreview
+++ b/.gitreview
diff --git a/INFO.yaml b/INFO.yaml
index 10c666a..10c666a 100644..100755
--- a/INFO.yaml
+++ b/INFO.yaml
diff --git a/LICENSE b/LICENSE
index 8dada3e..8dada3e 100644..100755
--- a/LICENSE
+++ b/LICENSE
diff --git a/docs/histo_graph.svg b/docs/histo_graph.svg
index e664aaf..e664aaf 100644..100755
--- a/docs/histo_graph.svg
+++ b/docs/histo_graph.svg
diff --git a/docs/redo_arch.svg b/docs/redo_arch.svg
index 680c5ba..680c5ba 100644..100755
--- a/docs/redo_arch.svg
+++ b/docs/redo_arch.svg
diff --git a/docs/specs.md b/docs/specs.md
index 656f045..656f045 100644..100755
--- a/docs/specs.md
+++ b/docs/specs.md
diff --git a/docs/uml.svg b/docs/uml.svg
index 8d6dd52..8d6dd52 100644..100755
--- a/docs/uml.svg
+++ b/docs/uml.svg
diff --git a/mdbc-server/pom.xml b/mdbc-server/pom.xml
index d2e5fd5..f01f90a 100755
--- a/mdbc-server/pom.xml
+++ b/mdbc-server/pom.xml
@@ -34,6 +34,12 @@
</parent>
<dependencies>
+ <dependency>
+ <groupId>org.apache.calcite</groupId>
+ <artifactId>calcite</artifactId>
+ <version>1.11.0</version>
+ <type>pom</type>
+ </dependency>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
diff --git a/mdbc-server/src/main/java/org/onap/music/exceptions/MDBCServiceException.java b/mdbc-server/src/main/java/org/onap/music/exceptions/MDBCServiceException.java
index 63ebbcc..63ebbcc 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/exceptions/MDBCServiceException.java
+++ b/mdbc-server/src/main/java/org/onap/music/exceptions/MDBCServiceException.java
diff --git a/mdbc-server/src/main/java/org/onap/music/exceptions/QueryException.java b/mdbc-server/src/main/java/org/onap/music/exceptions/QueryException.java
index b698a74..b698a74 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/exceptions/QueryException.java
+++ b/mdbc-server/src/main/java/org/onap/music/exceptions/QueryException.java
diff --git a/mdbc-server/src/main/java/org/onap/music/logging/EELFLoggerDelegate.java b/mdbc-server/src/main/java/org/onap/music/logging/EELFLoggerDelegate.java
index d8b5256..d8b5256 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/logging/EELFLoggerDelegate.java
+++ b/mdbc-server/src/main/java/org/onap/music/logging/EELFLoggerDelegate.java
diff --git a/mdbc-server/src/main/java/org/onap/music/logging/format/AppMessages.java b/mdbc-server/src/main/java/org/onap/music/logging/format/AppMessages.java
index 7bb5eca..7bb5eca 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/logging/format/AppMessages.java
+++ b/mdbc-server/src/main/java/org/onap/music/logging/format/AppMessages.java
diff --git a/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorSeverity.java b/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorSeverity.java
index 2d48b2d..2d48b2d 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorSeverity.java
+++ b/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorSeverity.java
diff --git a/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorTypes.java b/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorTypes.java
index 3ac4c97..3ac4c97 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorTypes.java
+++ b/mdbc-server/src/main/java/org/onap/music/logging/format/ErrorTypes.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/ArchiveProcess.java b/mdbc-server/src/main/java/org/onap/music/mdbc/ArchiveProcess.java
index c61d39e..c61d39e 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/ArchiveProcess.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/ArchiveProcess.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java b/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java
index 6bda739..6bda739 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/Configuration.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabaseOperations.java b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabaseOperations.java
index e10fe96..e10fe96 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabaseOperations.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabaseOperations.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java
index e6b4e0e..e6b4e0e 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/DatabasePartition.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/LockId.java b/mdbc-server/src/main/java/org/onap/music/mdbc/LockId.java
index 05483e5..05483e5 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/LockId.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/LockId.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java
index 4d43177..4d43177 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MDBCUtils.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcCallableStatement.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcCallableStatement.java
index b820686..b820686 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcCallableStatement.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcCallableStatement.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
index 352eacf..352eacf 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcConnection.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcPreparedStatement.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcPreparedStatement.java
index fa08d3c..fa08d3c 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcPreparedStatement.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcPreparedStatement.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServer.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServer.java
index d4c0933..d4c0933 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServer.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServer.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServerLogic.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServerLogic.java
index 33c5dbb..33c5dbb 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServerLogic.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcServerLogic.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcStatement.java b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcStatement.java
index 320531f..320531f 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcStatement.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/MdbcStatement.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/Range.java b/mdbc-server/src/main/java/org/onap/music/mdbc/Range.java
index e182368..e182368 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/Range.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/Range.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/RedoRow.java b/mdbc-server/src/main/java/org/onap/music/mdbc/RedoRow.java
index dc46445..dc46445 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/RedoRow.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/RedoRow.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
index 2e47726..2e47726 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/StateManager.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/NodeConfiguration.java b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/NodeConfiguration.java
index fb4656c..fb4656c 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/NodeConfiguration.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/NodeConfiguration.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/TablesConfiguration.java b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/TablesConfiguration.java
index 77df15f..77df15f 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/TablesConfiguration.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/TablesConfiguration.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/config-0.json b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/config-0.json
index 2207a52..2207a52 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/config-0.json
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/config-0.json
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/ranges.json b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/ranges.json
index 2a792e8..2a792e8 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/ranges.json
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/ranges.json
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/tableConfiguration.json b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/tableConfiguration.json
index 383593a..383593a 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/tableConfiguration.json
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/configurations/tableConfiguration.json
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/examples/EtdbTestClient.java b/mdbc-server/src/main/java/org/onap/music/mdbc/examples/EtdbTestClient.java
index 68d836b..68d836b 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/examples/EtdbTestClient.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/examples/EtdbTestClient.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
index 46d41d4..46d41d4 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/mixins/MusicMixin.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/query/Operation.java b/mdbc-server/src/main/java/org/onap/music/mdbc/query/Operation.java
new file mode 100644
index 0000000..6c2d52b
--- /dev/null
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/query/Operation.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START====================================================
+ * org.onap.music.mdbc
+ * =============================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END======================================================
+ */
+
+package org.onap.music.mdbc.query;
+
+public enum Operation {
+
+ INSERT("W"), SELECT("R"), UPDATE("W"), DELETE("W"), TABLE("T");
+
+ String operation;
+
+ String getOperation() {
+ return this.operation;
+ }
+
+ Operation(String operation) {
+ this.operation = operation;
+ }
+
+ } \ No newline at end of file
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java
new file mode 100644
index 0000000..bc9a8fc
--- /dev/null
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/query/QueryProcessor.java
@@ -0,0 +1,245 @@
+/*
+ * ============LICENSE_START====================================================
+ * org.onap.music.mdbc
+ * =============================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END======================================================
+ */
+
+package org.onap.music.mdbc.query;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.calcite.avatica.util.Casing;
+import org.apache.calcite.avatica.util.Quoting;
+import org.apache.calcite.config.Lex;
+import org.apache.calcite.sql.SqlCall;
+import org.apache.calcite.sql.SqlDialect;
+import org.apache.calcite.sql.SqlIdentifier;
+import org.apache.calcite.sql.SqlInsert;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlSelect;
+import org.apache.calcite.sql.SqlSetOption;
+import org.apache.calcite.sql.SqlUpdate;
+import org.apache.calcite.sql.fun.SqlInOperator;
+import org.apache.calcite.sql.parser.SqlParseException;
+import org.apache.calcite.sql.parser.SqlParser;
+import org.apache.calcite.sql.parser.SqlParserImplFactory;
+import org.apache.calcite.sql.parser.impl.SqlParserImpl;
+import org.apache.calcite.sql.util.SqlBasicVisitor;
+import org.apache.calcite.sql.util.SqlShuttle;
+import org.apache.calcite.sql.validate.SqlConformance;
+import org.apache.calcite.sql.validate.SqlConformanceEnum;
+import org.apache.calcite.util.Util;
+import org.onap.music.logging.EELFLoggerDelegate;
+
+import net.sf.jsqlparser.JSQLParserException;
+import net.sf.jsqlparser.parser.CCJSqlParserUtil;
+import net.sf.jsqlparser.statement.delete.Delete;
+import net.sf.jsqlparser.statement.insert.Insert;
+import net.sf.jsqlparser.statement.select.Select;
+import net.sf.jsqlparser.statement.update.Update;
+import net.sf.jsqlparser.util.TablesNamesFinder;
+
+public class QueryProcessor {
+
+ private static EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(QueryProcessor.class);
+
+ public List<String> tables = null;
+
+ public QueryProcessor() {
+
+ }
+
+ protected static SqlParserImplFactory parserImplFactory() {
+ return SqlParserImpl.FACTORY;
+ }
+
+ protected static SqlParser getSqlParser(String sql) {
+ Quoting quoting = Quoting.DOUBLE_QUOTE;
+ Casing unquotedCasing = Casing.TO_UPPER;
+ Casing quotedCasing = Casing.UNCHANGED;
+ SqlConformance conformance = SqlConformanceEnum.DEFAULT;
+
+ return SqlParser.create(sql, SqlParser.configBuilder().setParserFactory(parserImplFactory()).setQuoting(quoting)
+ .setUnquotedCasing(unquotedCasing).setQuotedCasing(quotedCasing).setConformance(conformance).build());
+ }
+
+ public static Map<String, List<String>> parseSqlQuery(String query) throws SqlParseException {
+ Map<String, List<String>> tableOpsMap = new HashMap<>();
+ /*SqlParser parser = SqlParser.create(query);
+ SqlNode sqlNode = parser.parseQuery();*/
+ SqlNode sqlNode = getSqlParser(query).parseStmt();
+
+ SqlBasicVisitor<Void> visitor = new SqlBasicVisitor<Void>() {
+
+ public Void visit(SqlCall call) {
+ if (call.getOperator() instanceof SqlInOperator) {
+ throw new Util.FoundOne(call);
+ }
+ return super.visit(call);
+ }
+
+ };
+
+ // sqlNode.accept(new SqlAnalyzer());
+ sqlNode.accept(visitor);
+
+ if (sqlNode instanceof SqlInsert) {
+ SqlInsert sqlInsert = (SqlInsert) sqlNode;
+ SqlNodeList targetColumnList = sqlInsert.getTargetColumnList();
+ System.out.println("targetColumnList: "+targetColumnList);
+ String tableName = sqlInsert.getTargetTable().toString();
+ List<String> Ops = tableOpsMap.get(tableName);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ Ops.add(Operation.INSERT.getOperation());
+ tableOpsMap.put(tableName, Ops);
+ } else if (sqlNode instanceof SqlUpdate) {
+ SqlUpdate sqlUpdate = (SqlUpdate) sqlNode;
+ String tableName = sqlUpdate.getTargetTable().toString();
+ List<String> Ops = tableOpsMap.get(tableName);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ Ops.add(Operation.UPDATE.getOperation());
+ tableOpsMap.put(tableName, Ops);
+ } else if (sqlNode instanceof SqlSelect) {
+ SqlSelect sqlSelect = (SqlSelect) sqlNode;
+ SqlNodeList selectList = sqlSelect.getSelectList();
+ String tables = sqlSelect.getFrom().toString();
+ String[] tablesArr = tables.split(",");
+
+ SqlNode where = sqlSelect.getWhere();
+
+ for (String table : tablesArr) {
+ String[] split = table.split("`");
+ String tableName = split[1];
+ List<String> Ops = tableOpsMap.get(tableName);
+ if (Ops == null) Ops = new ArrayList<>();
+ if (where == null) {
+ Ops.add(Operation.TABLE.getOperation());
+ tableOpsMap.put(split[1], Ops);
+ } else {
+ Ops.add(Operation.SELECT.getOperation());
+ tableOpsMap.put(split[1], Ops);
+ }
+ }
+ }
+
+ return tableOpsMap;
+ }
+
+ public static Map<String, List<String>> extractTableFromQuery(String sqlQuery) {
+ List<String> tables = null;
+ Map<String, List<String>> tableOpsMap = new HashMap<>();
+ try {
+ net.sf.jsqlparser.statement.Statement stmt = CCJSqlParserUtil.parse(sqlQuery);
+ if (stmt instanceof Insert) {
+ Insert s = (Insert) stmt;
+ String tbl = s.getTable().getName();
+ List<String> Ops = tableOpsMap.get(tbl);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ Ops.add(Operation.INSERT.getOperation());
+ tableOpsMap.put(tbl, Ops);
+ logger.debug(EELFLoggerDelegate.applicationLogger, "Inserting into table: " + tbl);
+ } else {
+ String tbl;
+ String where = "";
+ if (stmt instanceof Update) {
+ Update u = (Update) stmt;
+ tbl = u.getTables().get(0).getName();
+ List<String> Ops = tableOpsMap.get(tbl);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ if (u.getWhere() != null) {
+ where = u.getWhere().toString();
+ logger.debug(EELFLoggerDelegate.applicationLogger, "Updating table: " + tbl);
+ Ops.add(Operation.UPDATE.getOperation());
+ } else {
+ Ops.add(Operation.TABLE.getOperation());
+ }
+ tableOpsMap.put(tbl, Ops);
+ } else if (stmt instanceof Delete) {
+ Delete d = (Delete) stmt;
+ tbl = d.getTable().getName();
+ List<String> Ops = tableOpsMap.get(tbl);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ if (d.getWhere() != null) {
+ where = d.getWhere().toString();
+ Ops.add(Operation.DELETE.getOperation());
+ } else {
+ Ops.add(Operation.TABLE.getOperation());
+ }
+ tableOpsMap.put(tbl, Ops);
+ logger.debug(EELFLoggerDelegate.applicationLogger, "Deleting from table: " + tbl);
+ } else if (stmt instanceof Select) {
+ TablesNamesFinder tablesNamesFinder = new TablesNamesFinder();
+ tables = tablesNamesFinder.getTableList(stmt);
+ for (String table : tables) {
+ List<String> Ops = tableOpsMap.get(table);
+ if (Ops == null)
+ Ops = new ArrayList<>();
+ Ops.add(Operation.SELECT.getOperation());
+ tableOpsMap.put(table, Ops);
+ }
+ } else {
+ logger.error(EELFLoggerDelegate.errorLogger, "Not recognized sql type");
+ tbl = "";
+ }
+ }
+ } catch (JSQLParserException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return tableOpsMap;
+ }
+
+ public static void main(String[] args) throws SqlParseException {
+ String sqlQuery = "SELECT name, age FROM table1 t1, table2 t2 WHERE t1.id = t2.id";
+ // Map<String, List<String>> tableOpsMap = extractTableFromQuery(sqlQuery);
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "SELECT name, age FROM table1, table2 t2 WHERE id = t2.id";
+ // Map<String, List<String>> tableOpsMap = extractTableFromQuery(sqlQuery);
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "SELECT name, age FROM table1 t1";
+ // Map<String, List<String>> tableOpsMap = extractTableFromQuery(sqlQuery);
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "INSERT INTO Employees (id, name) values ('1','Vikram')";
+ // tableOpsMap = extractTableFromQuery(sqlQuery);
+ // System.out.println(tableOpsMap);
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "UPDATE Employees SET id = 1 WHERE id = 2";
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "UPDATE Employees SET id = 1";
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ sqlQuery = "UPDATE table1 SET id = 1";
+ System.out.println(parseSqlQuery(sqlQuery));
+
+ }
+
+}
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MriReference.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MriReference.java
index 61c7bf1..61c7bf1 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MriReference.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MriReference.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicRangeInformationRow.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicRangeInformationRow.java
index 6b67e5c..6b67e5c 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicRangeInformationRow.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicRangeInformationRow.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicTxDigestId.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicTxDigestId.java
index 33952e0..33952e0 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicTxDigestId.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/MusicTxDigestId.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/Operation.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/Operation.java
index 0c68575..0c68575 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/Operation.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/Operation.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/OperationType.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/OperationType.java
index 696f642..696f642 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/OperationType.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/OperationType.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/PartitionInformation.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/PartitionInformation.java
index 6724860..6724860 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/PartitionInformation.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/PartitionInformation.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/StagingTable.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/StagingTable.java
index d080c54..d080c54 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/StagingTable.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/StagingTable.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/TxCommitProgress.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/TxCommitProgress.java
index 575c9d3..575c9d3 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tables/TxCommitProgress.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tables/TxCommitProgress.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tests/ConnectionTest.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tests/ConnectionTest.java
index 2a8c45f..2a8c45f 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tests/ConnectionTest.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tests/ConnectionTest.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreateNodeConfigurations.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreateNodeConfigurations.java
index 00f6616..00f6616 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreateNodeConfigurations.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreateNodeConfigurations.java
diff --git a/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreatePartition.java b/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreatePartition.java
index d515539..d515539 100644..100755
--- a/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreatePartition.java
+++ b/mdbc-server/src/main/java/org/onap/music/mdbc/tools/CreatePartition.java
diff --git a/mdbc-server/src/main/resources/logback.xml b/mdbc-server/src/main/resources/logback.xml
index df02405..df02405 100644..100755
--- a/mdbc-server/src/main/resources/logback.xml
+++ b/mdbc-server/src/main/resources/logback.xml
diff --git a/mdbc-server/src/main/resources/mdbc_driver.properties b/mdbc-server/src/main/resources/mdbc_driver.properties
index 487feb3..487feb3 100644..100755
--- a/mdbc-server/src/main/resources/mdbc_driver.properties
+++ b/mdbc-server/src/main/resources/mdbc_driver.properties
diff --git a/mdbc-server/src/main/resources/music.properties b/mdbc-server/src/main/resources/music.properties
index 201651e..201651e 100644..100755
--- a/mdbc-server/src/main/resources/music.properties
+++ b/mdbc-server/src/main/resources/music.properties
diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/DatabaseOperationsTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/DatabaseOperationsTest.java
index 07c1451..07c1451 100644..100755
--- a/mdbc-server/src/test/java/org/onap/music/mdbc/DatabaseOperationsTest.java
+++ b/mdbc-server/src/test/java/org/onap/music/mdbc/DatabaseOperationsTest.java
diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/MDBCUtilsTest.java b/mdbc-server/src/test/java/org/onap/music/mdbc/MDBCUtilsTest.java
index a02578e..a02578e 100644..100755
--- a/mdbc-server/src/test/java/org/onap/music/mdbc/MDBCUtilsTest.java
+++ b/mdbc-server/src/test/java/org/onap/music/mdbc/MDBCUtilsTest.java
diff --git a/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java b/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java
index 3f8bd65..3f8bd65 100644..100755
--- a/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java
+++ b/mdbc-server/src/test/java/org/onap/music/mdbc/TestUtils.java