svnno****@sourc*****
svnno****@sourc*****
2009年 4月 15日 (水) 15:12:50 JST
Revision: 3285 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3285 Author: j5ik2o Date: 2009-04-15 15:12:50 +0900 (Wed, 15 Apr 2009) Log Message: ----------- リファクタリング Modified Paths: -------------- leto/jiemamy-entity-io/trunk/.classpath leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaWriterImplTest.java Added Paths: ----------- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescWriterImpl.java Removed Paths: ------------- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriter.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriterContext.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaWriterFactory.java leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityDescWriterImpl.java -------------- next part -------------- Modified: leto/jiemamy-entity-io/trunk/.classpath =================================================================== --- leto/jiemamy-entity-io/trunk/.classpath 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/.classpath 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src/main/java"/> - <classpathentry kind="src" path="src/main/resources"/> + <classpathentry excluding="META-INF/|META-INF/" kind="src" path="src/main/resources"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry kind="src" output="target/test-classes" path="src/test/resources"/> <classpathentry kind="con" path="org.devzuz.q.maven.jdt.core.mavenClasspathContainer"/> Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterContext.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterContext.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterContext.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterContext.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,433 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 14, 2009 + * + * 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.entity.io.gen.desc; + +import java.io.File; +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; + +/** + * TODO for kato + * + * @author kato + */ +public class DefaultEntityDescWriterContext implements EntityDescWriterContext { + + private Integer allocationSize; + + private GenerationType idGenerationType; + + private Integer initialValue; + + private File javaSrcFileDestDir; + + private String entityPackageName; + + private String javaSrcFileEncoding; + + private boolean overwrite; + + private String rootPackageName; + + private boolean applyDbCommentToJava; + + private boolean useTemporalType; + + private boolean useAccessor; + + private boolean showTableName; + + private String schemaName; + + private Pattern tableNamePattern; + + private String templateFileEncoding; + + private File templateFilePrimaryDir; + + private String templateName; + + private Pattern versionColumnNamePattern; + + private boolean showCatalogName; + + private boolean showColumnDefinition; + + private Pattern ignoreTableNamePattern; + + private boolean showColumnName; + + private boolean showJoinColumn; + + private boolean showSchemaName; + + private Class<?> entitySuperClass; + + private GenDialect dialect; + + private PersistenceConvention persistenceConvention; + + private File pluralFormFile; + + private DbTableMetaReader dbTableMetaReader; + + + public Integer getAllocationSize() { + return allocationSize; + } + + public DbTableMetaReader getDbTableMetaReader() { + return dbTableMetaReader; + } + + public GenDialect getDialect() { + return dialect; + } + + public String getEntityPackageName() { + return entityPackageName; + } + + public Class<?> getEntitySuperClass() { + return entitySuperClass; + } + + public GenerationType getIdGenerationType() { + return idGenerationType; + } + + public Pattern getIgnoreTableNamePattern() { + return ignoreTableNamePattern; + } + + public Integer getInitialValue() { + return initialValue; + } + + public File getJavaSrcFileDestDir() { + return javaSrcFileDestDir; + } + + public String getJavaSrcFileEncoding() { + return javaSrcFileEncoding; + } + + public PersistenceConvention getPersistenceConvention() { + return persistenceConvention; + } + + public File getPluralFormFile() { + return pluralFormFile; + } + + public String getRootPackageName() { + return rootPackageName; + } + + public String getSchemaName() { + return schemaName; + } + + public Pattern getTableNamePattern() { + return tableNamePattern; + } + + public String getTemplateFileEncoding() { + return templateFileEncoding; + } + + public File getTemplateFilePrimaryDir() { + return templateFilePrimaryDir; + } + + public String getTemplateName() { + return templateName; + } + + public Pattern getVersionColumnNamePattern() { + return versionColumnNamePattern; + } + + public boolean isApplyDbCommentToJava() { + return applyDbCommentToJava; + } + + public boolean isOverwrite() { + return overwrite; + } + + public boolean isShowCatalogName() { + return showCatalogName; + } + + public boolean isShowColumnDefinition() { + return showColumnDefinition; + } + + public boolean isShowColumnName() { + return showColumnName; + } + + public boolean isShowJoinColumn() { + return showJoinColumn; + } + + public boolean isShowSchemaName() { + return showSchemaName; + } + + public boolean isShowTableName() { + return showTableName; + } + + public boolean isUseAccessor() { + return useAccessor; + } + + public boolean isUseTemporalType() { + return useTemporalType; + } + + /** + * TODO for kato + * + * @param allocationSize + */ + public void setAllocationSize(Integer allocationSize) { + this.allocationSize = allocationSize; + } + + /** + * TODO for kato + * + * @param applyDbCommentToJava + */ + public void setApplyDbCommentToJava(boolean applyDbCommentToJava) { + this.applyDbCommentToJava = applyDbCommentToJava; + } + + public void setDbTableMetaReader(DbTableMetaReader dbTableMetaReader) { + this.dbTableMetaReader = dbTableMetaReader; + } + + public void setDialect(GenDialect dialect) { + this.dialect = dialect; + } + + /** + * TODO for kato + * + * @param entityPackageName + */ + public void setEntityPackageName(String entityPackageName) { + this.entityPackageName = entityPackageName; + } + + public void setEntitySuperClass(Class<?> entitySuperClass) { + this.entitySuperClass = entitySuperClass; + } + + /** + * TODO for kato + * + * @param idGenerationType + */ + public void setIdGenerationType(GenerationType idGenerationType) { + this.idGenerationType = idGenerationType; + } + + /** + * TODO for kato + * + * @param ignoreTableNamePattern + */ + public void setIgnoreTableNamePattern(Pattern ignoreTableNamePattern) { + this.ignoreTableNamePattern = ignoreTableNamePattern; + } + + /** + * TODO for kato + * + * @param initialValue + */ + public void setInitialValue(Integer initialValue) { + this.initialValue = initialValue; + } + + /** + * TODO for kato + * + * @param javaSrcFileDestDir + */ + public void setJavaSrcFileDestDir(File javaSrcFileDestDir) { + this.javaSrcFileDestDir = javaSrcFileDestDir; + } + + /** + * TODO for kato + * + * @param javaSrcFileEncoding + */ + public void setJavaSrcFileEncoding(String javaSrcFileEncoding) { + this.javaSrcFileEncoding = javaSrcFileEncoding; + } + + /** + * TODO for kato + * + * @param overwrite + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + + public void setPersistenceConvention(PersistenceConvention persistenceConvention) { + this.persistenceConvention = persistenceConvention; + } + + public void setPluralFormFile(File pluralFormFile) { + this.pluralFormFile = pluralFormFile; + } + + /** + * TODO for kato + * + * @param rootPackageName + */ + public void setRootPackageName(String rootPackageName) { + this.rootPackageName = rootPackageName; + } + + /** + * TODO for kato + * + * @param schemaName + */ + public void setSchemaName(String schemaName) { + this.schemaName = schemaName; + } + + /** + * TODO for kato + * + * @param showCatalogName + */ + public void setShowCatalogName(boolean showCatalogName) { + this.showCatalogName = showCatalogName; + } + + /** + * TODO for kato + * + * @param showColumnDefinition + */ + public void setShowColumnDefinition(boolean showColumnDefinition) { + this.showColumnDefinition = showColumnDefinition; + } + + public void setShowColumnName(boolean showColumnName) { + this.showColumnName = showColumnName; + } + + public void setShowJoinColumn(boolean showJoinColumn) { + this.showJoinColumn = showJoinColumn; + } + + public void setShowSchemaName(boolean showSchemaName) { + this.showSchemaName = showSchemaName; + } + + /** + * TODO for kato + * + * @param showTableName + */ + public void setShowTableName(boolean showTableName) { + this.showTableName = showTableName; + } + + /** + * TODO for kato + * + * @param tableNamePattern + */ + public void setTableNamePattern(Pattern tableNamePattern) { + this.tableNamePattern = tableNamePattern; + } + + /** + * TODO for kato + * + * @param templateFileEncoding + */ + public void setTemplateFileEncoding(String templateFileEncoding) { + this.templateFileEncoding = templateFileEncoding; + } + + /** + * TODO for kato + * + * @param templateFilePrimaryDir + */ + public void setTemplateFilePrimaryDir(File templateFilePrimaryDir) { + this.templateFilePrimaryDir = templateFilePrimaryDir; + } + + /** + * TODO for kato + * + * @param templateName + */ + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + /** + * TODO for kato + * + * @param useAccessor + */ + public void setUseAccessor(boolean useAccessor) { + this.useAccessor = useAccessor; + } + + /** + * TODO for kato + * + * @param useTemporalType + */ + public void setUseTemporalType(boolean useTemporalType) { + this.useTemporalType = useTemporalType; + } + + /** + * TODO for kato + * + * @param versionColumnNamePattern + */ + public void setVersionColumnNamePattern(Pattern versionColumnNamePattern) { + this.versionColumnNamePattern = versionColumnNamePattern; + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterContext.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterFactory.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterFactory.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterFactory.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterFactory.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,41 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * 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.entity.io.gen.desc; + +import java.io.IOException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.gen.desc.impl.EntityDescWriterImpl; +import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; + +/** + * {@link EntityDescWriterFactory}の実装クラス。 + * + * @author j5ik2o + */ +public class DefaultEntityDescWriterFactory implements EntityDescWriterFactory { + + public EntityDescWriter createEntityMetaWriter(EntityDescWriterContext entityDescWriterContext) + throws IdentityNotSupportedException, IOException { + Validate.notNull(entityDescWriterContext); + return new EntityDescWriterImpl(entityDescWriterContext); + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/DefaultEntityDescWriterFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriter.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriter.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriter.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriter.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,39 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * 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.entity.io.gen.desc; + +import java.io.IOException; + +import org.jiemamy.entity.io.meta.EntityMeta; + +/** + * {@link EntityMeta エンティティメタデータ}を書き込むインタフェース。 + * + * @author j5ik2o + */ +public interface EntityDescWriter { + + /** + * エンティティメタデータを書き込む。 + * + * @throws IOException 入出力が失敗した場合 + */ + void write() throws IOException; + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterContext.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriterContext.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterContext.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterContext.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,239 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * 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.entity.io.gen.desc; + +import java.io.File; +import java.util.regex.Pattern; + +import javax.persistence.GenerationType; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.gen.dialect.GenDialect; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; + +/** + * {@link EntityDescWriter}のコンテキストインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityDescWriterContext { + + /** + * 識別子の割り当てサイズを取得する。 + * + * @return 識別子の割り当てサイズ + */ + Integer getAllocationSize(); + + /** + * TODO for kato + * + * @return + */ + DbTableMetaReader getDbTableMetaReader(); + + /** + * TODO for kato + * + * @return + */ + GenDialect getDialect(); + + /** + * エンティティクラスのパッケージ名を取得する。 + * + * @return エンティティクラス + */ + String getEntityPackageName(); + + /** + * エンティティクラスのスーパークラスを取得する。 + * + * @return エンティティクラス + */ + Class<?> getEntitySuperClass(); + + /** + * 識別子を生成する方法を取得する。 + * + * @return {@link GenerationType} + */ + GenerationType getIdGenerationType(); + + /** + * 対象としないテーブル名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getIgnoreTableNamePattern(); + + /** + * 識別子の初期値を取得する。 + * + * @return 識別子の初期値 + */ + Integer getInitialValue(); + + /** + * Javaソースファイルの出力先ディレクトリを取得する。 + * + * @return Javaソースファイルの出力先ディレクトリ + */ + File getJavaSrcFileDestDir(); + + /** + * Javaファイルのエンコーディングを取得する。 + * + * @return Javaファイルのエンコーディング + */ + String getJavaSrcFileEncoding(); + + /** + * TODO for kato + * + */ + PersistenceConvention getPersistenceConvention(); + + /** + * TODO for kato + * + * @return + */ + File getPluralFormFile(); + + /** + * ルートパッケージ名を取得する。 + * + * @return パッケージ名 + */ + String getRootPackageName(); + + /** + * スキーマ名を取得する。 + * + * @return スキーマ名 + */ + String getSchemaName(); + + /** + * 対象とするテーブル名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getTableNamePattern(); + + /** + * テンプレートファイルのエンコーディングを取得する。 + * + * @return テンプレートファイルのエンコーディング + */ + String getTemplateFileEncoding(); + + /** + * テンプレートファイルを検索する際の優先ディレクトリを取得する。 + * + * @return テンプレートファイルを検索する際の優先ディレクトリ + */ + File getTemplateFilePrimaryDir(); + + /** + * テンプレート名を取得する。 + * + * @return テンプレート名 + */ + String getTemplateName(); + + /** + * エンティティのプロパティに@Versionを付与するカラム名の正規表現を取得する。 + * + * @return {@link Pattern} + */ + Pattern getVersionColumnNamePattern(); + + /** + * DB上のコメントをエンティティに適用するかどうかのフラグを取得する。 + * + * @return trueの場合適用する + */ + boolean isApplyDbCommentToJava(); + + /** + * 上書きフラグを取得する。 + * + * @return 上書きする場合は{@code true}、しない場合は{@code false} + */ + boolean isOverwrite(); + + /** + * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowCatalogName(); + + /** + * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowColumnDefinition(); + + /** + * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowColumnName(); + + /** + * JoinColumnアノテーションを明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowJoinColumn(); + + /** + * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowSchemaName(); + + /** + * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを取得する。 + * + * @return trueの場合明記する + */ + boolean isShowTableName(); + + /** + * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを取得する。 + * + * @return trueの場合 + */ + boolean isUseAccessor(); + + /** + * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 + * + * @return trueの場合@Temporalつきのjava.util.Dateにする。 + */ + boolean isUseTemporalType(); + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterContext.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterFactory.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaWriterFactory.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterFactory.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterFactory.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,42 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * 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.entity.io.gen.desc; + +import java.io.IOException; + +import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; + +/** + * {@link EntityDescWriter}用のファクトリインターフェイス。 + * + * @author j5ik2o + */ +public interface EntityDescWriterFactory { + + /** + * {@link EntityDescWriter}を生成する。 + * + * @param entityDescWriterContext {@link EntityDescWriterContext} + * @return {@link EntityDescWriter} + * @throws IdentityNotSupportedException + * @throws IOException + */ + EntityDescWriter createEntityMetaWriter(EntityDescWriterContext entityDescWriterContext) + throws IdentityNotSupportedException, IOException; +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/EntityDescWriterFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescWriterImpl.java (from rev 3283, leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityDescWriterImpl.java) =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescWriterImpl.java (rev 0) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescWriterImpl.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -0,0 +1,147 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 13, 2009 + * + * 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.entity.io.gen.desc.impl; + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.entity.io.convensition.PersistenceConvention; +import org.jiemamy.entity.io.convensition.impl.PersistenceConventionImpl; +import org.jiemamy.entity.io.gen.desc.EntityDesc; +import org.jiemamy.entity.io.gen.desc.EntityDescWriter; +import org.jiemamy.entity.io.gen.desc.EntityDescWriterContext; +import org.jiemamy.entity.io.gen.desc.EntitySetDesc; +import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; +import org.jiemamy.entity.io.gen.generator.GenerateException; +import org.jiemamy.entity.io.gen.generator.Generator; +import org.jiemamy.entity.io.gen.generator.impl.GeneratorContextImpl; +import org.jiemamy.entity.io.gen.generator.impl.GeneratorImpl; +import org.jiemamy.entity.io.gen.model.AssociationModelFactory; +import org.jiemamy.entity.io.gen.model.AttributeModelFactory; +import org.jiemamy.entity.io.gen.model.CompositeUniqueConstraintModelFactory; +import org.jiemamy.entity.io.gen.model.EntityModel; +import org.jiemamy.entity.io.gen.model.EntityModelFactory; +import org.jiemamy.entity.io.gen.model.impl.AssociationModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.AttributeModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.CompositeUniqueConstraintModelFactoryImpl; +import org.jiemamy.entity.io.gen.model.impl.EntityModelFactoryImpl; +import org.jiemamy.entity.io.utils.FileUtil; +import org.jiemamy.utils.ClassUtil; +import org.jiemamy.utils.StringUtil; + +/** + * EntityMetaWriterContextの実装クラス。 + * + * @author j5ik2o + */ +public class EntityDescWriterImpl implements EntityDescWriter { + + private Generator generator; + + private EntityDescWriterContext entityDescWriterContext; + + private EntityModelFactory entityModelFactory; + + private EntitySetDescFactory entitySetDescFactory; + + + /** + * インスタンスを生成する。 + * + * @param entityMetaWriterContext {@link EntityMetaWriterContext} + * @throws IdentityNotSupportedException + * @throws IOException + */ + public EntityDescWriterImpl(EntityDescWriterContext entityDescWriterContext) throws IdentityNotSupportedException, + IOException { + Validate.notNull(entityDescWriterContext); + Validate.notNull(entityDescWriterContext.getDbTableMetaReader()); + Validate.notNull(entityDescWriterContext.getJavaSrcFileEncoding()); + Validate.notNull(entityDescWriterContext.getTemplateName()); + this.entityDescWriterContext = entityDescWriterContext; + PersistenceConvention persistenceConvention = entityDescWriterContext.getPersistenceConvention(); + if (persistenceConvention == null) { + persistenceConvention = new PersistenceConventionImpl(); + } + entityModelFactory = createEntityModelFactory(entityDescWriterContext); + entitySetDescFactory = createEntitySetDescFactory(entityDescWriterContext, persistenceConvention); + } + + private EntityModelFactory createEntityModelFactory(EntityDescWriterContext entityDescWriterContext) { + AttributeModelFactory attributeModelFactory = + new AttributeModelFactoryImpl(entityDescWriterContext.isShowColumnName(), entityDescWriterContext + .isShowColumnDefinition(), entityDescWriterContext.isUseTemporalType()); + AssociationModelFactory associationModelFactory = + new AssociationModelFactoryImpl(entityDescWriterContext.isShowJoinColumn()); + CompositeUniqueConstraintModelFactory compositeUniqueConstraintModelFactory = + new CompositeUniqueConstraintModelFactoryImpl(); + EntityModelFactory result = + new EntityModelFactoryImpl(ClassUtil.concatName(entityDescWriterContext.getRootPackageName(), + entityDescWriterContext.getEntityPackageName()), entityDescWriterContext.getEntitySuperClass(), + attributeModelFactory, associationModelFactory, compositeUniqueConstraintModelFactory, + entityDescWriterContext.isUseAccessor(), entityDescWriterContext.isApplyDbCommentToJava(), + entityDescWriterContext.isShowCatalogName(), entityDescWriterContext.isShowSchemaName(), + entityDescWriterContext.isShowTableName()); + return result; + } + + private EntitySetDescFactory createEntitySetDescFactory(EntityDescWriterContext entityDescWriterContext, + PersistenceConvention persistenceConvention) throws IdentityNotSupportedException { + EntitySetDescFactory result = + new EntitySetDescFactoryImpl(entityDescWriterContext.getDbTableMetaReader(), persistenceConvention, + entityDescWriterContext.getDialect(), entityDescWriterContext.getVersionColumnNamePattern(), + entityDescWriterContext.getPluralFormFile(), entityDescWriterContext.getIdGenerationType(), + entityDescWriterContext.getInitialValue(), entityDescWriterContext.getAllocationSize()); + return result; + } + + public void write() throws IOException { + generator = + new GeneratorImpl(entityDescWriterContext.getTemplateFileEncoding(), entityDescWriterContext + .getTemplateFilePrimaryDir()); + GeneratorContextImpl context = new GeneratorContextImpl(); + context.setEncoding(entityDescWriterContext.getJavaSrcFileEncoding()); + context.setOverwrite(entityDescWriterContext.isOverwrite()); + context.setTemplateName(entityDescWriterContext.getTemplateName()); + + String packageName = + ClassUtil.concatName(entityDescWriterContext.getRootPackageName(), entityDescWriterContext + .getEntityPackageName()); + EntitySetDesc entitySetDesc = entitySetDescFactory.getEntitySetDesc(); + for (EntityDesc entityDesc : entitySetDesc.getEntityDescList()) { + File file = + FileUtil.createJavaFile(entityDescWriterContext.getJavaSrcFileDestDir(), packageName, StringUtil + .camelize(entityDesc.getName())); + context.setFile(file); + + EntityModel entityModel = entityModelFactory.getEntityModel(entityDesc); + context.setModel(entityModel); + try { + generator.generate(context); + } catch (GenerateException e) { + e.printStackTrace(); + throw new IOException(); + } + } + + } + +} Property changes on: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntityDescWriterImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/gen/desc/impl/EntitySetDescFactoryImpl.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -81,12 +81,8 @@ * インスタンスを構築する。 * * @param dbTableMetaReader テーブルメタデータのリーダ - <<<<<<< .mine * @param persistenceConvention 永続化層の命名規約 * @param dialect SQL方言 - ======= - * @param dialect - >>>>>>> .r3282 * @param versionColumnNamePattern バージョンカラム名のパターン * @param pluralFormFile 単語を複数系に変換するための辞書ファイル、使用しない場合は{@code null} * @param generationType エンティティの識別子の生成方法を示す列挙型 、生成しない場合は{@code null} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterContext.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterContext.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,402 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 14, 2009 - * - * 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.entity.io.meta; - -import java.io.File; -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; - -/** - * TODO for kato - * - * @author kato - */ -public class DefaultEntityDescWriterContext implements EntityDescWriterContext { - - private Integer allocationSize; - - private GenerationType idGenerationType; - - private Integer initialValue; - - private File javaSrcFileDestDir; - - private String entityPackageName; - - private String javaSrcFileEncoding; - - private boolean overwrite; - - private String rootPackageName; - - private boolean applyDbCommentToJava; - - private boolean useTemporalType; - - private boolean useAccessor; - - private boolean showTableName; - - private String schemaName; - - private Pattern tableNamePattern; - - private String templateFileEncoding; - - private File templateFilePrimaryDir; - - private String templateName; - - private Pattern versionColumnNamePattern; - - private boolean showCatalogName; - - private boolean showColumnDefinition; - - private Pattern ignoreTableNamePattern; - - private boolean showColumnName; - - private boolean showJoinColumn; - - private boolean showSchemaName; - - private Class<?> entitySuperClass; - - private GenDialect dialect; - - - public Integer getAllocationSize() { - return allocationSize; - } - - public DbTableMetaReader getDbTableMetaReader() { - // TODO Auto-generated method stub - return null; - } - - public GenDialect getDialect() { - return dialect; - } - - public String getEntityPackageName() { - return entityPackageName; - } - - public Class<?> getEntitySuperClass() { - return entitySuperClass; - } - - public GenerationType getIdGenerationType() { - return idGenerationType; - } - - public Pattern getIgnoreTableNamePattern() { - return ignoreTableNamePattern; - } - - public Integer getInitialValue() { - return initialValue; - } - - public File getJavaSrcFileDestDir() { - return javaSrcFileDestDir; - } - - public String getJavaSrcFileEncoding() { - return javaSrcFileEncoding; - } - - public PersistenceConvention getPersistenceConvention() { - // TODO Auto-generated method stub - return null; - } - - public File getPluralFormFile() { - // TODO Auto-generated method stub - return null; - } - - public String getRootPackageName() { - return rootPackageName; - } - - public String getSchemaName() { - return schemaName; - } - - public Pattern getTableNamePattern() { - return tableNamePattern; - } - - public String getTemplateFileEncoding() { - return templateFileEncoding; - } - - public File getTemplateFilePrimaryDir() { - return templateFilePrimaryDir; - } - - public String getTemplateName() { - return templateName; - } - - public Pattern getVersionColumnNamePattern() { - return versionColumnNamePattern; - } - - public boolean isApplyDbCommentToJava() { - return applyDbCommentToJava; - } - - public boolean isOverwrite() { - return overwrite; - } - - public boolean isShowCatalogName() { - return showCatalogName; - } - - public boolean isShowColumnDefinition() { - return showColumnDefinition; - } - - public boolean isShowColumnName() { - return showColumnName; - } - - public boolean isShowJoinColumn() { - return showJoinColumn; - } - - public boolean isShowSchemaName() { - return showSchemaName; - } - - public boolean isShowTableName() { - return showTableName; - } - - public boolean isUseAccessor() { - return useAccessor; - } - - public boolean isUseTemporalType() { - return useTemporalType; - } - - /** - * TODO for kato - * - * @param allocationSize - */ - public void setAllocationSize(Integer allocationSize) { - this.allocationSize = allocationSize; - } - - /** - * TODO for kato - * - * @param applyDbCommentToJava - */ - public void setApplyDbCommentToJava(boolean applyDbCommentToJava) { - this.applyDbCommentToJava = applyDbCommentToJava; - } - - public void setDialect(GenDialect dialect) { - this.dialect = dialect; - } - - /** - * TODO for kato - * - * @param entityPackageName - */ - public void setEntityPackageName(String entityPackageName) { - this.entityPackageName = entityPackageName; - } - - /** - * TODO for kato - * - * @param idGenerationType - */ - public void setIdGenerationType(GenerationType idGenerationType) { - this.idGenerationType = idGenerationType; - } - - /** - * TODO for kato - * - * @param ignoreTableNamePattern - */ - public void setIgnoreTableNamePattern(Pattern ignoreTableNamePattern) { - this.ignoreTableNamePattern = ignoreTableNamePattern; - } - - /** - * TODO for kato - * - * @param initialValue - */ - public void setInitialValue(Integer initialValue) { - this.initialValue = initialValue; - } - - /** - * TODO for kato - * - * @param javaSrcFileDestDir - */ - public void setJavaSrcFileDestDir(File javaSrcFileDestDir) { - this.javaSrcFileDestDir = javaSrcFileDestDir; - } - - /** - * TODO for kato - * - * @param javaSrcFileEncoding - */ - public void setJavaSrcFileEncoding(String javaSrcFileEncoding) { - this.javaSrcFileEncoding = javaSrcFileEncoding; - } - - /** - * TODO for kato - * - * @param overwrite - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - - /** - * TODO for kato - * - * @param rootPackageName - */ - public void setRootPackageName(String rootPackageName) { - this.rootPackageName = rootPackageName; - } - - /** - * TODO for kato - * - * @param schemaName - */ - public void setSchemaName(String schemaName) { - this.schemaName = schemaName; - } - - /** - * TODO for kato - * - * @param showCatalogName - */ - public void setShowCatalogName(boolean showCatalogName) { - this.showCatalogName = showCatalogName; - } - - /** - * TODO for kato - * - * @param showColumnDefinition - */ - public void setShowColumnDefinition(boolean showColumnDefinition) { - this.showColumnDefinition = showColumnDefinition; - } - - /** - * TODO for kato - * - * @param showTableName - */ - public void setShowTableName(boolean showTableName) { - this.showTableName = showTableName; - } - - /** - * TODO for kato - * - * @param tableNamePattern - */ - public void setTableNamePattern(Pattern tableNamePattern) { - this.tableNamePattern = tableNamePattern; - } - - /** - * TODO for kato - * - * @param templateFileEncoding - */ - public void setTemplateFileEncoding(String templateFileEncoding) { - this.templateFileEncoding = templateFileEncoding; - } - - /** - * TODO for kato - * - * @param templateFilePrimaryDir - */ - public void setTemplateFilePrimaryDir(File templateFilePrimaryDir) { - this.templateFilePrimaryDir = templateFilePrimaryDir; - } - - /** - * TODO for kato - * - * @param templateName - */ - public void setTemplateName(String templateName) { - this.templateName = templateName; - } - - /** - * TODO for kato - * - * @param useAccessor - */ - public void setUseAccessor(boolean useAccessor) { - this.useAccessor = useAccessor; - } - - /** - * TODO for kato - * - * @param useTemporalType - */ - public void setUseTemporalType(boolean useTemporalType) { - this.useTemporalType = useTemporalType; - } - - /** - * TODO for kato - * - * @param versionColumnNamePattern - */ - public void setVersionColumnNamePattern(Pattern versionColumnNamePattern) { - this.versionColumnNamePattern = versionColumnNamePattern; - } - -} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterFactory.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/DefaultEntityDescWriterFactory.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,41 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * 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.entity.io.meta; - -import java.io.IOException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; -import org.jiemamy.entity.io.meta.impl.EntityDescWriterImpl; - -/** - * {@link EntityMetaWriterFactory}の実装クラス。 - * - * @author j5ik2o - */ -public class DefaultEntityDescWriterFactory implements EntityMetaWriterFactory { - - public EntityDescWriter createEntityMetaWriter(EntityDescWriterContext entityDescWriterContext) - throws IdentityNotSupportedException, IOException { - Validate.notNull(entityDescWriterContext); - return new EntityDescWriterImpl(entityDescWriterContext); - } - -} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriter.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriter.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriter.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,41 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * 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.entity.io.meta; - -import java.io.IOException; -import java.util.List; - -import org.jiemamy.entity.io.gen.meta.DbTableMeta; - -/** - * {@link EntityMeta エンティティメタデータ}を書き込むインタフェース。 - * - * @author j5ik2o - */ -public interface EntityDescWriter { - - /** - * エンティティメタデータを書き込む。 - * - * @param tableMetaList {@link EntityMeta}のリスト - * @throws IOException 入出力が失敗した場合 - */ - void write(List<DbTableMeta> tableMetaList) throws IOException; - -} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriterContext.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriterContext.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityDescWriterContext.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,239 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * 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.entity.io.meta; - -import java.io.File; -import java.util.regex.Pattern; - -import javax.persistence.GenerationType; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.gen.dialect.GenDialect; -import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; - -/** - * {@link EntityDescWriter}のコンテキストインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityDescWriterContext { - - /** - * 識別子の割り当てサイズを取得する。 - * - * @return 識別子の割り当てサイズ - */ - Integer getAllocationSize(); - - /** - * TODO for kato - * - * @return - */ - DbTableMetaReader getDbTableMetaReader(); - - /** - * TODO for kato - * - * @return - */ - GenDialect getDialect(); - - /** - * エンティティクラスのパッケージ名を取得する。 - * - * @return エンティティクラス - */ - String getEntityPackageName(); - - /** - * エンティティクラスのスーパークラスを取得する。 - * - * @return エンティティクラス - */ - Class<?> getEntitySuperClass(); - - /** - * 識別子を生成する方法を取得する。 - * - * @return {@link GenerationType} - */ - GenerationType getIdGenerationType(); - - /** - * 対象としないテーブル名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getIgnoreTableNamePattern(); - - /** - * 識別子の初期値を取得する。 - * - * @return 識別子の初期値 - */ - Integer getInitialValue(); - - /** - * Javaソースファイルの出力先ディレクトリを取得する。 - * - * @return Javaソースファイルの出力先ディレクトリ - */ - File getJavaSrcFileDestDir(); - - /** - * Javaファイルのエンコーディングを取得する。 - * - * @return Javaファイルのエンコーディング - */ - String getJavaSrcFileEncoding(); - - /** - * TODO for kato - * - */ - PersistenceConvention getPersistenceConvention(); - - /** - * TODO for kato - * - * @return - */ - File getPluralFormFile(); - - /** - * ルートパッケージ名を取得する。 - * - * @return パッケージ名 - */ - String getRootPackageName(); - - /** - * スキーマ名を取得する。 - * - * @return スキーマ名 - */ - String getSchemaName(); - - /** - * 対象とするテーブル名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getTableNamePattern(); - - /** - * テンプレートファイルのエンコーディングを取得する。 - * - * @return テンプレートファイルのエンコーディング - */ - String getTemplateFileEncoding(); - - /** - * テンプレートファイルを検索する際の優先ディレクトリを取得する。 - * - * @return テンプレートファイルを検索する際の優先ディレクトリ - */ - File getTemplateFilePrimaryDir(); - - /** - * テンプレート名を取得する。 - * - * @return テンプレート名 - */ - String getTemplateName(); - - /** - * エンティティのプロパティに@Versionを付与するカラム名の正規表現を取得する。 - * - * @return {@link Pattern} - */ - Pattern getVersionColumnNamePattern(); - - /** - * DB上のコメントをエンティティに適用するかどうかのフラグを取得する。 - * - * @return trueの場合適用する - */ - boolean isApplyDbCommentToJava(); - - /** - * 上書きフラグを取得する。 - * - * @return 上書きする場合は{@code true}、しない場合は{@code false} - */ - boolean isOverwrite(); - - /** - * Tableアノテーションのcatalog属性にカタログ名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowCatalogName(); - - /** - * ColumnアノテーションのcolumnDefinition属性にカラム定義を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowColumnDefinition(); - - /** - * Columnアノテーションのname属性にカラム名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowColumnName(); - - /** - * JoinColumnアノテーションを明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowJoinColumn(); - - /** - * Tableアノテーションのschema属性にスキーマ名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowSchemaName(); - - /** - * Tableアノテーションのname属性にテーブル名を明記するかどうかのフラグを取得する。 - * - * @return trueの場合明記する - */ - boolean isShowTableName(); - - /** - * 生成するエンティティのアクセサメソッドを付与するかどうかのフラグを取得する。 - * - * @return trueの場合 - */ - boolean isUseAccessor(); - - /** - * 日付型カラムに対応するプロパティの型を@Temporalつきのjava.util.Dateとする。 - * - * @return trueの場合@Temporalつきのjava.util.Dateにする。 - */ - boolean isUseTemporalType(); - -} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaWriterFactory.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaWriterFactory.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/EntityMetaWriterFactory.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,42 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * 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.entity.io.meta; - -import java.io.IOException; - -import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; - -/** - * {@link EntityDescWriter}用のファクトリインターフェイス。 - * - * @author j5ik2o - */ -public interface EntityMetaWriterFactory { - - /** - * {@link EntityDescWriter}を生成する。 - * - * @param entityDescWriterContext {@link EntityDescWriterContext} - * @return {@link EntityDescWriter} - * @throws IdentityNotSupportedException - * @throws IOException - */ - EntityDescWriter createEntityMetaWriter(EntityDescWriterContext entityDescWriterContext) - throws IdentityNotSupportedException, IOException; -} Deleted: leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityDescWriterImpl.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityDescWriterImpl.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/main/java/org/jiemamy/entity/io/meta/impl/EntityDescWriterImpl.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -1,129 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on Apr 13, 2009 - * - * 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.entity.io.meta.impl; - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.entity.io.convensition.PersistenceConvention; -import org.jiemamy.entity.io.convensition.impl.PersistenceConventionImpl; -import org.jiemamy.entity.io.gen.desc.EntityDesc; -import org.jiemamy.entity.io.gen.desc.EntityDescFactory; -import org.jiemamy.entity.io.gen.desc.EntitySetDesc; -import org.jiemamy.entity.io.gen.desc.EntitySetDescFactory; -import org.jiemamy.entity.io.gen.desc.impl.EntitySetDescFactoryImpl; -import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; -import org.jiemamy.entity.io.gen.generator.GenerateException; -import org.jiemamy.entity.io.gen.generator.Generator; -import org.jiemamy.entity.io.gen.generator.impl.GeneratorContextImpl; -import org.jiemamy.entity.io.gen.generator.impl.GeneratorImpl; -import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.gen.model.EntityModel; -import org.jiemamy.entity.io.gen.model.EntityModelFactory; -import org.jiemamy.entity.io.meta.EntityDescWriter; -import org.jiemamy.entity.io.meta.EntityDescWriterContext; -import org.jiemamy.entity.io.utils.FileUtil; -import org.jiemamy.utils.ClassUtil; -import org.jiemamy.utils.StringUtil; - -/** - * EntityMetaWriterContextの実装クラス。 - * - * @author j5ik2o - */ -public class EntityDescWriterImpl implements EntityDescWriter { - - private Generator generator; - - private EntityDescWriterContext entityDescWriterContext; - - private EntityModelFactory entityModelFactory; - - private EntityDescFactory entityDescFactory; - - private EntitySetDescFactory entitySetDescFactory; - - private EntitySetDesc entitySetDesc; - - - /** - * インスタンスを生成する。 - * - * @param entityMetaWriterContext {@link EntityMetaWriterContext} - * @throws IdentityNotSupportedException - * @throws IOException - */ - public EntityDescWriterImpl(EntityDescWriterContext entityDescWriterContext) throws IdentityNotSupportedException, - IOException { - Validate.notNull(entityDescWriterContext); - Validate.notNull(entityDescWriterContext.getDbTableMetaReader()); - Validate.notNull(entityDescWriterContext.getJavaSrcFileEncoding()); - Validate.notNull(entityDescWriterContext.getTemplateName()); - this.entityDescWriterContext = entityDescWriterContext; - PersistenceConvention persistenceConvention = entityDescWriterContext.getPersistenceConvention(); - if (persistenceConvention == null) { - persistenceConvention = new PersistenceConventionImpl(); - } - entitySetDescFactory = - new EntitySetDescFactoryImpl(entityDescWriterContext.getDbTableMetaReader(), persistenceConvention, - entityDescWriterContext.getDialect(), entityDescWriterContext.getVersionColumnNamePattern(), - entityDescWriterContext.getPluralFormFile(), entityDescWriterContext.getIdGenerationType(), - entityDescWriterContext.getInitialValue(), entityDescWriterContext.getAllocationSize()); - - } - - private EntityModel convertModel(DbTableMeta dbTableMeta) { - EntityDesc entityDesc = entityDescFactory.getEntityDesc(dbTableMeta); - EntityModel result = entityModelFactory.getEntityModel(entityDesc); - return result; - } - - public void write(List<DbTableMeta> tableMetaList) throws IOException { - Validate.notNull(tableMetaList); - generator = - new GeneratorImpl(entityDescWriterContext.getTemplateFileEncoding(), entityDescWriterContext - .getTemplateFilePrimaryDir()); - GeneratorContextImpl context = new GeneratorContextImpl(); - context.setEncoding(entityDescWriterContext.getJavaSrcFileEncoding()); - context.setOverwrite(entityDescWriterContext.isOverwrite()); - context.setTemplateName(entityDescWriterContext.getTemplateName()); - - String packageName = - ClassUtil.concatName(entityDescWriterContext.getRootPackageName(), entityDescWriterContext - .getEntityPackageName()); - - for (DbTableMeta tableMeta : tableMetaList) { - File file = - FileUtil.createJavaFile(entityDescWriterContext.getJavaSrcFileDestDir(), packageName, StringUtil - .camelize(tableMeta.getName())); - context.setFile(file); - Object model = convertModel(tableMeta); - context.setModel(model); - try { - generator.generate(context); - } catch (GenerateException e) { - e.printStackTrace(); - throw new IOException(); - } - } - } -} Modified: leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaWriterImplTest.java =================================================================== --- leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaWriterImplTest.java 2009-04-15 05:19:21 UTC (rev 3284) +++ leto/jiemamy-entity-io/trunk/src/test/java/org/jiemamy/entity/io/meta/impl/EntityMetaWriterImplTest.java 2009-04-15 06:12:50 UTC (rev 3285) @@ -25,20 +25,20 @@ import java.util.regex.Pattern; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.jiemamy.Jiemamy; import org.jiemamy.dialect.generic.GenericDialect; +import org.jiemamy.entity.io.gen.desc.DefaultEntityDescWriterContext; +import org.jiemamy.entity.io.gen.desc.DefaultEntityDescWriterFactory; +import org.jiemamy.entity.io.gen.desc.EntityDescWriter; import org.jiemamy.entity.io.gen.desc.impl.IdentityNotSupportedException; import org.jiemamy.entity.io.gen.dialect.StandardGenDialect; import org.jiemamy.entity.io.gen.meta.DbColumnMeta; import org.jiemamy.entity.io.gen.meta.DbTableMeta; -import org.jiemamy.entity.io.meta.DefaultEntityDescWriterContext; -import org.jiemamy.entity.io.meta.DefaultEntityDescWriterFactory; -import org.jiemamy.entity.io.meta.EntityDescWriter; +import org.jiemamy.entity.io.gen.meta.DbTableMetaReader; import org.jiemamy.internal.test.ReflectionDialectProvider; import org.jiemamy.model.RootModel; import org.jiemamy.utils.ClassUtil; @@ -53,6 +53,18 @@ */ public class EntityMetaWriterImplTest { + private static class DbTableMetaReaderImpl implements DbTableMetaReader { + + List<DbTableMeta> dbTableMetas = CollectionsUtil.newArrayList(); + + + public List<DbTableMeta> read() { + return dbTableMetas; + } + + } + + private EntityDescWriter entityDescWriter; private static final Logger LOG = LoggerFactory.getLogger(EntityMetaWriterImplTest.class); @@ -75,20 +87,20 @@ } /** - * Test method for {@link org.jiemamy.entity.io.meta.impl.EntityDescWriterImpl#write(java.util.List)}. + * Test method for {@link org.jiemamy.entity.io.gen.desc.impl.EntityDescWriterImpl#write(java.util.List)}. * @throws IOException * @throws IdentityNotSupportedException * @throws ClassNotFoundException * @throws ResourceNotFoundException */ @Test - @Ignore public void testWrite() throws IOException, IdentityNotSupportedException, ClassNotFoundException, ResourceNotFoundException { DefaultEntityDescWriterContext context = new DefaultEntityDescWriterContext(); //context.setDialect(new TestDialect(jiemamy.getFactory(), jiemamy.getDialect(rootModel))); - + DbTableMetaReaderImpl dbTableMetaReader = new DbTableMetaReaderImpl(); + context.setDbTableMetaReader(dbTableMetaReader); context.setDialect(new StandardGenDialect()); context.setUseAccessor(true); context.setOverwrite(true); @@ -103,7 +115,7 @@ context.setJavaSrcFileDestDir(dir); entityDescWriter = new DefaultEntityDescWriterFactory().createEntityMetaWriter(context); - List<DbTableMeta> dbTableMetaList = CollectionsUtil.newArrayList(); + List<DbTableMeta> dbTableMetaList = dbTableMetaReader.dbTableMetas; DbTableMeta dbTableMeta = new DbTableMeta(); dbTableMeta.setName("EMPLOYEE"); @@ -130,6 +142,6 @@ dbTableMeta.addColumnMeta(columnMeta); dbTableMetaList.add(dbTableMeta); - entityDescWriter.write(dbTableMetaList); + entityDescWriter.write(); } }