[Jiemamy-notify:1429] commit [2659] イベント周りでテストが落ちていた件を修正。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 12日 (木) 23:53:33 JST


Revision: 2659
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2659
Author:   shin1
Date:     2009-02-12 23:53:32 +0900 (Thu, 12 Feb 2009)

Log Message:
-----------
イベント周りでテストが落ちていた件を修正。
参照リゾルバを使ったUUIDによる親子関係の確認メソッドが正しく移行できていなかった。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java	2009-02-12 14:50:35 UTC (rev 2658)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java	2009-02-12 14:53:32 UTC (rev 2659)
@@ -19,6 +19,7 @@
 package org.jiemamy;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 
@@ -28,6 +29,9 @@
 import org.jiemamy.model.JiemamyElement;
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.attribute.AttributeModel;
+import org.jiemamy.model.attribute.ColumnRef;
+import org.jiemamy.model.attribute.constraint.PrimaryKeyModel;
+import org.jiemamy.model.entity.EntityModel;
 import org.jiemamy.model.entity.TableModel;
 
 /**
@@ -54,14 +58,37 @@
 	 */
 	public static boolean isChild(JiemamyElement parent, JiemamyElement child) {
 		if (parent instanceof RootModel) {
-			// 必ず子供になるはず?
-			return true;
+			return isRootChild((RootModel) parent, child);
 		} else if (parent instanceof TableModel) {
 			return isTableChild((TableModel) parent, child);
+		} else if (parent instanceof PrimaryKeyModel) {
+			return isPrimaryKeyChild((PrimaryKeyModel) parent, child);
 		}
 		return false;
 	}
 	
+	private static boolean isPrimaryKeyChild(PrimaryKeyModel parent, JiemamyElement child) {
+		List<ColumnRef> columnRefs = parent.getKeyColumns();
+		for (ColumnRef ref : columnRefs) {
+			if (ref.getReferenceId().equals(child.getId())) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	private static boolean isRootChild(RootModel root, JiemamyElement child) {
+		for (EntityModel table : root.getEntities()) {
+			if (table == child) {
+				return true;
+			}
+			if (isChild(table, child)) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
 	private static boolean isTableChild(TableModel table, JiemamyElement child) {
 		for (AttributeModel attribute : table.getAttributes()) {
 			if (attribute == child) {



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