[Jiemamy-notify:1346] commit [2604] バリデータの実装を進めた。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 2日 (月) 22:29:23 JST


Revision: 2604
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2604
Author:   daisuke_m
Date:     2009-02-02 22:29:23 +0900 (Mon, 02 Feb 2009)

Log Message:
-----------
バリデータの実装を進めた。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java	2009-02-02 11:30:42 UTC (rev 2603)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java	2009-02-02 13:29:23 UTC (rev 2604)
@@ -67,7 +67,7 @@
 		 */
 		public InstanceSpaceProblem(String pos) {
 			super("X0000"); // TODO エラーコード設定
-			registerMessage(Locale.JAPAN, "{1}においてインスタンス空間が異なるモデルオブジェクトが存在します");
+			registerMessage(Locale.JAPAN, "{0}においてインスタンス空間が異なるモデルオブジェクトが存在します");
 			setArguments(new Object[] {
 				pos,
 			});

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java	2009-02-02 11:30:42 UTC (rev 2603)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java	2009-02-02 13:29:23 UTC (rev 2604)
@@ -19,6 +19,7 @@
 package org.jiemamy.validator.impl;
 
 import java.util.Collection;
+import java.util.Locale;
 import java.util.UUID;
 
 import org.slf4j.Logger;
@@ -62,18 +63,38 @@
 				for (ColumnRef columnRef : keyModel.getKeyColumns()) {
 					if (columnIds.contains(columnRef.getReferenceId()) == false) {
 						logger.error("key(" + keyModel.getId() + ") columns error");
-						// TODO keyColumnsに自テーブルのカラムでないものが含まれているProblem
-						result.add(new AbstractProblem("C") {
-							
-							public Severity getSeverity() {
-								return null;
-							}
-							
-						});
+						result.add(new IllegalKeyColumnRefProblem(tableModel, keyModel, columnRef));
 					}
 				}
 			}
 		}
 		return result;
 	}
+	
+
+	static class IllegalKeyColumnRefProblem extends AbstractProblem {
+		
+		/**
+		 * インスタンスを生成する。
+		 * 
+		 * @param tableModel
+		 * @param keyModel
+		 * @param columnRef
+		 */
+		public IllegalKeyColumnRefProblem(TableModel tableModel, KeyConstraintModel keyModel, ColumnRef columnRef) {
+			super("X0000"); // TODO エラーコード設定
+			registerMessage(Locale.JAPAN, "テーブル{0}({1})にキー{2}({3})が参照するカラム{4}は存在しません");
+			setArguments(new Object[] {
+				tableModel.getName(),
+				tableModel.getId().toString(),
+				keyModel.getName(),
+				keyModel.getId().toString(),
+				columnRef.getReferenceId().toString()
+			});
+		}
+		
+		public Severity getSeverity() {
+			return Severity.ERROR;
+		}
+	}
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java	2009-02-02 11:30:42 UTC (rev 2603)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java	2009-02-02 13:29:23 UTC (rev 2604)
@@ -18,6 +18,8 @@
  */
 package org.jiemamy.validator.impl;
 
+import java.util.Locale;
+
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -54,17 +56,32 @@
 			ElementReference<?> elementReference = (ElementReference<?>) element;
 			if (referenceResolver.resolve(elementReference) == null) {
 				logger.error("reference(" + pos + ") resolve error");
-				// TODO 参照が解決できないProblem
-				result.add(new AbstractProblem("D") {
-					
-					public Severity getSeverity() {
-						return null;
-					}
-					
-				});
+				result.add(new ReferenceProblem(elementReference, pos));
 				
 			}
 		}
 	}
 	
+
+	static class ReferenceProblem extends AbstractProblem {
+		
+		/**
+		 * インスタンスを生成する。
+		 * @param pos 
+		 * @param elementReference 
+		 */
+		private ReferenceProblem(ElementReference<?> elementReference, String pos) {
+			super("X0000"); // TODO エラーコード設定
+			registerMessage(Locale.JAPAN, "位置{0}において{1}に対する参照が解決できません");
+			setArguments(new Object[] {
+				pos,
+				elementReference.getReferenceId().toString()
+			});
+		}
+		
+		public Severity getSeverity() {
+			return Severity.FATAL;
+		}
+	}
+	
 }

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java	2009-02-02 11:30:42 UTC (rev 2603)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java	2009-02-02 13:29:23 UTC (rev 2604)
@@ -19,6 +19,7 @@
 package org.jiemamy.validator.impl;
 
 import java.util.Collection;
+import java.util.Locale;
 import java.util.UUID;
 
 import org.slf4j.Logger;
@@ -26,6 +27,7 @@
 
 import org.jiemamy.model.RootModel;
 import org.jiemamy.model.attribute.ColumnModel;
+import org.jiemamy.model.attribute.ColumnRef;
 import org.jiemamy.model.entity.TableModel;
 import org.jiemamy.model.index.IndexColumnModel;
 import org.jiemamy.model.index.IndexModel;
@@ -59,15 +61,10 @@
 			
 			for (IndexModel indexModel : tableModel.getIndexes()) {
 				for (IndexColumnModel indexColumnModel : indexModel.getColumns()) {
-					if (columnIds.contains(indexColumnModel.getColumn().getReferenceId()) == false) {
+					ColumnRef columnRef = indexColumnModel.getColumn();
+					if (columnIds.contains(columnRef.getReferenceId()) == false) {
 						logger.error("illegal index (" + indexColumnModel.getId() + ")");
-						result.add(new AbstractProblem("E") {
-							
-							public Severity getSeverity() {
-								return null;
-							}
-							
-						});
+						result.add(new IllegalIndexColumnRefProblem(tableModel, indexModel, columnRef));
 						
 					}
 				}
@@ -75,4 +72,35 @@
 		}
 		return result;
 	}
+	
+
+	/**
+	 * TODO for daisuke
+	 * 
+	 * @author daisuke
+	 */
+	static class IllegalIndexColumnRefProblem extends AbstractProblem {
+		
+		/**
+		 * インスタンスを生成する。
+		 * @param columnRef 
+		 * @param indexModel 
+		 * @param tableModel 
+		 */
+		private IllegalIndexColumnRefProblem(TableModel tableModel, IndexModel indexModel, ColumnRef columnRef) {
+			super("X0000"); // TODO エラーコード設定
+			registerMessage(Locale.JAPAN, "テーブル{0}({1})にインデックス{2}({3})が参照するカラム{4}は存在しません");
+			setArguments(new Object[] {
+				tableModel.getName(),
+				tableModel.getId().toString(),
+				indexModel.getName(),
+				indexModel.getId().toString(),
+				columnRef.getReferenceId().toString()
+			});
+		}
+		
+		public Severity getSeverity() {
+			return Severity.ERROR;
+		}
+	}
 }



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