You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2014/12/23 11:22:29 UTC
[1/2] incubator-ignite git commit: # ignite-32 WIP: Added type
descriptor with DB info.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-32 61b81e75e -> b935c61b9
# ignite-32 WIP: Added type descriptor with DB info.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5b63a475
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5b63a475
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5b63a475
Branch: refs/heads/ignite-32
Commit: 5b63a4757deef836281643f9bac5794d80b5a25c
Parents: 61b81e7
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Dec 23 17:22:02 2014 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Dec 23 17:22:02 2014 +0700
----------------------------------------------------------------------
.../query/GridCacheQueryTypeDescriptor.java | 77 +++++++++++++++++++
.../cache/query/GridCacheQueryTypeMetadata.java | 79 ++++++++++++++++++--
.../ignite/schema/db/DbMetadataParser.java | 13 +++-
3 files changed, 161 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b63a475/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
new file mode 100644
index 0000000..1aefe66
--- /dev/null
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeDescriptor.java
@@ -0,0 +1,77 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.gridgain.grid.cache.query;
+
+/**
+ * Type descriptor for field in database
+ */
+public class GridCacheQueryTypeDescriptor {
+ /** Column name in database. */
+ private String colName;
+
+ /** Column JDBC type in database. */
+ private int colJdbcType;
+
+ /** Corresponding java type. */
+ private Class<?> type;
+
+ /**
+ * @param colName Column name in database.
+ * @param colJdbcType Column JDBC type in database.
+ * @param type Corresponding java type.
+ */
+ public GridCacheQueryTypeDescriptor(String colName, int colJdbcType, Class<?> type) {
+ this.colName = colName;
+ this.colJdbcType = colJdbcType;
+ this.type = type;
+ }
+
+ /**
+ * @return Column name in database.
+ */
+ public String getColumnName() {
+ return colName;
+ }
+
+ /**
+ * @param colName Column name in database.
+ */
+ public void setColumnName(String colName) {
+ this.colName = colName;
+ }
+
+ /**
+ * @return Column JDBC type in database.
+ */
+ public int getColumnJdbcType() {
+ return colJdbcType;
+ }
+
+ /**
+ * @param colJdbcType Column JDBC type in database.
+ */
+ public void setColumnJdbcType(int colJdbcType) {
+ this.colJdbcType = colJdbcType;
+ }
+
+ /**
+ * @return Corresponding java type.
+ */
+ public Class<?> getType() {
+ return type;
+ }
+
+ /**
+ * @param type Corresponding java type.
+ */
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b63a475/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeMetadata.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeMetadata.java b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeMetadata.java
index b213a18..9223f43 100644
--- a/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeMetadata.java
+++ b/modules/core/src/main/java/org/gridgain/grid/cache/query/GridCacheQueryTypeMetadata.java
@@ -20,13 +20,22 @@ import java.util.*;
*/
public class GridCacheQueryTypeMetadata {
/** Type name, e.g. class name. */
- @GridToStringInclude
private String type;
+ /** Schema name in database. */
+ private String schema;
+
+ /** Table name in database. */
+ private String tbl;
+
/** Fields to be queried, in addition to indexed fields. */
@GridToStringInclude
private Map<String, Class<?>> qryFlds;
+ /** Type descriptors. */
+ @GridToStringInclude
+ private Map<String, GridCacheQueryTypeDescriptor> typeDescs;
+
/** Fields to index in ascending order. */
@GridToStringInclude
private Map<String, Class<?>> ascFlds;
@@ -48,6 +57,7 @@ public class GridCacheQueryTypeMetadata {
*/
public GridCacheQueryTypeMetadata() {
qryFlds = new LinkedHashMap<>();
+ typeDescs = new LinkedHashMap<>();
ascFlds = new LinkedHashMap<>();
descFlds = new LinkedHashMap<>();
txtFlds = new LinkedHashSet<>();
@@ -59,13 +69,16 @@ public class GridCacheQueryTypeMetadata {
*/
public GridCacheQueryTypeMetadata(GridCacheQueryTypeMetadata src) {
type = src.getType();
+ schema = src.getSchema();
+ tbl = src.getTableName();
- qryFlds = new HashMap<>(src.getQueryFields());
- ascFlds = new HashMap<>(src.getAscendingFields());
- descFlds = new HashMap<>(src.getDescendingFields());
- txtFlds = new HashSet<>(src.getTextFields());
+ qryFlds = new LinkedHashMap<>(src.getQueryFields());
+ typeDescs = new LinkedHashMap<>(src.getTypeDescriptors());
+ ascFlds = new LinkedHashMap<>(src.getAscendingFields());
+ descFlds = new LinkedHashMap<>(src.getDescendingFields());
+ txtFlds = new LinkedHashSet<>(src.getTextFields());
- grps = new HashMap<>(src.getGroups());
+ grps = new LinkedHashMap<>(src.getGroups());
}
/**
@@ -96,6 +109,60 @@ public class GridCacheQueryTypeMetadata {
}
/**
+ * Gets database schema name.
+ *
+ * @return Schema name.
+ */
+ public String getSchema() {
+ return schema;
+ }
+
+ /**
+ * Sets database schema name.
+ *
+ * @param schema Schema name.
+ */
+ public void setSchema(String schema) {
+ this.schema = schema;
+ }
+
+ /**
+ * Gets table name in database.
+ *
+ * @return Table name in database.
+ */
+ public String getTableName() {
+ return tbl;
+ }
+
+ /**
+ * Table name in database.
+ *
+ * @param tbl Table name in database.
+ */
+ public void setTableName(String tbl) {
+ this.tbl = tbl;
+ }
+
+ /**
+ * Gets database type descriptors.
+ *
+ * @return Map of type descriptors.
+ */
+ public Map<String, GridCacheQueryTypeDescriptor> getTypeDescriptors() {
+ return typeDescs;
+ }
+
+ /**
+ * Sets database types descriptors.
+ *
+ * @param typeDescs Map of type descriptors.
+ */
+ public void setTypeDescriptors(Map<String, GridCacheQueryTypeDescriptor> typeDescs) {
+ this.typeDescs = typeDescs;
+ }
+
+ /**
* Gets query-enabled fields.
*
* @return Collection of fields available for query.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5b63a475/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 e7e2cb9..0368140 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
@@ -135,7 +135,11 @@ public class DbMetadataParser {
public GridCacheQueryTypeMetadata parse(String catalog, String schema, String tbl) throws SQLException {
GridCacheQueryTypeMetadata res = new GridCacheQueryTypeMetadata();
+ res.setSchema(schema);
+ res.setTableName(tbl);
+
Map<String, Class<?>> qryFields = res.getQueryFields();
+ Map<String, GridCacheQueryTypeDescriptor> typeDescs = res.getTypeDescriptors();
Map<String, Class<?>> ascFields = res.getAscendingFields();
Map<String, Class<?>> descFields = res.getDescendingFields();
Map<String, LinkedHashMap<String, IgniteBiTuple<Class<?>, Boolean>>> groups = res.getGroups();
@@ -145,9 +149,14 @@ public class DbMetadataParser {
ResultSet flds = meta.getColumns(catalog, schema, tbl, null);
while (flds.next()) {
- String col = toJavaFieldName(flds.getString(4));
+ String dbName = flds.getString(4);
+ int jdbcType = flds.getInt(5);
+
+ String col = toJavaFieldName(dbName);
+ Class<?> type = dataType(jdbcType);
- qryFields.put(col, dataType(flds.getInt(5)));
+ qryFields.put(col, type);
+ typeDescs.put(col, new GridCacheQueryTypeDescriptor(dbName, jdbcType, type));
}
ResultSet idxs = meta.getIndexInfo(catalog, schema, tbl, false, true);
[2/2] incubator-ignite git commit: # ignite-32 WIP: Working on UI.
Posted by sb...@apache.org.
# ignite-32 WIP: Working on UI.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/b935c61b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/b935c61b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/b935c61b
Branch: refs/heads/ignite-32
Commit: b935c61b940b61bcc432a2ec66ec796d705e0688
Parents: 5b63a47
Author: AKuznetsov <ak...@gridgain.com>
Authored: Tue Dec 23 17:22:28 2014 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Tue Dec 23 17:22:28 2014 +0700
----------------------------------------------------------------------
.../org/apache/ignite/schema/ui/GridPaneEx.java | 94 ++++++++++++++++++++
.../apache/ignite/schema/ui/SchemaLoadApp.java | 92 ++++++++++---------
2 files changed, 144 insertions(+), 42 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b935c61b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
new file mode 100644
index 0000000..127c53c
--- /dev/null
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
@@ -0,0 +1,94 @@
+/* @java.file.header */
+
+/* _________ _____ __________________ _____
+ * __ ____/___________(_)______ /__ ____/______ ____(_)_______
+ * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
+ * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
+ * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
+ */
+
+package org.apache.ignite.schema.ui;
+
+import javafx.scene.*;
+import javafx.scene.control.*;
+import javafx.scene.layout.*;
+
+/**
+ * Utility extention of {@code GridPane}.
+ */
+public class GridPaneEx extends GridPane {
+ /**
+ * Add percent columns.
+ *
+ * @param cols Array of column percentages.
+ */
+ public void addPercentColumns(double ... cols) {
+ for (double col : cols) {
+ ColumnConstraints cc = new ColumnConstraints();
+ cc.setPercentWidth(col);
+
+ getColumnConstraints().add(cc);
+ }
+ }
+
+ /**
+ * Add label to grid pane.
+ *
+ * @param text Label text.
+ * @param colIx Column index position for the label within the grid pane.
+ * @param rowIx Row index position for the label within the grid pane.
+ * @return Label instance.
+ */
+ public Label addLabel(String text, int colIx, int rowIx) {
+ Label lb = new Label(text);
+
+ add(lb, colIx, rowIx);
+
+ return lb;
+ }
+
+ /**
+ * Add text field to gridpane.
+ *
+ * @param colIx Column index position for the text field within the grid pane.
+ * @param rowIx Row index position for the the text field within the grid pane.
+ * @return new label instance.
+ */
+ public TextField addTextField(int colIx, int rowIx) {
+ TextField tf = new TextField();
+
+ add(tf, colIx, rowIx);
+
+ return tf;
+ }
+
+ /**
+ * Add label and text field to gridpane.
+ *
+ * @param text Label text.
+ * @param colIx Column index position for the label within the grid pane.
+ * @param rowIx Row index position for the the label within the grid pane.
+ * @return New text field instance.
+ */
+ public TextField addTextField(String text, int colIx, int rowIx) {
+ return addLabeled(text, new TextField(), colIx, rowIx);
+ }
+
+ /**
+ * Add control with label.
+ *
+ * @param text Label text.
+ * @param ctrl Control to add.
+ * @param colIx Column index position for the label within the grid pane.
+ * @param rowIx Row index position for the the label within the grid pane.
+ * @return Added control.
+ */
+ public <T extends Node> T addLabeled(String text, T ctrl, int colIx, int rowIx) {
+ Label lb = new Label(text);
+
+ add(lb, colIx, rowIx);
+ add(ctrl, colIx + 1, rowIx);
+
+ return ctrl;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/b935c61b/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 b2e1d39..e7e061d 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
@@ -28,10 +28,10 @@ import java.util.*;
*/
public class SchemaLoadApp extends Application {
/** */
- private static Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
+ private static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
/** */
- private int step = 0;
+ private int step;
/** */
private BorderPane contentPane;
@@ -48,6 +48,11 @@ public class SchemaLoadApp extends Application {
/** */
private List<WizardPage> pages;
+ /**
+ * Create new {@code HBox} with default padding.
+ * @param spacing Amount of horizontal space between each child.
+ * @return New {@code HBox} instance.
+ */
private static HBox newHBox(int spacing) {
HBox hb = new HBox(spacing);
@@ -56,17 +61,32 @@ public class SchemaLoadApp extends Application {
return hb;
}
- private abstract class WizardPage {
+ /**
+ * Base class for wizard pages.
+ */
+ private abstract static class WizardPage {
+ /** */
protected Pane contentPane;
-
+ /** */
protected final String title;
+ /**
+ * @param title Page title.
+ */
protected WizardPage(String title) {
this.title = title;
}
+ /**
+ * Create wizard pane content.
+ *
+ * @return New pane instance with controls.
+ */
protected abstract Pane createContent();
+ /**
+ * @return Wizard page with controls.
+ */
protected Pane content() {
if (contentPane == null)
contentPane = createContent();
@@ -76,90 +96,78 @@ public class SchemaLoadApp extends Application {
}
- private class DbChooserPage extends WizardPage {
- public DbChooserPage() {
+ /**
+ * Wizard page for selecting DB settings.
+ */
+ private static class DbChooserPage extends WizardPage {
+ /**
+ * Create page.
+ */
+ private DbChooserPage() {
super("Choose Database");
}
+ /** {@inheritDoc} */
@Override protected Pane createContent() {
- GridPane gp = new GridPane();
-
- gp.setGridLinesVisible(true);
+ GridPaneEx gp = new GridPaneEx();
- ColumnConstraints col1 = new ColumnConstraints();
- col1.setPercentWidth(30);
- ColumnConstraints col2 = new ColumnConstraints();
- col2.setPercentWidth(70);
- gp.getColumnConstraints().addAll(col1, col2);
+ gp.addPercentColumns(30, 70);
gp.setAlignment(Pos.CENTER);
gp.setHgap(10);
gp.setVgap(10);
gp.setPadding(DFLT_PADDING);
- Label aliasLb = new Label("Alias:");
- gp.add(aliasLb, 0, 0);
+ gp.addLabel("Alias:", 0, 0);
ObservableList<String> options = FXCollections.observableArrayList("My Settings");
ComboBox<String> aliasCb = new ComboBox<>(options);
aliasCb.setPromptText("Schema load settings");
aliasCb.setEditable(true);
+ aliasCb.setMaxWidth(Double.MAX_VALUE);
gp.add(aliasCb, 1, 0);
- Label jdbcLb = new Label("JDBC Driver:");
- gp.add(jdbcLb, 0, 2);
-
- TextField jdbcTf = new TextField();
- gp.add(jdbcTf, 1, 2);
-
- Label urlLb = new Label("URL:");
- gp.add(urlLb, 0, 3);
-
- TextField urlTf = new TextField();
- gp.add(urlTf, 1, 3);
-
- Label userLb = new Label("User:");
- gp.add(userLb, 0, 4);
+ TextField jdbcTf = gp.addTextField("JDBC Driver:", 0, 2);
- TextField userTf = new TextField();
- gp.add(userTf, 1, 4);
+ TextField urlTf = gp.addTextField("URL:", 0, 3);
- Label pwdLb = new Label("Password:");
- gp.add(pwdLb, 0, 5);
+ TextField userTf = gp.addTextField("User:", 0, 4);
- PasswordField pwdTf = new PasswordField();
- gp.add(pwdTf, 1, 5);
+ PasswordField pwdTf = gp.addLabeled("Password:", new PasswordField(), 0, 5);
return gp;
}
}
- private class SelectTablesPage extends WizardPage {
- public SelectTablesPage() {
+ private static class SelectTablesPage extends WizardPage {
+ private SelectTablesPage() {
super("Select tables");
}
+ /** {@inheritDoc} */
@Override protected Pane createContent() {
return new HBox();
}
}
- private class ImportDbSchemaPage extends WizardPage {
- public ImportDbSchemaPage() {
+ private static class ImportDbSchemaPage extends WizardPage {
+ private ImportDbSchemaPage() {
super("Import Database Schema");
}
+ /** {@inheritDoc} */
@Override protected Pane createContent() {
return new HBox();
}
}
- private class GeneratePage extends WizardPage {
- public GeneratePage() {
+ private static class GeneratePage extends WizardPage {
+ private GeneratePage() {
super("Generate");
}
+ /** {@inheritDoc} */
@Override protected Pane createContent() {
HBox hb = new HBox();