ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [56/79] [abbrv] incubator-ignite git commit: # IGNITE-411 Fixed Oracle dialect.
Date Fri, 06 Mar 2015 06:49:08 GMT
# IGNITE-411 Fixed Oracle dialect.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/aba2b55b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/aba2b55b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/aba2b55b

Branch: refs/heads/ignite-45
Commit: aba2b55b0f8f076b097babdff137d0d55ab5e8d5
Parents: ae413fb
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Thu Mar 5 17:35:44 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Thu Mar 5 17:35:44 2015 +0700

----------------------------------------------------------------------
 .../parser/dialect/OracleMetadataDialect.java   | 66 +++++++++++++-------
 .../org/apache/ignite/schema/ui/MessageBox.java |  7 +++
 2 files changed, 52 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aba2b55b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
index 307d608..6b16042 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/dialect/OracleMetadataDialect.java
@@ -42,10 +42,11 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
         " WHERE a.owner = ? and a.table_name = ? AND a.constraint_type = 'P'";
 
     /** SQL to get indexes metadata. */
-    private static final String SQL_INDEXES = "select index_name, column_name, descend" +
-        " FROM all_ind_columns" +
-        " WHERE index_owner = ? and table_name = ?" +
-        " ORDER BY index_name, column_position";
+    private static final String SQL_INDEXES = "select i.index_name, u.column_expression,
i.column_name, i.descend" +
+        " FROM all_ind_columns i" +
+        " LEFT JOIN user_ind_expressions u on u.index_name = i.index_name and i.table_name
= u.table_name" +
+        " WHERE i.index_owner = ? and i.table_name = ?" +
+        " ORDER BY i.index_name, i.column_position";
 
     /** Owner index. */
     private static final int OWNER_IDX = 1;
@@ -71,11 +72,14 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
     /** Index name index. */
     private static final int IDX_NAME_IDX = 1;
 
+    /** Index name index. */
+    private static final int IDX_EXPR_IDX = 2;
+
     /** Index column name index. */
-    private static final int IDX_COL_NAME_IDX = 2;
+    private static final int IDX_COL_NAME_IDX = 3;
 
     /** Index column sort order index. */
-    private static final int IDX_COL_DESCEND_IDX = 3;
+    private static final int IDX_COL_DESCEND_IDX = 4;
 
     /**
      * @param rs Result set with column type metadata from Oracle database.
@@ -155,10 +159,20 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
         return OTHER;
     }
 
+    /**
+     * Retrieve primary key columns.
+     *
+     * @param stmt Prepared SQL statement to execute.
+     * @param owner DB owner.
+     * @param tbl Table name.
+     * @return Primary key columns.
+     * @throws SQLException If failed to retrieve primary key columns.
+     */
     private Set<String> primaryKeys(PreparedStatement stmt, String owner, String tbl)
throws SQLException {
         Set<String> pkCols = new HashSet<>();
 
-        stmt.setString(1, tbl);
+        stmt.setString(1, owner);
+        stmt.setString(2, tbl);
 
         try (ResultSet pkRs = stmt.executeQuery()) {
             while(pkRs.next())
@@ -168,6 +182,15 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
         return pkCols;
     }
 
+    /**
+     * Retrieve index columns.
+     *
+     * @param stmt Prepared SQL statement to execute.
+     * @param owner DB owner.
+     * @param tbl Table name.
+     * @return Index columns.
+     * @throws SQLException If failed to retrieve indexe columns.
+     */
     private Map<String, Map<String, Boolean>> indexes(PreparedStatement stmt,
String owner, String tbl)
         throws SQLException {
         Map<String, Map<String, Boolean>> idxs = new LinkedHashMap<>();
@@ -187,7 +210,11 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
                     idxs.put(idxName, idx);
                 }
 
-                idx.put(idxsRs.getString(IDX_COL_NAME_IDX), "DESC".equals(idxsRs.getString(IDX_COL_DESCEND_IDX)));
+                String expr = idxsRs.getString(IDX_EXPR_IDX);
+
+                String col = expr == null ? idxsRs.getString(IDX_COL_NAME_IDX) : expr.replaceAll("\"",
"");
+
+                idx.put(col, "DESC".equals(idxsRs.getString(IDX_COL_DESCEND_IDX)));
             }
         }
 
@@ -217,28 +244,25 @@ public class OracleMetadataDialect extends DatabaseMetadataDialect {
                 String prevSchema = "";
                 String prevTbl = "";
 
+                boolean first = true;
+
                 while (colsRs.next()) {
                     String owner = colsRs.getString(OWNER_IDX);
                     String tbl = colsRs.getString(TBL_NAME_IDX);
 
-                    if (!prevSchema.equals(owner) || !prevTbl.equals(tbl)) {
-                        pkCols = primaryKeys(pkStmt, owner, tbl);
+                    boolean changed = !owner.equals(prevSchema) || !tbl.equals(prevTbl);
 
-                        idxs = indexes(idxStmt, owner, tbl);
-                    }
+                    if (changed) {
+                        if (first)
+                            first = false;
+                        else
+                            tbls.add(table(prevSchema, prevTbl, cols, idxs));
 
-                    if (prevSchema.isEmpty()) {
                         prevSchema = owner;
                         prevTbl = tbl;
-                    }
-
-                    if (!owner.equals(prevSchema) || !tbl.equals(prevTbl)) {
-                        tbls.add(new DbTable(prevSchema, prevTbl, cols, null, null, null));
// TODO !!!
-
-                        prevSchema = owner;
-                        prevTbl = tbl;
-
                         cols = new ArrayList<>();
+                        pkCols = primaryKeys(pkStmt, owner, tbl);
+                        idxs = indexes(idxStmt, owner, tbl);
                     }
 
                     String colName = colsRs.getString(COL_NAME_IDX);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/aba2b55b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
index 07cbf05..cf6a705 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
@@ -23,12 +23,17 @@ import javafx.scene.control.*;
 import javafx.scene.layout.*;
 import javafx.stage.*;
 
+import java.util.logging.*;
+
 import static org.apache.ignite.schema.ui.Controls.*;
 
 /**
  * Message box functionality.
  */
 public class MessageBox extends ModalDialog {
+    /** Logger. */
+    private static final Logger log = Logger.getLogger(MessageBox.class.getName());
+
     /** Message box type. */
     private enum MessageType {
         /** Information. */
@@ -232,6 +237,8 @@ public class MessageBox extends ModalDialog {
      * @param e Optional exception to show.
      */
     public static void errorDialog(Stage owner, String msg, Throwable e) {
+        log.log(Level.SEVERE, msg, e);
+
         String exMsg = e != null ? (e.getMessage() != null ? e.getMessage() : e.getClass().getName())
: null;
 
         showDialog(owner, MessageType.ERROR, exMsg != null ? msg + "\n" + exMsg : msg, false);


Mime
View raw message