[Jiemamy-notify:1727] commit [2914] [ECL-11][CORE-21] Dialect特有データ型オプションのUI拡張ポイントを実装。 /

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 3月 19日 (木) 17:55:40 JST


Revision: 2914
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2914
Author:   daisuke_m
Date:     2009-03-19 17:55:40 +0900 (Thu, 19 Mar 2009)

Log Message:
-----------
[ECL-11][CORE-21] Dialect特有データ型オプションのUI拡張ポイントを実装。/
[CORE-106] CREATE INDEXの出力対応。/
[CORE-107] INSERT文VALUES句のクオート対応。/
MySQLにおいて、DROP TABLE に IF EXISTS を追加。/
PostgreSQLのエミッタを作成。/
XML Schemaにおいて、インデックス名を必須とした。
DatabaseImporter / SqlExporter を J-core に移動。

(J-composer は近日中に無くなる予定。jiemamy-exporter-html にリネームのうえ、artemisからはずれるかな?)

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultTokenResolver.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java
    artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java
    artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java
    vesta/trunk/org.jiemamy.eclipse.core/schema/dialects.exsd
    vesta/trunk/org.jiemamy.eclipse.ui/META-INF/MANIFEST.MF
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/index/IndexColumnModel.java
    zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd
    zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml

Added Paths:
-----------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/
    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/DatabaseReader.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgreSqlEmitter.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/AbstractPostgresObjectOption.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/CommitAction.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumOptionImpl.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumnOption.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexMethodType.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOption.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOptionImpl.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/NullOrder.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/PostgresObjectOption.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/StandardIndexMethod.java
    artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/TableOption.java
    vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/MySqlTypeOptionHandler.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/AbstractTypeOptionHandler.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionHandler.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/UIConstant.java

Removed Paths:
-------------
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java
    artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java


-------------- next part --------------
Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,67 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/25
- *
- * 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.composer.exporter;
-
-import java.io.File;
-
-import org.apache.commons.lang.Validate;
-
-/**
- * {@link HtmlExporter}に関する設定情報保持クラス。
- * 
- * @author daisuke
- */
-public abstract class AbstractFileExportConfig implements FileExportConfig {
-	
-	/** 出力先ファイル */
-	private File outputFile;
-	
-	/** 出力先ファイルが既に存在した場合、上書きするかどうか */
-	private boolean overwrite;
-	
-
-	public File getOutputFile() {
-		return outputFile;
-	}
-	
-	public boolean isOverwrite() {
-		return overwrite;
-	}
-	
-	/**
-	 * 出力ファイルを設定する。
-	 * 
-	 * @param outputFile 出力ファイル
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public void setOutputFile(File outputFile) {
-		Validate.notNull(outputFile);
-		this.outputFile = outputFile;
-	}
-	
-	/**
-	 * 出力ファイルが既に存在した場合、上書きするかどうかを設定する。
-	 * 
-	 * @param overwrite 上書きする場合は{@code true}、そうでない場合は{@code false}
-	 */
-	public void setOverwrite(boolean overwrite) {
-		this.overwrite = overwrite;
-	}
-	
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,62 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/25
- *
- * 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.composer.exporter;
-
-/**
- * {@link SqlExporter}に関する設定情報保持クラス。
- * 
- * @author daisuke
- */
-public class DefaultSqlExportConfig extends AbstractFileExportConfig implements SqlExportConfig {
-	
-	/** CREATE文の前にDROP文を出力するかどうか */
-	private boolean emitDropStatements;
-	
-	/** 出力するデータセットのインデックス */
-	private int dataSetIndex;
-	
-
-	public boolean emitDropStatements() {
-		return emitDropStatements;
-	}
-	
-	public int getDataSetIndex() {
-		return dataSetIndex;
-	}
-	
-	/**
-	 * 出力するデータセットのインデックスを設定する。
-	 * 
-	 * <p>INSERT文を出力しない場合は、負数を設定する。</p>
-	 * 
-	 * @param dataSetIndex 出力するデータセットのインデックス
-	 */
-	public void setDataSetIndex(int dataSetIndex) {
-		this.dataSetIndex = dataSetIndex;
-	}
-	
-	/**
-	 * CREATE文の前にDROP文を出力するかどうかを設定する。
-	 * 
-	 * @param emitDropStatements 出力する場合は{@code true}、そうでない場合は{@code false}
-	 */
-	public void setEmitDropStatements(boolean emitDropStatements) {
-		this.emitDropStatements = emitDropStatements;
-	}
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/25
- *
- * 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.composer.exporter;
-
-import java.io.File;
-
-import org.jiemamy.composer.ExportConfig;
-import org.jiemamy.composer.Exporter;
-
-/**
- * ファイルにを出力する{@link Exporter}に関する設定情報インターフェイス。
- * 
- * @author daisuke
- */
-public interface FileExportConfig extends ExportConfig {
-	
-	/**
-	 * 出力ファイルを取得する。
-	 * 
-	 * @return 出力ファイル. 未設定の場合は{@code null} 
-	 */
-	File getOutputFile();
-	
-	/**
-	 * 出力ファイルが既に存在した場合、上書きするかどうか調べる。
-	 * 
-	 * @return 上書きする場合は{@code true}、そうでない場合は{@code false}
-	 */
-	boolean isOverwrite();
-	
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,30 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/25
- *
- * 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.composer.exporter;
-
-import org.jiemamy.dialect.EmitConfig;
-
-/**
- * {@link SqlExporter}に関する設定情報インターフェイス。
- * 
- * @author daisuke
- */
-public interface SqlExportConfig extends FileExportConfig, EmitConfig {
-	
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,104 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2008/07/12
- *
- * 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.composer.exporter;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.List;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.CharEncoding;
-import org.apache.commons.lang.SystemUtils;
-import org.apache.commons.lang.Validate;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-import org.jiemamy.composer.ExportException;
-import org.jiemamy.composer.Exporter;
-import org.jiemamy.dialect.Dialect;
-import org.jiemamy.model.RootModel;
-import org.jiemamy.model.sql.SqlStatement;
-import org.jiemamy.utils.model.RootModelUtil;
-
-/**
- * モデルからSQLを構築するエクスポータ。
- * 
- * @author daisuke
- */
-public class SqlExporter implements Exporter<SqlExportConfig> {
-	
-	/** ConfigKey: オーバーライトするかどうか (Boolean) */
-	public static final String OVERWRITE = "overwrite";
-	
-	/** ConfigKey: 出力ファイル名 (String) */
-	public static final String OUTPUT_FILE = "outputFile";
-	
-	/** ConfigKey: 出力データセット番号 (Integer) */
-	public static final String DATA_SET_INDEX = "dataSetIndex";
-	
-
-	public boolean exportModel(RootModel rootModel, SqlExportConfig config) throws ExportException {
-		Validate.notNull(rootModel);
-		Validate.notNull(config);
-		Validate.notNull(config.getOutputFile());
-		
-		Writer writer = null;
-		try {
-			Dialect dialect = RootModelUtil.getDialect(rootModel);
-			
-			List<SqlStatement> statements = dialect.emitStatements(rootModel, config);
-			
-			File outputFile = config.getOutputFile();
-			if (outputFile.exists()) {
-				if (config.isOverwrite() == false) {
-					return false;
-				}
-				if (outputFile.delete() == false) {
-					throw new ExportException("Cannot delete file: " + outputFile.getAbsolutePath());
-				}
-			}
-			
-			writer = new OutputStreamWriter(new FileOutputStream(outputFile), CharEncoding.UTF_8);
-			for (SqlStatement stmt : statements) {
-				writer.write(stmt.toString());
-				writer.write(SystemUtils.LINE_SEPARATOR);
-			}
-		} catch (IOException e) {
-			throw new ExportException(e);
-		} catch (ClassNotFoundException e) {
-			throw new ExportException("Dialect not found: " + rootModel.getDialectClassName(), e);
-		} finally {
-			IOUtils.closeQuietly(writer);
-		}
-		return true;
-	}
-	
-	public String getName() {
-		return "SQL Exporter";
-	}
-	
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-	}
-	
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,103 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/02/25
- *
- * 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.composer.importer;
-
-import java.net.URL;
-
-import org.jiemamy.composer.ImportConfig;
-import org.jiemamy.dialect.Dialect;
-
-/**
- * {@link DatabaseImporter}に関する設定情報インターフェイス。
- * 
- * @author daisuke
- */
-public interface DatabaseImportConfig extends ImportConfig {
-	
-	/**
-	 * データベース名を取得する。
-	 * 
-	 * @return データベース名. 未設定の場合は{@code null}
-	 */
-	String getDatabaseName();
-	
-	/**
-	 * SQL方言を取得する。
-	 * 
-	 * @return SQL方言. 未設定の場合は{@code null}
-	 */
-	Dialect getDialect();
-	
-	/**
-	 * ドライバの完全修飾クラス名を取得する。
-	 * 
-	 * @return ドライバの完全修飾クラス名. 未設定の場合は{@code null}
-	 */
-	String getDriverClassName();
-	
-	/**
-	 * ドライバJARファイルのパス配列を取得する。
-	 * 
-	 * @return ドライバJARファイルのパス配列. 未設定の場合は{@code null}
-	 */
-	URL[] getDriverJarPath();
-	
-	/**
-	 * インポートするエンティティの種類を取得する。
-	 * 
-	 * @return インポートするエンティティの種類. 未設定の場合は{@code null}
-	 */
-	String[] getEntityTypes();
-	
-	/**
-	 * 接続パスワードを取得する。
-	 * 
-	 * @return 接続パスワード. 未設定の場合は{@code null}
-	 */
-	String getPassword();
-	
-	/**
-	 * スキーマ名を取得する。
-	 * 
-	 * @return スキーマ名. 未設定の場合は{@code null}
-	 */
-	String getSchema();
-	
-	/**
-	 * インポートするエンティティ名の配列を取得する。
-	 * 
-	 * @return インポートするエンティティ名の配列. 未設定の場合は{@code null}
-	 */
-	String[] getSelectedEntities();
-	
-	/**
-	 * 接続URIを取得する。
-	 * 
-	 * @return 接続URI. 未設定の場合は{@code null}
-	 */
-	String getUri();
-	
-	/**
-	 * 接続ユーザ名を取得する。
-	 * 
-	 * @return 接続ユーザ名. 未設定の場合は{@code null}
-	 */
-	String getUsername();
-	
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,275 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2008/07/26
- *
- * 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.composer.importer;
-
-import java.io.IOException;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.Driver;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.commons.lang.Validate;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-import org.jiemamy.JiemamyFactory;
-import org.jiemamy.composer.ImportConfig;
-import org.jiemamy.composer.ImportException;
-import org.jiemamy.composer.Importer;
-import org.jiemamy.dialect.Dialect;
-import org.jiemamy.dialect.generic.GenericDialect;
-import org.jiemamy.exception.DriverNotFoundException;
-import org.jiemamy.exception.GenericModelingModeException;
-import org.jiemamy.model.RootModel;
-import org.jiemamy.model.attribute.ColumnModel;
-import org.jiemamy.model.attribute.constraint.ForeignKey;
-import org.jiemamy.model.entity.EntityModel;
-import org.jiemamy.model.entity.TableModel;
-import org.jiemamy.utils.CollectionsUtil;
-import org.jiemamy.utils.DriverUtil;
-import org.jiemamy.utils.JmIOUtil;
-import org.jiemamy.utils.model.ForeignKeyUtil;
-import org.jiemamy.utils.model.RootModelUtil;
-import org.jiemamy.utils.model.TableUtil;
-import org.jiemamy.utils.visitor.AbstractResultSetVisitor;
-
-/**
- * データベースからモデルを生成するインポータ。
- * 
- * @author daisuke
- */
-public class DatabaseImporter implements Importer<DatabaseImportConfig> {
-	
-	/** ConfigKey: SQL方言 (Dialect) */
-	public static final String DIALECT = "dialect";
-	
-	/** ConfigKey: データベース名 (String) */
-	public static final String DATABASE_NAME = "databaseName";
-	
-	/** ConfigKey: ドライバJARファイルのURL (URL[]) */
-	public static final String DRIVER_JAR_PATH = "driverJarPath";
-	
-	/** ConfigKey: ドライバの完全修飾クラス名 (String) */
-	public static final String DRIVER_CLASS_NAME = "driverClassName";
-	
-	/** ConfigKey: DB接続URI (String) */
-	public static final String URI = "uri";
-	
-	/** ConfigKey: DB接続スキーマ名 (String) */
-	public static final String SCHEMA = "schema";
-	
-	/** ConfigKey: DB接続username (String) */
-	public static final String USERNAME = "username";
-	
-	/** ConfigKey: DB接続password (String) */
-	public static final String PASSWORD = "password";
-	
-	/** ConfigKey: importするエンティティ名 (String[]) */
-	public static final String SELECTED_ENTITIES = "selectedEntities";
-	
-	/** ConfigKey: importするエンティティの種類 (String[]) */
-	public static final String ENTITY_TYPES = "entityTypes";
-	
-	/** SQL方言 */
-	private Dialect dialect;
-	
-
-	public String getName() {
-		return "Database Importer";
-	}
-	
-	public boolean importModel(RootModel rootModel, DatabaseImportConfig config) throws ImportException {
-		Validate.notNull(rootModel);
-		Validate.notNull(config);
-		
-		Connection connection = null;
-		try {
-			dialect = config.getDialect();
-			if (dialect instanceof GenericDialect) {
-				throw new GenericModelingModeException();
-			}
-			
-			Properties props = new Properties();
-			props.setProperty("user", config.getUsername());
-			props.setProperty("password", config.getPassword());
-			
-			URL[] paths = config.getDriverJarPath();
-			String className = config.getDriverClassName();
-			Driver driver = DriverUtil.getDriverInstance(paths, className);
-			connection = driver.connect(config.getUri(), props);
-			DatabaseMetaData meta = connection.getMetaData();
-			
-			DatabaseReader reader = new DatabaseReader(dialect, config, meta);
-			
-			dialect.getAdvisor().setUpRead(connection);
-			reader.readEnities(new EntityImportVisitor(meta, rootModel, config));
-			reader.readRelations(new RelationImportVisitor(meta, rootModel, config));
-			dialect.getAdvisor().tearDownRead(connection);
-		} catch (GenericModelingModeException e) {
-			throw new ImportException(e);
-		} catch (DriverNotFoundException e) {
-			throw new ImportException(e);
-		} catch (InstantiationException e) {
-			throw new ImportException(e);
-		} catch (IllegalAccessException e) {
-			throw new ImportException(e);
-		} catch (IOException e) {
-			throw new ImportException(e);
-		} catch (SQLException e) {
-			throw new ImportException(e);
-		} catch (Exception e) {
-			throw new ImportException(e);
-		} finally {
-			JmIOUtil.closeQuietly(connection);
-		}
-		return true;
-	}
-	
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-	}
-	
-
-	/**
-	 * {@link RootModel}にEntityをインポートする、{@link ResultSet}に対するビジター。
-	 * 
-	 * <p>{@link DatabaseReader}に対するストラテジとも言える。</p>
-	 * 
-	 * @author daisuke
-	 */
-	class EntityImportVisitor extends AbstractResultSetVisitor<Void, RuntimeException> {
-		
-		/** DBメタデータ */
-		private DatabaseMetaData meta;
-		
-		/** 書き込み先モデル */
-		private RootModel rootModel;
-		
-		/**
-		 * 読み込み対象のエンティティ型リスト
-		 * 
-		 * 例えば "TABLE" とか "VIEW" とか。
-		 */
-		private List<String> entityTypes;
-		
-		/**
-		 * 読み込み対象のエンティティ名のリスト
-		 * 
-		 * ただし、空リストだった場合、全てのエンティティを読むことを意味する。
-		 */
-		private List<String> selectedEntities;
-		
-		private JiemamyFactory factory;
-		
-
-		/**
-		 * インスタンスを生成する。
-		 * 
-		 * @param meta DBメタデータ
-		 * @param rootModel 書き込み先モデル
-		 * @param ctx インポートに関するコンテキスト情報
-		 */
-		public EntityImportVisitor(DatabaseMetaData meta, RootModel rootModel, DatabaseImportConfig ctx) {
-			this.meta = meta;
-			this.rootModel = rootModel;
-			factory = rootModel.getJiemamy().getFactory();
-			String[] entityTypesValue = ctx.getEntityTypes();
-			if (entityTypesValue == null) {
-				entityTypesValue = new String[] {
-					"TABLE",
-					"VIEW"
-				};
-			}
-			entityTypes = Arrays.asList(entityTypesValue);
-			String[] selectedEntitiesValue = ctx.getSelectedEntities();
-			selectedEntities = selectedEntitiesValue == null ? null : Arrays.asList(selectedEntitiesValue);
-		}
-		
-		public Void visit(ResultSet entity) throws SQLException {
-			if ((entityTypes.contains(entity.getString("TABLE_TYPE")))
-					&& (selectedEntities == null || selectedEntities.contains(entity.getString("TABLE_NAME")))) {
-				EntityModel entityModel = dialect.createEntity(factory, entity, meta);
-				if (entityModel != null) {
-					rootModel.getEntities().add(entityModel);
-				}
-			}
-			return null;
-		}
-	}
-	
-	/**
-	 * {@link RootModel}にRelationをインポートする、{@link ResultSet}に対するビジター。
-	 * 
-	 * {@link DatabaseReader}に対するストラテジとも言える。
-	 * @author daisuke
-	 */
-	class RelationImportVisitor extends AbstractResultSetVisitor<Void, RuntimeException> {
-		
-		/** 書き込み先モデル */
-		private RootModel rootModel;
-		
-		/** キャッシュ */
-		private Map<String, ForeignKey> foreignKeys = CollectionsUtil.newHashMap();
-		
-
-		/**
-		 * インスタンスを生成する。
-		 * 
-		 * @param meta DBメタデータ
-		 * @param rootModel 書き込み先モデル
-		 * @param config インポート設定
-		 */
-		public RelationImportVisitor(DatabaseMetaData meta, RootModel rootModel, ImportConfig config) {
-			this.rootModel = rootModel;
-		}
-		
-		public Void visit(ResultSet keys) throws SQLException {
-			String fkName = keys.getString("FK_NAME");
-			String fkTableName = keys.getString("FKTABLE_NAME");
-			String fkColumnName = keys.getString("FKCOLUMN_NAME");
-			String pkTableName = keys.getString("PKTABLE_NAME");
-			String pkColumnName = keys.getString("PKCOLUMN_NAME");
-			
-			TableModel constrainedTable = RootModelUtil.getEntity(rootModel, TableModel.class, fkTableName);
-			TableModel referenceTable = RootModelUtil.getEntity(rootModel, TableModel.class, pkTableName);
-			
-			if (constrainedTable != null && referenceTable != null) {
-				JiemamyFactory factory = rootModel.getJiemamy().getFactory();
-				ForeignKey foreignKey = foreignKeys.get(fkName);
-				if (foreignKey == null) {
-					foreignKey = factory.newModel(ForeignKey.class);
-					foreignKey.setName(fkName);
-					constrainedTable.getAttributes().add(foreignKey);
-					foreignKeys.put(fkName, foreignKey);
-				}
-				ColumnModel fkColumn = TableUtil.getColumn(constrainedTable, fkColumnName);
-				ColumnModel pkColumn = TableUtil.getColumn(referenceTable, pkColumnName);
-				ForeignKeyUtil.addMapping(foreignKey, fkColumn, pkColumn);
-			}
-			return null;
-		}
-	}
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,129 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2008/07/18
- *
- * 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.composer.importer;
-
-import java.sql.DatabaseMetaData;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.apache.commons.lang.Validate;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-import org.jiemamy.dialect.Dialect;
-import org.jiemamy.utils.CollectionsUtil;
-import org.jiemamy.utils.ForEachUtil;
-import org.jiemamy.utils.visitor.AbstractResultSetVisitor;
-import org.jiemamy.utils.visitor.impl.EntityNamesVisitor;
-
-/**
- * データベースを読み込む。
- * 
- * <p>model, dialect, reader, database の関係を人間のメタファで説明しようとすると、
- * 方言というのは、リソース(読み出し対象)の性質である為、読み手が知っていれば読めるもの。
- * 方言を知っている読み手に対して、リソースを与えると、方言に応じて様々な情報を読み取る。
- * readerはこの「読み手」であり、databaseは「リソース」、modelは「様々な情報」である。</p>
- * 
- * @author daisuke
- */
-class DatabaseReader {
-	
-	// THINK DBを読み込んだ結果、modelを「出力する」主体はReaderである為、現在の実装のようにDialectに丸投げ委譲、
-	// というのは責務の重心がおかしい。Dialectは必要な部分のみReaderから問い合わせられるだけの立場であり、
-	// 基本的にモデルを組み立てる責務はReader側にあるものではないか?
-	
-	private final Dialect dialect;
-	
-	private final DatabaseImportConfig config;
-	
-	private final DatabaseMetaData meta;
-	
-
-	/**
-	 * インスタンスを生成する。
-	 * 
-	 * @param dialect SQL方言
-	 * @param config コンテキスト情報
-	 * @param meta DBメタデータ
-	 */
-	public DatabaseReader(Dialect dialect, DatabaseImportConfig config, DatabaseMetaData meta) {
-		Validate.notNull(dialect);
-		Validate.notNull(config);
-		Validate.notNull(meta);
-		this.dialect = dialect;
-		this.config = config;
-		this.meta = meta;
-	}
-	
-	/**
-	 * DB接続からエンティティを読み込む。
-	 * 
-	 * @param <T> 読み込んだ結果、戻り値型
-	 * @param visitor 各エンティティに情報に対するビジター
-	 * @return ビジターに依存した、実行結果
-	 * @throws SQLException SQLの実行に失敗した場合
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public <T>T readEnities(AbstractResultSetVisitor<T, RuntimeException> visitor) throws SQLException {
-		assert dialect != null;
-		assert config != null;
-		assert meta != null;
-		Validate.notNull(visitor);
-		
-		String schema = config.getSchema();
-		
-		ResultSet entities = meta.getTables(null, schema, "%", null);
-		T result = ForEachUtil.accept(entities, visitor);
-		
-		return result;
-	}
-	
-	/**
-	 * DB接続からリレーションを読み込む。
-	 * 
-	 * @param <T> 読み込んだ結果、戻り値型
-	 * @param visitor 各エンティティに情報に対するビジター
-	 * @return ビジターに依存した、実行結果
-	 * @throws SQLException SQLの実行に失敗した場合
-	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
-	 */
-	public <T>List<T> readRelations(AbstractResultSetVisitor<T, RuntimeException> visitor) throws SQLException {
-		assert dialect != null;
-		assert config != null;
-		assert meta != null;
-		Validate.notNull(visitor);
-		
-		String schema = config.getSchema();
-		
-		List<String> entityNames = readEnities(new EntityNamesVisitor());
-		
-		List<T> result = CollectionsUtil.newArrayList();
-		for (String entityName : entityNames) {
-			ResultSet relations = meta.getImportedKeys(null, schema, entityName);
-			result.add(ForEachUtil.accept(relations, visitor));
-		}
-		return result;
-	}
-	
-	@Override
-	public String toString() {
-		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
-	}
-}

Deleted: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java
===================================================================
--- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -1,193 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2008/07/12
- *
- * 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.composer.importer;
-
-import java.net.URL;
-
-import org.jiemamy.dialect.Dialect;
-
-/**
- * {@link DatabaseImporter}に関する設定情報保持クラス。
- * 
- * @author daisuke
- */
-public class DefaultDatabaseImportConfig 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 databaseName;
-	
-	/** スキーマ名 */
-	private String schema;
-	
-
-	public String getDatabaseName() {
-		return databaseName;
-	}
-	
-	public Dialect getDialect() {
-		return dialect;
-	}
-	
-	public String getDriverClassName() {
-		return driverClassName;
-	}
-	
-	public URL[] getDriverJarPath() {
-		return driverJarPath;
-	}
-	
-	public String[] getEntityTypes() {
-		return entityTypes;
-	}
-	
-	public String getPassword() {
-		return password;
-	}
-	
-	public String getSchema() {
-		return schema;
-	}
-	
-	public String[] getSelectedEntities() {
-		return selectedEntities;
-	}
-	
-	public String getUri() {
-		return uri;
-	}
-	
-	public String getUsername() {
-		return username;
-	}
-	
-	/**
-	 * データベース名を設定する。
-	 * 
-	 * @param databaseName データベース名
-	 */
-	public void setDatabaseName(String databaseName) {
-		this.databaseName = databaseName;
-	}
-	
-	/**
-	 * SQL方言を設定する。
-	 * 
-	 * @param dialect SQL方言
-	 */
-	public void setDialect(Dialect dialect) {
-		this.dialect = dialect;
-	}
-	
-	/**
-	 * ドライバの完全修飾クラス名を設定する。
-	 * 
-	 * @param driverClassName ドライバの完全修飾クラス名
-	 */
-	public void setDriverClassName(String driverClassName) {
-		this.driverClassName = driverClassName;
-	}
-	
-	/**
-	 * ドライバJARファイルのパス配列を設定する。
-	 * 
-	 * @param driverJarPath ドライバJARファイルのパス配列
-	 */
-	public void setDriverJarPath(URL[] driverJarPath) {
-		this.driverJarPath = driverJarPath;
-	}
-	
-	/**
-	 * インポートするエンティティの種類を設定する。
-	 * 
-	 * @param entityTypes インポートするエンティティの種類
-	 */
-	public void setEntityTypes(String[] entityTypes) {
-		this.entityTypes = entityTypes;
-	}
-	
-	/**
-	 * 接続パスワードを設定する。
-	 * 
-	 * @param password 接続パスワード
-	 */
-	public void setPassword(String password) {
-		this.password = password;
-	}
-	
-	/**
-	 * スキーマ名を設定する。
-	 * 
-	 * @param schema スキーマ名
-	 */
-	public void setSchema(String schema) {
-		this.schema = schema;
-	}
-	
-	/**
-	 * インポートするエンティティ名の配列を設定する。
-	 * 
-	 * @param selectedEntities インポートするエンティティ名の配列
-	 */
-	public void setSelectedEntities(String[] selectedEntities) {
-		this.selectedEntities = selectedEntities;
-	}
-	
-	/**
-	 * 接続URIを設定する。
-	 * 
-	 * @param uri 接続URI
-	 */
-	public void setUri(String uri) {
-		this.uri = uri;
-	}
-	
-	/**
-	 * 接続ユーザ名を設定する。
-	 * 
-	 * @param username 接続ユーザ名
-	 */
-	public void setUsername(String username) {
-		this.username = username;
-	}
-	
-}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/25
+ *
+ * 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.composer.exporter;
+
+import java.io.File;
+
+import org.apache.commons.lang.Validate;
+
+/**
+ * {@link HtmlExporter}に関する設定情報保持クラス。
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractFileExportConfig implements FileExportConfig {
+	
+	/** 出力先ファイル */
+	private File outputFile;
+	
+	/** 出力先ファイルが既に存在した場合、上書きするかどうか */
+	private boolean overwrite;
+	
+
+	public File getOutputFile() {
+		return outputFile;
+	}
+	
+	public boolean isOverwrite() {
+		return overwrite;
+	}
+	
+	/**
+	 * 出力ファイルを設定する。
+	 * 
+	 * @param outputFile 出力ファイル
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public void setOutputFile(File outputFile) {
+		Validate.notNull(outputFile);
+		this.outputFile = outputFile;
+	}
+	
+	/**
+	 * 出力ファイルが既に存在した場合、上書きするかどうかを設定する。
+	 * 
+	 * @param overwrite 上書きする場合は{@code true}、そうでない場合は{@code false}
+	 */
+	public void setOverwrite(boolean overwrite) {
+		this.overwrite = overwrite;
+	}
+	
+}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/25
+ *
+ * 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.composer.exporter;
+
+/**
+ * {@link SqlExporter}に関する設定情報保持クラス。
+ * 
+ * @author daisuke
+ */
+public class DefaultSqlExportConfig extends AbstractFileExportConfig implements SqlExportConfig {
+	
+	/** CREATE文の前にDROP文を出力するかどうか */
+	private boolean emitDropStatements;
+	
+	/** 出力するデータセットのインデックス */
+	private int dataSetIndex;
+	
+
+	public boolean emitDropStatements() {
+		return emitDropStatements;
+	}
+	
+	public int getDataSetIndex() {
+		return dataSetIndex;
+	}
+	
+	/**
+	 * 出力するデータセットのインデックスを設定する。
+	 * 
+	 * <p>INSERT文を出力しない場合は、負数を設定する。</p>
+	 * 
+	 * @param dataSetIndex 出力するデータセットのインデックス
+	 */
+	public void setDataSetIndex(int dataSetIndex) {
+		this.dataSetIndex = dataSetIndex;
+	}
+	
+	/**
+	 * CREATE文の前にDROP文を出力するかどうかを設定する。
+	 * 
+	 * @param emitDropStatements 出力する場合は{@code true}、そうでない場合は{@code false}
+	 */
+	public void setEmitDropStatements(boolean emitDropStatements) {
+		this.emitDropStatements = emitDropStatements;
+	}
+}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/25
+ *
+ * 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.composer.exporter;
+
+import java.io.File;
+
+import org.jiemamy.composer.ExportConfig;
+import org.jiemamy.composer.Exporter;
+
+/**
+ * ファイルにを出力する{@link Exporter}に関する設定情報インターフェイス。
+ * 
+ * @author daisuke
+ */
+public interface FileExportConfig extends ExportConfig {
+	
+	/**
+	 * 出力ファイルを取得する。
+	 * 
+	 * @return 出力ファイル. 未設定の場合は{@code null} 
+	 */
+	File getOutputFile();
+	
+	/**
+	 * 出力ファイルが既に存在した場合、上書きするかどうか調べる。
+	 * 
+	 * @return 上書きする場合は{@code true}、そうでない場合は{@code false}
+	 */
+	boolean isOverwrite();
+	
+}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/25
+ *
+ * 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.composer.exporter;
+
+import org.jiemamy.dialect.EmitConfig;
+
+/**
+ * {@link SqlExporter}に関する設定情報インターフェイス。
+ * 
+ * @author daisuke
+ */
+public interface SqlExportConfig extends FileExportConfig, EmitConfig {
+	
+}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/SqlExporter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2008/07/12
+ *
+ * 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.composer.exporter;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.List;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.CharEncoding;
+import org.apache.commons.lang.SystemUtils;
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import org.jiemamy.composer.ExportException;
+import org.jiemamy.composer.Exporter;
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.model.RootModel;
+import org.jiemamy.model.sql.SqlStatement;
+import org.jiemamy.utils.model.RootModelUtil;
+
+/**
+ * モデルからSQLを構築するエクスポータ。
+ * 
+ * @author daisuke
+ */
+public class SqlExporter implements Exporter<SqlExportConfig> {
+	
+	/** ConfigKey: オーバーライトするかどうか (Boolean) */
+	public static final String OVERWRITE = "overwrite";
+	
+	/** ConfigKey: 出力ファイル名 (String) */
+	public static final String OUTPUT_FILE = "outputFile";
+	
+	/** ConfigKey: 出力データセット番号 (Integer) */
+	public static final String DATA_SET_INDEX = "dataSetIndex";
+	
+
+	public boolean exportModel(RootModel rootModel, SqlExportConfig config) throws ExportException {
+		Validate.notNull(rootModel);
+		Validate.notNull(config);
+		Validate.notNull(config.getOutputFile());
+		
+		Writer writer = null;
+		try {
+			Dialect dialect = RootModelUtil.getDialect(rootModel);
+			
+			List<SqlStatement> statements = dialect.emitStatements(rootModel, config);
+			
+			File outputFile = config.getOutputFile();
+			if (outputFile.exists()) {
+				if (config.isOverwrite() == false) {
+					return false;
+				}
+				if (outputFile.delete() == false) {
+					throw new ExportException("Cannot delete file: " + outputFile.getAbsolutePath());
+				}
+			}
+			
+			writer = new OutputStreamWriter(new FileOutputStream(outputFile), CharEncoding.UTF_8);
+			for (SqlStatement stmt : statements) {
+				writer.write(stmt.toString());
+				writer.write(SystemUtils.LINE_SEPARATOR);
+			}
+		} catch (IOException e) {
+			throw new ExportException(e);
+		} catch (ClassNotFoundException e) {
+			throw new ExportException("Dialect not found: " + rootModel.getDialectClassName(), e);
+		} finally {
+			IOUtils.closeQuietly(writer);
+		}
+		return true;
+	}
+	
+	public String getName() {
+		return "SQL Exporter";
+	}
+	
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+	}
+	
+}

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/25
+ *
+ * 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.composer.importer;
+
+import java.net.URL;
+
+import org.jiemamy.composer.ImportConfig;
+import org.jiemamy.dialect.Dialect;
+
+/**
+ * {@link DatabaseImporter}に関する設定情報インターフェイス。
+ * 
+ * @author daisuke
+ */
+public interface DatabaseImportConfig extends ImportConfig {
+	
+	/**
+	 * データベース名を取得する。
+	 * 
+	 * @return データベース名. 未設定の場合は{@code null}
+	 */
+	String getDatabaseName();
+	
+	/**
+	 * SQL方言を取得する。
+	 * 
+	 * @return SQL方言. 未設定の場合は{@code null}
+	 */
+	Dialect getDialect();
+	
+	/**
+	 * ドライバの完全修飾クラス名を取得する。
+	 * 
+	 * @return ドライバの完全修飾クラス名. 未設定の場合は{@code null}
+	 */
+	String getDriverClassName();
+	
+	/**
+	 * ドライバJARファイルのパス配列を取得する。
+	 * 
+	 * @return ドライバJARファイルのパス配列. 未設定の場合は{@code null}
+	 */
+	URL[] getDriverJarPath();
+	
+	/**
+	 * インポートするエンティティの種類を取得する。
+	 * 
+	 * @return インポートするエンティティの種類. 未設定の場合は{@code null}
+	 */
+	String[] getEntityTypes();
+	
+	/**
+	 * 接続パスワードを取得する。
+	 * 
+	 * @return 接続パスワード. 未設定の場合は{@code null}
+	 */
+	String getPassword();
+	
+	/**
+	 * スキーマ名を取得する。
+	 * 
+	 * @return スキーマ名. 未設定の場合は{@code null}
+	 */
+	String getSchema();
+	
+	/**
+	 * インポートするエンティティ名の配列を取得する。
+	 * 
+	 * @return インポートするエンティティ名の配列. 未設定の場合は{@code null}
+	 */
+	String[] getSelectedEntities();
+	
+	/**
+	 * 接続URIを取得する。
+	 * 
+	 * @return 接続URI. 未設定の場合は{@code null}
+	 */
+	String getUri();
+	
+	/**
+	 * 接続ユーザ名を取得する。
+	 * 
+	 * @return 接続ユーザ名. 未設定の場合は{@code null}
+	 */
+	String getUsername();
+	
+}

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,275 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2008/07/26
+ *
+ * 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.composer.importer;
+
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.Driver;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import org.jiemamy.JiemamyFactory;
+import org.jiemamy.composer.ImportConfig;
+import org.jiemamy.composer.ImportException;
+import org.jiemamy.composer.Importer;
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.dialect.generic.GenericDialect;
+import org.jiemamy.exception.DriverNotFoundException;
+import org.jiemamy.exception.GenericModelingModeException;
+import org.jiemamy.model.RootModel;
+import org.jiemamy.model.attribute.ColumnModel;
+import org.jiemamy.model.attribute.constraint.ForeignKey;
+import org.jiemamy.model.entity.EntityModel;
+import org.jiemamy.model.entity.TableModel;
+import org.jiemamy.utils.CollectionsUtil;
+import org.jiemamy.utils.DriverUtil;
+import org.jiemamy.utils.JmIOUtil;
+import org.jiemamy.utils.model.ForeignKeyUtil;
+import org.jiemamy.utils.model.RootModelUtil;
+import org.jiemamy.utils.model.TableUtil;
+import org.jiemamy.utils.visitor.AbstractResultSetVisitor;
+
+/**
+ * データベースからモデルを生成するインポータ。
+ * 
+ * @author daisuke
+ */
+public class DatabaseImporter implements Importer<DatabaseImportConfig> {
+	
+	/** ConfigKey: SQL方言 (Dialect) */
+	public static final String DIALECT = "dialect";
+	
+	/** ConfigKey: データベース名 (String) */
+	public static final String DATABASE_NAME = "databaseName";
+	
+	/** ConfigKey: ドライバJARファイルのURL (URL[]) */
+	public static final String DRIVER_JAR_PATH = "driverJarPath";
+	
+	/** ConfigKey: ドライバの完全修飾クラス名 (String) */
+	public static final String DRIVER_CLASS_NAME = "driverClassName";
+	
+	/** ConfigKey: DB接続URI (String) */
+	public static final String URI = "uri";
+	
+	/** ConfigKey: DB接続スキーマ名 (String) */
+	public static final String SCHEMA = "schema";
+	
+	/** ConfigKey: DB接続username (String) */
+	public static final String USERNAME = "username";
+	
+	/** ConfigKey: DB接続password (String) */
+	public static final String PASSWORD = "password";
+	
+	/** ConfigKey: importするエンティティ名 (String[]) */
+	public static final String SELECTED_ENTITIES = "selectedEntities";
+	
+	/** ConfigKey: importするエンティティの種類 (String[]) */
+	public static final String ENTITY_TYPES = "entityTypes";
+	
+	/** SQL方言 */
+	private Dialect dialect;
+	
+
+	public String getName() {
+		return "Database Importer";
+	}
+	
+	public boolean importModel(RootModel rootModel, DatabaseImportConfig config) throws ImportException {
+		Validate.notNull(rootModel);
+		Validate.notNull(config);
+		
+		Connection connection = null;
+		try {
+			dialect = config.getDialect();
+			if (dialect instanceof GenericDialect) {
+				throw new GenericModelingModeException();
+			}
+			
+			Properties props = new Properties();
+			props.setProperty("user", config.getUsername());
+			props.setProperty("password", config.getPassword());
+			
+			URL[] paths = config.getDriverJarPath();
+			String className = config.getDriverClassName();
+			Driver driver = DriverUtil.getDriverInstance(paths, className);
+			connection = driver.connect(config.getUri(), props);
+			DatabaseMetaData meta = connection.getMetaData();
+			
+			DatabaseReader reader = new DatabaseReader(dialect, config, meta);
+			
+			dialect.getAdvisor().setUpRead(connection);
+			reader.readEnities(new EntityImportVisitor(meta, rootModel, config));
+			reader.readRelations(new RelationImportVisitor(meta, rootModel, config));
+			dialect.getAdvisor().tearDownRead(connection);
+		} catch (GenericModelingModeException e) {
+			throw new ImportException(e);
+		} catch (DriverNotFoundException e) {
+			throw new ImportException(e);
+		} catch (InstantiationException e) {
+			throw new ImportException(e);
+		} catch (IllegalAccessException e) {
+			throw new ImportException(e);
+		} catch (IOException e) {
+			throw new ImportException(e);
+		} catch (SQLException e) {
+			throw new ImportException(e);
+		} catch (Exception e) {
+			throw new ImportException(e);
+		} finally {
+			JmIOUtil.closeQuietly(connection);
+		}
+		return true;
+	}
+	
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+	}
+	
+
+	/**
+	 * {@link RootModel}にEntityをインポートする、{@link ResultSet}に対するビジター。
+	 * 
+	 * <p>{@link DatabaseReader}に対するストラテジとも言える。</p>
+	 * 
+	 * @author daisuke
+	 */
+	class EntityImportVisitor extends AbstractResultSetVisitor<Void, RuntimeException> {
+		
+		/** DBメタデータ */
+		private DatabaseMetaData meta;
+		
+		/** 書き込み先モデル */
+		private RootModel rootModel;
+		
+		/**
+		 * 読み込み対象のエンティティ型リスト
+		 * 
+		 * 例えば "TABLE" とか "VIEW" とか。
+		 */
+		private List<String> entityTypes;
+		
+		/**
+		 * 読み込み対象のエンティティ名のリスト
+		 * 
+		 * ただし、空リストだった場合、全てのエンティティを読むことを意味する。
+		 */
+		private List<String> selectedEntities;
+		
+		private JiemamyFactory factory;
+		
+
+		/**
+		 * インスタンスを生成する。
+		 * 
+		 * @param meta DBメタデータ
+		 * @param rootModel 書き込み先モデル
+		 * @param ctx インポートに関するコンテキスト情報
+		 */
+		public EntityImportVisitor(DatabaseMetaData meta, RootModel rootModel, DatabaseImportConfig ctx) {
+			this.meta = meta;
+			this.rootModel = rootModel;
+			factory = rootModel.getJiemamy().getFactory();
+			String[] entityTypesValue = ctx.getEntityTypes();
+			if (entityTypesValue == null) {
+				entityTypesValue = new String[] {
+					"TABLE",
+					"VIEW"
+				};
+			}
+			entityTypes = Arrays.asList(entityTypesValue);
+			String[] selectedEntitiesValue = ctx.getSelectedEntities();
+			selectedEntities = selectedEntitiesValue == null ? null : Arrays.asList(selectedEntitiesValue);
+		}
+		
+		public Void visit(ResultSet entity) throws SQLException {
+			if ((entityTypes.contains(entity.getString("TABLE_TYPE")))
+					&& (selectedEntities == null || selectedEntities.contains(entity.getString("TABLE_NAME")))) {
+				EntityModel entityModel = dialect.createEntity(factory, entity, meta);
+				if (entityModel != null) {
+					rootModel.getEntities().add(entityModel);
+				}
+			}
+			return null;
+		}
+	}
+	
+	/**
+	 * {@link RootModel}にRelationをインポートする、{@link ResultSet}に対するビジター。
+	 * 
+	 * {@link DatabaseReader}に対するストラテジとも言える。
+	 * @author daisuke
+	 */
+	class RelationImportVisitor extends AbstractResultSetVisitor<Void, RuntimeException> {
+		
+		/** 書き込み先モデル */
+		private RootModel rootModel;
+		
+		/** キャッシュ */
+		private Map<String, ForeignKey> foreignKeys = CollectionsUtil.newHashMap();
+		
+
+		/**
+		 * インスタンスを生成する。
+		 * 
+		 * @param meta DBメタデータ
+		 * @param rootModel 書き込み先モデル
+		 * @param config インポート設定
+		 */
+		public RelationImportVisitor(DatabaseMetaData meta, RootModel rootModel, ImportConfig config) {
+			this.rootModel = rootModel;
+		}
+		
+		public Void visit(ResultSet keys) throws SQLException {
+			String fkName = keys.getString("FK_NAME");
+			String fkTableName = keys.getString("FKTABLE_NAME");
+			String fkColumnName = keys.getString("FKCOLUMN_NAME");
+			String pkTableName = keys.getString("PKTABLE_NAME");
+			String pkColumnName = keys.getString("PKCOLUMN_NAME");
+			
+			TableModel constrainedTable = RootModelUtil.getEntity(rootModel, TableModel.class, fkTableName);
+			TableModel referenceTable = RootModelUtil.getEntity(rootModel, TableModel.class, pkTableName);
+			
+			if (constrainedTable != null && referenceTable != null) {
+				JiemamyFactory factory = rootModel.getJiemamy().getFactory();
+				ForeignKey foreignKey = foreignKeys.get(fkName);
+				if (foreignKey == null) {
+					foreignKey = factory.newModel(ForeignKey.class);
+					foreignKey.setName(fkName);
+					constrainedTable.getAttributes().add(foreignKey);
+					foreignKeys.put(fkName, foreignKey);
+				}
+				ColumnModel fkColumn = TableUtil.getColumn(constrainedTable, fkColumnName);
+				ColumnModel pkColumn = TableUtil.getColumn(referenceTable, pkColumnName);
+				ForeignKeyUtil.addMapping(foreignKey, fkColumn, pkColumn);
+			}
+			return null;
+		}
+	}
+}

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2008/07/18
+ *
+ * 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.composer.importer;
+
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.List;
+
+import org.apache.commons.lang.Validate;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.utils.CollectionsUtil;
+import org.jiemamy.utils.ForEachUtil;
+import org.jiemamy.utils.visitor.AbstractResultSetVisitor;
+import org.jiemamy.utils.visitor.impl.EntityNamesVisitor;
+
+/**
+ * データベースを読み込む。
+ * 
+ * <p>model, dialect, reader, database の関係を人間のメタファで説明しようとすると、
+ * 方言というのは、リソース(読み出し対象)の性質である為、読み手が知っていれば読めるもの。
+ * 方言を知っている読み手に対して、リソースを与えると、方言に応じて様々な情報を読み取る。
+ * readerはこの「読み手」であり、databaseは「リソース」、modelは「様々な情報」である。</p>
+ * 
+ * @author daisuke
+ */
+class DatabaseReader {
+	
+	// THINK DBを読み込んだ結果、modelを「出力する」主体はReaderである為、現在の実装のようにDialectに丸投げ委譲、
+	// というのは責務の重心がおかしい。Dialectは必要な部分のみReaderから問い合わせられるだけの立場であり、
+	// 基本的にモデルを組み立てる責務はReader側にあるものではないか?
+	
+	private final Dialect dialect;
+	
+	private final DatabaseImportConfig config;
+	
+	private final DatabaseMetaData meta;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param dialect SQL方言
+	 * @param config コンテキスト情報
+	 * @param meta DBメタデータ
+	 */
+	public DatabaseReader(Dialect dialect, DatabaseImportConfig config, DatabaseMetaData meta) {
+		Validate.notNull(dialect);
+		Validate.notNull(config);
+		Validate.notNull(meta);
+		this.dialect = dialect;
+		this.config = config;
+		this.meta = meta;
+	}
+	
+	/**
+	 * DB接続からエンティティを読み込む。
+	 * 
+	 * @param <T> 読み込んだ結果、戻り値型
+	 * @param visitor 各エンティティに情報に対するビジター
+	 * @return ビジターに依存した、実行結果
+	 * @throws SQLException SQLの実行に失敗した場合
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public <T>T readEnities(AbstractResultSetVisitor<T, RuntimeException> visitor) throws SQLException {
+		assert dialect != null;
+		assert config != null;
+		assert meta != null;
+		Validate.notNull(visitor);
+		
+		String schema = config.getSchema();
+		
+		ResultSet entities = meta.getTables(null, schema, "%", null);
+		T result = ForEachUtil.accept(entities, visitor);
+		
+		return result;
+	}
+	
+	/**
+	 * DB接続からリレーションを読み込む。
+	 * 
+	 * @param <T> 読み込んだ結果、戻り値型
+	 * @param visitor 各エンティティに情報に対するビジター
+	 * @return ビジターに依存した、実行結果
+	 * @throws SQLException SQLの実行に失敗した場合
+	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
+	 */
+	public <T>List<T> readRelations(AbstractResultSetVisitor<T, RuntimeException> visitor) throws SQLException {
+		assert dialect != null;
+		assert config != null;
+		assert meta != null;
+		Validate.notNull(visitor);
+		
+		String schema = config.getSchema();
+		
+		List<String> entityNames = readEnities(new EntityNamesVisitor());
+		
+		List<T> result = CollectionsUtil.newArrayList();
+		for (String entityName : entityNames) {
+			ResultSet relations = meta.getImportedKeys(null, schema, entityName);
+			result.add(ForEachUtil.accept(relations, visitor));
+		}
+		return result;
+	}
+	
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
+	}
+}

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,193 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2008/07/12
+ *
+ * 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.composer.importer;
+
+import java.net.URL;
+
+import org.jiemamy.dialect.Dialect;
+
+/**
+ * {@link DatabaseImporter}に関する設定情報保持クラス。
+ * 
+ * @author daisuke
+ */
+public class DefaultDatabaseImportConfig 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 databaseName;
+	
+	/** スキーマ名 */
+	private String schema;
+	
+
+	public String getDatabaseName() {
+		return databaseName;
+	}
+	
+	public Dialect getDialect() {
+		return dialect;
+	}
+	
+	public String getDriverClassName() {
+		return driverClassName;
+	}
+	
+	public URL[] getDriverJarPath() {
+		return driverJarPath;
+	}
+	
+	public String[] getEntityTypes() {
+		return entityTypes;
+	}
+	
+	public String getPassword() {
+		return password;
+	}
+	
+	public String getSchema() {
+		return schema;
+	}
+	
+	public String[] getSelectedEntities() {
+		return selectedEntities;
+	}
+	
+	public String getUri() {
+		return uri;
+	}
+	
+	public String getUsername() {
+		return username;
+	}
+	
+	/**
+	 * データベース名を設定する。
+	 * 
+	 * @param databaseName データベース名
+	 */
+	public void setDatabaseName(String databaseName) {
+		this.databaseName = databaseName;
+	}
+	
+	/**
+	 * SQL方言を設定する。
+	 * 
+	 * @param dialect SQL方言
+	 */
+	public void setDialect(Dialect dialect) {
+		this.dialect = dialect;
+	}
+	
+	/**
+	 * ドライバの完全修飾クラス名を設定する。
+	 * 
+	 * @param driverClassName ドライバの完全修飾クラス名
+	 */
+	public void setDriverClassName(String driverClassName) {
+		this.driverClassName = driverClassName;
+	}
+	
+	/**
+	 * ドライバJARファイルのパス配列を設定する。
+	 * 
+	 * @param driverJarPath ドライバJARファイルのパス配列
+	 */
+	public void setDriverJarPath(URL[] driverJarPath) {
+		this.driverJarPath = driverJarPath;
+	}
+	
+	/**
+	 * インポートするエンティティの種類を設定する。
+	 * 
+	 * @param entityTypes インポートするエンティティの種類
+	 */
+	public void setEntityTypes(String[] entityTypes) {
+		this.entityTypes = entityTypes;
+	}
+	
+	/**
+	 * 接続パスワードを設定する。
+	 * 
+	 * @param password 接続パスワード
+	 */
+	public void setPassword(String password) {
+		this.password = password;
+	}
+	
+	/**
+	 * スキーマ名を設定する。
+	 * 
+	 * @param schema スキーマ名
+	 */
+	public void setSchema(String schema) {
+		this.schema = schema;
+	}
+	
+	/**
+	 * インポートするエンティティ名の配列を設定する。
+	 * 
+	 * @param selectedEntities インポートするエンティティ名の配列
+	 */
+	public void setSelectedEntities(String[] selectedEntities) {
+		this.selectedEntities = selectedEntities;
+	}
+	
+	/**
+	 * 接続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/dialect/DefaultSqlEmitter.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -46,6 +46,9 @@
 import org.jiemamy.model.entity.TableModel;
 import org.jiemamy.model.entity.TableRef;
 import org.jiemamy.model.entity.ViewModel;
+import org.jiemamy.model.index.IndexColumnModel;
+import org.jiemamy.model.index.IndexModel;
+import org.jiemamy.model.index.IndexColumnModel.SortOrder;
 import org.jiemamy.model.sql.Identifier;
 import org.jiemamy.model.sql.Keyword;
 import org.jiemamy.model.sql.Literal;
@@ -98,8 +101,23 @@
 				result.add(new SqlStatementImpl(Literal.of(entityModel.getBeginScript(), LiteralType.FRAGMENT)));
 			}
 			
-			result.add(emitDdl(entityModel, config));
+			if (config.emitDropStatements()) {
+				result.add(emitDropEntityStatement(entityModel));
+			}
 			
+			result.add(emitCreateStatement(entityModel));
+			
+			if (entityModel instanceof TableModel) {
+				TableModel tableModel = (TableModel) entityModel;
+				for (IndexModel indexModel : tableModel.getIndexes()) {
+					if (config.emitDropStatements()) {
+						result.add(emitDropIndexStatement(indexModel));
+					}
+					
+					result.add(emitCreateIndexStatement(tableModel, indexModel));
+				}
+			}
+			
 			if (StringUtils.isEmpty(entityModel.getEndScript()) == false) {
 				result.add(new SqlStatementImpl(Literal.of(entityModel.getEndScript(), LiteralType.FRAGMENT)));
 			}
@@ -114,7 +132,7 @@
 				List<RecordModel> records = entry.getValue();
 				
 				for (RecordModel recordModel : records) {
-					result.add(emitDml(tableModel, recordModel));
+					result.add(emitInsertStatement(tableModel, recordModel));
 				}
 			}
 		}
@@ -127,14 +145,32 @@
 	}
 	
 	/**
-	 * DDLを出力する。
+	 * CREATE INDEX文を出力する。
 	 * 
-	 * @param entityModel 対象エンティティ
-	 * @param config 設定
-	 * @return DDL
+	 * @param tableModel インデックスをつけるテーブル
+	 * @param indexModel 対象インデックス
+	 * @return CREATE INDEX文
 	 */
-	protected SqlStatement emitDdl(EntityModel entityModel, EmitConfig config) {
-		return EntityEmitStrategy.fromEntity(entityModel).emit(entityModel, dataTypeResolver, tokenResolver);
+	protected SqlStatement emitCreateIndexStatement(TableModel tableModel, IndexModel indexModel) {
+		List<Token> tokens = CollectionsUtil.newArrayList();
+		tokens.add(Keyword.CREATE);
+		if (indexModel.isUnique()) {
+			tokens.add(Keyword.UNIQUE);
+		}
+		tokens.add(Keyword.INDEX);
+		tokens.add(Identifier.of(indexModel.getName()));
+		tokens.add(Keyword.ON);
+		tokens.add(Identifier.of(tableModel.getName()));
+		tokens.add(Separator.LEFT_PAREN);
+		
+		List<IndexColumnModel> indexColumns = indexModel.getIndexColumns();
+		for (IndexColumnModel indexColumnModel : indexColumns) {
+			tokens.addAll(emitIndexColumnClause(indexColumnModel));
+		}
+		tokens.remove(tokens.size() - 1);
+		tokens.add(Separator.RIGHT_PAREN);
+		tokens.add(Separator.SEMICOLON);
+		return new SqlStatementImpl(tokens);
 	}
 	
 	/**
@@ -143,7 +179,7 @@
 	 * @param schemaName スキーマ名
 	 * @return CREATE SCHEMA文
 	 */
-	private SqlStatement emitCreateSchemaStatement(String schemaName) {
+	protected SqlStatement emitCreateSchemaStatement(String schemaName) {
 		List<Token> tokens = CollectionsUtil.newArrayList();
 		tokens.add(Keyword.CREATE);
 		tokens.add(Keyword.SCHEMA);
@@ -153,13 +189,71 @@
 	}
 	
 	/**
+	 * DDLを出力する。
+	 * 
+	 * @param entityModel 対象エンティティ
+	 * @return DDL
+	 */
+	protected SqlStatement emitCreateStatement(EntityModel entityModel) {
+		return EntityEmitStrategy.fromEntity(entityModel).emit(entityModel, dataTypeResolver, tokenResolver);
+	}
+	
+	/**
+	 * エンティティのDROP文を出力する。
+	 * 
+	 * @param entityModel 対象エンティティ
+	 * @return DROP文
+	 */
+	protected SqlStatement emitDropEntityStatement(EntityModel entityModel) {
+		List<Token> tokens = CollectionsUtil.newArrayList();
+		tokens.add(Keyword.DROP);
+		tokens.addAll(tokenResolver.resolve(entityModel));
+		tokens.add(Identifier.of(entityModel.getName()));
+		tokens.add(Separator.SEMICOLON);
+		return new SqlStatementImpl(tokens);
+	}
+	
+	/**
+	 * インデックスのDROP文を出力する。
+	 * 
+	 * @param indexModel 対象インデックス
+	 * @return DROP文
+	 */
+	protected SqlStatement emitDropIndexStatement(IndexModel indexModel) {
+		List<Token> tokens = CollectionsUtil.newArrayList();
+		tokens.add(Keyword.DROP);
+		tokens.add(Keyword.INDEX);
+		tokens.add(Identifier.of(indexModel.getName()));
+		tokens.add(Separator.SEMICOLON);
+		return new SqlStatementImpl(tokens);
+	}
+	
+	/**
 	 * TODO for daisuke
 	 * 
+	 * @param indexColumnModel
+	 * @return 
+	 */
+	protected List<Token> emitIndexColumnClause(IndexColumnModel indexColumnModel) {
+		List<Token> tokens = CollectionsUtil.newArrayList();
+		ReferenceResolver referenceResolver = indexColumnModel.getJiemamy().getReferenceResolver();
+		ColumnRef columnRef = indexColumnModel.getColumnRef();
+		ColumnModel columnModel = referenceResolver.resolve(columnRef);
+		tokens.add(Identifier.of(columnModel.getName()));
+		SortOrder sortOrder = indexColumnModel.getSortOrder();
+		tokens.addAll(tokenResolver.resolve(sortOrder));
+		tokens.add(Separator.COMMA);
+		return tokens;
+	}
+	
+	/**
+	 * INSERT文を出力する。
+	 * 
 	 * @param tableModel
-	 * @param records
-	 * @return
+	 * @param recordModel
+	 * @return INSERT文
 	 */
-	private SqlStatement emitDml(TableModel tableModel, RecordModel records) {
+	protected SqlStatement emitInsertStatement(TableModel tableModel, RecordModel recordModel) {
 		JiemamyFactory factory = tableModel.getJiemamy().getFactory();
 		List<Token> tokens = CollectionsUtil.newArrayList();
 		tokens.add(Keyword.INSERT);
@@ -176,9 +270,11 @@
 			columnList.add(Identifier.of(columnModel.getName()));
 			columnList.add(Separator.COMMA);
 			
-			String string = records.getValues().get(factory.newReference(columnModel));
-			// FIXME Stringとは限らない。
-			dataList.add(Literal.of(string));
+			ReferenceResolver referenceResolver = columnModel.getJiemamy().getReferenceResolver();
+			BuiltinDataType builtinDataType =
+					DataTypeUtil.toBuiltinDataType(columnModel.getDataType(), referenceResolver);
+			String string = recordModel.getValues().get(factory.newReference(columnModel));
+			dataList.add(Literal.of(string, builtinDataType.getCategory().getLiteralType()));
 			dataList.add(Separator.COMMA);
 		}
 		columnList.remove(columnList.size() - 1);
@@ -196,7 +292,7 @@
 	
 
 	/**
-	 * 属性の出力戦略。
+	 * 属性の出力戦略列挙型。
 	 * 
 	 * @author daisuke
 	 */
@@ -505,7 +601,7 @@
 		 * @param entityModel エンティティモデル
 		 * @param dataTypeResolver データ型リゾルバ
 		 * @param tokenResolver トークンリゾルバ
-		 * @return Token列
+		 * @return トークンシーケンス
 		 */
 		public abstract SqlStatement emit(EntityModel entityModel, DataTypeResolver dataTypeResolver,
 				TokenResolver tokenResolver);

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultTokenResolver.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultTokenResolver.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultTokenResolver.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -23,6 +23,9 @@
 import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime;
 import org.jiemamy.model.attribute.constraint.ForeignKey.MatchType;
 import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction;
+import org.jiemamy.model.entity.TableModel;
+import org.jiemamy.model.entity.ViewModel;
+import org.jiemamy.model.index.IndexColumnModel.SortOrder;
 import org.jiemamy.model.sql.Keyword;
 import org.jiemamy.model.sql.Token;
 import org.jiemamy.utils.CollectionsUtil;
@@ -73,6 +76,17 @@
 				tokens.add(Keyword.NO);
 				tokens.add(Keyword.ACTION);
 			}
+		} else if (value instanceof SortOrder) {
+			SortOrder sortOrder = (SortOrder) value;
+			if (sortOrder == SortOrder.ASC) {
+				tokens.add(Keyword.ASC);
+			} else if (sortOrder == SortOrder.DESC) {
+				tokens.add(Keyword.DESC);
+			}
+		} else if (value instanceof TableModel) {
+			tokens.add(Keyword.TABLE);
+		} else if (value instanceof ViewModel) {
+			tokens.add(Keyword.VIEW);
 		}
 		return tokens;
 	}

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -64,7 +64,7 @@
 		this.columnRef = columnRef;
 	}
 	
-	public void setSortType(SortOrder sortOrder) {
+	public void setSortOrder(SortOrder sortOrder) {
 		this.sortOrder = sortOrder;
 	}
 	

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -30,6 +30,9 @@
 	/** CREATE */
 	public static final Keyword CREATE = new Keyword("CREATE");
 	
+	/** DROP */
+	public static final Keyword DROP = new Keyword("DROP");
+	
 	/** TABLE */
 	public static final Keyword TABLE = new Keyword("TABLE");
 	
@@ -138,6 +141,18 @@
 	/** VALUES */
 	public static final Keyword VALUES = new Keyword("VALUES");
 	
+	/** INDEX */
+	public static final Keyword INDEX = new Keyword("INDEX");
+	
+	/** ASC */
+	public static final Keyword ASC = new Keyword("ASC");
+	
+	/** DESC */
+	public static final Keyword DESC = new Keyword("DESC");
+	
+	/** WHERE */
+	public static final Keyword WHERE = new Keyword("WHERE");
+	
 
 	/**
 	 * インスタンスを生成する。

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/SqlStatementImpl.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -61,6 +61,18 @@
 		tokens.add(token);
 	}
 	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param index
+	 * @param tokens
+	 */
+	public void insert(int index, List<Token> tokens) {
+		for (Token token : tokens) {
+			this.tokens.add(index++, token);
+		}
+	}
+	
 	@Override
 	public String toString() {
 		return toString(new DefaultSqlFormatter());

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -49,6 +49,7 @@
 import org.jiemamy.model.entity.ViewModel;
 import org.jiemamy.model.index.IndexColumnModel;
 import org.jiemamy.model.index.IndexModel;
+import org.jiemamy.model.index.IndexColumnModel.SortOrder;
 import org.jiemamy.utils.CollectionsUtil;
 import org.jiemamy.utils.Disablable;
 import org.jiemamy.utils.builder.DataTypeBuilderImpl;
@@ -751,9 +752,11 @@
 		}
 		
 		empNameIndex = factory.newModel(IndexModel.class, uuid.get("9abc9e01-4cdb-42fe-a495-93b56af35a1d"));
+		empNameIndex.setName("IDX_EMP_NAME");
 		IndexColumnModel indexColumnModel =
 				factory.newModel(IndexColumnModel.class, uuid.get("52d2b6aa-fff7-4c33-af13-f4d0b63e8e58"));
 		indexColumnModel.setColumnRef(factory.newReference(empEmpName));
+		indexColumnModel.setSortOrder(SortOrder.DESC);
 		empNameIndex.getIndexColumns().add(indexColumnModel);
 		tableEmp.getIndexes().add(empNameIndex);
 	}

Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -30,7 +30,7 @@
 import org.jiemamy.Jiemamy;
 import org.jiemamy.model.sql.SqlStatement;
 import org.jiemamy.test.ReflectionDialectProvider;
-import org.jiemamy.test.TestModelBuilder2;
+import org.jiemamy.test.TestModelBuilder;
 import org.jiemamy.utils.model.RootModelUtil;
 
 /**
@@ -55,9 +55,9 @@
 	@Before
 	public void setUp() throws Exception {
 		jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider());
-		TestModelBuilder2 testModelBuilder = new TestModelBuilder2(jiemamy);
-		testModelBuilder.build();
-		Dialect dialect = RootModelUtil.getDialect(testModelBuilder.rootModel);
+		TestModelBuilder mb = new TestModelBuilder(jiemamy);
+		mb.build();
+		Dialect dialect = RootModelUtil.getDialect(mb.rootModel);
 		sqlEmitter = new DefaultSqlEmitter(new DefaultDataTypeResolver(dialect));
 	}
 	
@@ -82,6 +82,7 @@
 		List<SqlStatement> statements = sqlEmitter.emit(jiemamy.getFactory().getRootModel(), new MockEmitConfig());
 		for (SqlStatement sqlStatement : statements) {
 			logger.info(sqlStatement.toString());
+			// TODO assertion
 		}
 	}
 	
@@ -93,7 +94,7 @@
 		}
 		
 		public int getDataSetIndex() {
-			return -1;
+			return 0;
 		}
 		
 	}

Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java
===================================================================
--- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -18,12 +18,13 @@
  */
 package org.jiemamy.dialect.mysql;
 
+import java.util.Arrays;
 import java.util.List;
 
 import org.jiemamy.dialect.DataTypeResolver;
 import org.jiemamy.dialect.DefaultSqlEmitter;
 import org.jiemamy.dialect.DefaultTokenResolver;
-import org.jiemamy.dialect.EmitConfig;
+import org.jiemamy.dialect.SqlEmitter;
 import org.jiemamy.dialect.TokenResolver;
 import org.jiemamy.dialect.mysql.adapter.StorageEngine;
 import org.jiemamy.dialect.mysql.adapter.StorageEngineType;
@@ -42,7 +43,7 @@
 import org.jiemamy.utils.CollectionsUtil;
 
 /**
- * MySQL用のSqlEmitter実装クラス。
+ * MySQL用の{@link SqlEmitter}実装クラス。
  * 
  * @author daisuke
  */
@@ -64,10 +65,17 @@
 	}
 	
 	@Override
-	protected SqlStatement emitDdl(EntityModel entityModel, EmitConfig config) {
+	protected SqlStatement emitCreateStatement(EntityModel entityModel) {
 		return MySqlEntityEmitStrategy.fromEntity(entityModel).emit(entityModel, dataTypeResolver, tokenResolver);
 	}
 	
+	@Override
+	protected SqlStatement emitDropEntityStatement(EntityModel entityModel) {
+		SqlStatementImpl stmt = (SqlStatementImpl) super.emitDropEntityStatement(entityModel);
+		stmt.insert(2, Arrays.asList((Token) Keyword.of("IF"), Keyword.of("EXISTS")));
+		return stmt;
+	}
+	
 
 	/**
 	 * MySQL用エンティティ出力戦略。

Modified: artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java
===================================================================
--- artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -92,6 +92,7 @@
 		List<SqlStatement> statements = sqlEmitter.emit(jiemamy.getFactory().getRootModel(), new MockEmitConfig());
 		for (SqlStatement sqlStatement : statements) {
 			logger.info(sqlStatement.toString());
+			// TODO assertion
 		}
 	}
 	
@@ -99,11 +100,11 @@
 	private static class MockEmitConfig implements EmitConfig {
 		
 		public boolean emitDropStatements() {
-			return false;
+			return true;
 		}
 		
 		public int getDataSetIndex() {
-			return -1;
+			return 0;
 		}
 		
 	}

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgreSqlEmitter.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgreSqlEmitter.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgreSqlEmitter.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,162 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/02/24
+ *
+ * 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.dialect.postgresql;
+
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.jiemamy.ReferenceResolver;
+import org.jiemamy.dialect.DataTypeResolver;
+import org.jiemamy.dialect.DefaultSqlEmitter;
+import org.jiemamy.dialect.DefaultTokenResolver;
+import org.jiemamy.dialect.SqlEmitter;
+import org.jiemamy.dialect.TokenResolver;
+import org.jiemamy.dialect.postgresql.adapter.IndexColumnOption;
+import org.jiemamy.dialect.postgresql.adapter.IndexMethodType;
+import org.jiemamy.dialect.postgresql.adapter.IndexOption;
+import org.jiemamy.dialect.postgresql.adapter.NullOrder;
+import org.jiemamy.model.attribute.ColumnModel;
+import org.jiemamy.model.attribute.ColumnRef;
+import org.jiemamy.model.entity.TableModel;
+import org.jiemamy.model.index.IndexColumnModel;
+import org.jiemamy.model.index.IndexModel;
+import org.jiemamy.model.index.IndexColumnModel.SortOrder;
+import org.jiemamy.model.sql.Identifier;
+import org.jiemamy.model.sql.Keyword;
+import org.jiemamy.model.sql.Literal;
+import org.jiemamy.model.sql.Separator;
+import org.jiemamy.model.sql.SqlStatement;
+import org.jiemamy.model.sql.SqlStatementImpl;
+import org.jiemamy.model.sql.Token;
+import org.jiemamy.utils.CollectionsUtil;
+
+/**
+ * PostgreSQL用の{@link SqlEmitter}実装クラス。
+ * 
+ * @author daisuke
+ */
+public class PostgreSqlEmitter extends DefaultSqlEmitter {
+	
+	private static Logger logger = LoggerFactory.getLogger(PostgreSqlEmitter.class);
+	
+	private TokenResolver tokenResolver = new DefaultTokenResolver();
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param dataTypeResolver データ型リゾルバ
+	 */
+	public PostgreSqlEmitter(DataTypeResolver dataTypeResolver) {
+		super(dataTypeResolver);
+	}
+	
+	@Override
+	protected SqlStatement emitCreateIndexStatement(TableModel tableModel, IndexModel indexModel) {
+		if (indexModel.hasAdapter(IndexOption.class)) {
+			IndexOption indexOption = indexModel.getAdapter(IndexOption.class);
+			
+			List<Token> tokens = CollectionsUtil.newArrayList();
+			tokens.add(Keyword.CREATE);
+			if (indexModel.isUnique()) {
+				tokens.add(Keyword.UNIQUE);
+			}
+			tokens.add(Keyword.INDEX);
+			
+			if (indexOption.getConcurrently() != null && indexOption.getConcurrently() == true) {
+				tokens.add(Keyword.of("CONCURRENTLY"));
+			}
+			
+			tokens.add(Identifier.of(indexModel.getName()));
+			tokens.add(Keyword.ON);
+			tokens.add(Identifier.of(tableModel.getName()));
+			
+			if (indexOption.getIndexMethodType() != null) {
+				IndexMethodType indexMethodType = indexOption.getIndexMethodType();
+				tokens.add(Keyword.of("USING"));
+				tokens.add(Identifier.of(indexMethodType.toString()));
+			}
+			
+			tokens.add(Separator.LEFT_PAREN);
+			
+			List<IndexColumnModel> indexColumns = indexModel.getIndexColumns();
+			for (IndexColumnModel indexColumnModel : indexColumns) {
+				tokens.addAll(emitIndexColumnClause(indexColumnModel));
+			}
+			tokens.remove(tokens.size() - 1);
+			tokens.add(Separator.RIGHT_PAREN);
+			
+			if (indexOption.getFillfactor() != null) {
+				tokens.add(Keyword.WITH);
+				tokens.add(Separator.LEFT_PAREN);
+				tokens.add(Identifier.of("fillfactor"));
+				tokens.add(Separator.EQUAL);
+				tokens.add(Literal.of(indexOption.getFillfactor()));
+				tokens.add(Separator.RIGHT_PAREN);
+			}
+			if (indexOption.getTablespace() != null) {
+				tokens.add(Keyword.of("TABLESPACE"));
+				tokens.add(Identifier.of(indexOption.getTablespace()));
+			}
+			if (indexOption.getPredicate() != null) {
+				tokens.add(Keyword.WHERE);
+				tokens.add(Identifier.of(indexOption.getPredicate()));
+			}
+			
+			tokens.add(Separator.SEMICOLON);
+			return new SqlStatementImpl(tokens);
+		} else {
+			return super.emitCreateIndexStatement(tableModel, indexModel);
+		}
+	}
+	
+	@Override
+	protected List<Token> emitIndexColumnClause(IndexColumnModel indexColumnModel) {
+		if (indexColumnModel.hasAdapter(IndexColumnOption.class)) {
+			List<Token> tokens = CollectionsUtil.newArrayList();
+			ReferenceResolver referenceResolver = indexColumnModel.getJiemamy().getReferenceResolver();
+			ColumnRef columnRef = indexColumnModel.getColumnRef();
+			ColumnModel columnModel = referenceResolver.resolve(columnRef);
+			tokens.add(Identifier.of(columnModel.getName()));
+			SortOrder sortOrder = indexColumnModel.getSortOrder();
+			tokens.addAll(tokenResolver.resolve(sortOrder));
+			
+			IndexColumnOption indexColumnOption = indexColumnModel.getAdapter(IndexColumnOption.class);
+			if (indexColumnOption.getNullOrder() != null) {
+				NullOrder nullOrder = indexColumnOption.getNullOrder();
+				tokens.add(Keyword.NULL);
+				if (nullOrder == NullOrder.NULL_FIRST) {
+					tokens.add(Keyword.of("FIRST"));
+				} else if (nullOrder == NullOrder.NULL_LAST) {
+					tokens.add(Keyword.of("LAST"));
+				} else {
+					logger.warn("unkwnown NullOrder: " + nullOrder);
+					tokens.remove(tokens.size() - 1);
+				}
+			}
+			
+			tokens.add(Separator.COMMA);
+			return tokens;
+		} else {
+			return super.emitIndexColumnClause(indexColumnModel);
+		}
+	}
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgreSqlEmitter.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -102,6 +102,7 @@
 	 */
 	public PostgresqlDialect() {
 		super(typeList);
+		emitter = new PostgreSqlEmitter(getDataTypeResolver());
 	}
 	
 	@Override

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/AbstractPostgresObjectOption.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/AbstractPostgresObjectOption.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/AbstractPostgresObjectOption.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractPostgresObjectOption implements PostgresObjectOption {
+	
+	/** テーブルスペース */
+	private String tablespace;
+	
+
+	public String getTablespace() {
+		return tablespace;
+	}
+	
+	public void setTablespace(String tablespace) {
+		this.tablespace = tablespace;
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/AbstractPostgresObjectOption.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/CommitAction.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/CommitAction.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/CommitAction.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * トランザクションブロックの終了時点での一時テーブルの動作を制御する指示。
+ * 
+ * @author daisuke
+ */
+public enum CommitAction {
+	
+	/** トランザクションの終了時点で、特別な動作は行わない */
+	PRESERVE_ROWS,
+
+	/** 一時テーブル内の全ての行は、各トランザクションブロックの終わりで削除 */
+	DELETE_ROWS,
+
+	/** 一時テーブルは、現在のトランザクションブロックの終了時点で削除 */
+	DROP
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/CommitAction.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumOptionImpl.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumOptionImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumOptionImpl.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class IndexColumOptionImpl implements IndexColumnOption {
+	
+	private NullOrder nullOrder;
+	
+
+	public NullOrder getNullOrder() {
+		return nullOrder;
+	}
+	
+	public void setNullOrder(NullOrder nullOrder) {
+		this.nullOrder = nullOrder;
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumOptionImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumnOption.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumnOption.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumnOption.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface IndexColumnOption {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	NullOrder getNullOrder();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param nullOrder
+	 */
+	void setNullOrder(NullOrder nullOrder);
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexColumnOption.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexMethodType.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexMethodType.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexMethodType.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface IndexMethodType {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	String toString();
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexMethodType.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOption.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOption.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOption.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface IndexOption extends PostgresObjectOption {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	Boolean getConcurrently();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	Integer getFillfactor();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	IndexMethodType getIndexMethodType();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	String getPredicate();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param concurrently
+	 */
+	void setConcurrently(Boolean concurrently);
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param fillfactor
+	 */
+	void setFillfactor(Integer fillfactor);
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param indexMethodType
+	 */
+	void setIndexMethodType(IndexMethodType indexMethodType);
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param predicate
+	 */
+	void setPredicate(String predicate);
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOption.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOptionImpl.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOptionImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOptionImpl.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+import org.jiemamy.model.Adapter;
+import org.jiemamy.model.AdapterType;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+ @ Adapter(AdapterType.MODEL)
+public class IndexOptionImpl extends AbstractPostgresObjectOption implements IndexOption {
+	
+	private IndexMethodType indexMethodType;
+	
+	private Boolean concurrently;
+	
+	private Integer fillfactor;
+	
+	/** 部分インデックス生成用条件 */
+	private String predicate;
+	
+
+	public Boolean getConcurrently() {
+		return concurrently;
+	}
+	
+	public Integer getFillfactor() {
+		return fillfactor;
+	}
+	
+	public IndexMethodType getIndexMethodType() {
+		return indexMethodType;
+	}
+	
+	public String getPredicate() {
+		return predicate;
+	}
+	
+	public void setConcurrently(Boolean concurrently) {
+		this.concurrently = concurrently;
+	}
+	
+	public void setFillfactor(Integer fillfactor) {
+		this.fillfactor = fillfactor;
+	}
+	
+	public void setIndexMethodType(IndexMethodType indexMethodType) {
+		this.indexMethodType = indexMethodType;
+	}
+	
+	public void setPredicate(String predicate) {
+		this.predicate = predicate;
+	}
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/IndexOptionImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/NullOrder.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/NullOrder.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/NullOrder.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public enum NullOrder {
+	
+	/** NULLを非NULLより前にソートすることを指定 */
+	NULL_FIRST,
+
+	/** NULLを非NULLより後にソートすることを指定 */
+	NULL_LAST
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/NullOrder.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/PostgresObjectOption.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/PostgresObjectOption.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/PostgresObjectOption.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface PostgresObjectOption {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @return
+	 */
+	String getTablespace();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param tablespace
+	 */
+	void setTablespace(String tablespace);
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/PostgresObjectOption.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/StandardIndexMethod.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/StandardIndexMethod.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/StandardIndexMethod.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ * @see "http://www.postgresql.jp/document/current/html/sql-createindex.html"
+ */
+public enum StandardIndexMethod implements IndexMethodType {
+	
+	/** B-treeインデックスメソッド */
+	btree,
+
+	/** hashインデックスメソッド */
+	hash,
+
+	/** GiSTインデックスメソッド */
+	gist,
+
+	/** GINインデックスメソッド */
+	gin
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/StandardIndexMethod.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/TableOption.java
===================================================================
--- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/TableOption.java	                        (rev 0)
+++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/TableOption.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.dialect.postgresql.adapter;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface TableOption extends PostgresObjectOption {
+	
+	CommitAction getCommitAction();
+	
+	Boolean isTemporary();
+	
+}


Property changes on: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/adapter/TableOption.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse.core/schema/dialects.exsd
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.core/schema/dialects.exsd	2009-03-18 17:31:33 UTC (rev 2913)
+++ vesta/trunk/org.jiemamy.eclipse.core/schema/dialects.exsd	2009-03-19 08:55:40 UTC (rev 2914)
@@ -54,6 +54,7 @@
    <element name="dialect">
       <complexType>
          <sequence>
+            <element ref="typeOptionManager" minOccurs="0" maxOccurs="unbounded"/>
             <element ref="additionalTab" minOccurs="0" maxOccurs="unbounded"/>
          </sequence>
          <attribute name="class" type="string" use="required">
@@ -69,6 +70,21 @@
       </complexType>
    </element>
 
+   <element name="typeOptionManager">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.jiemamy.eclipse.editor.dialog.TypeOptionHandler"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
    <element name="additionalTab">
       <complexType>
          <attribute name="target" type="string" use="required">

Added: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/MySqlTypeOptionHandler.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/MySqlTypeOptionHandler.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/MySqlTypeOptionHandler.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.eclipse.dialect.mysql;
+
+import org.apache.commons.lang.BooleanUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.jiemamy.dialect.mysql.adapter.Unsigned;
+import org.jiemamy.eclipse.editor.dialog.AbstractTypeOptionHandler;
+import org.jiemamy.eclipse.editor.dialog.EditListener;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class MySqlTypeOptionHandler extends AbstractTypeOptionHandler {
+	
+	private static Logger logger = LoggerFactory.getLogger(MySqlTypeOptionHandler.class);
+	
+	private Button chkUnsigned;
+	
+	private Unsigned unsigned;
+	
+
+	public void createControl(Composite composite, EditListener editListener, Class<?> adapterClass) {
+		logger.trace("createControl");
+		
+		if (Unsigned.class.isAssignableFrom(adapterClass)) {
+			chkUnsigned = new Button(composite, SWT.CHECK);
+			chkUnsigned.setText("UNSIGNED"); // RESOURCE
+			chkUnsigned.addKeyListener(editListener);
+		}
+	}
+	
+	public void disable() {
+		logger.trace("disable");
+		setEnabledIfAlive(chkUnsigned, false);
+	}
+	
+	public void enable() {
+		logger.trace("enable");
+		setEnabledIfAlive(chkUnsigned, true);
+	}
+	
+	public void setValue(Object adapter) {
+		logger.trace("setValue");
+		Class<?> adapterClass = adapter.getClass();
+		if (Unsigned.class.isAssignableFrom(adapterClass)) {
+			unsigned = (Unsigned) adapter;
+			Boolean unsigned = this.unsigned.getUnsigned();
+			chkUnsigned.setSelection(BooleanUtils.isTrue(unsigned));
+		}
+	}
+	
+	public void writeBackToAdapter() {
+		logger.trace("writeBackToAdapter");
+		if (isAlive(chkUnsigned) && unsigned != null) {
+			boolean value = chkUnsigned.getSelection();
+			unsigned.setUnsigned(value == false ? null : value);
+		}
+	}
+	
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse.dialect.mysql/src/main/java/org/jiemamy/eclipse/dialect/mysql/MySqlTypeOptionHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse.ui/META-INF/MANIFEST.MF
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/META-INF/MANIFEST.MF	2009-03-18 17:31:33 UTC (rev 2913)
+++ vesta/trunk/org.jiemamy.eclipse.ui/META-INF/MANIFEST.MF	2009-03-19 08:55:40 UTC (rev 2914)
@@ -23,14 +23,17 @@
  org.jiemamy.eclipse.core
 Export-Package: org.jiemamy.eclipse,
  org.jiemamy.eclipse.action,
+ org.jiemamy.eclipse.composer,
  org.jiemamy.eclipse.editor,
  org.jiemamy.eclipse.editor.command,
+ org.jiemamy.eclipse.editor.dialog,
  org.jiemamy.eclipse.editor.dialog.root,
  org.jiemamy.eclipse.editor.editpart,
  org.jiemamy.eclipse.editor.editpart.diagram,
  org.jiemamy.eclipse.editor.editpart.outlinetree,
  org.jiemamy.eclipse.editor.editpolicy,
  org.jiemamy.eclipse.editor.figure,
+ org.jiemamy.eclipse.editor.tools,
  org.jiemamy.eclipse.editor.utils,
  org.jiemamy.eclipse.preference,
  org.jiemamy.eclipse.ui,

Added: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/AbstractTypeOptionHandler.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/AbstractTypeOptionHandler.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/AbstractTypeOptionHandler.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.eclipse.editor.dialog;
+
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractTypeOptionHandler implements TypeOptionHandler {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param control
+	 * @return
+	 */
+	public static boolean isAlive(Control control) {
+		return control != null && control.isDisposed() == false;
+	}
+	
+	/**
+	 * オプションコントロールが生きていれば、enableの値を設定する。
+	 * 
+	 * <p>死んでいる(存在しない or 破棄済み)場合は何もしない。</p>
+	 * 
+	 * @param control 対象コントロール
+	 * @param enabled enableの値
+	 */
+	public static void setEnabledIfAlive(Control control, boolean enabled) {
+		if (isAlive(control)) {
+			control.setEnabled(enabled);
+		}
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/AbstractTypeOptionHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionHandler.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionHandler.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionHandler.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.eclipse.editor.dialog;
+
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public interface TypeOptionHandler {
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param composite
+	 * @param editListener 
+	 * @param adapterClass
+	 */
+	void createControl(Composite composite, EditListener editListener, Class<?> adapterClass);
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 */
+	void disable();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 */
+	void enable();
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @param adapter
+	 */
+	void setValue(Object adapter);
+	
+	/**
+	 * TODO for daisuke
+	 * 
+	 */
+	void writeBackToAdapter();
+	
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionHandler.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -25,7 +25,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.Validate;
 import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
@@ -35,8 +34,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import org.jiemamy.eclipse.ui.UIConstant;
 import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter;
 import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter;
+import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter;
 import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter;
 import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter;
 import org.jiemamy.utils.LogMarker;
@@ -48,8 +49,6 @@
  */
 public class TypeOptionManager {
 	
-	private static final Color ERROR = new Color(null, 255, 200, 200);
-	
 	private static Logger logger = LoggerFactory.getLogger(TypeOptionManager.class);
 	
 	/** オプションコントロール描画対象の親 */
@@ -58,6 +57,8 @@
 	/** コントロールの操作を検知するリスナ */
 	private final EditListener editListener;
 	
+	private final TypeOptionHandler handler;
+	
 	/** サイズコントロール */
 	private Text txtSize;
 	
@@ -70,25 +71,32 @@
 	/** タイムゾーンコントロール */
 	private Button chkWithTimezone;
 	
+	/** 自動採番コントロール */
+	private Button chkSerial;
+	
 	private SizedDataTypeAdapter sizedDataTypeAdapter;
 	
 	private PrecisionedDataTypeAdapter precisionedDataTypeAdapter;
 	
 	private TimezonedDataTypeAdapter timezonedDataTypeAdapter;
 	
+	private SerialDataTypeAdapter serialDataTypeAdapter;
+	
 
 	/**
 	 * インスタンスを生成する。
 	 * 
 	 * @param composite オプションコントロール描画対象の親
 	 * @param editListener コントロールの操作を検知するリスナ
+	 * @param handler may be null
 	 * @throws IllegalArgumentException 引数に{@code null}を与えた場合
 	 */
-	public TypeOptionManager(Composite composite, EditListener editListener) {
+	public TypeOptionManager(Composite composite, EditListener editListener, TypeOptionHandler handler) {
 		Validate.notNull(composite);
 		Validate.notNull(editListener);
 		this.composite = composite;
 		this.editListener = editListener;
+		this.handler = handler;
 	}
 	
 	/**
@@ -136,6 +144,12 @@
 				chkWithTimezone = new Button(composite, SWT.CHECK);
 				chkWithTimezone.setText("WITH TIMEZONE"); // RESOURCE
 				chkWithTimezone.addKeyListener(editListener);
+			} else if (SerialDataTypeAdapter.class.isAssignableFrom(adapterClass)) {
+				chkSerial = new Button(composite, SWT.CHECK);
+				chkSerial.setText("自動採番"); // RESOURCE
+				chkSerial.addKeyListener(editListener);
+			} else if (handler != null) {
+				handler.createControl(composite, editListener, adapterClass);
 			}
 		}
 		
@@ -172,20 +186,28 @@
 	 * オプションコントロールをすべて無効にする。
 	 */
 	public void disable() {
-		setEnabledIfAlive(txtSize, false);
-		setEnabledIfAlive(txtPrecision, false);
-		setEnabledIfAlive(txtScale, false);
-		setEnabledIfAlive(chkWithTimezone, false);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtSize, false);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtPrecision, false);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtScale, false);
+		AbstractTypeOptionHandler.setEnabledIfAlive(chkWithTimezone, false);
+		AbstractTypeOptionHandler.setEnabledIfAlive(chkSerial, false);
+		if (handler != null) {
+			handler.disable();
+		}
 	}
 	
 	/**
 	 * オプションコントロールをすべて有効にする。
 	 */
 	public void enable() {
-		setEnabledIfAlive(txtSize, true);
-		setEnabledIfAlive(txtPrecision, true);
-		setEnabledIfAlive(txtScale, true);
-		setEnabledIfAlive(chkWithTimezone, true);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtSize, true);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtPrecision, true);
+		AbstractTypeOptionHandler.setEnabledIfAlive(txtScale, true);
+		AbstractTypeOptionHandler.setEnabledIfAlive(chkWithTimezone, true);
+		AbstractTypeOptionHandler.setEnabledIfAlive(chkSerial, true);
+		if (handler != null) {
+			handler.enable();
+		}
 	}
 	
 	/**
@@ -210,6 +232,12 @@
 			timezonedDataTypeAdapter = (TimezonedDataTypeAdapter) adapter;
 			Boolean withTimeZone = timezonedDataTypeAdapter.isWithTimezone();
 			chkWithTimezone.setSelection(BooleanUtils.isTrue(withTimeZone));
+		} else if (SerialDataTypeAdapter.class.isAssignableFrom(adapterClass)) {
+			serialDataTypeAdapter = (SerialDataTypeAdapter) adapter;
+			Boolean serial = serialDataTypeAdapter.isSerial();
+			chkSerial.setSelection(BooleanUtils.isTrue(serial));
+		} else if (handler != null) {
+			handler.setValue(adapter);
 		}
 	}
 	
@@ -217,29 +245,29 @@
 	 * コントロールからアダプタにデータを書き戻す。
 	 */
 	public void writeBackToAdapter() {
-		if (isAlive(txtSize) && sizedDataTypeAdapter != null) {
+		if (AbstractTypeOptionHandler.isAlive(txtSize) && sizedDataTypeAdapter != null) {
 			String text = txtSize.getText();
 			Integer value = null;
 			try {
 				value = Integer.valueOf(text);
 				txtSize.setBackground(null);
 			} catch (NumberFormatException e) {
-				txtSize.setBackground(ERROR);
+				txtSize.setBackground(UIConstant.COLOR_ERROR);
 			}
 			sizedDataTypeAdapter.setSize(value);
 		}
-		if (isAlive(txtPrecision) && precisionedDataTypeAdapter != null) {
+		if (AbstractTypeOptionHandler.isAlive(txtPrecision) && precisionedDataTypeAdapter != null) {
 			String text = txtPrecision.getText();
 			Integer value = null;
 			try {
 				value = Integer.valueOf(text);
 				txtPrecision.setBackground(null);
 			} catch (NumberFormatException e) {
-				txtPrecision.setBackground(ERROR);
+				txtPrecision.setBackground(UIConstant.COLOR_ERROR);
 			}
 			precisionedDataTypeAdapter.setPrecision(value);
 		}
-		if (isAlive(txtScale) && precisionedDataTypeAdapter != null) {
+		if (AbstractTypeOptionHandler.isAlive(txtScale) && precisionedDataTypeAdapter != null) {
 			String text = txtScale.getText();
 			Integer value = null;
 			if (StringUtils.isEmpty(text)) {
@@ -249,32 +277,22 @@
 					value = Integer.valueOf(text);
 					txtScale.setBackground(null);
 				} catch (NumberFormatException e) {
-					txtScale.setBackground(ERROR);
+					txtScale.setBackground(UIConstant.COLOR_ERROR);
 				}
 			}
 			precisionedDataTypeAdapter.setScale(value);
 		}
-		if (isAlive(chkWithTimezone) && timezonedDataTypeAdapter != null) {
+		if (AbstractTypeOptionHandler.isAlive(chkWithTimezone) && timezonedDataTypeAdapter != null) {
 			boolean value = chkWithTimezone.getSelection();
 			timezonedDataTypeAdapter.setWithTimezone(value == false ? null : value);
 		}
+		if (AbstractTypeOptionHandler.isAlive(chkSerial) && serialDataTypeAdapter != null) {
+			boolean value = chkSerial.getSelection();
+			serialDataTypeAdapter.setSerial(value == false ? null : value);
+		}
+		if (handler != null) {
+			handler.writeBackToAdapter();
+		}
 	}
 	
-	private boolean isAlive(Control control) {
-		return control != null && control.isDisposed() == false;
-	}
-	
-	/**
-	 * オプションコントロールが生きていれば、enableの値を設定する。
-	 * 
-	 * <p>死んでいる(存在しない or 破棄済み)場合は何もしない。</p>
-	 * 
-	 * @param control 対象コントロール
-	 * @param enabled enableの値
-	 */
-	private void setEnabledIfAlive(Control control, boolean enabled) {
-		if (isAlive(control)) {
-			control.setEnabled(enabled);
-		}
-	}
 }

Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -20,7 +20,9 @@
 
 import java.util.List;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.BaseLabelProvider;
@@ -60,8 +62,10 @@
 import org.jiemamy.eclipse.editor.DisplayPlace;
 import org.jiemamy.eclipse.editor.dialog.AbstractEditListener;
 import org.jiemamy.eclipse.editor.dialog.EditListener;
+import org.jiemamy.eclipse.editor.dialog.TypeOptionHandler;
 import org.jiemamy.eclipse.editor.dialog.TypeOptionManager;
 import org.jiemamy.eclipse.editor.utils.LabelStringUtil;
+import org.jiemamy.eclipse.extension.ExtensionResolver;
 import org.jiemamy.eclipse.ui.AbstractTableEditor;
 import org.jiemamy.eclipse.ui.DefaultTableEditorConfig;
 import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter;
@@ -318,7 +322,19 @@
 				}
 			});
 			
-			typeOptionManager = new TypeOptionManager(cmpTypeOption, editListener);
+			ExtensionResolver<Dialect> dialectResolver = JiemamyCorePlugin.getDialectResolver();
+			IConfigurationElement dialectElement =
+					dialectResolver.getExtensionConfigurationElements().get(rootModel.getDialectClassName());
+			IConfigurationElement[] children = dialectElement.getChildren("typeOptionHandler");
+			TypeOptionHandler handler = null;
+			if (ArrayUtils.isEmpty(children) == false) {
+				try {
+					handler = (TypeOptionHandler) children[0].createExecutableExtension("class");
+				} catch (Exception e) {
+					JiemamyUIPlugin.log(e);
+				}
+			}
+			typeOptionManager = new TypeOptionManager(cmpTypeOption, editListener, handler);
 			
 			chkIsNotNull.addSelectionListener(editListener);
 			

Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -21,7 +21,9 @@
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
+import org.eclipse.core.runtime.IConfigurationElement;
 import org.eclipse.jface.resource.ImageRegistry;
 import org.eclipse.jface.viewers.ArrayContentProvider;
 import org.eclipse.jface.viewers.BaseLabelProvider;
@@ -66,8 +68,10 @@
 import org.jiemamy.eclipse.editor.DisplayPlace;
 import org.jiemamy.eclipse.editor.dialog.AbstractEditListener;
 import org.jiemamy.eclipse.editor.dialog.EditListener;
+import org.jiemamy.eclipse.editor.dialog.TypeOptionHandler;
 import org.jiemamy.eclipse.editor.dialog.TypeOptionManager;
 import org.jiemamy.eclipse.editor.utils.LabelStringUtil;
+import org.jiemamy.eclipse.extension.ExtensionResolver;
 import org.jiemamy.eclipse.ui.AbstractTableEditor;
 import org.jiemamy.eclipse.ui.DefaultTableEditorConfig;
 import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter;
@@ -378,7 +382,19 @@
 				}
 			});
 			
-			typeOptionManager = new TypeOptionManager(cmpTypeOption, editListener);
+			ExtensionResolver<Dialect> dialectResolver = JiemamyCorePlugin.getDialectResolver();
+			IConfigurationElement dialectElement =
+					dialectResolver.getExtensionConfigurationElements().get(rootModel.getDialectClassName());
+			IConfigurationElement[] children = dialectElement.getChildren("typeOptionHandler");
+			TypeOptionHandler handler = null;
+			if (ArrayUtils.isEmpty(children) == false) {
+				try {
+					handler = (TypeOptionHandler) children[0].createExecutableExtension("class");
+				} catch (Exception e) {
+					JiemamyUIPlugin.log(e);
+				}
+			}
+			typeOptionManager = new TypeOptionManager(cmpTypeOption, editListener, handler);
 			
 			chkIsPK.addSelectionListener(editListener);
 			

Added: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/UIConstant.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/UIConstant.java	                        (rev 0)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/UIConstant.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/03/19
+ *
+ * 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.eclipse.ui;
+
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public final class UIConstant {
+	
+	public static final Color COLOR_ERROR = new Color(null, 255, 200, 200);
+	
+
+	private UIConstant() {
+	}
+}


Property changes on: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/UIConstant.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/index/IndexColumnModel.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/index/IndexColumnModel.java	2009-03-18 17:31:33 UTC (rev 2913)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/index/IndexColumnModel.java	2009-03-19 08:55:40 UTC (rev 2914)
@@ -63,7 +63,7 @@
 	 * @param sortType カラムソート方式
 	 * @since 0.2
 	 */
-	void setSortType(SortOrder sortType);
+	void setSortOrder(SortOrder sortType);
 	
 
 	/**

Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd	2009-03-18 17:31:33 UTC (rev 2913)
+++ zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd	2009-03-19 08:55:40 UTC (rev 2914)
@@ -412,7 +412,7 @@
 	<xsd:element name="index">
 		<xsd:complexType>
 			<xsd:sequence>
-				<xsd:element ref="name" minOccurs="0">
+				<xsd:element ref="name">
 					<xsd:annotation>
 						<xsd:documentation source="description" xml:lang="en">Physical name of INDEX</xsd:documentation> 
 						<xsd:documentation source="description" xml:lang="ja-JP">インデックス名</xsd:documentation>

Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-03-18 17:31:33 UTC (rev 2913)
+++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-03-19 08:55:40 UTC (rev 2914)
@@ -140,9 +140,11 @@
       </attributes>
       <indexes>
         <index id="9abc9e01-4cdb-42fe-a495-93b56af35a1d">
+          <name>IDX_EMP_NAME</name>
           <indexColumns>
             <indexColumn id="52d2b6aa-fff7-4c33-af13-f4d0b63e8e58">
               <columnRef ref="0e51b6df-43ab-408c-90ef-de13c6aab881"/>
+              <sortOrder>DESC</sortOrder>
             </indexColumn>
           </indexColumns>
           <unique>false</unique>



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