ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject incubator-ignite git commit: # IGNITE-32 WIP: Option for separate key fields from value object.
Date Mon, 29 Dec 2014 03:21:15 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 037f556ae -> 7fe676d80


# IGNITE-32 WIP: Option for separate key fields from value object.


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

Branch: refs/heads/ignite-32
Commit: 7fe676d80590ad8d8c82a098e965a3b84f54f21b
Parents: 037f556
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Mon Dec 29 10:21:17 2014 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Mon Dec 29 10:21:17 2014 +0700

----------------------------------------------------------------------
 .../ignite/schema/db/DbMetadataParser.java      | 20 ++++++----
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 39 ++++++++++++++------
 2 files changed, 41 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7fe676d8/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
index 8d3bb9a..1d0176c 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/db/DbMetadataParser.java
@@ -103,11 +103,12 @@ public class DbMetadataParser {
      * @param catalog Catalog name.
      * @param schema Schema name.
      * @param tbl Table name.
+     * @param separate If {@code true} separate key fields from value fields.
      * @return New initialized instance of {@code GridCacheQueryTypeMetadata}.
      * @throws SQLException If parsing failed.
      */
-    private static GridCacheQueryTypeMetadata parse(DatabaseMetaData meta, String catalog,
String schema, String tbl)
-        throws SQLException {
+    private static GridCacheQueryTypeMetadata parse(DatabaseMetaData meta, String catalog,
String schema, String tbl,
+        boolean separate) throws SQLException {
         GridCacheQueryTypeMetadata res = new GridCacheQueryTypeMetadata();
 
         res.setSchema(schema);
@@ -141,10 +142,14 @@ public class DbMetadataParser {
 
                 GridCacheQueryTypeDescriptor desc = new GridCacheQueryTypeDescriptor(javaName,
javaType, dbName, dbType);
 
-                if (pkFlds.contains(dbName))
+                if (pkFlds.contains(dbName)) {
                     keyDescs.add(desc);
 
-                valDescs.add(desc);
+                    if (!separate)
+                        valDescs.add(desc);
+                }
+                else
+                    valDescs.add(desc);
 
                 qryFields.put(javaName, javaType);
             }
@@ -186,11 +191,12 @@ public class DbMetadataParser {
      * Parse database metadata.
      *
      * @param conn Connection to database.
+     * @param separate If {@code true} separate key fields from value fields.
      * @return Map with schemes and tables metadata.
      * @throws SQLException If parsing failed.
      */
-    public static LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
parse(Connection conn)
-        throws SQLException {
+    public static LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
parse(Connection conn,
+        boolean separate) throws SQLException {
         DatabaseMetaData meta = conn.getMetaData();
 
         LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
res = new LinkedHashMap<>();
@@ -206,7 +212,7 @@ public class DbMetadataParser {
                     while (tbls.next()) {
                         String tbl = tbls.getString(3);
 
-                        items.put(tbl, parse(meta, catalog, schema, tbl));
+                        items.put(tbl, parse(meta, catalog, schema, tbl, separate));
                     }
                 }
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7fe676d8/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
index 4861171..bff3c85 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/SchemaLoadApp.java
@@ -79,13 +79,13 @@ public class SchemaLoadApp extends Application {
     private CheckBox pojoConstructorCh;
 
     /** */
-    private CheckBox xmlSingleFileCh;
+    private CheckBox pojoSeparateKeyCh;
 
     /** */
-    private GridPaneEx genPnl;
+    private CheckBox xmlSingleFileCh;
 
     /** */
-    private LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
schemas;
+    private GridPaneEx genPnl;
 
     /**
      * Fill tree with database metadata.
@@ -106,15 +106,22 @@ public class SchemaLoadApp extends Application {
             }
 
             try (Connection conn = DriverManager.getConnection(urlTf.getText(), userTf.getText(),
pwdTf.getText())) {
-                schemas = DbMetadataParser.parse(conn);
+                DatabaseMetaData meta = conn.getMetaData();
 
-                for (Map.Entry<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
schema : schemas.entrySet()) {
-                    CheckBoxTreeItem<String> schemaItem = new CheckBoxTreeItem<>(schema.getKey());
+                try (ResultSet schemas = meta.getSchemas()) {
+                    while(schemas.next()) {
+                        String schema = schemas.getString(1);
+                        String catalog = schemas.getString(2);
 
-                    rootItem.getChildren().add(schemaItem);
+                        CheckBoxTreeItem<String> schemaItem = new CheckBoxTreeItem<>(schema);
 
-                    for (String tbl : schema.getValue().keySet())
-                        schemaItem.getChildren().add(new CheckBoxTreeItem<>(tbl));
+                        rootItem.getChildren().add(schemaItem);
+
+                        try (ResultSet tbls = meta.getTables(catalog, schema, "%", null))
{
+                            while(tbls.next())
+                                schemaItem.getChildren().add(new CheckBoxTreeItem<>(tbls.getString(3)));
+                        }
+                    }
                 }
             }
 
@@ -139,13 +146,18 @@ public class SchemaLoadApp extends Application {
 
             List<GridCacheQueryTypeMetadata> all = new ArrayList<>();
 
+            LinkedHashMap<String, LinkedHashMap<String, GridCacheQueryTypeMetadata>>
metas;
+
+            try (Connection conn = DriverManager.getConnection(urlTf.getText(), userTf.getText(),
pwdTf.getText())) {
+                metas = DbMetadataParser.parse(conn, pojoSeparateKeyCh.isSelected());
+            }
+
             boolean constructor = pojoConstructorCh.isSelected();
 
             for (TreeItem<String> schemeItem : rootItem.getChildren()) {
                 for (TreeItem<String> tblItem : schemeItem.getChildren()) {
                     if (((CheckBoxTreeItem)tblItem).isSelected()) {
-                        GridCacheQueryTypeMetadata meta = schemas.get(schemeItem.getValue())
-                            .get(tblItem.getValue());
+                        GridCacheQueryTypeMetadata meta = metas.get(schemeItem.getValue()).get(tblItem.getValue());
 
                         all.add(meta);
 
@@ -265,6 +277,8 @@ public class SchemaLoadApp extends Application {
 
         pwdTf = connPnl.addLabeled("Password:", new PasswordField());
 
+        connPnl.add(new Text("Put JDBC driver jar file into '/drivers' folder."), 2);
+
         // Generation pane.
         genPnl = new GridPaneEx(DFLT_PADDING);
 
@@ -278,6 +292,7 @@ public class SchemaLoadApp extends Application {
         genPnl.addRow();
         genPnl.addRow();
         genPnl.addRow();
+        genPnl.addRow();
 
         rootItem = new CheckBoxTreeItem<>("Database");
         rootItem.setExpanded(true);
@@ -318,6 +333,8 @@ public class SchemaLoadApp extends Application {
             }
         }));
 
+        pojoSeparateKeyCh = genPnl.add(checkBox("Separate Key Fields For POJOs", true), 3);
+
         pojoConstructorCh = genPnl.add(checkBox("Generate Constructors For POJOs", false),
3);
 
         xmlSingleFileCh = genPnl.add(checkBox("Write All Configurations To Single File",
true), 3);


Mime
View raw message