svnno****@sourc*****
svnno****@sourc*****
2009年 2月 24日 (火) 10:27:03 JST
Revision: 2723 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2723 Author: daisuke_m Date: 2009-02-24 10:27:03 +0900 (Tue, 24 Feb 2009) Log Message: ----------- MySQLのStorageEngineに対応。 Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StandardEngine.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngine.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java Added Paths: ----------- 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/adapter/StorageEngineImpl.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineType.java artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -61,7 +61,8 @@ /** {@link ConnectionAdvisor} */ private ConnectionAdvisor advisor = new DefaultConnectionAdvisor(); - private SqlEmitter emitter = new DefaultSqlEmitter(dataTypeResolver); + /** エミッタ */ + protected SqlEmitter emitter = new DefaultSqlEmitter(dataTypeResolver); public EntityModel createEntity(RootModel rootModel, ResultSet entity, DatabaseMetaData meta) throws SQLException { 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-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -62,8 +62,6 @@ private final DataTypeResolver dataTypeResolver; - private ReferenceResolver referenceResolver; - private TokenResolver tokenResolver = new DefaultTokenResolver(); @@ -78,7 +76,6 @@ public List<SqlStatement> emit(RootModel rootModel, EmitConfig config) { List<SqlStatement> result = CollectionsUtil.newArrayList(); - referenceResolver = rootModel.getJiemamy().getReferenceResolver(); // THINK RootBeginScript と CreateSchemaStatement、どっちが先? @@ -110,6 +107,17 @@ } /** + * DDLを出力する。 + * + * @param entity 対象エンティティ + * @param config 設定 + * @return DDL + */ + protected SqlStatement emitDdl(EntityModel entity, EmitConfig config) { + return EntityEmitStrategy.fromEntity(entity).emit(entity, dataTypeResolver, tokenResolver); + } + + /** * CREATE SCHEMA文を出力する。 * * @param schemaName スキーマ名 @@ -124,31 +132,21 @@ return new SqlStatementImpl(tokens); } - /** - * DDLを出力する。 - * - * @param entity 対象エンティティ - * @param config 設定 - * @return DDL - */ - private SqlStatement emitDdl(EntityModel entity, EmitConfig config) { - return EntityEmitStrategy.fromEntity(entity).emit(entity, dataTypeResolver, referenceResolver, tokenResolver); - } - /** * 属性の出力戦略。 * * @author daisuke */ - private enum AttributeEmitStrategy { + protected enum AttributeEmitStrategy { /** カラムの出力戦略 */ COLUMN(ColumnModel.class) { @Override public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + TokenResolver tokenResolver) { + ReferenceResolver referenceResolver = attributeModel.getJiemamy().getReferenceResolver(); ColumnModel columnModel = (ColumnModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(new Identifier(columnModel.getName())); @@ -210,12 +208,13 @@ @Override public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + TokenResolver tokenResolver) { PrimaryKeyModel pkModel = (PrimaryKeyModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); addConstraintNameDefinition(pkModel, tokens); tokens.add(Keyword.PRIMARY); tokens.add(Keyword.KEY); + ReferenceResolver referenceResolver = attributeModel.getJiemamy().getReferenceResolver(); addColumnList(tokens, pkModel.getKeyColumns(), referenceResolver); return tokens; } @@ -227,12 +226,13 @@ @Override public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + TokenResolver tokenResolver) { UniqueKeyModel ukModel = (UniqueKeyModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); addConstraintNameDefinition(ukModel, tokens); tokens.add(Keyword.UNIQUE); tokens.add(Keyword.KEY); + ReferenceResolver referenceResolver = attributeModel.getJiemamy().getReferenceResolver(); addColumnList(tokens, ukModel.getKeyColumns(), referenceResolver); return tokens; } @@ -243,7 +243,8 @@ @Override public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + TokenResolver tokenResolver) { + ReferenceResolver referenceResolver = attributeModel.getJiemamy().getReferenceResolver(); ForeignKeyModel fkModel = (ForeignKeyModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); addConstraintNameDefinition(fkModel, tokens); @@ -282,35 +283,12 @@ } }, -// /** NOT NULL制約の出力戦略 */ -// NN(NotNullConstraintModel.class) { -// -// @Override -// public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, -// ReferenceResolver referenceResolver, TokenResolver tokenResolver) { -// NotNullConstraintModel nnModel = (NotNullConstraintModel) attributeModel; -// List<Token> tokens = CollectionsUtil.newArrayList(); -// addConstraintNameDefinition(nnModel, tokens); -// tokens.add(Keyword.CHECK); -// tokens.add(Separator.LEFT_PAREN); -// -// ColumnModel columnModel = referenceResolver.resolve(nnModel.getColumn()); -// tokens.add(new Identifier(columnModel.getName())); -// -// tokens.add(Operator.IS); -// tokens.add(Operator.NOT); -// tokens.add(Literal.NULL); -// tokens.add(Separator.RIGHT_PAREN); -// return tokens; -// } -// }, - /** CHECK制約の出力戦略 */ TABLE_CHECK(TableCheckModel.class) { @Override public List<Token> emit(AttributeModel attributeModel, DataTypeResolver dataTypeResolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + TokenResolver tokenResolver) { CheckConstraintModel checkModel = (CheckConstraintModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); addConstraintNameDefinition(checkModel, tokens); @@ -374,12 +352,11 @@ * * @param attributeModel 属性モデル * @param resolver - * @param referenceResolver * @param tokenResolver * @return Token列 */ public abstract List<Token> emit(AttributeModel attributeModel, DataTypeResolver resolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver); + TokenResolver tokenResolver); } @@ -388,14 +365,13 @@ * * @author daisuke */ - private enum EntityEmitStrategy { + protected enum EntityEmitStrategy { /** テーブルの出力戦略 */ TABLE(TableModel.class) { @Override - public SqlStatement emit(EntityModel entityModel, DataTypeResolver resolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + public SqlStatement emit(EntityModel entityModel, DataTypeResolver resolver, TokenResolver tokenResolver) { TableModel tableModel = (TableModel) entityModel; List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); @@ -403,9 +379,8 @@ tokens.add(new Identifier(tableModel.getName())); tokens.add(Separator.LEFT_PAREN); for (AttributeModel attributeModel : tableModel.getAttributes()) { - List<Token> attributes = - AttributeEmitStrategy.fromAttribute(attributeModel).emit(attributeModel, resolver, - referenceResolver, tokenResolver); + AttributeEmitStrategy strategy = AttributeEmitStrategy.fromAttribute(attributeModel); + List<Token> attributes = strategy.emit(attributeModel, resolver, tokenResolver); tokens.addAll(attributes); tokens.add(Separator.COMMA); } @@ -420,8 +395,7 @@ VIEW(ViewModel.class) { @Override - public SqlStatement emit(EntityModel entityModel, DataTypeResolver resolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver) { + public SqlStatement emit(EntityModel entityModel, DataTypeResolver resolver, TokenResolver tokenResolver) { ViewModel viewModel = (ViewModel) entityModel; List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); @@ -467,12 +441,11 @@ * * @param entityModel エンティティモデル * @param resolver - * @param referenceResolver * @param tokenResolver * @return Token列 */ public abstract SqlStatement emit(EntityModel entityModel, DataTypeResolver resolver, - ReferenceResolver referenceResolver, TokenResolver tokenResolver); + TokenResolver tokenResolver); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java 2009-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Separator.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -35,7 +35,10 @@ LEFT_PAREN("("), /** 右括弧 */ - RIGHT_PAREN(")"); + RIGHT_PAREN(")"), + + /** イコール */ + EQUAL("="); private final String string; Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -47,6 +47,7 @@ */ public MySqlDialect() { List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); + // FIXME 適当 list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CHARACTER, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARCHAR, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CLOB, SizedDataTypeAdapter.class)); @@ -66,7 +67,8 @@ list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIMESTAMP, TimezonedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTERVAL)); allDataTypes = UnmodifiableList.decorate(list); - // FIXME 適当 + + emitter = new MySqlEmitter(getDataTypeResolver()); } public List<BuiltinDataTypeMold> getAllDataTypes() { Added: 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 (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -0,0 +1,173 @@ +/* + * 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.mysql; + +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.TokenResolver; +import org.jiemamy.dialect.mysql.adapter.StorageEngine; +import org.jiemamy.dialect.mysql.adapter.StorageEngineType; +import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.datatype.LiteralType; +import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.ViewModel; +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; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class MySqlEmitter extends DefaultSqlEmitter { + + private final DataTypeResolver dataTypeResolver; + + private TokenResolver tokenResolver = new DefaultTokenResolver(); + + + /** + * インスタンスを生成する。 + * + * @param dataTypeResolver + */ + public MySqlEmitter(DataTypeResolver dataTypeResolver) { + super(dataTypeResolver); + this.dataTypeResolver = dataTypeResolver; + } + + @Override + protected SqlStatement emitDdl(EntityModel entity, EmitConfig config) { + return MySqlEntityEmitStrategy.fromEntity(entity).emit(entity, dataTypeResolver, tokenResolver); + } + + + /** + * MySQL用エンティティ出力戦略。 + * + * @author daisuke + */ + private enum MySqlEntityEmitStrategy { + + /** テーブルの出力戦略 */ + TABLE(TableModel.class) { + + @Override + public SqlStatement emit(EntityModel entityModel, DataTypeResolver dataTypeResolver, + TokenResolver tokenResolver) { + TableModel tableModel = (TableModel) entityModel; + List<Token> tokens = CollectionsUtil.newArrayList(); + tokens.add(Keyword.CREATE); + tokens.add(Keyword.TABLE); + tokens.add(new Identifier(tableModel.getName())); + tokens.add(Separator.LEFT_PAREN); + for (AttributeModel attributeModel : tableModel.getAttributes()) { + AttributeEmitStrategy strategy = AttributeEmitStrategy.fromAttribute(attributeModel); + List<Token> attributes = strategy.emit(attributeModel, dataTypeResolver, tokenResolver); + tokens.addAll(attributes); + tokens.add(Separator.COMMA); + } + tokens.remove(tokens.size() - 1); + tokens.add(Separator.RIGHT_PAREN); + + if (tableModel.hasAdapter(StorageEngine.class)) { + StorageEngineType type = tableModel.getAdapter(StorageEngine.class).getType(); + if (type != null) { + tokens.add(Keyword.of("ENGINE")); + tokens.add(Separator.EQUAL); + tokens.add(new Identifier(type.toString())); + } + } + + tokens.add(Separator.SEMICOLON); + return new SqlStatementImpl(tokens); + } + }, + + /** ビューの出力戦略 */ + VIEW(ViewModel.class) { + + @Override + public SqlStatement emit(EntityModel entityModel, DataTypeResolver dataTypeResolver, + TokenResolver tokenResolver) { + ViewModel viewModel = (ViewModel) entityModel; + List<Token> tokens = CollectionsUtil.newArrayList(); + tokens.add(Keyword.CREATE); + tokens.add(Keyword.VIEW); + tokens.add(new Identifier(viewModel.getName())); + tokens.add(Keyword.AS); + tokens.add(new Literal(viewModel.getDefinition(), LiteralType.FRAGMENT)); + tokens.add(Separator.SEMICOLON); + return new SqlStatementImpl(tokens); + } + }; + + /** + * エンティティモデルから出力戦略を取得する。 + * + * @param entity 出力対象のエンティティモデル + * @return 出力戦略 + */ + public static MySqlEntityEmitStrategy fromEntity(EntityModel entity) { + for (MySqlEntityEmitStrategy s : values()) { + if (s.clazz == entity.getClass()) { + return s; + } + for (Class<?> c : entity.getClass().getInterfaces()) { + if (s.clazz == c) { + return s; + } + } + } + return null; + } + + + private final Class<? extends EntityModel> clazz; + + + MySqlEntityEmitStrategy(Class<? extends EntityModel> clazz) { + this.clazz = clazz; + } + + /** + * エンティティモデルからToken列を出力する。 + * + * @param entityModel エンティティモデル + * @param dataTypeResolver + * @param tokenResolver + * @return Token列 + */ + public abstract SqlStatement emit(EntityModel entityModel, DataTypeResolver dataTypeResolver, + TokenResolver tokenResolver); + + } + +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StandardEngine.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StandardEngine.java 2009-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StandardEngine.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -27,7 +27,7 @@ * @author daisuke */ @Adapter(AdapterType.MODEL) -public enum StandardEngine implements StorageEngine { +public enum StandardEngine implements StorageEngineType { /** * デフォルトのMySQLストレージエンジンと、ウェブ、データウェアハウス、そしてその他のアプリケーション環境で一番利用される Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngine.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngine.java 2009-02-23 22:50:56 UTC (rev 2722) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngine.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -26,8 +26,16 @@ public interface StorageEngine { /** - * エンジンタイプを文字列に変換します。 + * TODO for daisuke + * + * @return */ - String toString(); + StorageEngineType getType(); + /** + * TODO for daisuke + * + * @param type + */ + void setType(StorageEngineType type); } Added: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineImpl.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineImpl.java (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineImpl.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -0,0 +1,43 @@ +/* + * 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.mysql.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; + +/** + * TODO for daisuke + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class StorageEngineImpl implements StorageEngine { + + private StorageEngineType type; + + + public StorageEngineType getType() { + return type; + } + + public void setType(StorageEngineType type) { + this.type = type; + } + +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineType.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineType.java (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineType.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -0,0 +1,33 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/07 + * + * 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.mysql.adapter; + +/** + * MySQLのストレージエンジンを表すインターフェイス。 + * + * @author daisuke + */ +public interface StorageEngineType { + + /** + * エンジンタイプを文字列に変換します。 + */ + String toString(); + +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/StorageEngineType.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -0,0 +1,92 @@ +/* + * 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.mysql; + +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.Jiemamy; +import org.jiemamy.dialect.DefaultDataTypeResolver; +import org.jiemamy.dialect.SqlEmitter; +import org.jiemamy.dialect.mysql.adapter.StandardEngine; +import org.jiemamy.dialect.mysql.adapter.StorageEngine; +import org.jiemamy.dialect.mysql.adapter.StorageEngineImpl; +import org.jiemamy.model.sql.SqlStatement; +import org.jiemamy.test.TestModelBuilder; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class MySqlEmitterTest { + + private static Logger logger = LoggerFactory.getLogger(MySqlEmitterTest.class); + + private Jiemamy jiemamy; + + private SqlEmitter sqlEmitter; + + + /** + * setup + * + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + TestModelBuilder mb = new TestModelBuilder(); + mb.build(); + + mb.tableDept.registerAdapter(new StorageEngineImpl()); + mb.tableDept.getAdapter(StorageEngine.class).setType(StandardEngine.InnoDB); + + jiemamy = mb.getJiemamy(); + sqlEmitter = new MySqlEmitter(new DefaultDataTypeResolver()); + } + + /** + * teardown + * + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + jiemamy = null; + sqlEmitter = null; + } + + /** + * 正常にSQLが出力されること。 + * + * @throws Exception + */ + @Test + public void test01_正常にSQLが出力されること() throws Exception { + List<SqlStatement> statements = sqlEmitter.emit(jiemamy.getFactory().getRootModel(), null); + for (SqlStatement sqlStatement : statements) { + logger.info(sqlStatement.toString()); + } + } +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-23 22:50:56 UTC (rev 2722) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-24 01:27:03 UTC (rev 2723) @@ -108,7 +108,7 @@ * * @param statements SQL文のリスト * @return 生成した{@link RootModel} - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException 実装がこの機能を提供していない場合 */ RootModel parseStatements(List<SqlStatement> statements);