[Jiemamy-notify:1977] commit [3135] テストDB接続まわりの整備。 /

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 6日 (月) 19:12:58 JST


Revision: 3135
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3135
Author:   daisuke_m
Date:     2009-04-06 19:12:57 +0900 (Mon, 06 Apr 2009)

Log Message:
-----------
テストDB接続まわりの整備。 /
refactor

Modified Paths:
--------------
    artemis/trunk/jiemamy-artemis-test/pom.xml
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DriverUtil.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ResourceTraversal.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/swap/SwapObject.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer.java
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer2.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/ImportMetadataConfig.java

Added Paths:
-----------
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstanceTest.java
    artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DefaultDatabaseConnectionConfig.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/DatabaseConnectionConfig.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-artemis-test/pom.xml
===================================================================
--- artemis/trunk/jiemamy-artemis-test/pom.xml	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-artemis-test/pom.xml	2009-04-06 10:12:57 UTC (rev 3135)
@@ -76,13 +76,18 @@
       <artifactId>jiemamy-dialect-postgresql</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jiemamy-dialect-oracle</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jiemamy-dialect-mysql</artifactId>
+      <version>${project.version}</version>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
-      <artifactId>jiemamy-dialect-mysql</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>${project.groupId}</groupId>
       <artifactId>jiemamy-dialect-sql99</artifactId>
       <version>${project.version}</version>
     </dependency>

Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -22,24 +22,22 @@
 import static org.hamcrest.Matchers.notNullValue;
 import static org.junit.Assert.assertThat;
 
-import java.io.File;
-import java.io.InputStream;
 import java.net.URL;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.jiemamy.composer.exporter.DefaultSqlExportConfig;
-import org.jiemamy.dialect.postgresql.PostgresqlDialect;
+import org.jiemamy.dialect.Dialect;
 import org.jiemamy.internal.test.TestModelEntry;
 import org.jiemamy.internal.test.TestModelsTestBase;
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.sql.SqlStatement;
+import org.jiemamy.utils.DatabaseConnectionConfig;
 import org.jiemamy.utils.DriverUtil;
 import org.jiemamy.utils.JmIOUtil;
 import org.jiemamy.utils.SqlExecuter;
@@ -58,60 +56,58 @@
 	public void doTest(TestModelEntry entry) throws Exception {
 		Jiemamy jiemamy = entry.getBuiltModel();
 		
-		RootModel rootModel = jiemamy.getFactory().getRootModel();
-		rootModel.setDialectClassName(PostgresqlDialect.class.getName());
-		
-		DefaultSqlExportConfig config = new DefaultSqlExportConfig();
-		config.setEmitDropStatements(true);
-		config.setDataSetIndex(-1); // FIXME この行削除しても動くように
-		List<SqlStatement> statements = jiemamy.emitStatements(rootModel, config);
-		
-		Properties propFile = new Properties();
-		InputStream in = null;
-		
-		try {
-			in = DatabaseTest.class.getResourceAsStream("/database.properties");
-			if (in == null) {
-				// This accout is only available from Hudson
-				propFile.put("postgres_uri", "jdbc:postgresql://griffon.jiemamy.org:5432/jiemamy01");
-				propFile.put("postgres_user", "jiemamy01");
-				propFile.put("postgres_password", "dummy");
-			} else {
-				propFile.load(in);
-			}
-		} finally {
-			IOUtils.closeQuietly(in);
-		}
-		
-		Connection connection = null;
-		try {
+		for (TestDatabaseInstance db : TestDatabaseInstance.values()) {
+			logger.info("== Database: " + db.name());
 			
-			Properties props = new Properties();
-			props.setProperty("user", propFile.getProperty("postgres_user"));
-			props.setProperty("password", propFile.getProperty("postgres_password"));
+			List<SqlStatement> statements = emitStatements(jiemamy, db);
 			
-			URL[] paths = new URL[] {
-				new File("./src/test/resources/postgresql-8.3-603.jdbc3.jar").toURL()
-			};
-			
-			Driver driver = DriverUtil.getDriverInstance(paths, "org.postgresql.Driver");
-			connection = driver.connect(propFile.getProperty("postgres_uri"), props);
-			
-			assertThat(connection, is(notNullValue()));
-			
-			SqlExecuter executer = new SqlExecuter(connection);
-			
-			for (SqlStatement stmt : statements) {
-				boolean ignoreSqlException = stmt.toString().startsWith("DROP");
-				if (ignoreSqlException) {
-					executer.executeIgnoreSqlException(stmt.toString());
-				} else {
-					executer.execute(stmt.toString());
+			DatabaseConnectionConfig connectionConfig = db.getConfig();
+			Connection connection = null;
+			try {
+				Properties props = new Properties();
+				props.setProperty("user", connectionConfig.getUsername());
+				props.setProperty("password", connectionConfig.getPassword());
+				
+				URL[] paths = connectionConfig.getDriverJarPaths();
+				String className = connectionConfig.getDriverClassName();
+				Driver driver = DriverUtil.getDriverInstance(paths, className);
+				connection = driver.connect(connectionConfig.getUri(), props);
+				
+				assertThat(connection, is(notNullValue()));
+				
+				SqlExecuter executer = new SqlExecuter(connection);
+				
+				for (SqlStatement stmt : statements) {
+					boolean ignoreSqlException = stmt.toString().startsWith("DROP");
+					if (ignoreSqlException) {
+						executer.executeIgnoreSqlException(stmt.toString());
+					} else {
+						executer.execute(stmt.toString());
+					}
 				}
+			} finally {
+				JmIOUtil.closeQuietly(connection);
 			}
-		} finally {
-			JmIOUtil.closeQuietly(connection);
 		}
 	}
 	
+	/**
+	 * SQL文を出力する。
+	 * 
+	 * @param jiemamy 対象のJiemamyコンテキスト
+	 * @param db テストデータベース情報
+	 * @return SQL文のリスト
+	 * @throws ClassNotFoundException {@link RootModel}に設定された{@link Dialect}の実装クラスが見つからない場合
+
+	 */
+	private List<SqlStatement> emitStatements(Jiemamy jiemamy, TestDatabaseInstance db) throws ClassNotFoundException {
+		RootModel rootModel = jiemamy.getFactory().getRootModel();
+		rootModel.setDialectClassName(db.getDialectClassName());
+		
+		DefaultSqlExportConfig exportConfig = new DefaultSqlExportConfig();
+		exportConfig.setEmitDropStatements(false); // TODO trueの場合もテスト
+		exportConfig.setDataSetIndex(-1); // FIXME この行削除しても動くように
+		List<SqlStatement> statements = jiemamy.emitStatements(rootModel, exportConfig);
+		return statements;
+	}
 }

Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -29,8 +29,6 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.CharEncoding;
 import org.apache.commons.lang.SystemUtils;
-import org.junit.After;
-import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -72,40 +70,25 @@
 		list.add("jiemamy-view");
 		list.add("jiemamy-artemis-test");
 		list.add("jiemamy-html-exporter");
+		list.add("jiemamy-jpa-importer");
 		list.add("maven-jiemamy-plugin");
 		list.add("jiemamy-dialect-sql99");
 		list.add("jiemamy-dialect-postgresql");
 		list.add("jiemamy-dialect-mysql");
+		list.add("jiemamy-dialect-oracle");
 		
 		list.add("org.jiemamy.eclipse.core");
 		list.add("org.jiemamy.eclipse.ui");
 		list.add("org.jiemamy.eclipse.dialect.sql99");
 		list.add("org.jiemamy.eclipse.dialect.postgresql");
 		list.add("org.jiemamy.eclipse.dialect.mysql");
+		list.add("org.jiemamy.eclipse.dialect.oracle");
 		
 		projects = list;
 	}
 	
 
 	/**
-	 * テストを初期化する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@Before
-	public void setUp() throws Exception {
-	}
-	
-	/**
-	 * テストの情報を破棄する。
-	 * 
-	 * @throws Exception 例外が発生した場合
-	 */
-	@After
-	public void tearDown() throws Exception {
-	}
-	
-	/**
 	 * 全てのjavaファイルにライセンスコメントがついていること。
 	 * 
 	 * @throws Exception 例外が発生した場合

Added: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java	                        (rev 0)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/06
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed 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.
+ */
+package org.jiemamy;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.dialect.mysql.MySqlDialect;
+import org.jiemamy.dialect.oracle.OracleDialect;
+import org.jiemamy.dialect.postgresql.PostgresqlDialect;
+import org.jiemamy.utils.CollectionsUtil;
+import org.jiemamy.utils.DatabaseConnectionConfig;
+import org.jiemamy.utils.DefaultDatabaseConnectionConfig;
+
+/**
+ * テストに用いるリアルDBインスタンスの接続情報列挙型。
+ * 
+ * @author daisuke
+ */
+public enum TestDatabaseInstance {
+	
+	/** PostgreSQL 8.1 */
+	PostgreSQL(PostgresqlDialect.class),
+
+	/** MySQL 5.?? TODO バージョン確認 */
+	MySQL(MySqlDialect.class),
+
+	/** Oracle Database 10g Express Edition */
+	Oracle(OracleDialect.class),
+
+	;
+	
+	/** SQL方言クラス名 */
+	private final String dialectClassName;
+	
+
+	TestDatabaseInstance(Class<? extends Dialect> dialectClass) {
+		dialectClassName = dialectClass.getName();
+	}
+	
+	/**
+	 * テストDB接続設定を取得する。
+	 * 
+	 * @return テストDB接続設定
+	 * @throws IOException 入出力エラーが発生した場合
+	 */
+	public DatabaseConnectionConfig getConfig() throws IOException {
+		InputStream in = null;
+		try {
+			in = getClass().getResourceAsStream("/database.properties");
+			if (in == null) {
+				in = getClass().getResourceAsStream("/database_hudson.properties");
+			}
+			
+			Properties props = new Properties();
+			props.load(in);
+			
+			String key = name();
+			List<URL> driverJarPaths = CollectionsUtil.newArrayList();
+			for (String path : props.getProperty(key + "_driverJar").split(";")) {
+				driverJarPaths.add(new File(path).toURL());
+			}
+			
+			DefaultDatabaseConnectionConfig config = new DefaultDatabaseConnectionConfig();
+			config.setDriverJarPath(driverJarPaths.toArray(new URL[driverJarPaths.size()]));
+			config.setDriverClassName(props.getProperty(key + "_driverClass"));
+			config.setUri(props.getProperty(key + "_uri"));
+			config.setUsername(props.getProperty(key + "_user"));
+			config.setPassword(props.getProperty(key + "_password"));
+			return config;
+		} finally {
+			IOUtils.closeQuietly(in);
+		}
+	}
+	
+	/**
+	 * SQL方言クラス名を取得する。
+	 * 
+	 * @return SQL方言クラス名
+	 */
+	public String getDialectClassName() {
+		return dialectClassName;
+	}
+}


Property changes on: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstanceTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstanceTest.java	                        (rev 0)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstanceTest.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/06
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed 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.
+ */
+package org.jiemamy;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.util.Properties;
+
+import org.junit.Test;
+
+import org.jiemamy.utils.DatabaseConnectionConfig;
+import org.jiemamy.utils.DriverUtil;
+import org.jiemamy.utils.JmIOUtil;
+
+/**
+ * {@link TestDatabaseInstance}のテストクラス。
+ * 
+ * @author daisuke
+ */
+public class TestDatabaseInstanceTest {
+	
+	/**
+	 * 全てのテストDBに接続できること。
+	 * 
+	 * @throws Exception 例外が発生した場合
+	 */
+	@Test
+	public void test01_全てのテストDBに接続できること() throws Exception {
+		for (TestDatabaseInstance db : TestDatabaseInstance.values()) {
+			DatabaseConnectionConfig config = db.getConfig();
+			Properties props = new Properties();
+			props.setProperty("user", config.getUsername());
+			props.setProperty("password", config.getPassword());
+			
+			URL[] paths = config.getDriverJarPaths();
+			if (existsAll(paths) == false) {
+				// driver jarファイルが見つからない場合、テストをスキップする
+				continue;
+			}
+			String className = config.getDriverClassName();
+			
+			Connection connection = null;
+			try {
+				Driver driver = DriverUtil.getDriverInstance(paths, className);
+				connection = driver.connect(config.getUri(), props);
+				assertThat(connection, is(notNullValue()));
+			} finally {
+				JmIOUtil.closeQuietly(connection);
+			}
+			
+		}
+	}
+	
+	private boolean existsAll(URL[] paths) {
+		for (URL path : paths) {
+			try {
+				File file = new File(path.toURI());
+				if (file.exists() == false) {
+					return false;
+				}
+			} catch (URISyntaxException e) {
+				return false;
+			}
+		}
+		return true;
+	}
+}


Property changes on: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstanceTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties	                        (rev 0)
+++ artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties	2009-04-06 10:12:57 UTC (rev 3135)
@@ -0,0 +1,18 @@
+PostgreSQL_driverJar = ./src/test/resources/postgresql-8.3-603.jdbc3.jar
+PostgreSQL_driverClass = org.postgresql.Driver
+PostgreSQL_uri = jdbc:postgresql://griffon.jiemamy.org:5432/jiemamy01
+PostgreSQL_user = jiemamy01
+PostgreSQL_password = dummy
+
+MySQL_driverJar = TODO
+MySQL_driverClass = com.mysql.jdbc.Driver
+MySQL_uri = jdbc:mysql://griffon.jiemamy.org/jiemamy01
+MySQL_user = jiemamy01
+MySQL_password = dummy
+
+Oracle_driverJar = TODO
+Oracle_driverClass = oracle.jdbc.driver.OracleDriver
+Oracle_uri = jdbc:oracle:thin:@griffon.jiemamy.org:1521:jiemamy01
+Oracle_user = jiemamy01
+Oracle_password = dummy
+


Property changes on: artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -18,65 +18,15 @@
  */
 package org.jiemamy.composer.importer;
 
-import java.net.URL;
-
 import org.jiemamy.composer.ImportConfig;
-import org.jiemamy.dialect.Dialect;
 import org.jiemamy.dialect.ImportMetadataConfig;
+import org.jiemamy.utils.DatabaseConnectionConfig;
 
 /**
  * {@link DatabaseImporter}に関する設定情報インターフェイス。
  * 
  * @author daisuke
  */
-public interface DatabaseImportConfig extends ImportConfig, ImportMetadataConfig {
+public interface DatabaseImportConfig extends ImportConfig, DatabaseConnectionConfig, ImportMetadataConfig {
 	
-	/**
-	 * SQL方言を取得する。
-	 * 
-	 * @return SQL方言. 未設定の場合は{@code null}
-	 */
-	Dialect getDialect();
-	
-	/**
-	 * ドライバの完全修飾クラス名を取得する。
-	 * 
-	 * @return ドライバの完全修飾クラス名. 未設定の場合は{@code null}
-	 */
-	String getDriverClassName();
-	
-	/**
-	 * ドライバJARファイルのパス配列を取得する。
-	 * 
-	 * @return ドライバJARファイルのパス配列. 未設定の場合は{@code null}
-	 */
-	URL[] getDriverJarPath();
-	
-	/**
-	 * 接続パスワードを取得する。
-	 * 
-	 * @return 接続パスワード. 未設定の場合は{@code null}
-	 */
-	String getPassword();
-	
-	/**
-	 * 接続URIを取得する。
-	 * 
-	 * @return 接続URI. 未設定の場合は{@code null}
-	 */
-	String getUri();
-	
-	/**
-	 * 接続ユーザ名を取得する。
-	 * 
-	 * @return 接続ユーザ名. 未設定の場合は{@code null}
-	 */
-	String getUsername();
-	
-	/**
-	 * テーブルのコンテンツをデータセットとしてインポートするかどうかを取得する。
-	 * 
-	 * @return テーブルのコンテンツをデータセットとしてインポートするかどうか
-	 */
-	boolean isImportDataSet();
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -109,7 +109,7 @@
 			props.setProperty("user", config.getUsername());
 			props.setProperty("password", config.getPassword());
 			
-			URL[] paths = config.getDriverJarPath();
+			URL[] paths = config.getDriverJarPaths();
 			String className = config.getDriverClassName();
 			Driver driver = DriverUtil.getDriverInstance(paths, className);
 			connection = driver.connect(config.getUri(), props);

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -18,41 +18,25 @@
  */
 package org.jiemamy.composer.importer;
 
-import java.net.URL;
-
 import org.jiemamy.dialect.Dialect;
+import org.jiemamy.utils.DefaultDatabaseConnectionConfig;
 
 /**
  * {@link DatabaseImporter}に関する設定情報保持クラス。
  * 
  * @author daisuke
  */
-public class DefaultDatabaseImportConfig implements DatabaseImportConfig {
+public class DefaultDatabaseImportConfig extends DefaultDatabaseConnectionConfig implements DatabaseImportConfig {
 	
 	/** SQL方言 */
 	private Dialect dialect;
 	
-	/** ドライバの完全修飾クラス名 */
-	private String driverClassName;
-	
-	/** ドライバJARファイルのパス配列 */
-	private URL[] driverJarPath;
-	
 	/** インポートするエンティティの種類 */
 	private String[] entityTypes;
 	
-	/** 接続パスワード */
-	private String password;
-	
 	/** インポートするエンティティ名の配列 */
 	private String[] selectedEntities;
 	
-	/** 接続URI */
-	private String uri;
-	
-	/** 接続ユーザ名 */
-	private String username;
-	
 	/** スキーマ名 */
 	private String schema;
 	
@@ -64,22 +48,10 @@
 		return dialect;
 	}
 	
-	public String getDriverClassName() {
-		return driverClassName;
-	}
-	
-	public URL[] getDriverJarPath() {
-		return driverJarPath.clone();
-	}
-	
 	public String[] getEntityTypes() {
 		return entityTypes.clone();
 	}
 	
-	public String getPassword() {
-		return password;
-	}
-	
 	public String getSchema() {
 		return schema;
 	}
@@ -88,14 +60,6 @@
 		return selectedEntities.clone();
 	}
 	
-	public String getUri() {
-		return uri;
-	}
-	
-	public String getUsername() {
-		return username;
-	}
-	
 	public boolean isImportDataSet() {
 		return importDataSet;
 	}
@@ -110,24 +74,6 @@
 	}
 	
 	/**
-	 * ドライバの完全修飾クラス名を設定する。
-	 * 
-	 * @param driverClassName ドライバの完全修飾クラス名
-	 */
-	public void setDriverClassName(String driverClassName) {
-		this.driverClassName = driverClassName;
-	}
-	
-	/**
-	 * ドライバJARファイルのパス配列を設定する。
-	 * 
-	 * @param driverJarPath ドライバJARファイルのパス配列
-	 */
-	public void setDriverJarPath(URL[] driverJarPath) {
-		this.driverJarPath = driverJarPath.clone();
-	}
-	
-	/**
 	 * インポートするエンティティの種類を設定する。
 	 * 
 	 * @param entityTypes インポートするエンティティの種類
@@ -146,15 +92,6 @@
 	}
 	
 	/**
-	 * 接続パスワードを設定する。
-	 * 
-	 * @param password 接続パスワード
-	 */
-	public void setPassword(String password) {
-		this.password = password;
-	}
-	
-	/**
 	 * スキーマ名を設定する。
 	 * 
 	 * @param schema スキーマ名
@@ -172,22 +109,4 @@
 		this.selectedEntities = selectedEntities.clone();
 	}
 	
-	/**
-	 * 接続URIを設定する。
-	 * 
-	 * @param uri 接続URI
-	 */
-	public void setUri(String uri) {
-		this.uri = uri;
-	}
-	
-	/**
-	 * 接続ユーザ名を設定する。
-	 * 
-	 * @param username 接続ユーザ名
-	 */
-	public void setUsername(String username) {
-		this.username = username;
-	}
-	
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomBuilder.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -276,6 +276,15 @@
 		return document;
 	}
 	
+	private void buildColumn(Element attributeElement, ColumnModel columnModel) {
+		newDataTypeElement(attributeElement, columnModel.getDataType());
+		DomUtil.newChild(attributeElement, DEFAULT_VALUE, columnModel.getDefaultValue());
+		newColumnConstraintsElement(attributeElement, columnModel.getNotNullConstraint());
+		newColumnConstraintsElement(attributeElement, columnModel.getUniqueKey());
+		newColumnConstraintsElement(attributeElement, columnModel.getPrimaryKey());
+		newColumnConstraintsElement(attributeElement, columnModel.getCheckConstraint());
+	}
+	
 	private void buildDataSetSection(Element rootElement) {
 		Element insertDataSetElement = DomUtil.newChild(rootElement, DATASETS);
 		for (DataSetModel insertDataSetModel : rootModel.getDataSets()) {
@@ -331,6 +340,37 @@
 		}
 	}
 	
+	private void buildKeyConstraint(Element attributeElement, KeyConstraint keyeyConstraint) {
+		Element columnRefsElement = DomUtil.newChild(attributeElement, COLUMN_REFS);
+		for (ColumnRef pkColumn : keyeyConstraint.getKeyColumns()) {
+			Element columnRefElement = DomUtil.newChild(columnRefsElement, COLUMN_REF);
+			columnRefElement.setAttribute(CoreQName.REF.getQNameString(), pkColumn.getReferenceId().toString());
+		}
+		
+		if (keyeyConstraint instanceof ForeignKey) {
+			ForeignKey foreignKey = (ForeignKey) keyeyConstraint;
+			
+			Element kyColumnsElement = DomUtil.newChild(attributeElement, REFERENCE_COLUMNS);
+			for (ColumnRef keyColumnRef : foreignKey.getReferenceColumns()) {
+				Element columnRefElement = DomUtil.newChild(kyColumnsElement, COLUMN_REF);
+				columnRefElement.setAttribute(CoreQName.REF.getQNameString(), keyColumnRef.getReferenceId().toString());
+			}
+			
+			if (foreignKey.getDeferrability() != null) {
+				Deferrability deferrability = foreignKey.getDeferrability();
+				Element deferrabilityElement = DomUtil.newChild(attributeElement, DEFERRABILITY);
+				deferrabilityElement.setAttribute(CoreQName.ID.getQNameString(), deferrability.getId().toString());
+				DomUtil.newChild(deferrabilityElement, DEFERRABLE, BooleanUtils.toStringTrueFalse(deferrability
+					.isDeferrable()));
+				DomUtil.newChild(deferrabilityElement, INITIALLY_CHECK_TIME, deferrability.getInitiallyCheckTime());
+			}
+			
+			DomUtil.newChild(attributeElement, MATCH_TYPE, foreignKey.getMatchType());
+			DomUtil.newChild(attributeElement, ON_DELETE, foreignKey.getOnDelete());
+			DomUtil.newChild(attributeElement, ON_UPDATE, foreignKey.getOnUpdate());
+		}
+	}
+	
 	private void buildMiscSection(Element rootElement) {
 		DomUtil.newChild(rootElement, DIALECT, rootModel.getDialectClassName());
 		DomUtil.newChild(rootElement, SCHEMA_NAME, rootModel.getSchemaName());
@@ -346,99 +386,10 @@
 			
 			if (entityModel instanceof TableModel) {
 				TableModel tableModel = (TableModel) entityModel;
-				entityElement = DomUtil.newChild(entitiesElement, TABLE);
-				DomUtil.newChild(entityElement, NAME, tableModel.getName());
-				DomUtil.newChild(entityElement, LOGICAL_NAME, tableModel.getLogicalName());
-				DomUtil.newChild(entityElement, DESCRIPTION, tableModel.getDescription());
-				DomUtil.newChild(entityElement, BEGIN_SCRIPT, tableModel.getBeginScript());
-				DomUtil.newChild(entityElement, END_SCRIPT, tableModel.getEndScript());
-				
-				Element attributesElement = DomUtil.newChild(entityElement, ATTRIBUTES);
-				for (AttributeModel attributeModel : tableModel.getAttributes()) {
-					Element attributeElement = DomUtil.newChild(attributesElement, getQName(attributeModel));
-					attributeElement.setAttribute(CoreQName.ID.getQNameString(), attributeModel.getId().toString());
-					DomUtil.newChild(attributeElement, NAME, attributeModel.getName());
-					DomUtil.newChild(attributeElement, LOGICAL_NAME, attributeModel.getLogicalName());
-					DomUtil.newChild(attributeElement, DESCRIPTION, attributeModel.getDescription());
-					if (attributeModel instanceof ColumnModel) {
-						ColumnModel columnModel = (ColumnModel) attributeModel;
-						newDataTypeElement(attributeElement, columnModel.getDataType());
-						DomUtil.newChild(attributeElement, DEFAULT_VALUE, columnModel.getDefaultValue());
-						newColumnConstraintsElement(attributeElement, columnModel.getNotNullConstraint());
-						newColumnConstraintsElement(attributeElement, columnModel.getUniqueKey());
-						newColumnConstraintsElement(attributeElement, columnModel.getPrimaryKey());
-						newColumnConstraintsElement(attributeElement, columnModel.getCheckConstraint());
-					} else if (attributeModel instanceof KeyConstraint) {
-						KeyConstraint keyeyModel = (KeyConstraint) attributeModel;
-						Element columnRefsElement = DomUtil.newChild(attributeElement, COLUMN_REFS);
-						for (ColumnRef pkColumn : keyeyModel.getKeyColumns()) {
-							Element columnRefElement = DomUtil.newChild(columnRefsElement, COLUMN_REF);
-							columnRefElement.setAttribute(CoreQName.REF.getQNameString(), pkColumn.getReferenceId()
-								.toString());
-						}
-						
-						if (attributeModel instanceof ForeignKey) {
-							ForeignKey foreignKey = (ForeignKey) keyeyModel;
-							
-							Element kyColumnsElement = DomUtil.newChild(attributeElement, REFERENCE_COLUMNS);
-							for (ColumnRef keyColumnRef : foreignKey.getReferenceColumns()) {
-								Element columnRefElement = DomUtil.newChild(kyColumnsElement, COLUMN_REF);
-								columnRefElement.setAttribute(CoreQName.REF.getQNameString(), keyColumnRef
-									.getReferenceId().toString());
-							}
-							
-							if (foreignKey.getDeferrability() != null) {
-								Deferrability deferrability = foreignKey.getDeferrability();
-								Element deferrabilityElement = DomUtil.newChild(attributeElement, DEFERRABILITY);
-								deferrabilityElement.setAttribute(CoreQName.ID.getQNameString(), deferrability.getId()
-									.toString());
-								DomUtil.newChild(deferrabilityElement, DEFERRABLE, BooleanUtils
-									.toStringTrueFalse(deferrability.isDeferrable()));
-								DomUtil.newChild(deferrabilityElement, INITIALLY_CHECK_TIME, deferrability
-									.getInitiallyCheckTime());
-							}
-							
-							DomUtil.newChild(attributeElement, MATCH_TYPE, foreignKey.getMatchType());
-							DomUtil.newChild(attributeElement, ON_DELETE, foreignKey.getOnDelete());
-							DomUtil.newChild(attributeElement, ON_UPDATE, foreignKey.getOnUpdate());
-						}
-					} else if (attributeModel instanceof TableCheckConstraint) {
-						TableCheckConstraint tableCheckConstraint = (TableCheckConstraint) attributeModel;
-						DomUtil.newChild(attributeElement, EXPRESSION, tableCheckConstraint.getExpression());
-						writeAdapters(attributeElement, tableCheckConstraint.getAdapters());
-					}
-					writeAdapters(attributeElement, attributeModel.getAdapters());
-				}
-				
-				Element indexesElement = DomUtil.newChild(entityElement, INDEXES);
-				for (IndexModel indexModel : tableModel.getIndexes()) {
-					Element indexElement = DomUtil.newChild(indexesElement, CoreQName.INDEX);
-					indexElement.setAttribute(CoreQName.ID.getQNameString(), indexModel.getId().toString());
-					DomUtil.newChild(indexElement, NAME, indexModel.getName());
-					
-					Element indexColumnsElement = DomUtil.newChild(indexElement, INDEX_COLUMNNS);
-					for (IndexColumnModel indexColumnModel : indexModel.getIndexColumns()) {
-						Element indexColumnElement = DomUtil.newChild(indexColumnsElement, INDEX_COLUMNN);
-						indexColumnElement.setAttribute(CoreQName.ID.getQNameString(), indexColumnModel.getId()
-							.toString());
-						Element indexColumnRefElement = DomUtil.newChild(indexColumnElement, COLUMN_REF);
-						indexColumnRefElement.setAttribute(CoreQName.REF.getQNameString(), indexColumnModel
-							.getColumnRef().getReferenceId().toString());
-						DomUtil.newChild(indexColumnElement, SORT_ORDER, indexColumnModel.getSortOrder());
-					}
-					
-					Element uniqueElement = DomUtil.newChild(indexElement, UNIQUE);
-					uniqueElement.setTextContent(Boolean.toString(indexModel.isUnique()));
-				}
+				entityElement = buildTable(entitiesElement, tableModel);
 			} else if (entityModel instanceof ViewModel) {
 				ViewModel viewModel = (ViewModel) entityModel;
-				entityElement = DomUtil.newChild(entitiesElement, VIEW);
-				DomUtil.newChild(entityElement, NAME, viewModel.getName());
-				DomUtil.newChild(entityElement, LOGICAL_NAME, viewModel.getLogicalName());
-				DomUtil.newChild(entityElement, DESCRIPTION, viewModel.getDescription());
-				DomUtil.newChild(entityElement, BEGIN_SCRIPT, viewModel.getBeginScript());
-				DomUtil.newChild(entityElement, END_SCRIPT, viewModel.getEndScript());
-				DomUtil.newChild(entityElement, DEFINITION, viewModel.getDefinition());
+				entityElement = buildView(entitiesElement, viewModel);
 			} else {
 				throw new UnexpectedConditionError("unknown entity:" + entityModel.getClass().getName());
 			}
@@ -448,6 +399,84 @@
 		}
 	}
 	
+	/**
+	 * テーブル要素を構築する。
+	 * 
+	 * @param entitiesElement 親となるentities要素
+	 * @param tableModel 対象{@link TableModel}
+	 * @return 構築したXML要素
+	 */
+	private Element buildTable(Element entitiesElement, TableModel tableModel) {
+		Element entityElement;
+		entityElement = DomUtil.newChild(entitiesElement, TABLE);
+		DomUtil.newChild(entityElement, NAME, tableModel.getName());
+		DomUtil.newChild(entityElement, LOGICAL_NAME, tableModel.getLogicalName());
+		DomUtil.newChild(entityElement, DESCRIPTION, tableModel.getDescription());
+		DomUtil.newChild(entityElement, BEGIN_SCRIPT, tableModel.getBeginScript());
+		DomUtil.newChild(entityElement, END_SCRIPT, tableModel.getEndScript());
+		
+		Element attributesElement = DomUtil.newChild(entityElement, ATTRIBUTES);
+		for (AttributeModel attributeModel : tableModel.getAttributes()) {
+			Element attributeElement = DomUtil.newChild(attributesElement, getQName(attributeModel));
+			attributeElement.setAttribute(CoreQName.ID.getQNameString(), attributeModel.getId().toString());
+			DomUtil.newChild(attributeElement, NAME, attributeModel.getName());
+			DomUtil.newChild(attributeElement, LOGICAL_NAME, attributeModel.getLogicalName());
+			DomUtil.newChild(attributeElement, DESCRIPTION, attributeModel.getDescription());
+			if (attributeModel instanceof ColumnModel) {
+				ColumnModel columnModel = (ColumnModel) attributeModel;
+				buildColumn(attributeElement, columnModel);
+			} else if (attributeModel instanceof KeyConstraint) {
+				KeyConstraint keyeyConstraint = (KeyConstraint) attributeModel;
+				buildKeyConstraint(attributeElement, keyeyConstraint);
+			} else if (attributeModel instanceof TableCheckConstraint) {
+				TableCheckConstraint tableCheckConstraint = (TableCheckConstraint) attributeModel;
+				DomUtil.newChild(attributeElement, EXPRESSION, tableCheckConstraint.getExpression());
+				writeAdapters(attributeElement, tableCheckConstraint.getAdapters());
+			}
+			writeAdapters(attributeElement, attributeModel.getAdapters());
+		}
+		
+		Element indexesElement = DomUtil.newChild(entityElement, INDEXES);
+		for (IndexModel indexModel : tableModel.getIndexes()) {
+			Element indexElement = DomUtil.newChild(indexesElement, CoreQName.INDEX);
+			indexElement.setAttribute(CoreQName.ID.getQNameString(), indexModel.getId().toString());
+			DomUtil.newChild(indexElement, NAME, indexModel.getName());
+			
+			Element indexColumnsElement = DomUtil.newChild(indexElement, INDEX_COLUMNNS);
+			for (IndexColumnModel indexColumnModel : indexModel.getIndexColumns()) {
+				Element indexColumnElement = DomUtil.newChild(indexColumnsElement, INDEX_COLUMNN);
+				indexColumnElement.setAttribute(CoreQName.ID.getQNameString(), indexColumnModel.getId().toString());
+				Element indexColumnRefElement = DomUtil.newChild(indexColumnElement, COLUMN_REF);
+				indexColumnRefElement.setAttribute(CoreQName.REF.getQNameString(), indexColumnModel.getColumnRef()
+					.getReferenceId().toString());
+				DomUtil.newChild(indexColumnElement, SORT_ORDER, indexColumnModel.getSortOrder());
+			}
+			
+			Element uniqueElement = DomUtil.newChild(indexElement, UNIQUE);
+			uniqueElement.setTextContent(Boolean.toString(indexModel.isUnique()));
+		}
+		return entityElement;
+	}
+	
+	/**
+	 * ビュー要素を構築する。
+	 * 
+	 * @param entitiesElement 親となるentities要素
+	 * @param viewModel 対象{@link ViewModel}
+	 * @return 構築したXML要素
+	 */
+	private Element buildView(Element entitiesElement, ViewModel viewModel) {
+		Element entityElement;
+		entityElement = DomUtil.newChild(entitiesElement, VIEW);
+		DomUtil.newChild(entityElement, NAME, viewModel.getName());
+		DomUtil.newChild(entityElement, LOGICAL_NAME, viewModel.getLogicalName());
+		DomUtil.newChild(entityElement, DESCRIPTION, viewModel.getDescription());
+		DomUtil.newChild(entityElement, BEGIN_SCRIPT, viewModel.getBeginScript());
+		DomUtil.newChild(entityElement, END_SCRIPT, viewModel.getEndScript());
+		DomUtil.newChild(entityElement, DEFINITION, viewModel.getDefinition());
+		return entityElement;
+	}
+	
 	private JiemamyQName getQName(AttributeModel attributeModel) {
 		if (attributeModel instanceof ColumnModel) {
 			return CoreQName.COLUMN;

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -65,7 +65,7 @@
 			props.setProperty("user", config.getUsername());
 			props.setProperty("password", config.getPassword());
 			
-			URL[] paths = config.getDriverJarPath();
+			URL[] paths = config.getDriverJarPaths();
 			String className = config.getDriverClassName();
 			Driver driver = DriverUtil.getDriverInstance(paths, className);
 			connection = driver.connect(config.getUri(), props);
@@ -75,7 +75,6 @@
 				String type = entityModel instanceof TableModel ? "TABLE" : "VIEW";
 				sqlExecuter.execute(String.format("DROP %s \"%s\";", type, entityModel.getName()));
 			}
-			
 		} catch (DriverNotFoundException e) {
 			throw new ImportException(e);
 		} catch (InstantiationException e) {

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DefaultDatabaseConnectionConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DefaultDatabaseConnectionConfig.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DefaultDatabaseConnectionConfig.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/06
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed 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.
+ */
+package org.jiemamy.utils;
+
+import java.net.URL;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class DefaultDatabaseConnectionConfig implements DatabaseConnectionConfig {
+	
+	/** ドライバの完全修飾クラス名 */
+	private String driverClassName;
+	
+	/** ドライバJARファイルのパス配列 */
+	private URL[] driverJarPath;
+	
+	/** 接続パスワード */
+	private String password;
+	
+	/** 接続URI */
+	private String uri;
+	
+	/** 接続ユーザ名 */
+	private String username;
+	
+
+	public String getDriverClassName() {
+		return driverClassName;
+	}
+	
+	public URL[] getDriverJarPaths() {
+		return driverJarPath.clone();
+	}
+	
+	public String getPassword() {
+		return password;
+	}
+	
+	public String getUri() {
+		return uri;
+	}
+	
+	public String getUsername() {
+		return username;
+	}
+	
+	/**
+	 * ドライバの完全修飾クラス名を設定する。
+	 * 
+	 * @param driverClassName ドライバの完全修飾クラス名
+	 */
+	public void setDriverClassName(String driverClassName) {
+		this.driverClassName = driverClassName;
+	}
+	
+	/**
+	 * ドライバJARファイルのパス配列を設定する。
+	 * 
+	 * @param driverJarPath ドライバJARファイルのパス配列
+	 */
+	public void setDriverJarPath(URL[] driverJarPath) {
+		this.driverJarPath = driverJarPath.clone();
+	}
+	
+	/**
+	 * 接続パスワードを設定する。
+	 * 
+	 * @param password 接続パスワード
+	 */
+	public void setPassword(String password) {
+		this.password = password;
+	}
+	
+	/**
+	 * 接続URIを設定する。
+	 * 
+	 * @param uri 接続URI
+	 */
+	public void setUri(String uri) {
+		this.uri = uri;
+	}
+	
+	/**
+	 * 接続ユーザ名を設定する。
+	 * 
+	 * @param username 接続ユーザ名
+	 */
+	public void setUsername(String username) {
+		this.username = username;
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DefaultDatabaseConnectionConfig.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DriverUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DriverUtil.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DriverUtil.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -19,6 +19,7 @@
 package org.jiemamy.utils;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URISyntaxException;
@@ -53,6 +54,7 @@
 	 * @throws IOException 入出力エラーが発生した場合
 	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
 	 * @throws IllegalArgumentException URIとして不適切なURLが引数に含まれていた場合
+	 * @throws FileNotFoundException ファイルが見つからなかった場合
 	 */
 	public static List<Class<? extends Driver>> getDriverClasses(URL[] paths) throws IOException {
 		Validate.notNull(paths);
@@ -63,7 +65,11 @@
 		
 		for (URL path : paths) {
 			try {
-				JarFile jarFile = new JarFile(new File(path.toURI())); //JarFileUtil.toJarFile(path);
+				File file = new File(path.toURI());
+				if (file.exists() == false) {
+					throw new FileNotFoundException(file.getAbsolutePath());
+				}
+				JarFile jarFile = new JarFile(file); //JarFileUtil.toJarFile(path);
 				ResourceTraversal.forEach(jarFile, new GetDriverClassesFromJarHandler(driverList, classLoader));
 			} catch (URISyntaxException e) {
 				throw new IllegalArgumentException(path.toString(), e);
@@ -81,6 +87,7 @@
 	 * @throws IllegalAccessException ドライバの実装が不正だった場合
 	 * @throws InstantiationException ドライバの実装が不正だった場合
 	 * @throws DriverNotFoundException ドライバが見つからなかった場合
+	 * @throws FileNotFoundException ファイルが見つからなかった場合
 	 * @throws IOException I/Oエラーが発生した場合
 	 * @throws IllegalArgumentException 引数pathsに{@code null}を与えた場合
 	 */

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ResourceTraversal.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ResourceTraversal.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ResourceTraversal.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -28,6 +28,8 @@
 
 import org.apache.commons.io.IOUtils;
 
+import org.jiemamy.exception.UnexpectedConditionError;
+
 /**
  * リソースをトラバースするためのクラス。
  * 
@@ -122,6 +124,7 @@
 	}
 	
 	private ResourceTraversal() {
+		throw new UnexpectedConditionError("不到達ポイント");
 	}
 	
 

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/swap/SwapObject.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/swap/SwapObject.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/swap/SwapObject.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -54,12 +54,10 @@
 	/**
 	 * インスタンスを生成する。
 	 * 
-	 * <p>
-	 * {@link Swapper }へシリアライズ要求を行う前に、RealObjectへの弱参照を保持する。
-	 * </p>
+	 * <p>{@link Swapper}へシリアライズ要求を行う前に、RealObjectへの弱参照を保持する。</p>
 	 * 
 	 * @param obj スワップの対象とするオブジェクト
-	 * @throws SwapException
+	 * @throws SwapException シリアライズに失敗した場合
 	 */
 	public SwapObject(T obj) throws SwapException {
 		ref = new WeakReference<T>(obj);
@@ -69,13 +67,11 @@
 	/**
 	 * スワップ済みのオブジェクトを取得する。
 	 * 
-	 * <p>
-	 * RealObject への弱参照が到達可能な場合、到達した RealObject を返す。<br>
-	 * 到達できない場合は{@link Swapper }へ RealObject のデシリアライズ要求を委譲する。
-	 * </p>
+	 * <p>RealObject への弱参照が到達可能な場合、到達した RealObject を返す。
+	 * 到達できない場合は{@link Swapper }へ RealObject のデシリアライズ要求を委譲する。</p>
 	 * 
 	 * @return スワップ済みのオブジェクト
-	 * @throws SwapException
+	 * @throws SwapException デシリアライズに失敗した場合
 	 */
 	public synchronized T get() throws SwapException {
 		T obj = ref.get();
@@ -91,14 +87,12 @@
 	/**
 	 * スワップする RealObject を引数の内容で更新する。
 	 * 
-	 * <p>
-	 * スワップしている RealObject の更新は{@link Swapper }が検知することができないため、<br>
-	 * RealObject が更新され、そのオブジェクトをスワップ情報にも更新しなければならない場合は<br>
-	 * 必ずこのメソッドを呼ぶ必要がある。
-	 * </p>
+	 * <p>スワップしている RealObject の更新は{@link Swapper }が検知することができないため、
+	 * RealObject が更新され、そのオブジェクトをスワップ情報にも更新しなければならない場合は
+	 * 必ずこのメソッドを呼ぶ必要がある。</p>
 	 * 
 	 * @param obj 更新する RealObject
-	 * @throws SwapException
+	 * @throws SwapException シリアライズに失敗した場合
 	 */
 	public synchronized void update(T obj) throws SwapException {
 		ref = new WeakReference<T>(obj);

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -142,19 +142,25 @@
 		INSTANCE;
 		
 		public int compare(NodeAdapter o1, NodeAdapter o2) {
+			Integer result = null;
 			if (o1 == null && o2 == null) {
-				return 0;
+				result = 0;
 			} else if (o1 == null) {
-				return -1;
+				result = -1;
 			} else if (o2 == null) {
-				return 1;
+				result = 1;
 			} else if (o1.unwrap() == null && o2.unwrap() == null) {
-				return o1.getClass().getName().compareTo(o2.getClass().getName());
+				result = o1.getClass().getName().compareTo(o2.getClass().getName());
 			} else if (o1.unwrap() == null) {
-				return 1;
+				result = 1;
 			} else if (o2.unwrap() == null) {
-				return -1;
+				result = -1;
 			}
+			
+			if (result != null) {
+				return result;
+			}
+			
 			EntityModel e1 = o1.unwrap();
 			EntityModel e2 = o2.unwrap();
 			if (e1 != null && e2 != null) {

Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer2.java
===================================================================
--- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer2.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/enhance/ViewFactoryExtensionEnhancer2.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -148,19 +148,25 @@
 		INSTANCE;
 		
 		public int compare(NodeAdapter o1, NodeAdapter o2) {
+			Integer result = null;
 			if (o1 == null && o2 == null) {
-				return 0;
+				result = 0;
 			} else if (o1 == null) {
-				return -1;
+				result = -1;
 			} else if (o2 == null) {
-				return 1;
+				result = 1;
 			} else if (o1.unwrap() == null && o2.unwrap() == null) {
-				return o1.getClass().getName().compareTo(o2.getClass().getName());
+				result = o1.getClass().getName().compareTo(o2.getClass().getName());
 			} else if (o1.unwrap() == null) {
-				return 1;
+				result = 1;
 			} else if (o2.unwrap() == null) {
-				return -1;
+				result = -1;
 			}
+			
+			if (result != null) {
+				return result;
+			}
+			
 			EntityModel e1 = o1.unwrap();
 			EntityModel e2 = o2.unwrap();
 			if (e1 != null && e2 != null) {

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/ImportMetadataConfig.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/ImportMetadataConfig.java	2009-04-06 06:43:48 UTC (rev 3134)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/ImportMetadataConfig.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -29,6 +29,13 @@
 public interface ImportMetadataConfig {
 	
 	/**
+	 * SQL方言を取得する。
+	 * 
+	 * @return SQL方言. 未設定の場合は{@code null}
+	 */
+	Dialect getDialect();
+	
+	/**
 	 * インポートするエンティティの種類を取得する。
 	 * 
 	 * @return インポートするエンティティの種類. 未設定の場合は{@code null}
@@ -49,4 +56,11 @@
 	 */
 	String[] getSelectedEntities();
 	
+	/**
+	 * テーブルのコンテンツをデータセットとしてインポートするかどうかを取得する。
+	 * 
+	 * @return テーブルのコンテンツをデータセットとしてインポートするかどうか
+	 */
+	boolean isImportDataSet();
+	
 }

Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/DatabaseConnectionConfig.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/DatabaseConnectionConfig.java	                        (rev 0)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/DatabaseConnectionConfig.java	2009-04-06 10:12:57 UTC (rev 3135)
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/06
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed 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.
+ */
+package org.jiemamy.utils;
+
+import java.net.URL;
+
+/**
+ * DB接続に必要な設定インターフェイス。
+ * 
+ * @since 0.2
+ * @author daisuke
+ */
+public interface DatabaseConnectionConfig {
+	
+	/**
+	 * ドライバの完全修飾クラス名を取得する。
+	 * 
+	 * @return ドライバの完全修飾クラス名. 未設定の場合は{@code null}
+	 */
+	String getDriverClassName();
+	
+	/**
+	 * ドライバJARファイルのパス配列を取得する。
+	 * 
+	 * @return ドライバJARファイルのパス配列. 未設定の場合は{@code null}
+	 */
+	URL[] getDriverJarPaths();
+	
+	/**
+	 * 接続パスワードを取得する。
+	 * 
+	 * @return 接続パスワード. 未設定の場合は{@code null}
+	 */
+	String getPassword();
+	
+	/**
+	 * 接続URIを取得する。
+	 * 
+	 * @return 接続URI. 未設定の場合は{@code null}
+	 */
+	String getUri();
+	
+	/**
+	 * 接続ユーザ名を取得する。
+	 * 
+	 * @return 接続ユーザ名. 未設定の場合は{@code null}
+	 */
+	String getUsername();
+	
+}


Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/DatabaseConnectionConfig.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



Jiemamy-notify メーリングリストの案内
Back to archive index