[Jiemamy-notify:2129] commit [3209] ・リファクタリング

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 10日 (金) 21:16:17 JST


Revision: 3209
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3209
Author:   j5ik2o
Date:     2009-04-10 21:16:17 +0900 (Fri, 10 Apr 2009)

Log Message:
-----------
・リファクタリング
・Docletを使わないようにした

Modified Paths:
--------------
    charon/jiemamy-jpa-importer/trunk/pom.xml
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultColumnModelConverter.java
    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/meta/ColumnMeta.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/TableMeta.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImpl.java
    charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Depertment.java
    charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Employee.java
    charon/jiemamy-jpa-importer/trunk/src/test/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImplTest.java

Added Paths:
-----------
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/ColumnName.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/TableName.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaCommand.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaReaderFactory.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityLogicalNameReadCommand.java
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderFactoryImpl.java

Removed Paths:
-------------
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/PropertyMetaUtil.java


-------------- next part --------------
Modified: charon/jiemamy-jpa-importer/trunk/pom.xml
===================================================================
--- charon/jiemamy-jpa-importer/trunk/pom.xml	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/pom.xml	2009-04-10 12:16:17 UTC (rev 3209)
@@ -105,28 +105,6 @@
 			<version>0.2-SNAPSHOT</version>
 		</dependency>
 	</dependencies>
-	<!-- 
-	<profiles>
-		<profile>
-			<id>default-tools.jar</id>
-			<activation>
-				<property>
-					<name>java.vendor</name>
-					<value>Sun Microsystems Inc.</value>
-				</property>
-			</activation>
-			<dependencies>
-				<dependency>
-					<groupId>com.sun</groupId>
-					<artifactId>tools</artifactId>
-					<version>${java.version}</version>
-					<scope>system</scope>
-					<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
-				</dependency>
-			</dependencies>
-		</profile>
-	</profiles>
-	-->
 	<distributionManagement>
 		<site>
 			<id>jiemamy-report</id>

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/ColumnName.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/ColumnName.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/ColumnName.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * カラム名用のアノテーション
+ * 
+ * @author j5ik2o
+ */
+ @ Retention(RetentionPolicy.RUNTIME)
+ @ Target(ElementType.FIELD)
+public @interface ColumnName {
+	
+	/** 論理名 */
+	String logical() default "";
+	
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/ColumnName.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/TableName.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/TableName.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/TableName.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * テーブル名用のアノテーション
+ * 
+ * @author j5ik2o
+ */
+ @ Retention(RetentionPolicy.RUNTIME)
+ @ Target(ElementType.TYPE)
+public @interface TableName {
+	
+	/** 論理名 */
+	String logical() default "";
+	
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/annotation/TableName.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultColumnModelConverter.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultColumnModelConverter.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/DefaultColumnModelConverter.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -29,7 +29,6 @@
 
 import org.jiemamy.JiemamyFactory;
 import org.jiemamy.composer.importer.meta.PropertyMeta;
-import org.jiemamy.composer.importer.meta.PropertyMetaUtil;
 import org.jiemamy.dialect.BuiltinDataTypeMold;
 import org.jiemamy.dialect.Dialect;
 import org.jiemamy.exception.JiemamyError;
@@ -117,7 +116,7 @@
 		JiemamyFactory factory = rootModel.getJiemamy().getFactory();
 		ColumnModel cm = factory.newModel(ColumnModel.class);
 		cm.setName(propertyMeta.getColumnMeta().getName());
-		cm.setLogicalName(PropertyMetaUtil.getComment(propertyMeta));
+		cm.setLogicalName(propertyMeta.getColumnMeta().getLogicalName());
 		if (propertyMeta.isId()) {
 			cm.setPrimaryKey(factory.newModel(PrimaryKey.class));
 		}

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-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/JpaImporter.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -30,13 +30,15 @@
 import org.jiemamy.composer.importer.meta.EntityMeta;
 import org.jiemamy.composer.importer.meta.EntityMetaReader;
 import org.jiemamy.composer.importer.meta.EntityMetaReaderContext;
+import org.jiemamy.composer.importer.meta.EntityMetaReaderFactory;
 import org.jiemamy.composer.importer.meta.PropertyMeta;
 import org.jiemamy.composer.importer.meta.impl.ColumnMetaFactoryImpl;
 import org.jiemamy.composer.importer.meta.impl.EntityMetaFactoryImpl;
-import org.jiemamy.composer.importer.meta.impl.EntityMetaReaderImpl;
+import org.jiemamy.composer.importer.meta.impl.EntityMetaReaderFactoryImpl;
 import org.jiemamy.composer.importer.meta.impl.PropertyMetaFactoryImpl;
 import org.jiemamy.composer.importer.meta.impl.TableMetaFactoryImpl;
 import org.jiemamy.dialect.Dialect;
+import org.jiemamy.dialect.generic.GenericDialect;
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.attribute.ColumnModel;
 import org.jiemamy.model.entity.TableModel;
@@ -53,15 +55,51 @@
 	
 	private static final Logger LOG = LoggerFactory.getLogger(JpaImporter.class);
 	
+	private static final Dialect DEFAULT_DIALECT = new GenericDialect();
+	
 	private static final TableModelConverter DEFALUT_TABLE_CONVETER = new DefaultTableModelConverter();
 	
-	private static ColumnModelConverter DEFALUT_COLUMN_CONVETER;
+	private static ColumnModelConverter defaultColumnConverter = null;
 	
 
+	/**
+	 * {@link ColumnModelConverter}を取得する。
+	 * 
+	 * @param config {@link JpaImportConfig}
+	 * @return {@link ColumnModelConverter}
+	 */
+	protected ColumnModelConverter getColumnModelConverter(JpaImportConfig config) {
+		if (config.getColumnModelConverter() != null) {
+			return config.getColumnModelConverter();
+		}
+		if (defaultColumnConverter == null) {
+			Dialect dialect = getDialect(config);
+			defaultColumnConverter = new DefaultColumnModelConverter(dialect);
+		}
+		return defaultColumnConverter;
+	}
+	
+	private Dialect getDialect(JpaImportConfig config) {
+		return DEFAULT_DIALECT;
+	}
+	
 	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 DEFALUT_TABLE_CONVETER;
+	}
+	
 	public boolean importModel(RootModel rootModel, JpaImportConfig config) throws ImportException {
 		Validate.notNull(rootModel);
 		Validate.notNull(config);
@@ -85,9 +123,9 @@
 		
 		context.setEntityMetaFactory(new EntityMetaFactoryImpl(new TableMetaFactoryImpl(), new PropertyMetaFactoryImpl(
 				new ColumnMetaFactoryImpl())));
-		EntityMetaReader entityMetaReader = new EntityMetaReaderImpl(context);
-		
+		EntityMetaReaderFactory entityMetaReaderFactory = new EntityMetaReaderFactoryImpl();
 		try {
+			EntityMetaReader entityMetaReader = entityMetaReaderFactory.createEntityMetaReader(context);
 			List<EntityMeta> entityMetas = entityMetaReader.read();
 			TableModelConverter tmc = getTableModelConverter(config);
 			ColumnModelConverter cmc = getColumnModelConverter(config);
@@ -110,36 +148,6 @@
 		return false;
 	}
 	
-	/**
-	 * {@link ColumnModelConverter}を取得する。
-	 * 
-	 * @param config {@link JpaImportConfig}
-	 * @return {@link ColumnModelConverter}
-	 */
-	protected ColumnModelConverter getColumnModelConverter(JpaImportConfig config) {
-		if (config.getColumnModelConverter() != null) {
-			return config.getColumnModelConverter();
-		}
-		if (DEFALUT_COLUMN_CONVETER == null) {
-			Dialect dialect = config.getDialect();
-			DEFALUT_COLUMN_CONVETER = new DefaultColumnModelConverter(dialect);
-		}
-		return DEFALUT_COLUMN_CONVETER;
-	}
-	
-	/**
-	 * {@link TableModelConverter}を取得する。
-	 * 
-	 * @param config {@link JpaImportConfig}
-	 * @return {@link TableModelConverter}
-	 */
-	protected TableModelConverter getTableModelConverter(JpaImportConfig config) {
-		if (config.getTableModelConverter() != null) {
-			return config.getTableModelConverter();
-		}
-		return DEFALUT_TABLE_CONVETER;
-	}
-	
 	private List<File> toFiles(List<String> paths) {
 		List<File> result = CollectionsUtil.newArrayList();
 		for (String path : paths) {

Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/ColumnMeta.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/ColumnMeta.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/ColumnMeta.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -30,6 +30,8 @@
 	/** 名前 */
 	private String name;
 	
+	private String logicalName;
+	
 	/** 挿入可能フラグ */
 	private boolean insertable = true;
 	
@@ -57,6 +59,15 @@
 	}
 	
 	/**
+	 * 論理名を取得する。
+	 * 
+	 * @return 論理名
+	 */
+	public String getLogicalName() {
+		return logicalName;
+	}
+	
+	/**
 	 * 名前を取得する。
 	 * 
 	 * @return 名前
@@ -129,6 +140,15 @@
 	}
 	
 	/**
+	 * 論理名を設定する。
+	 * 
+	 * @param logicalName 論理名
+	 */
+	public void setLogicalName(String logicalName) {
+		this.logicalName = logicalName;
+	}
+	
+	/**
 	 * 名前を設定する。
 	 * 
 	 * @param name 名前

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaCommand.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaCommand.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaCommand.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.meta;
+
+import java.util.List;
+
+/**
+ * {@link EntityMeta}を処理するためのコマンドインターフェイス。
+ * 
+ * @author j5ik2o
+ */
+public interface EntityMetaCommand {
+	
+	/**
+	 * {@link EntityMeta}を処理します。
+	 * 
+	 * @param entityMetaList {@link EntityMeta}のリスト
+	 */
+	void execute(List<EntityMeta> entityMetaList);
+	
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaReaderFactory.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaReaderFactory.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaReaderFactory.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.meta;
+
+/**
+ * {@link EntityMetaReader}用のファクトリインターフェイス。
+ * 
+ * @author j5ik2o
+ */
+public interface EntityMetaReaderFactory {
+	
+	/**
+	 * {@link EntityMetaReader}を生成します。
+	 * 
+	 * @param entityMetaReaderContext {@link EntityMetaReaderContext}
+	 * @return {@link EntityMetaReader}
+	 */
+	EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext);
+	
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/EntityMetaReaderFactory.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Deleted: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/PropertyMetaUtil.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/PropertyMetaUtil.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/PropertyMetaUtil.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on Apr 5, 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.meta;
-
-/**
- * {@link PropertyMeta}に関するユーティリティクラス。
- * 
- * @author j5ik2o
- */
-public class PropertyMetaUtil {
-	
-	/** コメントのキー */
-	protected static String commentKey = PropertyMetaUtil.class.getName() + "_comment";
-	
-
-	/**
-	 * コメントを取得する。
-	 * 
-	 * @param propertyMeta プロパティメタデータ
-	 * @return コメント
-	 */
-	public static String getComment(PropertyMeta propertyMeta) {
-		return propertyMeta.getAdditionalInfo(commentKey);
-	}
-	
-	/**
-	 * コメントを設定する。
-	 * 
-	 * @param propertyMeta プロパティメタデータ
-	 * @param comment コメント
-	 */
-	public static void setComment(PropertyMeta propertyMeta, String comment) {
-		propertyMeta.addAdditionalInfo(commentKey, comment);
-	}
-	
-	/**
-	 * インスタンスを生成する。
-	 * 
-	 */
-	protected PropertyMetaUtil() {
-		
-	}
-}

Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/TableMeta.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/TableMeta.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/TableMeta.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -31,6 +31,9 @@
 	/** 名前 */
 	protected String name;
 	
+	/** 論理名 */
+	protected String logicalName;
+	
 	/** カタログ */
 	protected String catalog;
 	
@@ -64,6 +67,15 @@
 	}
 	
 	/**
+	 * 論理名を取得する。
+	 * 
+	 * @return 論理名
+	 */
+	public String getLogicalName() {
+		return logicalName;
+	}
+	
+	/**
 	 * 名前を返します。
 	 * 
 	 * @return 名前
@@ -91,6 +103,15 @@
 	}
 	
 	/**
+	 * 論理名を設定する。
+	 * 
+	 * @param logicalName 論理名
+	 */
+	public void setLogicalName(String logicalName) {
+		this.logicalName = logicalName;
+	}
+	
+	/**
 	 * 名前を設定します。
 	 * 
 	 * @param name 名前

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityLogicalNameReadCommand.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityLogicalNameReadCommand.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityLogicalNameReadCommand.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.meta.impl;
+
+import java.util.List;
+
+import org.jiemamy.composer.annotation.ColumnName;
+import org.jiemamy.composer.annotation.TableName;
+import org.jiemamy.composer.importer.meta.EntityMeta;
+import org.jiemamy.composer.importer.meta.EntityMetaCommand;
+import org.jiemamy.composer.importer.meta.PropertyMeta;
+
+/**
+ * 論理名を読み取って{@link EntityMeta}に設定するコマンドクラス。
+ * 
+ * @author j5ik2o
+ */
+public class EntityLogicalNameReadCommand implements EntityMetaCommand {
+	
+	public void execute(List<EntityMeta> entityMetaList) {
+		for (EntityMeta entityMeta : entityMetaList) {
+			TableName tn = entityMeta.getEntityClass().getAnnotation(TableName.class);
+			if (tn != null) {
+				String tableLogicalName = tn.logical();
+				entityMeta.getTableMeta().setLogicalName(tableLogicalName);
+			}
+			for (PropertyMeta propertyMeta : entityMeta.getAllColumnPropertyMeta()) {
+				ColumnName cn = propertyMeta.getField().getAnnotation(ColumnName.class);
+				if (cn == null) {
+					continue;
+				}
+				String columnLogicalName = cn.logical();
+				propertyMeta.getColumnMeta().setLogicalName(columnLogicalName);
+			}
+		}
+	}
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityLogicalNameReadCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderFactoryImpl.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderFactoryImpl.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderFactoryImpl.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 10, 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.meta.impl;
+
+import org.jiemamy.composer.importer.meta.EntityMetaReader;
+import org.jiemamy.composer.importer.meta.EntityMetaReaderContext;
+import org.jiemamy.composer.importer.meta.EntityMetaReaderFactory;
+
+/**
+ * {@link EntityMetaReaderFactory}の実装クラス。
+ * 
+ * @author j5ik2o
+ */
+public class EntityMetaReaderFactoryImpl implements EntityMetaReaderFactory {
+	
+	public EntityMetaReader createEntityMetaReader(EntityMetaReaderContext entityMetaReaderContext) {
+		return new EntityMetaReaderImpl(entityMetaReaderContext);
+	}
+	
+}


Property changes on: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderFactoryImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImpl.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImpl.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImpl.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -36,6 +36,7 @@
 import org.jiemamy.composer.importer.meta.DocletUnavailableException;
 import org.jiemamy.composer.importer.meta.EntityClassNotFoundException;
 import org.jiemamy.composer.importer.meta.EntityMeta;
+import org.jiemamy.composer.importer.meta.EntityMetaCommand;
 import org.jiemamy.composer.importer.meta.EntityMetaFactory;
 import org.jiemamy.composer.importer.meta.EntityMetaReader;
 import org.jiemamy.composer.importer.meta.EntityMetaReaderContext;
@@ -54,23 +55,13 @@
  * 
  * @author j5ik2o
  */
- @ SuppressWarnings("restriction")
 public class EntityMetaReaderImpl implements EntityMetaReader {
 	
 	private static final Logger LOG = LoggerFactory.getLogger(EntityMetaReaderImpl.class);
 	
 	private final EntityMetaReaderContext entityMetaReaderContext;
 	
-	/** Docletが使用可能な場合{@code true} */
-	protected static boolean docletAvailable;
-	static {
-		try {
-			Class.forName("com.sun.javadoc.Doclet"); // tools.jar
-			docletAvailable = true;
-		} catch (final Throwable ignore) {
-			LOG.warn("", ignore);
-		}
-	}
+	private EntityMetaCommand logicalNameReadCommand = new EntityLogicalNameReadCommand();
 	
 
 	/**
@@ -78,7 +69,7 @@
 	* 
 	* @param entityMetaReaderContext コンテキスト
 	*/
-	public EntityMetaReaderImpl(EntityMetaReaderContext entityMetaReaderContext) {
+	EntityMetaReaderImpl(EntityMetaReaderContext entityMetaReaderContext) {
 		Validate.notNull(entityMetaReaderContext);
 		Validate.notNull(entityMetaReaderContext.getClassPathDirs());
 		Validate.notEmpty(entityMetaReaderContext.getClassPathDirs());
@@ -100,35 +91,6 @@
 		return urlClassLoader;
 	}
 	
-	/**
-	 * Docletの引数の配列を作成します。
-	 * 
-	 * @return Docletの引数の配列
-	 * @throws IOException 入出力が失敗した場合
-	 */
-	protected String[] createDocletArgs() throws IOException {
-		StringBuilder srcDirListBuf = new StringBuilder();
-		for (File dir : entityMetaReaderContext.getJavaSrcFileDirs()) {
-			srcDirListBuf.append(FileUtil.getCanonicalPath(dir));
-			srcDirListBuf.append(File.pathSeparator);
-		}
-		srcDirListBuf.setLength(srcDirListBuf.length() - File.pathSeparator.length());
-		
-		List<String> args = new ArrayList<String>();
-		args.add("-doclet");
-		args.add(CommentDoclet.class.getName());
-		args.add("-sourcepath");
-		args.add(srcDirListBuf.toString());
-		args.add("-encoding");
-		args.add(entityMetaReaderContext.getJavaFileEncoding());
-		args.add("-subpackages");
-		args.add(entityMetaReaderContext.getPackageName());
-		if (LOG.isDebugEnabled()) {
-			args.add("-verbose");
-		}
-		return args.toArray(new String[args.size()]);
-	}
-	
 	private boolean isIgnoreShortClassName(String shortClassName) {
 		Validate.notNull(shortClassName);
 		if (entityMetaReaderContext.getIgnoreShortClassNamePatterns().isEmpty()) {
@@ -218,24 +180,7 @@
 	 * @throws IOException 入出力が失敗した場合
 	 */
 	protected void readComment(List<EntityMeta> entityMetaList) throws DocletUnavailableException, IOException {
-		if (!docletAvailable) {
-			return;
-			//throw new DocletUnavailableException();
-		}
-		String[] args = createDocletArgs();
-		if (LOG.isDebugEnabled()) {
-			StringBuilder buf = new StringBuilder();
-			for (String arg : args) {
-				buf.append(arg).append(" ");
-			}
-			LOG.debug(String.format("Doclet Arguments = %s", buf.toString()));
-		}
-		CommentDocletContext.setEntityMetaList(entityMetaList);
-		try {
-			//com.sun.tools.javadoc.Main.execute(args);
-		} finally {
-			CommentDocletContext.setEntityMetaList(null);
-		}
+		logicalNameReadCommand.execute(entityMetaList);
 	}
 	
 	private List<URL> toURLs(List<File> files) throws MalformedURLException {

Modified: charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Depertment.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Depertment.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Depertment.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -23,27 +23,29 @@
 import javax.persistence.Id;
 import javax.persistence.Version;
 
+import org.jiemamy.composer.annotation.ColumnName;
+import org.jiemamy.composer.annotation.TableName;
+
 /**
- * 部署
+ * 部署テーブル。
  * 
  * @author j5ik2o
  */
 @Entity
+ @ TableName(logical = "部署")
 public class Depertment {
 	
-	/** 
-	 * 部署ID
-	 */
 	@Id
+	@ColumnName(logical = "部署ID")
 	private Long depertmentId;
 	
-	/** 部署名 */
 	@Column(nullable = false)
+	@ColumnName(logical = "部署名")
 	private String depertmentName;
 	
-	/** バージョン */
 	@Version
 	@Column(nullable = false)
+	@ColumnName(logical = "バージョン")
 	private Long version;
 	
 

Modified: charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Employee.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Employee.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/test/java/example/entity/Employee.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -23,31 +23,37 @@
 import javax.persistence.Id;
 import javax.persistence.JoinColumn;
 import javax.persistence.ManyToOne;
+import javax.persistence.Table;
 import javax.persistence.Version;
 
+import org.jiemamy.composer.annotation.ColumnName;
+import org.jiemamy.composer.annotation.TableName;
+
 /**
  * 従業員
  * 
  * @author j5ik2o
  */
 @Entity
+ @ Table(name = "EMPLOYEE")
+ @ TableName(logical = "従業員")
 public class Employee {
 	
-	/** 従業員ID */
 	@Id
+	@ColumnName(logical = "従業員ID")
 	private Long employeeId;
 	
-	/** 従業員名 */
 	@Column(nullable = false)
+	@ColumnName(logical = "従業員名")
 	private String employeeName;
 	
-	/** 部署ID */
 	@Column(nullable = false)
+	@ColumnName(logical = "部署ID")
 	private Long depertmentId;
 	
-	/** バージョン */
 	@Version
 	@Column(nullable = false)
+	@ColumnName(logical = "バージョン")
 	private Long version;
 	
 	@ManyToOne

Modified: charon/jiemamy-jpa-importer/trunk/src/test/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImplTest.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/test/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImplTest.java	2009-04-10 11:23:58 UTC (rev 3208)
+++ charon/jiemamy-jpa-importer/trunk/src/test/java/org/jiemamy/composer/importer/meta/impl/EntityMetaReaderImplTest.java	2009-04-10 12:16:17 UTC (rev 3209)
@@ -60,13 +60,13 @@
 		classPathDirs.add(new File(JpaImporterTestUtil.getBuildDirNoException()));
 		context.setClassPathDirs(classPathDirs);
 		context.setPackageName("example.entity");
-		context.setReadComment(false);
+		context.setReadComment(true);
 		List<File> javaFileSrcDirs = CollectionsUtil.newArrayList();
 		javaFileSrcDirs.add(new File("src/test/java"));
 		context.setJavaSrcFileDirs(javaFileSrcDirs);
 		context.setEntityMetaFactory(new EntityMetaFactoryImpl(new TableMetaFactoryImpl(), new PropertyMetaFactoryImpl(
 				new ColumnMetaFactoryImpl())));
-		entityMetaReader = new EntityMetaReaderImpl(context);
+		entityMetaReader = new EntityMetaReaderFactoryImpl().createEntityMetaReader(context);
 		List<EntityMeta> entityMetas = entityMetaReader.read();
 		
 		EntityMeta em = entityMetas.get(0);



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