svnno****@sourc*****
svnno****@sourc*****
2009年 4月 7日 (火) 19:32:41 JST
Revision: 3159 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3159 Author: j5ik2o Date: 2009-04-07 19:32:41 +0900 (Tue, 07 Apr 2009) Log Message: ----------- Converterを新規投入。 Modified Paths: -------------- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultJpaImportConfig.java charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImportConfig.java charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImporter.java Added Paths: ----------- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultTableModelConverter.java charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/TableModelConverter.java -------------- next part -------------- Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultJpaImportConfig.java =================================================================== --- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultJpaImportConfig.java 2009-04-07 10:01:16 UTC (rev 3158) +++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultJpaImportConfig.java 2009-04-07 10:32:41 UTC (rev 3159) @@ -43,6 +43,8 @@ private List<String> ignoreEntityClassNamePatterns; + private TableModelConverter tableModelConverter; + public List<String> getClassPathDirs() { return classPathDirs; @@ -72,6 +74,10 @@ return rootPackageName; } + public TableModelConverter getTableModelConverter() { + return tableModelConverter; + } + public boolean isApplyJavaComment() { return applyJavaComment; } @@ -148,4 +154,13 @@ this.rootPackageName = rootPackageName; } + /** + * {@link TableModelConverter}を設定する。 + * + * @param tableModelConverter {@link TableModelConverter} + */ + public void setTableModelConverter(TableModelConverter tableModelConverter) { + this.tableModelConverter = tableModelConverter; + } + } Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultTableModelConverter.java =================================================================== --- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultTableModelConverter.java (rev 0) +++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultTableModelConverter.java 2009-04-07 10:32:41 UTC (rev 3159) @@ -0,0 +1,39 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 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.composer.importer; + +import org.jiemamy.composer.importer.meta.EntityMeta; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.TableModel; + +/** + * {@link TableModelConverter}のデフォルト実装。 + * + * @author j5ik2o + */ +public class DefaultTableModelConverter implements TableModelConverter { + + public TableModel convert(RootModel rootModel, EntityMeta entityMeta) { + // TODO ちゃんと組む + TableModel tm = rootModel.getJiemamy().getFactory().newModel(TableModel.class); + tm.setName(entityMeta.getName()); + return tm; + } + +} Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultTableModelConverter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImportConfig.java =================================================================== --- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImportConfig.java 2009-04-07 10:01:16 UTC (rev 3158) +++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImportConfig.java 2009-04-07 10:32:41 UTC (rev 3159) @@ -82,6 +82,13 @@ String getRootPackageName(); /** + * {@link TableModelConverter}を取得する。 + * + * @return {@link TableModelConverter} + */ + TableModelConverter getTableModelConverter(); + + /** * JavaDocのコメントを利用するフラグ値を取得する。 * * @return trueの場合は利用する Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImporter.java =================================================================== --- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImporter.java 2009-04-07 10:01:16 UTC (rev 3158) +++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImporter.java 2009-04-07 10:32:41 UTC (rev 3159) @@ -23,7 +23,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jiemamy.Jiemamy; import org.jiemamy.composer.ImportException; import org.jiemamy.composer.Importer; import org.jiemamy.composer.importer.meta.EntityClassNotFoundException; @@ -50,11 +49,26 @@ private static final Logger LOG = LoggerFactory.getLogger(JpaImporter.class); + private static final TableModelConverter DEFAULT_TABLE_CONVERTER = new DefaultTableModelConverter(); + public String getName() { return "JPA Importer"; } + /** + * {@link TableModelConverter}を取得する。 + * + * @param config {@link JpaImportConfig} + * @return {@link TableModelConverter} + */ + protected TableModelConverter getTableModelConverter(JpaImportConfig config) { + if (config.getTableModelConverter() != null) { + return config.getTableModelConverter(); + } + return DEFAULT_TABLE_CONVERTER; + } + public boolean importModel(RootModel rootModel, JpaImportConfig config) throws ImportException { Validate.notNull(rootModel); Validate.notNull(config); @@ -81,12 +95,11 @@ EntityMetaReader entityMetaReader = new EntityMetaReaderImpl(context); try { - Jiemamy jiemamy = rootModel.getJiemamy(); List<EntityMeta> entityMetas = entityMetaReader.read(); + TableModelConverter tbc = getTableModelConverter(config); for (EntityMeta em : entityMetas) { LOG.debug(LogMarker.DETAIL, em.toString()); - TableModel tm = jiemamy.getFactory().newModel(TableModel.class); - tm.setName(em.getName()); + TableModel tm = tbc.convert(rootModel, em); rootModel.getEntities().add(tm); } } catch (IOException e) { @@ -94,7 +107,6 @@ } catch (EntityClassNotFoundException e) { throw new ImportException(e); } - return false; } Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/TableModelConverter.java =================================================================== --- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/TableModelConverter.java (rev 0) +++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/TableModelConverter.java 2009-04-07 10:32:41 UTC (rev 3159) @@ -0,0 +1,40 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on Apr 7, 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.composer.importer; + +import org.jiemamy.composer.importer.meta.EntityMeta; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.TableModel; + +/** + * {@TableModel}に変換するコンバータです。 + * + * @author j5ik2o + */ +public interface TableModelConverter { + + /** + * {@link EntityMeta}から{@TableModel}に変換する。 + * + * @param rootModel {@link RootModel} + * @param entityMeta {@link EntityMeta} + * @return {@link TableModel} + */ + TableModel convert(RootModel rootModel, EntityMeta entityMeta); +} Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/TableModelConverter.java ___________________________________________________________________ Added: svn:mime-type + text/plain