# IGNITE-330 reworked for demo.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0bee444a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0bee444a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0bee444a Branch: refs/heads/ignite-497-stick Commit: 0bee444ac72a1fb19687792e55d8f6ad3cd052b1 Parents: 6aa1a01 Author: AKuznetsov <akuznet...@gridgain.com> Authored: Mon Mar 23 12:28:45 2015 +0700 Committer: AKuznetsov <akuznet...@gridgain.com> Committed: Mon Mar 23 12:28:45 2015 +0700 ---------------------------------------------------------------------- bin/ignite-schema-import.bat | 71 +++++++++++----- bin/ignite-schema-import.sh | 28 ++++--- examples/schema-import/README.txt | 18 +++- examples/schema-import/bin/db-init.sql | 9 ++ examples/schema-import/bin/schema-import.bat | 88 -------------------- .../schema-import/bin/schema-import.properties | 30 +++++++ examples/schema-import/bin/schema-import.sh | 57 ------------- modules/schema-import/pom.xml | 6 ++ .../ignite/schema/generator/CodeGenerator.java | 10 +-- .../ignite/schema/generator/XmlGenerator.java | 14 ++-- .../ignite/schema/ui/SchemaImportApp.java | 63 ++++++++++---- .../schema/test/AbstractSchemaImportTest.java | 19 +---- 12 files changed, 188 insertions(+), 225 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/bin/ignite-schema-import.bat ---------------------------------------------------------------------- diff --git a/bin/ignite-schema-import.bat b/bin/ignite-schema-import.bat index 864b6b4..c7cfc0e 100644 --- a/bin/ignite-schema-import.bat +++ b/bin/ignite-schema-import.bat @@ -16,7 +16,7 @@ :: :: -:: Ignite Schema Import Utility. +:: Starts Ignite Schema Import Utility. :: @echo off @@ -24,34 +24,30 @@ if "%OS%" == "Windows_NT" setlocal :: Check JAVA_HOME. -if defined JAVA_HOME goto checkJdk - echo %0, ERROR: - echo JAVA_HOME environment variable is not found. - echo Please point JAVA_HOME variable to location of JDK 1.7 or JDK 1.8. - echo You can also download latest JDK at http://java.com/download. +if not "%JAVA_HOME%" == "" goto checkJdk + echo %0, ERROR: JAVA_HOME environment variable is not found. + echo %0, ERROR: Please create JAVA_HOME variable pointing to location of JDK 1.7 or JDK 1.8. + echo %0, ERROR: You can also download latest JDK at: http://java.sun.com/getjava goto error_finish :checkJdk :: Check that JDK is where it should be. if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion - echo %0, ERROR: - echo JAVA is not found in JAVA_HOME=%JAVA_HOME%. - echo Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8. - echo You can also download latest JDK at http://java.com/download. + echo %0, ERROR: The JDK is not found in %JAVA_HOME%. + echo %0, ERROR: Please modify your script so that JAVA_HOME would point to valid location of JDK. goto error_finish :checkJdkVersion "%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr "1\.[78]\." > nul if %ERRORLEVEL% equ 0 goto checkIgniteHome1 - echo %0, ERROR: - echo The version of JAVA installed in %JAVA_HOME% is incorrect. - echo Please point JAVA_HOME variable to installation of JDK 1.7 or JDK 1.8. - echo You can also download latest JDK at http://java.com/download. + echo %0, ERROR: The version of JAVA installed in %JAVA_HOME% is incorrect. + echo %0, ERROR: Please install JDK 1.7 or 1.8. + echo %0, ERROR: You can also download latest JDK at: http://java.sun.com/getjava goto error_finish :: Check IGNITE_HOME. :checkIgniteHome1 -if defined IGNITE_HOME goto checkIgniteHome2 +if not "%IGNITE_HOME%" == "" goto checkIgniteHome2 pushd "%~dp0"/.. set IGNITE_HOME=%CD% popd @@ -70,27 +66,58 @@ set IGNITE_HOME=%IGNITE_HOME:~0,-1% goto checkIgniteHome2 :checkIgniteHome3 -if exist "%IGNITE_HOME%\config" goto run +if exist "%IGNITE_HOME%\config" goto checkIgniteHome4 echo %0, ERROR: Ignite installation folder is not found or IGNITE_HOME environment variable is not valid. echo Please create IGNITE_HOME environment variable pointing to location of echo Ignite installation folder. goto error_finish +:checkIgniteHome4 + +:: +:: Set SCRIPTS_HOME - base path to scripts. +:: +set SCRIPTS_HOME=%IGNITE_HOME%\bin + +:: Remove trailing spaces +for /l %%a in (1,1,31) do if /i "%SCRIPTS_HOME:~-1%" == " " set SCRIPTS_HOME=%SCRIPTS_HOME:~0,-1% + +if /i "%SCRIPTS_HOME%\" == "%~dp0" goto run + echo %0, WARN: IGNITE_HOME environment variable may be pointing to wrong folder: %IGNITE_HOME% + :run :: -:: Set CLASS PATH. +:: Set IGNITE_LIBS :: -set CP=%JAVA_HOME%\jre\lib\jfxrt.jar;%IGNITE_HOME%\bin\include\schema-import\* +call "%SCRIPTS_HOME%\include\setenv.bat" +call "%SCRIPTS_HOME%\include\target-classpath.bat" &:: Will be removed in release. +set CP=%JAVA_HOME%/jre/lib/jfxrt.jar;%IGNITE_HOME%\bin\include\schema-import/*;%IGNITE_LIBS% :: -:: JVM options. See http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp for more details. +:: Parse command line parameters. :: -:: ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE +call "%SCRIPTS_HOME%\include\parseargs.bat" %* +if %ERRORLEVEL% neq 0 ( + echo Arguments parsing failed + exit /b %ERRORLEVEL% +) + :: -if "%JVM_OPTS%" == "" set JVM_OPTS=-Xms256m -Xmx1g +:: Set program name. +:: +set PROG_NAME=ignite-schema-import.bat +if "%OS%" == "Windows_NT" set PROG_NAME=%~nx0% + +:: +:: Program args. +:: +if "%ARGS%" == "" set ARGS=%* -"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "%CP%" org.apache.ignite.schema.ui.SchemaImportApp %* +:: +:: Starts Ignite Schema Import Utility. +:: +"%JAVA_HOME%\bin\java.exe" %JVM_OPTS% -cp "%CP%" org.apache.ignite.schema.ui.SchemaImportApp %ARGS% :error_finish http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/bin/ignite-schema-import.sh ---------------------------------------------------------------------- diff --git a/bin/ignite-schema-import.sh b/bin/ignite-schema-import.sh index abc8dfa..ca4b713 100755 --- a/bin/ignite-schema-import.sh +++ b/bin/ignite-schema-import.sh @@ -17,9 +17,9 @@ # # -# Ignite Schema Import Utility. +# Starts Ignite Schema Import Utility. # - + # # Import common functions. # @@ -46,11 +46,23 @@ checkJava setIgniteHome # -# Set CLASS PATH. +# Parse command line parameters. +# +. "${SCRIPTS_HOME}"/include/parseargs.sh + +# +# Set IGNITE_LIBS. # . "${SCRIPTS_HOME}"/include/setenv.sh . "${SCRIPTS_HOME}"/include/target-classpath.sh # Will be removed in release. -CP="${JAVA_HOME}/jre/lib/jfxrt.jar${SEP}${IGNITE_HOME}/bin/include/schema-import/*" +CP="${JAVA_HOME}/jre/lib/jfxrt.jar${SEP}${IGNITE_HOME}/bin/include/schema-import/*${SEP}${IGNITE_LIBS}" + +# +# JVM options. See http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp for more details. +# +# ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE +# +JVM_OPTS="-Xms256m -Xmx1g -XX:MaxPermSize=128M ${JVM_OPTS}" # Mac OS specific support to display correct name in the dock. osname=`uname` @@ -60,14 +72,8 @@ if [ "${DOCK_OPTS}" == "" ]; then fi # -# JVM options. See http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp for more details. +# Starts Ignite Schema Import Utility. # -# ADD YOUR/CHANGE ADDITIONAL OPTIONS HERE -# -if [ -z "$JVM_OPTS" ] ; then - JVM_OPTS="-Xms256m -Xmx1g" -fi - case $osname in Darwin*) "$JAVA" ${JVM_OPTS} "${DOCK_OPTS}" -cp "${CP}" org.apache.ignite.schema.ui.SchemaImportApp "$@" http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/examples/schema-import/README.txt ---------------------------------------------------------------------- diff --git a/examples/schema-import/README.txt b/examples/schema-import/README.txt index 5000d2a..fb28230 100644 --- a/examples/schema-import/README.txt +++ b/examples/schema-import/README.txt @@ -10,6 +10,20 @@ support for integrating with persistence stores. This utility automatically conn the underlying database and generates all the required XML OR-mapping configuration and Java domain model POJOs. -For information on how to get started with Apache Ignite Schema Import Utility please visit: +Schema Import Utility Demo +========================== - http://apacheignite.readme.io/v1.0/docs/automatic-persistence +1. Start H2 database: "examples/schema-import/bin/h2-server.sh" + H2 database will start and H2 Console will be opened in your default browser. + Paste content of "examples/schema-import/bin/db-init.sql" into H2 Console and execute. + +2. Start Schema Import utility: "bin/ignite-schema-import.sh -customPrefs=examples/schema-import/bin/schema-import.properties" + Schema Utility will start with predifined settings for this demo. + Click "Next", "Generate" and answer "Yes" to override warning. + +3. Import "examples/schema-import/pom.xml" in your Java IDE. + Run "Demo.java" example. + +For more information on how to get started with Apache Ignite Schema Import Utility please visit: + + http://apacheignite.readme.io/docs/automatic-persistence http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/examples/schema-import/bin/db-init.sql ---------------------------------------------------------------------- diff --git a/examples/schema-import/bin/db-init.sql b/examples/schema-import/bin/db-init.sql new file mode 100644 index 0000000..c7175f2 --- /dev/null +++ b/examples/schema-import/bin/db-init.sql @@ -0,0 +1,9 @@ +-- Script of database initialization for Schema Import Demo. +create table PERSON(id integer not null, first_name varchar(50), last_name varchar(50), PRIMARY KEY(id)); + +insert into PERSON(id, first_name, last_name) values(1, 'Johannes', 'Kepler'); +insert into PERSON(id, first_name, last_name) values(2, 'Galileo', 'Galilei'); +insert into PERSON(id, first_name, last_name) values(3, 'Henry', 'More'); +insert into PERSON(id, first_name, last_name) values(4, 'Polish', 'Brethren'); +insert into PERSON(id, first_name, last_name) values(5, 'Robert', 'Boyle'); +insert into PERSON(id, first_name, last_name) values(6, 'Isaac', 'Newton'); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/examples/schema-import/bin/schema-import.bat ---------------------------------------------------------------------- diff --git a/examples/schema-import/bin/schema-import.bat b/examples/schema-import/bin/schema-import.bat deleted file mode 100644 index 18bf01d..0000000 --- a/examples/schema-import/bin/schema-import.bat +++ /dev/null @@ -1,88 +0,0 @@ -:: -:: Licensed to the Apache Software Foundation (ASF) under one or more -:: contributor license agreements. See the NOTICE file distributed with -:: this work for additional information regarding copyright ownership. -:: The ASF licenses this file to You 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. -:: - -:: -:: Starts Ignite Schema Import Wizard with predefined settings for the demo. -:: - -@echo off - -if "%OS%" == "Windows_NT" setlocal - -:: Check JAVA_HOME. -if not "%JAVA_HOME%" == "" goto checkJdk - echo %0, ERROR: JAVA_HOME environment variable is not found. - echo %0, ERROR: Please create JAVA_HOME variable pointing to location of JDK 1.7 or JDK 1.8. - echo %0, ERROR: You can also download latest JDK at: http://java.sun.com/getjava -goto error_finish - -:checkJdk -:: Check that JDK is where it should be. -if exist "%JAVA_HOME%\bin\java.exe" goto checkJdkVersion - echo %0, ERROR: The JDK is not found in %JAVA_HOME%. - echo %0, ERROR: Please modify your script so that JAVA_HOME would point to valid location of JDK. -goto error_finish - -:checkJdkVersion -"%JAVA_HOME%\bin\java.exe" -version 2>&1 | findstr "1\.[78]\." > nul -if %ERRORLEVEL% equ 0 goto checkIgniteHome1 - echo %0, ERROR: The version of JAVA installed in %JAVA_HOME% is incorrect. - echo %0, ERROR: Please install JDK 1.7 or 1.8. - echo %0, ERROR: You can also download latest JDK at: http://java.sun.com/getjava -goto error_finish - -:: Check IGNITE_HOME. -:checkIgniteHome1 -if not "%IGNITE_HOME%" == "" goto checkIgniteHome2 - pushd "%~dp0"/../../.. - set IGNITE_HOME=%CD% - popd - -:checkIgniteHome2 -:: Strip double quotes from IGNITE_HOME -set IGNITE_HOME=%IGNITE_HOME:"=% - -:: remove all trailing slashes from IGNITE_HOME. -if %IGNITE_HOME:~-1,1% == \ goto removeTrailingSlash -if %IGNITE_HOME:~-1,1% == / goto removeTrailingSlash -goto checkIgniteHome3 - -:removeTrailingSlash -set IGNITE_HOME=%IGNITE_HOME:~0,-1% -goto checkIgniteHome2 - -:checkIgniteHome3 -if exist "%IGNITE_HOME%\config" goto run - echo %0, ERROR: Ignite installation folder is not found or IGNITE_HOME environment variable is not valid. - echo Please create IGNITE_HOME environment variable pointing to location of - echo Ignite installation folder. - goto error_finish - -:run - -:: Starts Ignite Schema Import Wizard with settings for demo. -"%IGNITE_HOME%\bin\ignite-schema-import.bat" ^ - jdbc.db.preset=0 ^ - jdbc.driver.jar="%IGNITE_HOME%\libs\ignite-indexing\h2-1.3.175.jar" ^ - jdbc.driver.class=org.h2.Driver ^ - jdbc.url="jdbc:h2:tcp://localhost/%IGNITE_HOME%\examples\schema-import\demo" ^ - jdbc.user=sa ^ - out.folder="%IGNITE_HOME%\examples\schema-import\src\main\java" ^ - pojo.package=org.apache.ignite.schema ^ - pojo.constructor=true - -:error_finish http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/examples/schema-import/bin/schema-import.properties ---------------------------------------------------------------------- diff --git a/examples/schema-import/bin/schema-import.properties b/examples/schema-import/bin/schema-import.properties new file mode 100644 index 0000000..1ab14da --- /dev/null +++ b/examples/schema-import/bin/schema-import.properties @@ -0,0 +1,30 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You 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. +# + +######################################################################### +# +# Predifined properties for Ignite Schema Import Demo +# +######################################################################### +jdbc.db.preset=0 +jdbc.driver.jar=%IGNITE_HOME%/libs/ignite-indexing/h2-1.3.175.jar +jdbc.driver.class=org.h2.Driver +jdbc.url=jdbc:h2:tcp://localhost/%IGNITE_HOME%/examples/schema-import/demo +jdbc.user=sa +out.folder=%IGNITE_HOME%/examples/schema-import/src/main/java +pojo.package=org.apache.ignite.schema +pojo.constructor=true http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/examples/schema-import/bin/schema-import.sh ---------------------------------------------------------------------- diff --git a/examples/schema-import/bin/schema-import.sh b/examples/schema-import/bin/schema-import.sh deleted file mode 100755 index 7517abb..0000000 --- a/examples/schema-import/bin/schema-import.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You 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. -# - -# -# Starts Ignite Schema Import Wizard with predefined settings for the demo. -# - -# -# Import common functions. -# -if [ "${IGNITE_HOME}" = "" ]; - then IGNITE_HOME_TMP="$(dirname "$(cd "$(dirname "$0")/../.."; "pwd")")"; - else IGNITE_HOME_TMP=${IGNITE_HOME}; -fi - -# -# Set SCRIPTS_HOME - base path to scripts. -# -SCRIPTS_HOME="${IGNITE_HOME_TMP}/bin" - -source "${SCRIPTS_HOME}"/include/functions.sh - -# -# Discover path to Java executable and check it's version. -# -checkJava - -# -# Discover IGNITE_HOME environment variable. -# -setIgniteHome - -# Starts Ignite Schema Import Wizard with settings for this demo. -"${IGNITE_HOME}/bin/ignite-schema-import.sh" \ - jdbc.db.preset=0 \ - jdbc.driver.jar="${IGNITE_HOME}/libs/ignite-indexing/h2-1.3.175.jar" \ - jdbc.driver.class=org.h2.Driver \ - jdbc.url="jdbc:h2:tcp://localhost/${IGNITE_HOME}/examples/schema-import/demo" \ - jdbc.user=sa \ - out.folder="${IGNITE_HOME}/examples/schema-import/src/main/java" \ - pojo.package=org.apache.ignite.schema \ - pojo.constructor=true http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/modules/schema-import/pom.xml ---------------------------------------------------------------------- diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml index 61a99a8..bbfc61d 100644 --- a/modules/schema-import/pom.xml +++ b/modules/schema-import/pom.xml @@ -37,6 +37,12 @@ <dependencies> <dependency> + <groupId>org.apache.ignite</groupId> + <artifactId>ignite-core</artifactId> + <version>${ignite.version}</version> + </dependency> + + <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.3.175</version> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java index 5d26ec8..a10bea7 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java @@ -479,10 +479,10 @@ public class CodeGenerator { String outFolder, ConfirmCallable askOverwrite) throws IOException { File pkgFolder = new File(outFolder, pkg.replace('.', File.separatorChar)); - File configurationSnippet = new File(pkgFolder, "ConfigurationSnippet.java"); + File cacheConfig = new File(pkgFolder, "CacheConfig.java"); - if (configurationSnippet.exists()) { - MessageBox.Result choice = askOverwrite.confirm(configurationSnippet.getName()); + if (cacheConfig.exists()) { + MessageBox.Result choice = askOverwrite.confirm(cacheConfig.getName()); if (CANCEL == choice) throw new IllegalStateException("Java snippet generation was canceled!"); @@ -495,7 +495,7 @@ public class CodeGenerator { header(src, pkg, "org.apache.ignite.cache.*;org.apache.ignite.cache.store.*;" + "org.apache.ignite.cache.store.jdbc.*;;javax.sql.*;java.sql.Types;java.util.*;", - "ConfigurationSnippet", "ConfigurationSnippet"); + "CacheConfig", "CacheConfig"); add1(src, "/** Configure cache store. */"); add1(src, "public static CacheStore store() {"); @@ -551,6 +551,6 @@ public class CodeGenerator { add0(src, "}"); - write(src, configurationSnippet); + write(src, cacheConfig); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java index 0c9e78f..85b9275 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java @@ -17,6 +17,8 @@ package org.apache.ignite.schema.generator; +import org.apache.ignite.cache.*; +import org.apache.ignite.lang.*; import org.apache.ignite.schema.model.*; import org.apache.ignite.schema.ui.*; import org.w3c.dom.*; @@ -65,12 +67,12 @@ public class XmlGenerator { * * @param doc XML document. * @param parent Parent XML node. - * @param cls Bean class name. + * @param cls Bean class. */ - private static Element addBean(Document doc, Node parent, String cls) { + private static Element addBean(Document doc, Node parent, Class<?> cls) { Element elem = doc.createElement("bean"); - elem.setAttribute("class", cls); + elem.setAttribute("class", cls.getName()); parent.appendChild(elem); @@ -154,7 +156,7 @@ public class XmlGenerator { Element list = addElement(doc, prop, "list"); for (PojoField field : fields) { - Element item = addBean(doc, list, "org.apache.ignite.cache.CacheTypeFieldMetadata"); + Element item = addBean(doc, list, CacheTypeFieldMetadata.class); addProperty(doc, item, "databaseName", field.dbName()); Element dbType = addProperty(doc, item, "databaseType", null); @@ -208,7 +210,7 @@ public class XmlGenerator { for (Map.Entry<String, IndexItem> field : fields.entrySet()) { Element entry2 = addElement(doc, val1, "entry", "key", field.getKey()); - Element val2 = addBean(doc, entry2, "org.apache.ignite.lang.IgniteBiTuple"); + Element val2 = addBean(doc, entry2, IgniteBiTuple.class); IndexItem idx = field.getValue(); @@ -229,7 +231,7 @@ public class XmlGenerator { */ private static void addTypeMetadata(Document doc, Node parent, String pkg, PojoDescriptor pojo, boolean includeKeys) { - Element bean = addBean(doc, parent, "org.apache.ignite.cache.CacheTypeMetadata"); + Element bean = addBean(doc, parent, CacheTypeMetadata.class); addProperty(doc, bean, "databaseSchema", pojo.schema()); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java index 6096adb..a6d0ffa 100644 --- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java +++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java @@ -28,6 +28,8 @@ import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.*; import javafx.util.*; +import org.apache.ignite.internal.util.io.*; +import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.schema.generator.*; import org.apache.ignite.schema.model.*; import org.apache.ignite.schema.parser.*; @@ -37,6 +39,7 @@ import java.net.*; import java.sql.*; import java.util.*; import java.util.concurrent.*; +import java.util.logging.*; import static javafx.embed.swing.SwingFXUtils.*; import static org.apache.ignite.schema.ui.Controls.*; @@ -46,6 +49,9 @@ import static org.apache.ignite.schema.ui.Controls.*; */ @SuppressWarnings("UnnecessaryFullyQualifiedName") public class SchemaImportApp extends Application { + /** Logger. */ + private static final Logger log = Logger.getLogger(SchemaImportApp.class.getName()); + /** Presets for database settings. */ private static class Preset { /** Name in preferences. */ @@ -155,6 +161,9 @@ public class SchemaImportApp extends Application { PREF_NAMING_PATTERN, PREF_NAMING_REPLACE }; + /** */ + private static final String CUSTOM_PREFS = "-customPrefs="; + /** */ private Stage owner; @@ -1308,19 +1317,6 @@ public class SchemaImportApp extends Application { prefs.put(key, String.valueOf(val)); } - /** - * Override parameter in preferences. - * - * @param key Parameter name in preferences. - * @param val Value specified in application parameters. - */ - private void overrideParam(String key, String val) { - String param = key + "="; - - if (val.startsWith(param)) - prefs.setProperty(key, val.substring(param.length())); - } - /** {@inheritDoc} */ @Override public void start(Stage primaryStage) { owner = primaryStage; @@ -1329,14 +1325,45 @@ public class SchemaImportApp extends Application { try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(prefsFile))) { prefs.load(in); } - catch (IOException ignore) { - // No-op. + catch (IOException e) { + log.log(Level.SEVERE, "Failed to load preferences. Default preferences will be used", e); } // Override params. - for (String arg : getParameters().getRaw()) - for (String pref : PREFS) - overrideParam(pref, arg); + for (String arg : getParameters().getRaw()) { + if (arg.startsWith(CUSTOM_PREFS)) { + String customPrefsFileName = arg.substring(CUSTOM_PREFS.length()); + + if (customPrefsFileName.isEmpty()) + log.log(Level.WARNING, "Path to file with custom preferences is not specified."); + else { + File customPrefsFile = U.resolveIgnitePath(customPrefsFileName); + + if (customPrefsFile == null) + log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " + + customPrefsFile); + else { + Properties customPrefs = new Properties(); + + try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(customPrefsFile))) { + customPrefs.load(in); + } + catch (IOException e) { + log.log(Level.SEVERE, "Failed to load custom preferences.", e); + } + + String igniteHome = GridFilenameUtils.separatorsToUnix(U.getIgniteHome()); + + for (Map.Entry<Object, Object> prop : customPrefs.entrySet()) { + String key = prop.getKey().toString(); + String val = prop.getValue().toString().replaceAll("%IGNITE_HOME%", igniteHome); + + prefs.setProperty(key, val); + } + } + } + } + } // Restore presets. for (Preset preset : presets) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0bee444a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java ---------------------------------------------------------------------- diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java index 09b50c9..0c3ecb1 100644 --- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java +++ b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java @@ -18,6 +18,7 @@ package org.apache.ignite.schema.test; import junit.framework.*; +import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.schema.model.PojoDescriptor; import org.apache.ignite.schema.parser.DatabaseMetadataParser; import org.apache.ignite.schema.ui.*; @@ -48,20 +49,6 @@ public abstract class AbstractSchemaImportTest extends TestCase { /** List of generated for test database POJO objects. */ protected List<PojoDescriptor> pojos; - /** - * Quietly closes given resource ignoring possible checked exception. - * - * @param rsrc Resource to close. - */ - private void closeQuiet(AutoCloseable rsrc) { - try { - rsrc.close(); - } - catch (Exception ignored) { - // No-op. - } - } - /** {@inheritDoc} */ @Override public void setUp() throws Exception { Class.forName("org.h2.Driver"); @@ -104,11 +91,11 @@ public abstract class AbstractSchemaImportTest extends TestCase { conn.commit(); - closeQuiet(stmt); + U.closeQuiet(stmt); pojos = DatabaseMetadataParser.parse(conn, false); - closeQuiet(conn); + U.closeQuiet(conn); } /**