ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject incubator-ignite git commit: # IGNITE-32: Use primitives for not null columns by default.
Date Tue, 27 Jan 2015 06:30:08 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-32 48d553092 -> f304e00c6


# IGNITE-32: Use primitives for not null columns by default.


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

Branch: refs/heads/ignite-32
Commit: f304e00c624c298b1fb348fdda36a090046614c4
Parents: 48d5530
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Tue Jan 27 13:30:08 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Tue Jan 27 13:30:08 2015 +0700

----------------------------------------------------------------------
 .../apache/ignite/schema/model/PojoField.java   | 24 ++++++++++++++++++++
 .../schema/parser/DatabaseMetadataParser.java   | 19 ++++++++--------
 .../org/apache/ignite/schema/ui/Controls.java   |  2 +-
 .../apache/ignite/schema/ui/SchemaLoadApp.java  | 12 +++++++---
 4 files changed, 44 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f304e00c/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
index 2f497d9..b85908b 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/model/PojoField.java
@@ -31,9 +31,15 @@ import static java.sql.Types.*;
  * Field descriptor with properties for JavaFX GUI bindings.
  */
 public class PojoField {
+    /** If this field should be used for code generation. */
+    private final BooleanProperty use;
+
     /** If this field belongs to primary key. */
     private final BooleanProperty key;
 
+    /** If this field is an affinity key. */
+    private final BooleanProperty ak;
+
     /** If this field initially belongs to primary key. */
     private final boolean keyPrev;
 
@@ -150,8 +156,12 @@ public class PojoField {
     public PojoField(boolean key, CacheQueryTypeDescriptor desc, boolean nullable) {
         keyPrev = key;
 
+        use = new SimpleBooleanProperty(true);
+
         this.key = new SimpleBooleanProperty(key);
 
+        ak = new SimpleBooleanProperty(false);
+
         javaNamePrev = desc.getJavaName();
 
         javaName = new SimpleStringProperty(javaNamePrev);
@@ -350,6 +360,13 @@ public class PojoField {
     }
 
     /**
+     * @return Boolean property support for {@code use} property.
+     */
+    public BooleanProperty useProperty() {
+        return use;
+    }
+
+    /**
      * @return Boolean property support for {@code key} property.
      */
     public BooleanProperty keyProperty() {
@@ -357,6 +374,13 @@ public class PojoField {
     }
 
     /**
+     * @return Boolean property support for {@code affinityKey} property.
+     */
+    public BooleanProperty affinityKeyProperty() {
+        return ak;
+    }
+
+    /**
      * @return String property support for {@code javaName} property.
      */
     public StringProperty javaNameProperty() {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f304e00c/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index 98ad4c2..3e51d2d 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -75,32 +75,33 @@ public class DatabaseMetadataParser {
      * Convert JDBC data type to java type.
      *
      * @param type JDBC SQL data type.
+     * @param nullable {@code true} if {@code NULL} is allowed for this field in database.
      * @return Java data type.
      */
-    private static Class<?> dataType(int type) {
+    private static Class<?> dataType(int type, boolean nullable) {
         switch (type) {
             case BIT:
             case BOOLEAN:
-                return Boolean.class;
+                return nullable ? Boolean.class : boolean.class;
 
             case TINYINT:
-                return Byte.class;
+                return nullable ? Byte.class : byte.class;
 
             case SMALLINT:
-                return Short.class;
+                return nullable ? Short.class : short.class;
 
             case INTEGER:
-                return Integer.class;
+                return nullable ? Integer.class : int.class;
 
             case BIGINT:
-                return Long.class;
+                return nullable ? Long.class : int.class;
 
             case REAL:
-                return Float.class;
+                return nullable ? Float.class : float.class;
 
             case FLOAT:
             case DOUBLE:
-                return Double.class;
+                return nullable ? Double.class : double.class;
 
             case NUMERIC:
             case DECIMAL:
@@ -191,7 +192,7 @@ public class DatabaseMetadataParser {
 
                 String javaName = toJavaFieldName(dbName);
 
-                Class<?> javaType = dataType(dbType);
+                Class<?> javaType = dataType(dbType, nullable);
 
                 CacheQueryTypeDescriptor desc = new CacheQueryTypeDescriptor(javaName, javaType,
dbName, dbType);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f304e00c/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
----------------------------------------------------------------------
diff --git a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
index 177c9f5..a5f324d 100644
--- a/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
+++ b/modules/schema-load/src/main/java/org/apache/ignite/schema/ui/Controls.java
@@ -415,7 +415,7 @@ public class Controls {
      * @return New {@code TableColumn} instance.
      */
     public static <S> TableColumn<S, Boolean> booleanColumn(String colName, String
propName, String tip) {
-        TableColumn<S, Boolean> col = tableColumn(colName, propName, tip, 70, 70, true);
+        TableColumn<S, Boolean> col = tableColumn(colName, propName, tip, 50, 50, true);
 
         col.setCellFactory(CheckBoxTableCellEx.<S>cellFactory());
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/f304e00c/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 2ab8cc2..2b18cd1 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
@@ -642,9 +642,15 @@ public class SchemaLoadApp extends Application {
 
         pojosTbl = tableView("Tables not found in database", useCol, keyClsCol, valClsCol);
 
+        TableColumn<PojoField, Boolean> useFldCol = booleanColumn("Use", "use",
+            "If checked then this field will used for XML and POJO generation");
+
         TableColumn<PojoField, Boolean> keyCol = booleanColumn("Key", "key",
             "If checked then this field will be part of key object");
 
+        TableColumn<PojoField, Boolean> akCol = booleanColumn("AK", "affinityKey",
+            "If checked then this field will be marked with @CacheAffinityKeyMapped annotation
in generated POJO");
+
         TableColumn<PojoField, String> dbNameCol = tableColumn("DB Name", "dbName",
"Field name in database");
 
         TableColumn<PojoField, String> dbTypeNameCol = tableColumn("DB Type", "dbTypeName",
"Field type in database");
@@ -667,7 +673,7 @@ public class SchemaLoadApp extends Application {
             "Field java type in POJO class", JavaTypeCell.cellFactory());
 
         final TableView<PojoField> fieldsTbl = tableView("Select table to see table
columns",
-            keyCol, dbNameCol, dbTypeNameCol, javaNameCol, javaTypeNameCol);
+            useFldCol, keyCol, akCol, dbNameCol, dbTypeNameCol, javaNameCol, javaTypeNameCol);
 
         genPnl.add(splitPane(pojosTbl, fieldsTbl, 0.6), 3);
 
@@ -851,8 +857,8 @@ public class SchemaLoadApp extends Application {
 
         primaryStage.setScene(scene(rootPane));
 
-        primaryStage.setWidth(600);
-        primaryStage.setMinWidth(600);
+        primaryStage.setWidth(650);
+        primaryStage.setMinWidth(650);
 
         primaryStage.setHeight(650);
         primaryStage.setMinHeight(650);


Mime
View raw message