[Jiemamy-notify:1940] commit [3101] 新規追加しました。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 4日 (土) 22:25:26 JST


Revision: 3101
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3101
Author:   j5ik2o
Date:     2009-04-04 22:25:26 +0900 (Sat, 04 Apr 2009)

Log Message:
-----------
新規追加しました。

Added Paths:
-----------
    charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaFactoryImpl.java


-------------- next part --------------
Added: charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaFactoryImpl.java
===================================================================
--- charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaFactoryImpl.java	                        (rev 0)
+++ charon/jiemamy-jpa-importer/trunk/src/main/java/org/jiemamy/composer/importer/meta/impl/EntityMetaFactoryImpl.java	2009-04-04 13:25:26 UTC (rev 3101)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on Apr 4, 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 javax.persistence.Entity;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.Validate;
+
+import org.jiemamy.composer.importer.meta.EntityMeta;
+import org.jiemamy.composer.importer.meta.EntityMetaFactory;
+
+/**
+ * {@link EntityMetaFactory}の実装クラス。
+ * 
+ * @author j5ik2o
+ */
+public class EntityMetaFactoryImpl implements EntityMetaFactory {
+	
+	private EntityMeta createEntityMeta(Class<?> entityClass) throws NonEntityException {
+		Validate.notNull(entityClass);
+		Entity entityAnnotation = entityClass.getAnnotation(Entity.class);
+		if (entityAnnotation == null) {
+			throw new NonEntityException(String.format("%s is not entity class.", entityClass.getName()));
+		}
+		EntityMeta entityMeta = new EntityMeta();
+		doEntityClass(entityMeta, entityClass);
+		doName(entityMeta, entityAnnotation);
+		// TODO エンティティクラスからEntityMetaを作成する(残項目あり)
+		return entityMeta;
+	}
+	
+	private void doEntityClass(EntityMeta entityMeta, Class<?> entityClass) {
+		entityMeta.setEntityClass(entityClass);
+	}
+	
+	private void doName(EntityMeta entityMeta, Entity entityAnnotation) {
+		String entityName = entityAnnotation.name();
+		if (StringUtils.isEmpty(entityName)) {
+			entityName = StringUtils.uncapitalize(entityMeta.getEntityClass().getSimpleName());
+		}
+		entityMeta.setName(entityName);
+	}
+	
+	public EntityMeta getEntityMeta(Class<?> entityClass) throws NonEntityException {
+		Validate.notNull(entityClass);
+		// TODO まずキャッシュから探し、なかったら作成して返す
+		EntityMeta entityMeta = createEntityMeta(entityClass);
+		return entityMeta;
+	}
+	
+}


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



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