[Jiemamy-notify:1699] commit [2891] チェック制約まわりの整備。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 3月 17日 (火) 04:30:51 JST


Revision: 2891
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2891
Author:   daisuke_m
Date:     2009-03-17 04:30:51 +0900 (Tue, 17 Mar 2009)

Log Message:
-----------
チェック制約まわりの整備。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java
    vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java
    zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -85,7 +85,7 @@
 		return uniqueKey;
 	}
 	
-	public void setCheck(ColumnCheckConstraint checkConstraint) {
+	public void setCheckConstraint(ColumnCheckConstraint checkConstraint) {
 		this.checkConstraint = checkConstraint;
 	}
 	

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -84,7 +84,7 @@
 	 * 
 	 * @return 精度
 	 */
-	public int getPrecision() {
+	public Integer getPrecision() {
 		return precision;
 	}
 	
@@ -93,7 +93,7 @@
 	 * 
 	 * @return スケール
 	 */
-	public int getScale() {
+	public Integer getScale() {
 		return scale;
 	}
 	

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -75,7 +75,7 @@
 	 * 
 	 * @return シリアル(通し番号)型であれば{@code true}
 	 */
-	public boolean isSerial() {
+	public Boolean isSerial() {
 		return serial;
 	}
 	

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -55,7 +55,6 @@
 import static org.jiemamy.xml.CoreQName.SCHEMA_NAME;
 import static org.jiemamy.xml.CoreQName.SORT_ORDER;
 import static org.jiemamy.xml.CoreQName.TABLE;
-import static org.jiemamy.xml.CoreQName.TABLE_CHECK_CONSTRAINT;
 import static org.jiemamy.xml.CoreQName.TABLE_REF;
 import static org.jiemamy.xml.CoreQName.TYPE_CATEGORY;
 import static org.jiemamy.xml.CoreQName.TYPE_NAME;
@@ -232,16 +231,6 @@
 		writeAdapters(checkElement, checkConstraint.getAdapters());
 	}
 	
-	private static void writeTableCheckConstrait(Element parentElement, TableCheckConstraint checkConstraint) {
-		Element checkElement = DomUtil.newChild(parentElement, TABLE_CHECK_CONSTRAINT);
-		checkElement.setAttribute(CoreQName.ID.getQNameString(), checkConstraint.getId().toString());
-		DomUtil.newChild(checkElement, NAME, checkConstraint.getName());
-		DomUtil.newChild(checkElement, LOGICAL_NAME, checkConstraint.getLogicalName());
-		DomUtil.newChild(checkElement, DESCRIPTION, checkConstraint.getDescription());
-		DomUtil.newChild(checkElement, EXPRESSION, checkConstraint.getExpression());
-		writeAdapters(checkElement, checkConstraint.getAdapters());
-	}
-	
 
 	private RootModel rootModel;
 	
@@ -414,8 +403,9 @@
 							DomUtil.newChild(attributeElement, ON_UPDATE, foreignKey.getOnUpdate());
 						}
 					} else if (attributeModel instanceof TableCheckConstraint) {
-						TableCheckConstraint tableCheckModel = (TableCheckConstraint) attributeModel;
-						writeTableCheckConstrait(attributeElement, tableCheckModel);
+						TableCheckConstraint tableCheckConstraint = (TableCheckConstraint) attributeModel;
+						DomUtil.newChild(attributeElement, EXPRESSION, tableCheckConstraint.getExpression());
+						writeAdapters(attributeElement, tableCheckConstraint.getAdapters());
 					}
 					writeAdapters(attributeElement, attributeModel.getAdapters());
 				}

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -311,7 +311,7 @@
 			checkConstraint.setName(XpathUtil.getTextContent(checkElement, "core:name"));
 			checkConstraint.setExpression(XpathUtil.getTextContent(checkElement, "core:expression"));
 			readAdapter(checkElement, checkConstraint);
-			columnModel.setCheck(checkConstraint);
+			columnModel.setCheckConstraint(checkConstraint);
 		}
 		
 		columnModel.setDescription(XpathUtil.getTextContent(columnElement, "core:description"));

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -722,6 +722,12 @@
 			.build());
 		tableEmp.getAttributes().add(empSal);
 		
+		ColumnCheckConstraint checkConstraint =
+				factory.newModel(ColumnCheckConstraint.class, uuid.get("873f6660-7a61-4c2c-87a0-e922fa03b88c"));
+		checkConstraint.setName("positive_sal");
+		checkConstraint.setExpression("SAL >= 0");
+		empSal.setCheckConstraint(checkConstraint);
+		
 		empDeptId = factory.newModel(ColumnModel.class, uuid.get("4ae69b7a-7a0e-422a-89dc-0f0cff77565b"));
 		empDeptId.setName("DEPT_ID");
 		empDeptId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build());

Modified: vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
===================================================================
--- vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ vesta/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -631,8 +631,10 @@
 			} else if (dataType instanceof BuiltinDataType) {
 				BuiltinDataType builtinDataType = (BuiltinDataType) dataType;
 				cmbColumnType.setText(builtinDataType.getTypeName());
-				Integer size = builtinDataType.getAdapter(SizedDataTypeAdapter.class).getSize();
-				txtColumnSize.setText(StringUtils.defaultIfEmpty(ObjectUtils.toString(size), ""));
+				if (builtinDataType.hasAdapter(SizedDataTypeAdapter.class)) {
+					Integer size = builtinDataType.getAdapter(SizedDataTypeAdapter.class).getSize();
+					txtColumnSize.setText(StringUtils.defaultIfEmpty(ObjectUtils.toString(size), ""));
+				}
 			}
 			txtDefaultValue.setText(StringUtils.defaultIfEmpty(columnModel.getDefaultValue(), ""));
 			txtDescription.setText(StringUtils.defaultIfEmpty(columnModel.getDescription(), ""));
@@ -773,7 +775,11 @@
 					// ignore
 				}
 				if (chkIsPK.getSelection() == false && primaryKey != null) {
-					jiemamyFacade.removeKeyColumn(primaryKey, columnModel);
+					try {
+						jiemamyFacade.removeKeyColumn(primaryKey, columnModel);
+					} catch (IllegalArgumentException e) {
+						// ignore
+					}
 					// FIXME BUG ここでremoveされない?
 				} else {
 					if (primaryKey == null) {

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java	2009-03-16 18:40:06 UTC (rev 2890)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java	2009-03-16 19:30:51 UTC (rev 2891)
@@ -88,7 +88,7 @@
 	 * @param check チェック制約
 	 * @since 0.2
 	 */
-	void setCheck(ColumnCheckConstraint check);
+	void setCheckConstraint(ColumnCheckConstraint check);
 	
 	/**
 	 * 型記述子を設定する。

Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-03-16 18:40:06 UTC (rev 2890)
+++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml	2009-03-16 19:30:51 UTC (rev 2891)
@@ -95,6 +95,10 @@
             </adapter>
           </dataType>
           <notNull id="a446779a-4fb6-4a0f-8262-22daae856e85"/>
+          <columnCheck id="873f6660-7a61-4c2c-87a0-e922fa03b88c">
+            <name>positive_sal</name>
+            <expression>SAL &lt;= 0</expression>
+          </columnCheck>
         </column>
         <column id="4ae69b7a-7a0e-422a-89dc-0f0cff77565b">
           <name>DEPT_ID</name>



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