svnno****@sourc*****
svnno****@sourc*****
2009年 4月 7日 (火) 02:15:35 JST
Revision: 3141 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3141 Author: daisuke_m Date: 2009-04-07 02:15:35 +0900 (Tue, 07 Apr 2009) Log Message: ----------- jiemamy-commonsとjiemamy-test-helperを利用した構成に変更。 Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/pom.xml artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java artemis/trunk/jiemamy-core/pom.xml artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultDataTypeResolver.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultEntityImportVisitor.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/enhance/FactoryExtension.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilderImpl.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/datatype/BuiltinDataTypeImplTest.java artemis/trunk/jiemamy-dialect-mysql/pom.xml artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java artemis/trunk/jiemamy-dialect-oracle/pom.xml artemis/trunk/jiemamy-dialect-postgresql/pom.xml artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java artemis/trunk/jiemamy-dialect-sql99/pom.xml artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java artemis/trunk/jiemamy-view/pom.xml charon/jiemamy-jpa-importer/trunk/pom.xml eros/maven-jiemamy-plugin/trunk/pom.xml eros/maven-jiemamy-plugin/trunk/src/test/resources/sample.xml hestia/trunk/org.jiemamy.eclipse.core/.classpath hestia/trunk/org.jiemamy.eclipse.core/META-INF/MANIFEST.MF hestia/trunk/org.jiemamy.eclipse.core/build.properties hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java leto/jiemamy-commons/trunk/pom.xml leto/jiemamy-test-helper/trunk/trunk/pom.xml zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml Added Paths: ----------- leto/jiemamy-commons/trunk/src/main/java/org/ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/Instruction.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ModelUtil.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/UuidStrategy.java leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/package-info.java Removed Paths: ------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/internal/test/ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/attribute/RepresentationAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/PrecisionedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SerialDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SizedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/TimezonedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/package-info.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/Instruction.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelEntry.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/UuidStrategy.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/AnnotationUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/CollectionsUtil.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelBuilder2Test.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/pom.xml =================================================================== --- artemis/trunk/jiemamy-artemis-test/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-artemis-test/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -55,13 +55,19 @@ <version>1.3</version> <scope>test</scope> </dependency> + <dependency> + <groupId>xmlunit</groupId> + <artifactId>xmlunit</artifactId> + <version>1.2</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> <dependency> - <groupId>xmlunit</groupId> - <artifactId>xmlunit</artifactId> - <version>1.2</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/TestDatabaseInstance.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -45,7 +45,7 @@ /** PostgreSQL 8.1 */ PostgreSQL(PostgresqlDialect.class), - /** MySQL 5.?? TODO バージョン確認 */ + /** MySQL 5.0.45 */ MySQL(MySqlDialect.class), /** Oracle Database 10g Express Edition */ Modified: artemis/trunk/jiemamy-core/pom.xml =================================================================== --- artemis/trunk/jiemamy-core/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -88,9 +88,9 @@ <scope>test</scope> </dependency> <dependency> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - <version>1.3.1</version> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> <scope>test</scope> </dependency> <dependency> @@ -155,6 +155,11 @@ <artifactId>generic-tree</artifactId> <version>0.1.0</version> </dependency> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-spec-core</artifactId> Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -33,12 +33,12 @@ import org.jiemamy.dialect.internal.BuiltinDataTypeMoldImpl; import org.jiemamy.dialect.internal.impl.DefaultDataTypeResolver; import org.jiemamy.dialect.internal.impl.DefaultMoldManager; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.constraint.ForeignKey; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.sql.SqlStatement; import org.jiemamy.utils.CollectionsUtil; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultDataTypeResolver.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultDataTypeResolver.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultDataTypeResolver.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -29,15 +29,15 @@ import org.jiemamy.dialect.BuiltinDataTypeMold; import org.jiemamy.dialect.DataTypeResolver; import org.jiemamy.dialect.MoldManager; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.internal.model.sql.Keyword; import org.jiemamy.internal.model.sql.Literal; import org.jiemamy.internal.model.sql.Separator; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.sql.Token; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.model.DataTypeUtil; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultEntityImportVisitor.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultEntityImportVisitor.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultEntityImportVisitor.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -35,13 +35,13 @@ import org.jiemamy.dialect.DataTypeResolver; import org.jiemamy.dialect.ImportMetadataConfig; import org.jiemamy.dialect.internal.EntityImportVisitor; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.ColumnRef; import org.jiemamy.model.attribute.constraint.NotNullConstraint; import org.jiemamy.model.attribute.constraint.PrimaryKey; import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/enhance/FactoryExtension.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/enhance/FactoryExtension.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/enhance/FactoryExtension.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -36,7 +36,6 @@ import org.jiemamy.internal.model.RootModelImpl; import org.jiemamy.internal.model.attribute.ColumnModelImpl; import org.jiemamy.internal.model.attribute.ColumnRefImpl; -import org.jiemamy.internal.model.attribute.RepresentationAdapter; import org.jiemamy.internal.model.attribute.constraint.ColumnCheckConstraintImpl; import org.jiemamy.internal.model.attribute.constraint.DeferrabilityImpl; import org.jiemamy.internal.model.attribute.constraint.ForeignKeyImpl; @@ -59,6 +58,7 @@ import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.RepresentationAdapter; import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint; import org.jiemamy.model.attribute.constraint.Deferrability; import org.jiemamy.model.attribute.constraint.ForeignKey; Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/attribute/RepresentationAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/attribute/RepresentationAdapter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/attribute/RepresentationAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,91 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/26 - * - * 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.internal.model.attribute; - -import org.apache.commons.lang.ClassUtils; - -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; - -/** - * 代表カラムかどうかを表すアラプタ。 - * - * <p>例えばEMP, DEPTテーブルがあり、EMPがDEPTを外部キー参照しているとする。 - * EMPのINSERT文用データを入力中に、ユーザは「DEPT_ID = 3 の部署」ではなく「経理部」をイメージするのが自然である。 - * SQL的には 3 を出力すべきだが、入力・選択は「経理部」で行いたい。このように、DEPTテーブルを代表するカラムを代表カラムと呼ぶ。</p> - * - * @author daisuke - */ - @ Adapter(AdapterType.MODEL) -public class RepresentationAdapter { - - private Boolean representation; - - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final RepresentationAdapter other = (RepresentationAdapter) obj; - if (representation == null) { - if (other.representation != null) { - return false; - } - } else if (!representation.equals(other.representation)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((representation == null) ? 0 : representation.hashCode()); - return result; - } - - /** - * 代表カラムかどうかを取得する。 - * @return 代表カラムかどうか - */ - public Boolean isRepresentation() { - return representation; - } - - /** - * 代表カラムかどうかを設定する。 - * @param representation 代表カラムかどうか - */ - public void setRepresentation(Boolean representation) { - this.representation = representation; - } - - @Override - public String toString() { - return ClassUtils.getShortClassName(this, "null") + "[" + representation + "]"; - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/PrecisionedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,141 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/20 - * - * 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.internal.model.datatype.adapter; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; -import org.jiemamy.model.datatype.DataTypeAdapter; - -/** - * 精度とスケールを持つDataType用のアダプタ。 - * - * @author daisuke - */ - @ Adapter(AdapterType.MODEL) -public class PrecisionedDataTypeAdapter implements DataTypeAdapter { - - /** 精度 */ - private Integer precision; - - /** スケール */ - private Integer scale; - - - public void copy(DataTypeAdapter src) { - Validate.notNull(src); - if (src instanceof PrecisionedDataTypeAdapter) { - precision = ((PrecisionedDataTypeAdapter) src).precision; - scale = ((PrecisionedDataTypeAdapter) src).scale; - } else { - throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() - + ")"); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final PrecisionedDataTypeAdapter other = (PrecisionedDataTypeAdapter) obj; - if (precision == null) { - if (other.precision != null) { - return false; - } - } else if (!precision.equals(other.precision)) { - return false; - } - if (scale == null) { - if (other.scale != null) { - return false; - } - } else if (!scale.equals(other.scale)) { - return false; - } - return true; - } - - /** - * 精度を取得する。 - * - * @return 精度 - */ - public Integer getPrecision() { - return precision; - } - - /** - * スケールを取得する。 - * - * @return スケール - */ - public Integer getScale() { - return scale; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((precision == null) ? 0 : precision.hashCode()); - result = prime * result + ((scale == null) ? 0 : scale.hashCode()); - return result; - } - - /** - * 精度を設定する。 - * - * @param precision 精度 - */ - public void setPrecision(Integer precision) { - this.precision = precision; - } - - /** - * スケールを設定する。 - * - * @param scale スケール - */ - public void setScale(Integer scale) { - this.scale = scale; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (precision != null) { - sb.append("("); - sb.append(precision); - if (scale != null) { - sb.append(", "); - sb.append(scale); - } - sb.append(")"); - } - return sb.toString(); - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SerialDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SerialDataTypeAdapter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SerialDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,99 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/10 - * - * 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.internal.model.datatype.adapter; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; -import org.jiemamy.model.datatype.DataTypeAdapter; - -/** - * シリアル(通し番号)型であることを表すアダプタ。 - * - * @author daisuke - */ - @ Adapter(AdapterType.MODEL) -public class SerialDataTypeAdapter implements DataTypeAdapter { - - /** シリアル(通し番号)型であるどうか */ - private Boolean serial; - - - public void copy(DataTypeAdapter src) { - // nothing to do - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final SerialDataTypeAdapter other = (SerialDataTypeAdapter) obj; - if (serial == null) { - if (other.serial != null) { - return false; - } - } else if (!serial.equals(other.serial)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((serial == null) ? 0 : serial.hashCode()); - return result; - } - - /** - * シリアル(通し番号)型であるどうかを取得する。 - * - * @return シリアル(通し番号)型であれば{@code true} - */ - public Boolean isSerial() { - return serial; - } - - /** - * シリアル(通し番号)型であるどうかを設定する。 - * - * @param serial シリアル(通し番号)型であるどうか - */ - public void setSerial(Boolean serial) { - this.serial = serial; - } - - @Override - public String toString() { - if (serial != null && serial) { - return "SERIAL"; - } - return StringUtils.EMPTY; - } - -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SizedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SizedDataTypeAdapter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/SizedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,106 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/20 - * - * 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.internal.model.datatype.adapter; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; -import org.jiemamy.model.datatype.DataTypeAdapter; - -/** - * サイズを持つDataType用のアダプタ。 - * @author daisuke - */ - @ Adapter(AdapterType.MODEL) -public class SizedDataTypeAdapter implements DataTypeAdapter { - - /** サイズ */ - private Integer size; - - - public void copy(DataTypeAdapter src) { - Validate.notNull(src); - if (src instanceof SizedDataTypeAdapter) { - size = ((SizedDataTypeAdapter) src).size; - } else { - throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() - + ")"); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final SizedDataTypeAdapter other = (SizedDataTypeAdapter) obj; - if (size == null) { - if (other.size != null) { - return false; - } - } else if (!size.equals(other.size)) { - return false; - } - return true; - } - - /** - * サイズを取得する。 - * - * @return サイズ - */ - public Integer getSize() { - return size; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((size == null) ? 0 : size.hashCode()); - return result; - } - - /** - * サイズを設定する。 - * - * @param size サイズ - */ - public void setSize(Integer size) { - this.size = size; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (size != null) { - sb.append("("); - sb.append(size); - sb.append(")"); - } - return sb.toString(); - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/TimezonedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,107 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/20 - * - * 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.internal.model.datatype.adapter; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; -import org.jiemamy.model.datatype.DataTypeAdapter; - -/** - * タイムゾーン管理の有無を持つDataType用のアダプタ。 - * - * @author daisuke - */ - @ Adapter(AdapterType.MODEL) -public class TimezonedDataTypeAdapter implements DataTypeAdapter { - - /** タイムゾーンを管理するかどうか */ - private Boolean withTimezone; - - - public void copy(DataTypeAdapter src) { - Validate.notNull(src); - if (src instanceof TimezonedDataTypeAdapter) { - withTimezone = ((TimezonedDataTypeAdapter) src).withTimezone; - } else { - throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() - + ")"); - } - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final TimezonedDataTypeAdapter other = (TimezonedDataTypeAdapter) obj; - if (withTimezone == null) { - if (other.withTimezone != null) { - return false; - } - } else if (!withTimezone.equals(other.withTimezone)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((withTimezone == null) ? 0 : withTimezone.hashCode()); - return result; - } - - /** - * タイムゾーンを管理するかどうかを取得する。 - * - * @return 精度 - */ - public Boolean isWithTimezone() { - return withTimezone; - } - - /** - * タイムゾーンを管理するかどうかを設定する。 - * - * @param withTimezone 精度 - */ - public void setWithTimezone(Boolean withTimezone) { - this.withTimezone = withTimezone; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - if (withTimezone != null) { - sb.append(" "); - sb.append(withTimezone ? "WITH" : "WITHOUT"); - sb.append(" TIMEZONE"); - } - return sb.toString(); - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/package-info.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/package-info.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/adapter/package-info.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,9 +0,0 @@ -/** - * Jiemamyモデルの「データ型」に対する基本的なアダプタの実装を提供するパッケージ。 - * - * <p>このパッケージは、データ型に対する拡張を行うアダプタクラスを含む。</p> - * - * @author daisuke - */ -package org.jiemamy.internal.model.datatype.adapter; - Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,768 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * 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.internal.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.jiemamy.Artemis; -import org.jiemamy.InstanceProvider; -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.internal.model.attribute.RepresentationAdapter; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKey; -import org.jiemamy.model.attribute.constraint.NotNullConstraint; -import org.jiemamy.model.attribute.constraint.PrimaryKey; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.model.index.IndexColumnModel; -import org.jiemamy.model.index.IndexModel; -import org.jiemamy.model.index.IndexColumnModel.SortOrder; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.Disablable; -import org.jiemamy.utils.builder.DataTypeBuilderImpl; -import org.jiemamy.utils.model.ColumnUtil; -import org.jiemamy.utils.model.DataSetUtil; -import org.jiemamy.utils.model.ForeignKeyUtil; -import org.jiemamy.utils.model.KeyConstraintUtil; -import org.jiemamy.utils.model.RecordUtil; - -/** - * Jiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class CoreTestModelBuilder implements TestModelBuilder { - - private static final String ID_1 = "1"; - - private static final String ID_2 = "2"; - - private static final String ID_3 = "3"; - - private static final String ID_4 = "4"; - - private static final String DIALECT_CLASS_NAME = "org.jiemamy.dialect.mysql.MySqlDialect"; - - // ---- basics - - /** UUID生成戦略 */ - public final UuidStrategy uuid; - - /** 生成方針 */ - public final Instruction instruction; - - /** 生成するモデルのインスタンス空間 */ - public final Jiemamy jiemamy; - - /** 生成に使用するファクトリ */ - public final JiemamyFactory factory; - - /** 生成したモデル */ - public final RootModel rootModel; - - // ---- models - - /** 生成したモデル */ - public DomainModel domainId; - - /** 生成したモデル */ - public DomainModel domainName; - - // dept - - /** 生成したモデル */ - public TableModel tableDept; - - /** 生成したモデル */ - public ColumnModel deptId; - - /** 生成したモデル */ - public ColumnModel deptDeptNo; - - /** 生成したモデル */ - public ColumnModel deptDeptName; - - /** 生成したモデル */ - public ColumnModel deptLoc; - - /** 生成したモデル */ - public PrimaryKey deptPk; - - // emp - - /** 生成したモデル */ - public TableModel tableEmp; - - /** 生成したモデル */ - public ColumnModel empId; - - /** 生成したモデル */ - public ColumnModel empEmpNo; - - /** 生成したモデル */ - - public ColumnModel empEmpName; - - /** 生成したモデル */ - public ColumnModel empMgrId; - - /** 生成したモデル */ - public ColumnModel empHiredate; - - /** 生成したモデル */ - public ColumnModel empSal; - - /** 生成したモデル */ - public ColumnModel empDeptId; - - /** 生成したモデル */ - public PrimaryKey empPk; - - // highSal - - /** 生成したモデル */ - public ViewModel viewHighSal; - - // fk - - /** 生成したモデル */ - public ForeignKey fkEmpEmp; - - /** 生成したモデル */ - public ForeignKey fkEmpDept; - - private IndexModel empNameIndex; - - - /** - * インスタンスを生成する。 - */ - public CoreTestModelBuilder() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param dialectProvider SQL方言プロバイダ - */ - public CoreTestModelBuilder(InstanceProvider<Dialect> dialectProvider) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance(new Artemis(), dialectProvider)); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public CoreTestModelBuilder(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - this.uuid = uuid; - this.instruction = instruction; - this.jiemamy = jiemamy; - factory = jiemamy.getFactory(); - - if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { - throw new IllegalArgumentException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - public Jiemamy build() { - rootModel.setDialectClassName(DIALECT_CLASS_NAME); - rootModel.setBeginScript("BEGIN;"); - rootModel.setEndScript("COMMIT;"); - rootModel.setDescription("Jiemamyテストモデル1"); - rootModel.setSchemaName("FOO"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - - return jiemamy; - } - - /** - * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 - * - * @return Jiemamyオブジェクト - */ - public Jiemamy getJiemamy() { - return jiemamy; - } - - /** - * データセットを生成する。 - */ - protected void createDataSets() { - if (instruction.supressUseDataSet) { - return; - } - // データセットの生成・追加(1) - DataSetModel dataSetEn = factory.newModel(DataSetModel.class, uuid.get("b73100b5-2d70-4b48-a825-311eacb63b2f")); - dataSetEn.setName("データ群en"); - DataSetUtil.setRecord(dataSetEn, tableDept, createDataSetEnDept()); - DataSetUtil.setRecord(dataSetEn, tableEmp, createDataSetEnEmp()); - rootModel.getDataSets().add(dataSetEn); - - // データセットの生成・追加(2) - DataSetModel dataSetJa = factory.newModel(DataSetModel.class, uuid.get("91246ed4-1ef3-440e-bf12-40fa4439a71b")); - dataSetJa.setName("データ群ja"); - DataSetUtil.setRecord(dataSetJa, tableDept, createDataSetJaDept()); - DataSetUtil.setRecord(dataSetJa, tableEmp, createDataSetJaEmp()); - rootModel.getDataSets().add(dataSetJa); - } - - /** - * ドメインを生成する。 - */ - protected void createDomains() { - if (instruction.supressUseDomain) { - return; - } - - domainId = factory.newModel(DomainModel.class, uuid.get("2eec0aa0-5122-4eb7-833d-9f5a43e7abe9")); - domainId.setName("ID"); - domainId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); - domainId.setNotNullConstraint(notNull); - ColumnCheckConstraint check = - factory.newModel(ColumnCheckConstraint.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); - check.setName("hoge"); - check.setExpression("VALUE > 0"); - domainId.setCheckConstraint(check); - domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true); - rootModel.getDomains().add(domainId); - - domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7")); - domainName.setName("NAME"); - domainName.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(32).build()); - domainName.setDescription("人名用の型です。"); - rootModel.getDomains().add(domainName); - } - - /** - * エンティティを生成する。 - */ - protected void createEntities() { - createTableDept(); - rootModel.getEntities().add(tableDept); - createTableEmp(); - rootModel.getEntities().add(tableEmp); - createViewHighSal(); - rootModel.getEntities().add(viewHighSal); - } - - /** - * 外部キーを生成する。 - */ - protected void createForeignKeys() { - if (instruction.supressUseForeignKey) { - return; - } - - int pkIndex = tableEmp.getAttributes().indexOf(empPk); - - fkEmpEmp = factory.newModel(ForeignKey.class, uuid.get("e43d3c43-33c8-4b02-aa42-83f2d868cfe6")); - fkEmpEmp.setName("emp_mgr_id_fkey"); - KeyConstraintUtil.addKeyColumn(fkEmpEmp, empMgrId); - ForeignKeyUtil.addReferenceColumn(fkEmpEmp, empId); - fkEmpEmp.setOnDelete(ReferentialAction.SET_NULL); - Deferrability deferrability = - factory.newModel(Deferrability.class, uuid.get("9af096ba-8841-41ba-9dd4-02628b800bf0")); - deferrability.setDeferrable(true); - deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); - fkEmpEmp.setDeferrability(deferrability); - tableEmp.getAttributes().add(pkIndex + 1, fkEmpEmp); - - fkEmpDept = factory.newModel(ForeignKey.class, uuid.get("e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed")); - fkEmpDept.setName("emp_dept_id_fkey"); - KeyConstraintUtil.addKeyColumn(fkEmpDept, empDeptId); - ForeignKeyUtil.addReferenceColumn(fkEmpDept, deptId); - tableEmp.getAttributes().add(pkIndex + 2, fkEmpDept); - } - - private List<RecordModel> createDataSetEnDept() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("176bfb08-99cb-4c76-bf8e-6979e0c7afb9")); - RecordUtil.addValue(record, deptId, ID_1); - RecordUtil.addValue(record, deptDeptNo, "10"); - RecordUtil.addValue(record, deptDeptName, "ACCOUNTING"); - RecordUtil.addValue(record, deptLoc, "NEW YORK"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3971430b-ef1d-4e5a-b996-f2acfa7536c0")); - RecordUtil.addValue(record, deptId, ID_2); - RecordUtil.addValue(record, deptDeptNo, "20"); - RecordUtil.addValue(record, deptDeptName, "RESEARCH"); - RecordUtil.addValue(record, deptLoc, "DALLAS"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0591cc1e-45a6-4598-b85a-20fae51b7991")); - RecordUtil.addValue(record, deptId, ID_3); - RecordUtil.addValue(record, deptDeptNo, "30"); - RecordUtil.addValue(record, deptDeptName, "SALES"); - RecordUtil.addValue(record, deptLoc, "CHICAGO"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("ac275955-4710-484a-b694-f7acc6ded08f")); - RecordUtil.addValue(record, deptId, ID_4); - RecordUtil.addValue(record, deptDeptNo, "40"); - RecordUtil.addValue(record, deptDeptName, "OPERATIONS"); - RecordUtil.addValue(record, deptLoc, "BOSTON"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnEmp() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("6ce22d69-bd75-4822-946f-a51221fd45eb")); - RecordUtil.addValue(record, empId, ID_1); - RecordUtil.addValue(record, empEmpNo, "10"); - RecordUtil.addValue(record, empEmpName, "SMITH"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2003-02-01"); - RecordUtil.addValue(record, empSal, "40"); - RecordUtil.addValue(record, empDeptId, ID_3); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); - RecordUtil.addValue(record, empId, ID_2); - RecordUtil.addValue(record, empEmpNo, "20"); - RecordUtil.addValue(record, empEmpName, "ALLEN"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2000-03-04"); - RecordUtil.addValue(record, empSal, "50"); - RecordUtil.addValue(record, empDeptId, ID_4); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); - RecordUtil.addValue(record, empId, ID_3); - RecordUtil.addValue(record, empEmpNo, "30"); - RecordUtil.addValue(record, empEmpName, "WARD"); -// RecordUtil.addValue(record, empMgrId, null); - RecordUtil.addValue(record, empHiredate, "1993-12-05"); - RecordUtil.addValue(record, empSal, "60"); - RecordUtil.addValue(record, empDeptId, ID_4); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); - RecordUtil.addValue(record, empId, ID_4); - RecordUtil.addValue(record, empEmpNo, "40"); - RecordUtil.addValue(record, empEmpName, "JONES"); - RecordUtil.addValue(record, empMgrId, ID_2); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "36"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("4206acce-b31f-4c2e-8682-4796254a4dca")); - RecordUtil.addValue(record, empId, "5"); - RecordUtil.addValue(record, empEmpNo, "50"); - RecordUtil.addValue(record, empEmpName, "MARTIN"); - RecordUtil.addValue(record, empMgrId, ID_1); - RecordUtil.addValue(record, empHiredate, "2002-05-30"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, ID_3); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("6748ce0e-462d-44df-a536-18f14a3c2643")); - RecordUtil.addValue(record, empId, "6"); - RecordUtil.addValue(record, empEmpNo, "60"); - RecordUtil.addValue(record, empEmpName, "BLAKE"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f8564bdf-f61c-4711-b606-69aed74324a6")); - RecordUtil.addValue(record, empId, "7"); - RecordUtil.addValue(record, empEmpNo, "70"); - RecordUtil.addValue(record, empEmpName, "CLARK"); - RecordUtil.addValue(record, empMgrId, ID_1); - RecordUtil.addValue(record, empHiredate, "2004-09-01"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, ID_1); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("dd1cc8e1-7562-4539-86d8-5390d043325a")); - RecordUtil.addValue(record, empId, "8"); - RecordUtil.addValue(record, empEmpNo, "80"); - RecordUtil.addValue(record, empEmpName, "SCOTT"); - RecordUtil.addValue(record, empMgrId, ID_4); - RecordUtil.addValue(record, empHiredate, "2008-03-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaDept() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("61671217-d61c-4f42-9985-4f6b2c970171")); - RecordUtil.addValue(record, deptId, ID_1); - RecordUtil.addValue(record, deptDeptNo, "10"); - RecordUtil.addValue(record, deptDeptName, "経理部"); - RecordUtil.addValue(record, deptLoc, "広島"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("171d019e-163f-42f6-82dc-15340798fdf4")); - RecordUtil.addValue(record, deptId, ID_2); - RecordUtil.addValue(record, deptDeptNo, "20"); - RecordUtil.addValue(record, deptDeptName, "研究開発部"); - RecordUtil.addValue(record, deptLoc, "京都"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("838344e6-093d-4202-aaca-bacf1a7ff376")); - RecordUtil.addValue(record, deptId, ID_3); - RecordUtil.addValue(record, deptDeptNo, "30"); - RecordUtil.addValue(record, deptDeptName, "営業部"); - RecordUtil.addValue(record, deptLoc, "東京"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2f29bb19-0a20-4251-8052-568194e6101c")); - RecordUtil.addValue(record, deptId, ID_4); - RecordUtil.addValue(record, deptDeptNo, "40"); - RecordUtil.addValue(record, deptDeptName, "経営本部"); - // locは指定せず、特定しない状態 - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaEmp() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("9365e670-1eff-4a23-90bd-f794b9742b10")); - RecordUtil.addValue(record, empId, ID_1); - RecordUtil.addValue(record, empEmpNo, "10"); - RecordUtil.addValue(record, empEmpName, "鈴木 茂"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2003-02-01"); - RecordUtil.addValue(record, empSal, "40"); - RecordUtil.addValue(record, empDeptId, ID_3); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); - RecordUtil.addValue(record, empId, ID_2); - RecordUtil.addValue(record, empEmpNo, "20"); - RecordUtil.addValue(record, empEmpName, "内海 透"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2000-03-04"); - RecordUtil.addValue(record, empSal, "50"); - RecordUtil.addValue(record, empDeptId, ID_4); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); - RecordUtil.addValue(record, empId, ID_3); - RecordUtil.addValue(record, empEmpNo, "30"); - RecordUtil.addValue(record, empEmpName, "村瀬 武彦"); -// RecordUtil.addValue(record, empMgrId, null); - RecordUtil.addValue(record, empHiredate, "1993-12-05"); - RecordUtil.addValue(record, empSal, "60"); - RecordUtil.addValue(record, empDeptId, ID_4); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); - RecordUtil.addValue(record, empId, ID_4); - RecordUtil.addValue(record, empEmpNo, "40"); - RecordUtil.addValue(record, empEmpName, "近藤 美樹"); - RecordUtil.addValue(record, empMgrId, ID_2); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "36"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("c10562ee-4ab9-40a5-8a21-83f331df5c85")); - RecordUtil.addValue(record, empId, "5"); - RecordUtil.addValue(record, empEmpNo, "50"); - RecordUtil.addValue(record, empEmpName, "榊 美子"); - RecordUtil.addValue(record, empMgrId, ID_1); - RecordUtil.addValue(record, empHiredate, "2002-05-30"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, ID_3); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("29c9a655-f4ed-4753-aea6-1e21cb28f891")); - RecordUtil.addValue(record, empId, "6"); - RecordUtil.addValue(record, empEmpNo, "60"); - RecordUtil.addValue(record, empEmpName, "三浦 佑"); - RecordUtil.addValue(record, empMgrId, ID_3); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("b65b9b12-bb68-4845-a514-a57f0bd57616")); - RecordUtil.addValue(record, empId, "7"); - RecordUtil.addValue(record, empEmpNo, "70"); - RecordUtil.addValue(record, empEmpName, "前島 孝幸"); - RecordUtil.addValue(record, empMgrId, ID_1); - RecordUtil.addValue(record, empHiredate, "2004-09-01"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, ID_1); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0eb27151-323a-4679-bde4-0b01f561139f")); - RecordUtil.addValue(record, empId, "8"); - RecordUtil.addValue(record, empEmpNo, "80"); - RecordUtil.addValue(record, empEmpName, "島崎 由比"); - RecordUtil.addValue(record, empMgrId, ID_4); - RecordUtil.addValue(record, empHiredate, "2008-03-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, ID_2); - result.add(record); - - return result; - } - - private void createTableDept() { - tableDept = factory.newModel(TableModel.class, uuid.get("d7489ed6-0add-443d-95cf-234376eb0455")); - tableDept.setName("T_DEPT"); - tableDept.setBeginScript("/* test begin script */"); - tableDept.setDescription("部署マスタです。"); - - deptId = factory.newModel(ColumnModel.class, uuid.get("c7ed225d-92a6-4cc2-90de-60531804464e")); - deptId.setName("ID"); - if (instruction.supressUseDomain) { - deptId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(deptId, domainId); - } - deptId.setLogicalName("部署ID"); - deptPk = factory.newModel(PrimaryKey.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); - deptPk.setName("dept_pkey"); - deptPk.getKeyColumns().add(factory.newReference(deptId)); - deptId.setPrimaryKey(deptPk); - tableDept.getAttributes().add(deptId); - - deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); - deptDeptNo.setName("DEPT_NO"); - deptDeptNo.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - deptDeptNo.setLogicalName("部署番号"); - tableDept.getAttributes().add(deptDeptNo); - - deptDeptName = factory.newModel(ColumnModel.class, uuid.get("1fcd63d3-974e-4d2e-a0d8-3b9c233104d9")); - deptDeptName.setName("DEPT_NAME"); - deptDeptName.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(20).build()); - deptDeptName.setLogicalName("部署名"); - deptDeptName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableDept.getAttributes().add(deptDeptName); - - deptLoc = factory.newModel(ColumnModel.class, uuid.get("7bf79e76-07b8-43b6-a993-b8ef374a31f5")); - deptLoc.setName("LOC"); - deptLoc.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(20).build()); - deptLoc.setLogicalName("ロケーション"); - deptLoc.setDefaultValue("secret"); - tableDept.getAttributes().add(deptLoc); - - Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); - columnNotNullMap.put(deptDeptNo.getId(), uuid.get("cc709f63-a886-4207-a316-58ad7f279e10")); - columnNotNullMap.put(deptDeptName.getId(), uuid.get("fab2f883-0489-4661-bd57-f04286188eef")); - - for (ColumnModel columnModel : Arrays.asList(deptDeptNo, deptDeptName)) { - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableEmp() { - tableEmp = factory.newModel(TableModel.class, uuid.get("9f522e56-809c-45fd-8416-39201014218b")); - tableEmp.setName("T_EMP"); - tableEmp.setLogicalName("従業員"); - tableEmp.setBeginScript("/* test end script */"); - tableEmp.setDescription("従業員マスタです。"); - - empId = factory.newModel(ColumnModel.class, uuid.get("44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e")); - empId.setName("ID"); - if (instruction.supressUseDomain) { - empId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(empId, domainId); - } - empId.setLogicalName("従業員ID"); - tableEmp.getAttributes().add(empId); - - empEmpNo = factory.newModel(ColumnModel.class, uuid.get("248a429b-2159-4ebd-a791-eee42a059374")); - empEmpNo.setName("EMP_NO"); - empEmpNo.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - empEmpNo.setLogicalName("従業員番号"); - NotNullConstraint notNullEmpEmpNo = - factory.newModel(NotNullConstraint.class, uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); - notNullEmpEmpNo.getAdapter(Disablable.class).setDisabled(true); - empEmpNo.setNotNullConstraint(notNullEmpEmpNo); - tableEmp.getAttributes().add(empEmpNo); - - empEmpName = factory.newModel(ColumnModel.class, uuid.get("0e51b6df-43ab-408c-90ef-de13c6aab881")); - empEmpName.setName("EMP_NAME"); - if (instruction.supressUseDomain) { - empEmpName.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(32).build()); - } else { - ColumnUtil.setDataType(empEmpName, domainName); - } - empEmpName.setLogicalName("従業員名"); - empEmpName.setDefaultValue("no name"); - empEmpName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableEmp.getAttributes().add(empEmpName); - - empMgrId = factory.newModel(ColumnModel.class, uuid.get("3d21a85a-72de-41b3-99dd-f4cb94e58d84")); - empMgrId.setName("MGR_ID"); - empMgrId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - empMgrId.setLogicalName("上司ID"); - tableEmp.getAttributes().add(empMgrId); - - empHiredate = factory.newModel(ColumnModel.class, uuid.get("f0b57eed-98ab-4c21-9855-218c592814dc")); - empHiredate.setName("HIREDATE"); - empHiredate.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.DATE).build()); - tableEmp.getAttributes().add(empHiredate); - - empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); - empSal.setName("SAL"); - empSal.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.NUMERIC).setPrecision(7).setScale(2) - .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()); - tableEmp.getAttributes().add(empDeptId); - - empPk = factory.newModel(PrimaryKey.class, uuid.get("6145e6a0-9ff7-4033-999d-99d80392a48f")); - empPk.setName("emp_pkey"); - empPk.getKeyColumns().add(factory.newReference(empId)); - tableEmp.getAttributes().add(empPk); - - Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); - columnNotNullMap.put(empEmpName.getId(), uuid.get("41f178b9-2cb5-4dad-a6c0-48df2d5b1300")); - columnNotNullMap.put(empHiredate.getId(), uuid.get("2d66fd73-8d6b-41d8-b6b8-daec7d6c0c53")); - columnNotNullMap.put(empSal.getId(), uuid.get("a446779a-4fb6-4a0f-8262-22daae856e85")); - columnNotNullMap.put(empDeptId.getId(), uuid.get("b9a0fdce-a965-4118-ae71-5dc7150f6d4e")); - - for (ColumnModel columnModel : Arrays.asList(empEmpName, empHiredate, empSal, empDeptId)) { - NotNullConstraint notNull = - factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); - columnModel.setNotNullConstraint(notNull); - } - - empNameIndex = factory.newModel(IndexModel.class, uuid.get("9abc9e01-4cdb-42fe-a495-93b56af35a1d")); - empNameIndex.setName("IDX_EMP_NAME"); - IndexColumnModel indexColumnModel = - factory.newModel(IndexColumnModel.class, uuid.get("52d2b6aa-fff7-4c33-af13-f4d0b63e8e58")); - indexColumnModel.setColumnRef(factory.newReference(empEmpName)); - indexColumnModel.setSortOrder(SortOrder.DESC); - empNameIndex.getIndexColumns().add(indexColumnModel); - tableEmp.getIndexes().add(empNameIndex); - } - - private void createViewHighSal() { - viewHighSal = factory.newModel(ViewModel.class, uuid.get("516f7961-cb7b-48e2-990b-7fb0c750c3a4")); - viewHighSal.setName("V_HIGH_SAL_EMP"); - viewHighSal.setDefinition("SELECT * FROM T_EMP WHERE SAL > 2000;"); - viewHighSal.setLogicalName("高給取り"); - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,824 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * 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.internal.test; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.internal.model.attribute.RepresentationAdapter; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKey; -import org.jiemamy.model.attribute.constraint.NotNullConstraint; -import org.jiemamy.model.attribute.constraint.PrimaryKey; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.utils.builder.DataTypeBuilderImpl; -import org.jiemamy.utils.model.ColumnUtil; -import org.jiemamy.utils.model.DataSetUtil; -import org.jiemamy.utils.model.ForeignKeyUtil; -import org.jiemamy.utils.model.KeyConstraintUtil; -import org.jiemamy.utils.model.RecordUtil; - -/** - * Jiemamyテストモデル1(ORDERテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class CoreTestModelBuilder2 implements TestModelBuilder { - - private static final String ID_1 = "1"; - - private static final String ID_2 = "2"; - - private static final String ID_3 = "3"; - - private static final String ID_4 = "4"; - - private static final String DIALECT_CLASS_NAME = "org.jiemamy.dialect.mysql.MySqlDialect"; - - // ---- basics - - /** UUID生成戦略 */ - public final UuidStrategy uuid; - - /** 生成方針 */ - public final Instruction instruction; - - /** 生成するモデルのインスタンス空間 */ - public final Jiemamy jiemamy; - - /** 生成に使用するファクトリ */ - public final JiemamyFactory factory; - - /** 生成したモデル */ - public final RootModel rootModel; - - // ---- models - - /** 生成したモデル */ - public DomainModel idDomain; - - /** 生成したモデル */ - public DomainModel nameDomain; - - // item - - /** 生成したモデル */ - public TableModel tableItem; - - /** 生成したモデル */ - public ColumnModel itemId; - - /** 生成したモデル */ - public ColumnModel itemName; - - /** 生成したモデル */ - public ColumnModel itemPrice; - - /** 生成したモデル */ - public PrimaryKey itemPk; - - // user - - /** 生成したモデル */ - public TableModel tableUser; - - /** 生成したモデル */ - public ColumnModel userId; - - /** 生成したモデル */ - public ColumnModel userName; - - /** 生成したモデル */ - public PrimaryKey userPk; - - // order - - /** 生成したモデル */ - public TableModel tableOrder; - - /** 生成したモデル */ - public ColumnModel orderId; - - /** 生成したモデル */ - public ColumnModel orderUserId; - - /** 生成したモデル */ - public ColumnModel orderDate; - - /** 生成したモデル */ - public PrimaryKey orderPk; - - // detail - - /** 生成したモデル */ - public TableModel tableDetail; - - /** 生成したモデル */ - public ColumnModel detailId; - - /** 生成したモデル */ - public ColumnModel detailOrderId; - - /** 生成したモデル */ - public ColumnModel detailItemId; - - /** 生成したモデル */ - public ColumnModel detailQuantity; - - /** 生成したモデル */ - public PrimaryKey detailPk; - - // fk - - /** 生成したモデル */ - public ForeignKey fkDetailItem; - - /** 生成したモデル */ - public ForeignKey fkDetailOrder; - - /** 生成したモデル */ - public ForeignKey fkOrderUser; - - - /** - * インスタンスを生成する。 - */ - public CoreTestModelBuilder2() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder2(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public CoreTestModelBuilder2(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - this.uuid = uuid; - this.instruction = instruction; - this.jiemamy = jiemamy; - factory = jiemamy.getFactory(); - - if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { - throw new IllegalArgumentException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public CoreTestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - public Jiemamy build() { - rootModel.setDialectClassName(DIALECT_CLASS_NAME); - rootModel.setBeginScript("BEGIN;"); - rootModel.setEndScript("COMMIT;"); - rootModel.setDescription("Jiemamyテストモデル2"); - rootModel.setSchemaName("BAR"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - - return jiemamy; - } - - /** - * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 - * - * @return Jiemamyオブジェクト - */ - public Jiemamy getJiemamy() { - return jiemamy; - } - - /** - * データセットを生成する。 - */ - protected void createDataSets() { - if (instruction.supressUseDataSet) { - return; - } - // データセットの生成・追加(1) - DataSetModel dataSetEn = factory.newModel(DataSetModel.class); - dataSetEn.setName("データ群en"); - DataSetUtil.setRecord(dataSetEn, tableItem, createDataSetEnItem()); - DataSetUtil.setRecord(dataSetEn, tableUser, createDataSetEnUser()); - DataSetUtil.setRecord(dataSetEn, tableOrder, createDataSetEnOrder()); - DataSetUtil.setRecord(dataSetEn, tableDetail, createDataSetEnDetail()); - rootModel.getDataSets().add(dataSetEn); - - // データセットの生成・追加(2) - DataSetModel dataSetJa = factory.newModel(DataSetModel.class); - dataSetJa.setName("データ群ja"); - DataSetUtil.setRecord(dataSetJa, tableItem, createDataSetJaItem()); - DataSetUtil.setRecord(dataSetJa, tableUser, createDataSetJaUser()); - DataSetUtil.setRecord(dataSetJa, tableOrder, createDataSetJaOrder()); - DataSetUtil.setRecord(dataSetJa, tableDetail, createDataSetJaDetail()); - rootModel.getDataSets().add(dataSetJa); - } - - /** - * ドメインを生成する。 - */ - protected void createDomains() { - if (instruction.supressUseDomain) { - return; - } - - idDomain = factory.newModel(DomainModel.class, uuid.get("9a3ba23c-b328-4c70-a32d-3e4be3ee3f08")); - idDomain.setName("ID"); - idDomain.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - idDomain.setNotNullConstraint(factory.newModel(NotNullConstraint.class)); - idDomain.getAdapter(SerialDataTypeAdapter.class).setSerial(true); - rootModel.getDomains().add(idDomain); - - nameDomain = factory.newModel(DomainModel.class, uuid.get("e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193")); - nameDomain.setName("NAME"); - nameDomain.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(32).build()); - nameDomain.setDescription("人名用の型です。"); - rootModel.getDomains().add(nameDomain); - } - - /** - * エンティティを生成する。 - */ - protected void createEntities() { - createTableItem(); - rootModel.getEntities().add(tableItem); - createTableUser(); - rootModel.getEntities().add(tableUser); - createTableOrder(); - rootModel.getEntities().add(tableOrder); - createTableDetail(); - rootModel.getEntities().add(tableDetail); - } - - /** - * 外部キーを生成する。 - */ - protected void createForeignKeys() { - if (instruction.supressUseForeignKey) { - return; - } - - fkDetailItem = factory.newModel(ForeignKey.class, uuid.get("df781ad0-112a-4db7-a76c-4395b15600b2")); - KeyConstraintUtil.addKeyColumn(fkDetailItem, detailItemId); - ForeignKeyUtil.addReferenceColumn(fkDetailItem, itemId); - fkDetailItem.setOnDelete(ReferentialAction.RESTRICT); - tableDetail.getAttributes().add(fkDetailItem); - - fkDetailOrder = factory.newModel(ForeignKey.class, uuid.get("fca97c96-db8c-44b4-8427-6207601eaa94")); - KeyConstraintUtil.addKeyColumn(fkDetailOrder, detailOrderId); - ForeignKeyUtil.addReferenceColumn(fkDetailOrder, orderId); - fkDetailOrder.setOnDelete(ReferentialAction.CASCADE); - Deferrability deferrability = - factory.newModel(Deferrability.class, uuid.get("1726a29c-0984-4042-b2c3-c601671892a1")); - deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); - fkDetailOrder.setDeferrability(deferrability); - tableDetail.getAttributes().add(fkDetailOrder); - - fkOrderUser = factory.newModel(ForeignKey.class, uuid.get("325b5aa9-821e-4791-aac5-2d3eb64f9392")); - KeyConstraintUtil.addKeyColumn(fkOrderUser, orderUserId); - ForeignKeyUtil.addReferenceColumn(fkOrderUser, userId); - fkOrderUser.setOnDelete(ReferentialAction.RESTRICT); - Deferrability deferrability2 = - factory.newModel(Deferrability.class, uuid.get("899f5889-ac30-44dc-b078-35a1b1edc8f0")); - deferrability2.setInitiallyCheckTime(InitiallyCheckTime.IMMEDIATE); - fkOrderUser.setDeferrability(deferrability2); - tableOrder.getAttributes().add(fkOrderUser); - } - - private List<RecordModel> createDataSetEnDetail() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("546244f5-afa2-4e7e-bde0-5a811ced77af")); - RecordUtil.addValue(record, detailId, ID_1); - RecordUtil.addValue(record, detailOrderId, ID_1); - RecordUtil.addValue(record, detailItemId, ID_1); - RecordUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("943fda94-a3f2-4c47-b19f-9e8655b47362")); - RecordUtil.addValue(record, detailId, ID_2); - RecordUtil.addValue(record, detailOrderId, ID_1); - RecordUtil.addValue(record, detailItemId, ID_4); - RecordUtil.addValue(record, detailQuantity, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d11db81a-2d53-42b4-9f10-17f98f1f7081")); - RecordUtil.addValue(record, detailId, ID_3); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_2); - RecordUtil.addValue(record, detailQuantity, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("0aa0dd6f-5656-4994-abfe-05f05aec7275")); - RecordUtil.addValue(record, detailId, ID_4); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_3); - RecordUtil.addValue(record, detailQuantity, "6"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("4b9be90a-886f-47d8-89f0-da03d7ad419e")); - RecordUtil.addValue(record, detailId, "5"); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_4); - RecordUtil.addValue(record, detailQuantity, "12"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("23665133-7f4e-4f65-af7c-0de1b655f7c9")); - RecordUtil.addValue(record, detailId, "6"); - RecordUtil.addValue(record, detailOrderId, ID_3); - RecordUtil.addValue(record, detailItemId, ID_2); - RecordUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnItem() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("7162b83a-1815-4b08-8c11-8e6400c05a9e")); - RecordUtil.addValue(record, itemId, ID_1); - RecordUtil.addValue(record, itemName, "DIAMOND"); - RecordUtil.addValue(record, itemPrice, "100000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("a3d6480d-9088-49d8-a500-872262a635d5")); - RecordUtil.addValue(record, itemId, ID_2); - RecordUtil.addValue(record, itemName, "EMERALD"); - RecordUtil.addValue(record, itemPrice, "75000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("bf4556ff-fb81-472c-945d-14067945e7c2")); - RecordUtil.addValue(record, itemId, ID_3); - RecordUtil.addValue(record, itemName, "RUBY"); - RecordUtil.addValue(record, itemPrice, "30000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("fc30dd3e-495d-4f7c-9237-dd9f84c14eb5")); - RecordUtil.addValue(record, itemId, ID_4); - RecordUtil.addValue(record, itemName, "SAPPHIRE"); - RecordUtil.addValue(record, itemPrice, "10000"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnOrder() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("bf813157-8690-4eb3-9168-cd4906f13f27")); - RecordUtil.addValue(record, orderId, ID_1); - RecordUtil.addValue(record, orderUserId, ID_2); - RecordUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("645b241d-a6ba-4821-8682-448f59949b3e")); - RecordUtil.addValue(record, orderId, ID_2); - RecordUtil.addValue(record, orderUserId, ID_3); - RecordUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("654ceb1b-b6eb-406d-8eac-aa07c7c41e62")); - RecordUtil.addValue(record, orderId, ID_3); - RecordUtil.addValue(record, orderUserId, ID_2); - RecordUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetEnUser() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("c60fb4ba-e3d6-415e-a22c-20fbaf4e04e6")); - RecordUtil.addValue(record, userId, ID_1); - RecordUtil.addValue(record, userName, "SMITH"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("83d5c923-7c61-4393-8185-ac95042f6476")); - RecordUtil.addValue(record, userId, ID_2); - RecordUtil.addValue(record, userName, "ALLEN"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2ddd8857-3fca-4020-bb23-49d0126af6fc")); - RecordUtil.addValue(record, userId, ID_3); - RecordUtil.addValue(record, userName, "WARD"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2b9aeb38-97de-439e-b96b-40a1c82d249e")); - RecordUtil.addValue(record, userId, ID_4); - RecordUtil.addValue(record, userName, "JONES"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("a6242c24a-b415-4a93-867b-16a68c2fe884")); - RecordUtil.addValue(record, userId, "5"); - RecordUtil.addValue(record, userName, "MARTIN"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3b9d3161-a613-4090-a095-708433b23491")); - RecordUtil.addValue(record, userId, "6"); - RecordUtil.addValue(record, userName, "BLAKE"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("aeaad211-b62e-4a35-b410-d107753469e9")); - RecordUtil.addValue(record, userId, "7"); - RecordUtil.addValue(record, userName, "CLARK"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("8c7c220d-ff7f-48c4-9ce7-1395ed1816fa")); - RecordUtil.addValue(record, userId, "8"); - RecordUtil.addValue(record, userName, "SCOTT"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaDetail() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("5a6604ce-6ed2-4542-b009-2a3264b0946a")); - RecordUtil.addValue(record, detailId, ID_1); - RecordUtil.addValue(record, detailOrderId, ID_1); - RecordUtil.addValue(record, detailItemId, ID_1); - RecordUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("db883c9c-b7d3-44f4-88ba-d9753eeae58a")); - RecordUtil.addValue(record, detailId, ID_2); - RecordUtil.addValue(record, detailOrderId, ID_1); - RecordUtil.addValue(record, detailItemId, ID_4); - RecordUtil.addValue(record, detailQuantity, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("04e92727-483c-42ad-b671-c1e4661c1844")); - RecordUtil.addValue(record, detailId, ID_3); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_2); - RecordUtil.addValue(record, detailQuantity, "2"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f5147476-8bc6-4656-9d0c-fd883a24a18c")); - RecordUtil.addValue(record, detailId, ID_4); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_3); - RecordUtil.addValue(record, detailQuantity, "6"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d849f188-9940-4ecc-98a8-868dac5b3b4e")); - RecordUtil.addValue(record, detailId, "5"); - RecordUtil.addValue(record, detailOrderId, ID_2); - RecordUtil.addValue(record, detailItemId, ID_4); - RecordUtil.addValue(record, detailQuantity, "12"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2abef8cc-bfb7-4565-ba4e-afca3bf98811")); - RecordUtil.addValue(record, detailId, "6"); - RecordUtil.addValue(record, detailOrderId, ID_3); - RecordUtil.addValue(record, detailItemId, ID_2); - RecordUtil.addValue(record, detailQuantity, "1"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaItem() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("5fd803d4-5a05-496b-813e-6399955a79bb")); - RecordUtil.addValue(record, itemId, ID_1); - RecordUtil.addValue(record, itemName, "ダイヤモンド"); - RecordUtil.addValue(record, itemPrice, "100000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d59e426b-e5ed-433e-8d5a-e748dc75af60")); - RecordUtil.addValue(record, itemId, ID_2); - RecordUtil.addValue(record, itemName, "エメラルド"); - RecordUtil.addValue(record, itemPrice, "75000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("59e0a554-162a-4c48-b13d-1dda7fc936e0")); - RecordUtil.addValue(record, itemId, ID_3); - RecordUtil.addValue(record, itemName, "ルビー"); - RecordUtil.addValue(record, itemPrice, "30000"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("1c86858f-1e8b-4fc5-807f-f0548e1811e4")); - RecordUtil.addValue(record, itemId, ID_4); - RecordUtil.addValue(record, itemName, "サファイヤ"); - RecordUtil.addValue(record, itemPrice, "10000"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaOrder() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("2bdf3969-c2e5-4e3e-a939-2907ca3a5b6a")); - RecordUtil.addValue(record, orderId, ID_1); - RecordUtil.addValue(record, orderUserId, ID_2); - RecordUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("cca67c6f-a3b2-4b43-a466-be72ccd66e8f")); - RecordUtil.addValue(record, orderId, ID_2); - RecordUtil.addValue(record, orderUserId, ID_3); - RecordUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("1f74ab8a-3191-464b-89c3-f4f3dddb8ce8")); - RecordUtil.addValue(record, orderId, ID_2); - RecordUtil.addValue(record, orderUserId, ID_2); - RecordUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); - result.add(record); - - return result; - } - - private List<RecordModel> createDataSetJaUser() { - List<RecordModel> result = new ArrayList<RecordModel>(); - - RecordModel record = factory.newModel(RecordModel.class, uuid.get("25288a67-b4c7-4296-8113-835afeb15c9d")); - RecordUtil.addValue(record, userId, ID_1); - RecordUtil.addValue(record, userName, "鈴木 茂"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); - RecordUtil.addValue(record, userId, ID_2); - RecordUtil.addValue(record, userName, "内海 透"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); - RecordUtil.addValue(record, userId, ID_3); - RecordUtil.addValue(record, userName, "村瀬 武彦"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); - RecordUtil.addValue(record, userId, ID_4); - RecordUtil.addValue(record, userName, "近藤 美樹"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("2f09b9fe-78fd-4f8a-abf2-f077040f45f2")); - RecordUtil.addValue(record, userId, "5"); - RecordUtil.addValue(record, userName, "榊 美子"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("e3431be3-462c-4419-a2a0-e821597490cc")); - RecordUtil.addValue(record, userId, "6"); - RecordUtil.addValue(record, userName, "三浦 佑"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("c50a3e24-dd00-4969-aae9-69cf9be7f035")); - RecordUtil.addValue(record, userId, "7"); - RecordUtil.addValue(record, userName, "前島 孝幸"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("890bf55f-8bfd-420c-a9df-801da73bc46d")); - RecordUtil.addValue(record, userId, "8"); - RecordUtil.addValue(record, userName, "島崎 由比"); - result.add(record); - - return result; - } - - private void createTableDetail() { - tableDetail = factory.newModel(TableModel.class, uuid.get("5705ed1a-f329-4f21-9956-94caf4863fba")); - tableDetail.setName("T_DETAIL"); - tableDetail.setLogicalName("明細"); - tableDetail.setDescription("明細テーブルです。"); - - detailId = factory.newModel(ColumnModel.class, uuid.get("d3571020-4e1b-4158-958d-b5460fa6c32c")); - detailId.setName("ID"); - if (instruction.supressUseDomain) { - detailId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(detailId, idDomain); - } - detailId.setLogicalName("ユーザID"); - tableDetail.getAttributes().add(detailId); - - detailOrderId = factory.newModel(ColumnModel.class, uuid.get("a28c64c6-b379-41a4-9563-b774f5bce165")); - detailOrderId.setName("ORDER_ID"); - detailOrderId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - tableDetail.getAttributes().add(detailOrderId); - - detailItemId = factory.newModel(ColumnModel.class, uuid.get("b4d50786-3b3e-4557-baa3-b739159f0530")); - detailItemId.setName("ITEM_ID"); - detailItemId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - tableDetail.getAttributes().add(detailItemId); - - detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); - detailQuantity.setName("QUANTITY"); - detailQuantity.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - tableDetail.getAttributes().add(detailQuantity); - - detailPk = factory.newModel(PrimaryKey.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); - detailPk.getKeyColumns().add(factory.newReference(detailId)); - tableDetail.getAttributes().add(detailPk); - - for (ColumnModel columnModel : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableItem() { - tableItem = factory.newModel(TableModel.class, uuid.get("7ecf5ba1-e80c-472c-b19b-bef2649d7974")); - tableItem.setName("T_ITEM"); - tableItem.setBeginScript("/* test begin script of T_ITEM */"); - tableItem.setEndScript("/* test end script of T_ITEM */"); - tableItem.setDescription("商品マスタです。"); - - itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); - itemId.setName("ID"); - if (instruction.supressUseDomain) { - itemId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(itemId, idDomain); - } - itemId.setLogicalName("商品ID"); - tableItem.getAttributes().add(itemId); - - itemName = factory.newModel(ColumnModel.class, uuid.get("5c9b38e1-2cc9-45f9-ad3f-20b02471cc40")); - itemName.setName("NAME"); - itemName.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(20).build()); - itemName.setLogicalName("商品名"); - itemName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableItem.getAttributes().add(itemName); - - itemPrice = factory.newModel(ColumnModel.class, uuid.get("7a0cabe3-d382-4e5d-845b-dadd1b637a5f")); - itemPrice.setName("PRICE"); - itemPrice.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(20).build()); - itemPrice.setLogicalName("価格"); - tableItem.getAttributes().add(itemPrice); - - itemPk = factory.newModel(PrimaryKey.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); - itemPk.getKeyColumns().add(factory.newReference(itemId)); - tableItem.getAttributes().add(itemPk); - - for (ColumnModel columnModel : Arrays.asList(itemName, itemPrice)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableOrder() { - tableOrder = factory.newModel(TableModel.class, uuid.get("cefee0d9-d23f-441b-986a-66660354ec74")); - tableOrder.setName("T_ORDER"); - tableOrder.setLogicalName("注文"); - tableOrder.setDescription("注文テーブルです。"); - - orderId = factory.newModel(ColumnModel.class, uuid.get("b647212a-4d8f-4d18-88e4-5397e54ebe67")); - orderId.setName("ID"); - if (instruction.supressUseDomain) { - orderId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(orderId, idDomain); - } - orderId.setLogicalName("注文ID"); - tableOrder.getAttributes().add(orderId); - - orderUserId = factory.newModel(ColumnModel.class, uuid.get("db7a2f62-9658-406a-9dc1-8b90ae2da47c")); - orderUserId.setName("USER_ID"); - orderUserId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - orderUserId.setLogicalName("オーダーユーザID"); - tableOrder.getAttributes().add(orderUserId); - - orderDate = factory.newModel(ColumnModel.class, uuid.get("4ce761b0-137b-4105-ad2a-2efcba5e6bc4")); - orderDate.setName("ORDER_DATE"); - orderDate.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.TIMESTAMP).build()); - tableOrder.getAttributes().add(orderDate); - - orderPk = factory.newModel(PrimaryKey.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); - orderPk.getKeyColumns().add(factory.newReference(orderId)); - tableOrder.getAttributes().add(orderPk); - - for (ColumnModel columnModel : Arrays.asList(orderUserId, orderDate)) { - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - columnModel.setNotNullConstraint(notNull); - } - } - - private void createTableUser() { - tableUser = factory.newModel(TableModel.class, uuid.get("0802ef7b-b2da-4fc4-8104-0c99a1e472d5")); - tableUser.setName("T_USER"); - tableUser.setLogicalName("ユーザ"); - tableUser.setDescription("ユーザマスタです。"); - - userId = factory.newModel(ColumnModel.class, uuid.get("6b022a79-45a6-4be4-9d3d-cfb27042a08e")); - userId.setName("ID"); - if (instruction.supressUseDomain) { - userId.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.INTEGER).build()); - } else { - ColumnUtil.setDataType(userId, idDomain); - } - userId.setLogicalName("ユーザID"); - tableUser.getAttributes().add(userId); - - userName = factory.newModel(ColumnModel.class, uuid.get("dacc68d2-fe32-4f4b-8082-9d55232ba7da")); - userName.setName("NAME"); - if (instruction.supressUseDomain) { - userName.setDataType(new DataTypeBuilderImpl(factory, DataTypeCategory.VARCHAR).setSize(32).build()); - } else { - ColumnUtil.setDataType(userName, nameDomain); - } - userName.setLogicalName("ユーザ名"); - userName.setDefaultValue("no name"); - userName.getAdapter(RepresentationAdapter.class).setRepresentation(true); - tableUser.getAttributes().add(userName); - - userPk = factory.newModel(PrimaryKey.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); - userPk.getKeyColumns().add(factory.newReference(userId)); - tableUser.getAttributes().add(userPk); - - NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); - userName.setNotNullConstraint(notNull); - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/Instruction.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/Instruction.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/Instruction.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,37 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/23 - * - * 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.internal.test; - -/** - * {@link CoreTestModelBuilder}等に対する指示クラス。 - * - * @author daisuke - */ -public class Instruction { - - /** ドメインを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseDomain; - - /** 外部キーを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseForeignKey; - - /** DataSetを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ - public boolean supressUseDataSet; - -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,50 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/10 - * - * 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.internal.test; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; - -import org.jiemamy.Jiemamy; -import org.jiemamy.dialect.Dialect; -import org.jiemamy.exception.UnexpectedConditionError; - -/** - * 相対パスから強引にDialectを取得するための、テスト用インスタンス取得戦略クラス。 - * @author daisuke - */ -public class ReflectionDialectProvider extends Jiemamy.DefaultInstanceProvider<Dialect> { - - /** - * インスタンスを生成する。 - */ - public ReflectionDialectProvider() { - try { - classLoader = new URLClassLoader(new URL[] { - new File("../jiemamy-dialect-mysql/target/classes").toURL(), - new File("../jiemamy-dialect-postgresql/target/classes").toURL(), - new File("../jiemamy-dialect-sql99/target/classes").toURL() - }); - } catch (MalformedURLException e) { - throw new UnexpectedConditionError("spell miss?", e); - } - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,36 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * 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.internal.test; - -import org.jiemamy.Jiemamy; - -/** - * テストモデルを構築するテスト用ロジックのインターフェイス。 - * - * @author daisuke - */ -public interface TestModelBuilder { - - /** - * モデルをビルドする。 - * - * @return ビルドしたモデルのJiemamyコンテキスト - */ - Jiemamy build(); -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,78 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * 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.internal.test; - -import java.io.InputStream; - -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.CharEncoding; - -import org.jiemamy.Artemis; -import org.jiemamy.Jiemamy; -import org.jiemamy.exception.UnexpectedConditionError; - -/** - * テスト用モデルの構築を行うビルダを供給するプロバイダ。 - * - * @author daisuke - */ -public enum TestModelBuilders { - - /** */ - EMP_DEPT(new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml")), - - /** */ - ORDER(new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml")); - - private static String getXml(String path) { - InputStream in = TestModelBuilders.class.getResourceAsStream(path); - String xml; - try { - xml = IOUtils.toString(in, CharEncoding.UTF_8); - } catch (Exception e) { - throw new UnexpectedConditionError("リソースにアクセスできない", e); - } - return xml; - } - - private static Jiemamy newJiemamy() { - return Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - } - - - private final TestModelBuilder builder; - - private final String xml; - - - TestModelBuilders(TestModelBuilder builder, String xml) { - this.builder = builder; - this.xml = xml; - } - - /** - * TODO for daisuke - * - * @return - */ - public Jiemamy getBuiltModel() { - return builder.build(); - } - -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelEntry.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelEntry.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/TestModelEntry.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,77 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * 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.internal.test; - -import org.jiemamy.Jiemamy; - -/** - * テストモデルのエントリを表すクラス。 - * - * @author daisuke - */ -public class TestModelEntry { - - /** テストモデル名 */ - private final String name; - - /** ビルダ */ - private final TestModelBuilder builder; - - private final String xml; - - - /** - * インスタンスを生成する。 - * - * @param name テストモデル名 - * @param builder ビルダ - * @param xml このモデルを表現するXML - */ - public TestModelEntry(String name, TestModelBuilder builder, String xml) { - this.name = name; - this.builder = builder; - this.xml = xml; - } - - /** - * ビルダを取得する。 - * @return ビルダ - */ - public Jiemamy getBuiltModel() { - return builder.build(); - } - - /** - * テストモデル名を取得する。 - * - * @return テストモデル名 - */ - public String getName() { - return name; - } - - /** - * このモデルを表現するXMLを取得する。 - * @return このモデルを表現するXML - */ - public String getXml() { - return xml; - } - -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/UuidStrategy.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/UuidStrategy.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/UuidStrategy.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,49 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/23 - * - * 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.internal.test; - -import java.util.UUID; - -/** - * テストモデルを組み立てる際、モデルIDをランダム生成するか、毎回固定で生成するかを決める戦略クラス。 - * - * @author daisuke - */ -public enum UuidStrategy { - - /** 固定 */ - FIXED { - - @Override - UUID get(String name) { - return UUID.fromString(name); - } - }, - - /** 都度生成 */ - GENERATE { - - @Override - UUID get(String name) { - return UUID.randomUUID(); - } - }; - - abstract UUID get(String name); -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/AnnotationUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/AnnotationUtil.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/AnnotationUtil.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,60 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/04 - * - * 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.utils; - -import java.lang.annotation.Annotation; - -import org.apache.commons.lang.Validate; - -/** - * アノテーションを処理するユーティリティクラス。 - * - * @author daisuke - */ -public class AnnotationUtil { - - /** - * target自身の型、及びそのインターフェイスのいずれかが持つアノテーションを取得する。 - * - * @param <T> アノテーションの型 - * @param target 調査対象オブジェクト - * @param annotationClass アノテーションの型 - * @return 取得したアノテーション - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <T extends Annotation>T getTypeAnnotation(Object target, Class<T> annotationClass) { - Validate.notNull(target); - Validate.notNull(annotationClass); - - Annotation classAnnotation = target.getClass().getAnnotation(annotationClass); - if (classAnnotation != null) { - return annotationClass.cast(classAnnotation); - } - for (Class<?> interf : target.getClass().getInterfaces()) { - Annotation interfaceAnnotation = interf.getAnnotation(annotationClass); - if (interfaceAnnotation != null) { - return annotationClass.cast(interfaceAnnotation); - } - } - return null; - } - - private AnnotationUtil() { - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/CollectionsUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/CollectionsUtil.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/CollectionsUtil.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,182 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/09 - * - * 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.utils; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import org.apache.commons.lang.Validate; - -/** - * Java5のgenericsや可変長を活用する、コレクションのためのユーティリティ。 - * - * <p>org.seasar.framework.util.tiger.CollectionsUtil のサブセット</p> - * - * @author daisuke - */ -public class CollectionsUtil { - - /** - * {@link ArrayList}の新しいインスタンスを生成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList() - */ - public static <E>ArrayList<E> newArrayList() { - return new ArrayList<E>(); - } - - /** - * {@link ArrayList}の新しいインスタンスを生成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @param c 要素がリストに配置されるコレクション - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList(Collection) - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <E>ArrayList<E> newArrayList(final Collection<? extends E> c) { - Validate.notNull(c); - return new ArrayList<E>(c); - } - - /** - * {@link ArrayList}の新しいインスタンスを生成する。 - * - * @param <E> {@link ArrayList}の要素型 - * @param initialCapacity リストの初期容量 - * @return {@link ArrayList}の新しいインスタンス - * @see ArrayList#ArrayList(int) - */ - public static <E>ArrayList<E> newArrayList(final int initialCapacity) { - return new ArrayList<E>(initialCapacity); - } - - /** - * {@link HashMap}の新しいインスタンスを生成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap() - */ - public static <K, V>HashMap<K, V> newHashMap() { - return new HashMap<K, V>(); - } - - /** - * {@link HashMap}の新しいインスタンスを生成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param initialCapacity 初期容量 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int) - */ - public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity) { - return new HashMap<K, V>(initialCapacity); - } - - /** - * {@link HashMap}の新しいインスタンスを生成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param initialCapacity 初期容量 - * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int, float) - */ - public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity, final float loadFactor) { - return new HashMap<K, V>(initialCapacity, loadFactor); - } - - /** - * {@link HashMap}の新しいインスタンスを生成する。 - * - * @param <K> {@link HashMap}のキーの型 - * @param <V> {@link HashMap}の値の型 - * @param m 作成されるマップに配置されるマップ - * @return {@link HashMap}の新しいインスタンス - * @see HashMap#HashMap(int, float) - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <K, V>HashMap<K, V> newHashMap(final Map<? extends K, ? extends V> m) { - Validate.notNull(m); - return new HashMap<K, V>(m); - } - - /** - * {@link HashSet}の新しいインスタンスを生成する。 - * - * @param <E> {@link HashSet}の要素型 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet() { - return new HashSet<E>(); - } - - /** - * {@link HashSet}の新しいインスタンスを生成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param c 要素がセットに配置されるコレクション - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public static <E>HashSet<E> newHashSet(final Collection<? extends E> c) { - Validate.notNull(c); - return new HashSet<E>(c); - } - - /** - * {@link HashSet}の新しいインスタンスを生成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param initialCapacity 初期容量 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet(final int initialCapacity) { - return new HashSet<E>(initialCapacity); - } - - /** - * {@link HashSet}の新しいインスタンスを生成する。 - * - * @param <E> {@link HashSet}の要素型 - * @param initialCapacity 初期容量 - * @param loadFactor 負荷係数 - * @return {@link HashSet}の新しいインスタンス - * @see HashSet#HashSet() - */ - public static <E>HashSet<E> newHashSet(final int initialCapacity, final float loadFactor) { - return new HashSet<E>(initialCapacity, loadFactor); - } - - private CollectionsUtil() { - } - -} Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilderImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilderImpl.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilderImpl.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -24,11 +24,11 @@ import org.jiemamy.dialect.BuiltinDataTypeMold; import org.jiemamy.dialect.Dialect; import org.jiemamy.dialect.generic.GenericDialect; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.RootModel; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.utils.model.RootModelUtil; /** Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -43,7 +43,6 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.composer.Importer; import org.jiemamy.dialect.Dialect; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.internal.test.ReflectionDialectProvider; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; @@ -51,6 +50,7 @@ import org.jiemamy.model.attribute.constraint.ForeignKey; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.utils.CollectionsUtil; Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/datatype/BuiltinDataTypeImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/datatype/BuiltinDataTypeImplTest.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/model/datatype/BuiltinDataTypeImplTest.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -31,9 +31,9 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.dialect.BuiltinDataTypeMold; import org.jiemamy.dialect.internal.BuiltinDataTypeMoldImpl; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; /** * {@link BuiltinDataType}のテストクラス。 Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelBuilder2Test.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelBuilder2Test.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelBuilder2Test.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,177 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/23 - * - * 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.internal.test; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.io.File; -import java.util.Collection; -import java.util.UUID; - -import com.thoughtworks.xstream.XStream; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.ClassUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.Artemis; -import org.jiemamy.Jiemamy; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.utils.model.RootModelUtil; -import org.jiemamy.utils.model.TableUtil; -import org.jiemamy.validator.AllValidator; -import org.jiemamy.validator.Problem; - -/** - * {@link CoreTestModelBuilder2}のテストクラス。 - * - * <p>コピペで組み立ててたら整合性が不安になったので作ってみたw</p> - * - * @author daisuke - */ -public class TestModelBuilder2Test { - - private static Logger logger = LoggerFactory.getLogger(TestModelBuilder2Test.class); - - private CoreTestModelBuilder2 mb; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); - mb = new CoreTestModelBuilder2(jiemamy); - mb.build(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - mb = null; - } - - /** - * 意図通りのモデル生成を確認する。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_意図通りのモデル生成を確認する() throws Exception { - Jiemamy jiemamy = mb.getJiemamy(); - - RootModel rootModel = jiemamy.getFactory().getRootModel(); - assertThat(rootModel, is(notNullValue())); - assertThat(rootModel.getEntities().size(), is(4)); - - TableModel user = RootModelUtil.getEntity(rootModel, TableModel.class, "T_USER"); - assertThat(user, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(user), is(mb.userPk)); - assertThat(TableUtil.getPrimaryKey(user).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(user).getKeyColumns().get(0).getReferenceId(), is(mb.userId.getId())); - assertThat(TableUtil.getColumns(user).size(), is(2)); - assertThat(TableUtil.getColumn(user, "ID"), is(mb.userId)); - assertThat(TableUtil.getColumn(user, "NAME"), is(mb.userName)); - assertThat(TableUtil.getForeignKeys(user).size(), is(0)); - - TableModel item = RootModelUtil.getEntity(rootModel, TableModel.class, "T_ITEM"); - assertThat(item, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(item), is(mb.itemPk)); - assertThat(TableUtil.getPrimaryKey(item).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(item).getKeyColumns().get(0).getReferenceId(), is(mb.itemId.getId())); - assertThat(TableUtil.getColumns(item).size(), is(3)); - assertThat(TableUtil.getColumn(item, "ID"), is(mb.itemId)); - assertThat(TableUtil.getColumn(item, "NAME"), is(mb.itemName)); - assertThat(TableUtil.getColumn(item, "PRICE"), is(mb.itemPrice)); - assertThat(TableUtil.getForeignKeys(item).size(), is(0)); - - TableModel order = RootModelUtil.getEntity(rootModel, TableModel.class, "T_ORDER"); - assertThat(order, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(order), is(mb.orderPk)); - assertThat(TableUtil.getPrimaryKey(order).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(order).getKeyColumns().get(0).getReferenceId(), is(mb.orderId.getId())); - assertThat(TableUtil.getColumns(order).size(), is(3)); - assertThat(TableUtil.getColumn(order, "ID"), is(mb.orderId)); - assertThat(TableUtil.getColumn(order, "ORDER_DATE"), is(mb.orderDate)); - assertThat(TableUtil.getColumn(order, "USER_ID"), is(mb.orderUserId)); - assertThat(TableUtil.getForeignKeys(order).size(), is(1)); - - TableModel detail = RootModelUtil.getEntity(rootModel, TableModel.class, "T_DETAIL"); - assertThat(detail, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(detail), is(mb.detailPk)); - assertThat(TableUtil.getPrimaryKey(detail).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(detail).getKeyColumns().get(0).getReferenceId(), is(mb.detailId.getId())); - assertThat(TableUtil.getColumns(detail).size(), is(4)); - assertThat(TableUtil.getColumn(detail, "ID"), is(mb.detailId)); - assertThat(TableUtil.getColumn(detail, "ORDER_ID"), is(mb.detailOrderId)); - assertThat(TableUtil.getColumn(detail, "ITEM_ID"), is(mb.detailItemId)); - assertThat(TableUtil.getColumn(detail, "QUANTITY"), is(mb.detailQuantity)); - assertThat(TableUtil.getForeignKeys(detail).size(), is(2)); - } - - /** - * 全ての標準バリデータを問題なく通過すること。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_全ての標準バリデータを問題なく通過すること() throws Exception { - Jiemamy jiemamy = mb.getJiemamy(); - RootModel rootModel = jiemamy.getFactory().getRootModel(); - - Collection<Problem> problems = new AllValidator().validate(rootModel); - for (Problem problem : problems) { - logger.error(problem.getMessage()); - } - assertThat(problems.size(), is(0)); - } - - /** - * TODO for daisuke - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void xstream() throws Exception { - Jiemamy jiemamy = mb.getJiemamy(); - RootModel rootModel = jiemamy.getFactory().getRootModel(); - XStream xstream = new XStream(); - xstream.addImmutableType(UUID.class); - xstream.useAttributeFor("id", UUID.class); - String xml = xstream.toXML(rootModel); - FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this.getClass()) + ".xml"), - xml, CharEncoding.UTF_8); - } - -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,55 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/04/04 - * - * 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.internal.test; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * {@link TestModelBuilder}で生成したモデルを使用してテストを行う為の基底クラス。 - * - * @author daisuke - */ -public abstract class TestModelsTestBase { - - private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); - - - /** - * テストを行う。 - * - * @param entry テストモデルのエントリ - * @throws Exception 例外が発生した場合 - */ - public abstract void doTest(TestModelBuilders entry) throws Exception; - - /** - * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testAllEntries() throws Exception { - for (TestModelBuilders entry : TestModelBuilders.values()) { - logger.info("==== Test Model: " + entry.name()); - doTest(entry); - } - } -} Modified: artemis/trunk/jiemamy-dialect-mysql/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-mysql/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -47,6 +47,17 @@ <version>1.1</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -46,9 +46,9 @@ import org.jiemamy.dialect.internal.impl.DefaultDialectInitializer; import org.jiemamy.dialect.internal.impl.DefaultMoldManager; import org.jiemamy.dialect.mysql.adapter.Unsigned; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.validator.CompositeValidator; import org.jiemamy.validator.Validator; Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -28,7 +28,6 @@ import org.jiemamy.dialect.internal.impl.DefaultTokenResolver; import org.jiemamy.dialect.mysql.adapter.StorageEngine; import org.jiemamy.dialect.mysql.adapter.StorageEngineType; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.internal.model.sql.Identifier; import org.jiemamy.internal.model.sql.Keyword; import org.jiemamy.internal.model.sql.Literal; @@ -39,6 +38,7 @@ import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.LiteralType; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; Modified: artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -40,13 +40,13 @@ import org.jiemamy.dialect.mysql.adapter.StandardEngine; import org.jiemamy.dialect.mysql.adapter.StorageEngine; import org.jiemamy.dialect.mysql.adapter.StorageEngineImpl; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.internal.test.CoreTestModelBuilder; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.PrimaryKey; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.sql.SqlStatement; import org.jiemamy.utils.model.RootModelUtil; Modified: artemis/trunk/jiemamy-dialect-oracle/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-oracle/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-oracle/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -47,6 +47,17 @@ <version>1.1</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> Modified: artemis/trunk/jiemamy-dialect-postgresql/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-postgresql/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -47,6 +47,17 @@ <version>1.1</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> Modified: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -44,9 +44,9 @@ import org.jiemamy.dialect.internal.SqlEmitter; import org.jiemamy.dialect.internal.impl.DefaultDialectInitializer; import org.jiemamy.dialect.internal.impl.DefaultMoldManager; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.validator.CompositeValidator; import org.jiemamy.validator.Validator; Modified: artemis/trunk/jiemamy-dialect-sql99/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-sql99/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-sql99/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -47,6 +47,17 @@ <version>1.1</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-core</artifactId> Modified: artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -46,9 +46,9 @@ import org.jiemamy.dialect.internal.BuiltinDataTypeMoldImpl; import org.jiemamy.dialect.internal.impl.DefaultDialectInitializer; import org.jiemamy.dialect.internal.impl.DefaultMoldManager; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.validator.CompositeValidator; import org.jiemamy.validator.Validator; Modified: artemis/trunk/jiemamy-view/pom.xml =================================================================== --- artemis/trunk/jiemamy-view/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-view/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -49,6 +49,12 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>jiemamy-spec-core</artifactId> <version>0.2-SNAPSHOT</version> </dependency> Deleted: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java 2009-04-06 11:24:58 UTC (rev 3140) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -1,207 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/22 - * - * 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.internal.test; - -import java.util.List; - -import org.jiemamy.Jiemamy; -import org.jiemamy.OfficialSpecs; -import org.jiemamy.model.ConnectionProfile; -import org.jiemamy.model.DiagramPresentationModel; -import org.jiemamy.model.DiagramPresentations; -import org.jiemamy.model.NodeProfile; -import org.jiemamy.model.connection.ConnectionAdapter; -import org.jiemamy.model.geometory.JmColor; -import org.jiemamy.model.geometory.JmPoint; -import org.jiemamy.model.geometory.JmRectangle; -import org.jiemamy.model.node.NodeAdapter; -import org.jiemamy.model.node.StickyModel; - -/** - * Jiemamy VIEW仕様範囲を含めたJiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 - * - * @author daisuke - */ -public class ViewTestModelBuilder extends CoreTestModelBuilder { - - /** StickyModel for Test */ - protected StickyModel sticky; - - private static final int OFFSET = 50; - - - /** - * インスタンスを生成する。 - */ - public ViewTestModelBuilder() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - */ - public ViewTestModelBuilder(Instruction instruction) { - super(instruction); - } - - /** - * インスタンスを生成する。 - * - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { - super(instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(Jiemamy jiemamy) { - super(jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - */ - public ViewTestModelBuilder(UuidStrategy uuid) { - super(uuid); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction) { - super(uuid, instruction); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param instruction 設定オブジェクト - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { - super(uuid, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid UUID生成ストラテジ - * @param jiemamy コンテキスト - */ - public ViewTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { - super(uuid, jiemamy); - } - - @Override - public Jiemamy build() { - Jiemamy jiemamy = super.build(); - createPresentations(); - - return jiemamy; - } - - @Override - protected void createEntities() { - super.createEntities(); - if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { - sticky = factory.newModel(StickyModel.class, uuid.get("43beb884-2562-4480-8030-bb797f701783")); - sticky.setContents("メモーー"); - } - } - - private void createPresentations() { - if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { - DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); - - // ダイアグラム表現の生成・追加(1) - DiagramPresentationModel presentation1 = - factory.newModel(DiagramPresentationModel.class, uuid.get("1deca0e8-6153-47ad-abe8-ac764f768d96")); - presentation1.setName("全部表示する"); - - NodeProfile empProfile = - factory.newModel(NodeProfile.class, uuid.get("aa7caa23-7958-4bd0-a356-8f09d4b74f08")); - presentation1.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empProfile); - empProfile.setBoundary(new JmRectangle(360, 60)); - - NodeProfile deptProfile = - factory.newModel(NodeProfile.class, uuid.get("eb6506ef-4a25-4296-b6d7-c08741f19d5a")); - presentation1.getNodeProfiles().put(tableDept.getAdapter(NodeAdapter.class), deptProfile); - deptProfile.setBoundary(new JmRectangle(60, 60)); - - NodeProfile viewProfile = - factory.newModel(NodeProfile.class, uuid.get("2387bfd0-7106-44ad-a34e-24231bbea6d5")); - presentation1.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewProfile); - viewProfile.setBoundary(new JmRectangle(60, 270)); - - NodeProfile stickyProfile = - factory.newModel(NodeProfile.class, uuid.get("2689d193-52a1-4fd4-a14c-9857274518c5")); - presentation1.getNodeProfiles().put(sticky, stickyProfile); - stickyProfile.setBoundary(new JmRectangle(360, 270)); - stickyProfile.setColor(new JmColor(10, 11, 12)); - - ConnectionProfile connectionProfile1 = - factory.newModel(ConnectionProfile.class, uuid.get("366b547f-a2a6-42b2-a3a4-38745436c425")); - List<JmPoint> bendpoints = connectionProfile1.getBendpoints(); - NodeProfile nodeProf = presentation1.getNodeProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); - JmRectangle boundary = nodeProf.getBoundary(); - bendpoints.add(0, new JmPoint(Math.max(boundary.x - OFFSET, 0), boundary.y)); - bendpoints.add(1, new JmPoint(boundary.x, Math.max(boundary.y - OFFSET, 0))); - presentation1.getConnectionProfiles().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), connectionProfile1); - - ConnectionProfile connectionProfile2 = - factory.newModel(ConnectionProfile.class, uuid.get("e5b3d709-2aea-4e26-a90c-b8f438d2da9d")); - presentation1.getConnectionProfiles() - .put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile2); - diagramPresentations.add(presentation1); - - // ダイアグラム表現の生成・追加(2) - DiagramPresentationModel presentation2 = - factory.newModel(DiagramPresentationModel.class, uuid.get("53c7cdb7-1512-46c7-8ee3-aadec6007896")); - presentation2.setName("一部表示する"); - - NodeProfile nodeProfile1 = - factory.newModel(NodeProfile.class, uuid.get("d71ff015-101c-4669-8745-312d1da34efe")); - presentation2.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), nodeProfile1); - nodeProfile1.setBoundary(new JmRectangle(60, 60)); - - NodeProfile nodeProfile2 = - factory.newModel(NodeProfile.class, uuid.get("2df7718f-d71e-4dbf-8327-e0ad36f03d5d")); - presentation2.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), nodeProfile2); - nodeProfile2.setBoundary(new JmRectangle(270, 270)); - - ConnectionProfile connectionProfile = - factory.newModel(ConnectionProfile.class, uuid.get("b615f111-5143-4b12-bfdb-9a06806a9ace")); - presentation2.getConnectionProfiles().put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile); - diagramPresentations.add(presentation2); - } - } -} Modified: charon/jiemamy-jpa-importer/trunk/pom.xml =================================================================== --- charon/jiemamy-jpa-importer/trunk/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ charon/jiemamy-jpa-importer/trunk/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -60,6 +60,12 @@ <version>0.94</version> <scope>test</scope> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-test-helper</artifactId> + <version>0.0.1-SNAPSHOT</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> @@ -85,6 +91,11 @@ <artifactId>geronimo-jpa_3.0_spec</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> <dependency> <groupId>${project.groupId}</groupId> <artifactId>jiemamy-spec-core</artifactId> Modified: eros/maven-jiemamy-plugin/trunk/pom.xml =================================================================== --- eros/maven-jiemamy-plugin/trunk/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ eros/maven-jiemamy-plugin/trunk/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -39,6 +39,12 @@ <build> <plugins> <plugin> + <artifactId>maven-resources-plugin</artifactId> + <configuration> + <encoding>UTF-8</encoding> + </configuration> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.5</source> Modified: eros/maven-jiemamy-plugin/trunk/src/test/resources/sample.xml =================================================================== --- eros/maven-jiemamy-plugin/trunk/src/test/resources/sample.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ eros/maven-jiemamy-plugin/trunk/src/test/resources/sample.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -11,7 +11,7 @@ <dataType> <typeCategory>INTEGER</typeCategory> <typeName>INTEGER</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter"> <serial>true</serial> </adapter> </dataType> @@ -27,7 +27,7 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>32</size> </adapter> </dataType> @@ -64,7 +64,7 @@ <dataType ref="62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7"/> <defaultValue>no name</defaultValue> <notNull id="41f178b9-2cb5-4dad-a6c0-48df2d5b1300"/> - <adapter class="org.jiemamy.internal.model.attribute.RepresentationAdapter"> + <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> <representation>true</representation> </adapter> </column> @@ -89,7 +89,7 @@ <dataType> <typeCategory>NUMERIC</typeCategory> <typeName>NUMERIC</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter"> <precision>7</precision> <scale>2</scale> </adapter> @@ -179,12 +179,12 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>20</size> </adapter> </dataType> <notNull id="fab2f883-0489-4661-bd57-f04286188eef"/> - <adapter class="org.jiemamy.internal.model.attribute.RepresentationAdapter"> + <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> <representation>true</representation> </adapter> </column> @@ -194,7 +194,7 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>20</size> </adapter> </dataType> Modified: hestia/trunk/org.jiemamy.eclipse.core/.classpath =================================================================== --- hestia/trunk/org.jiemamy.eclipse.core/.classpath 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.core/.classpath 2009-04-06 17:15:35 UTC (rev 3141) @@ -14,6 +14,7 @@ <classpathentry exported="true" kind="lib" path="lib/generic-tree-0.1.0.jar" sourcepath="lib/sources/generic-tree-0.1.0-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/javassist-3.8.0.GA.jar" sourcepath="lib/sources/javassist-3.8.0.GA-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/jcl-over-slf4j-1.5.5.jar" sourcepath="lib/sources/jcl-over-slf4j-1.5.5-sources.jar"/> + <classpathentry exported="true" kind="lib" path="lib/jiemamy-commons-0.0.1-SNAPSHOT.jar" sourcepath="lib/sources/jiemamy-commons-0.0.1-SNAPSHOT-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/jiemamy-core-0.2.0-SNAPSHOT.jar" sourcepath="lib/sources/jiemamy-core-0.2.0-SNAPSHOT-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/jiemamy-spec-core-0.2-SNAPSHOT.jar" sourcepath="lib/sources/jiemamy-spec-core-0.2-SNAPSHOT-sources.jar"/> <classpathentry exported="true" kind="lib" path="lib/jiemamy-spec-view-0.2-SNAPSHOT.jar" sourcepath="lib/sources/jiemamy-spec-view-0.2-SNAPSHOT-sources.jar"/> Modified: hestia/trunk/org.jiemamy.eclipse.core/META-INF/MANIFEST.MF =================================================================== --- hestia/trunk/org.jiemamy.eclipse.core/META-INF/MANIFEST.MF 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.core/META-INF/MANIFEST.MF 2009-04-06 17:15:35 UTC (rev 3141) @@ -23,7 +23,8 @@ lib/slf4j-api-1.5.5.jar, lib/eclipse-common-0.0.4.jar, lib/opencsv-1.8.jar, - lib/commons-lang-2.4.jar + lib/commons-lang-2.4.jar, + lib/jiemamy-commons-0.0.1-SNAPSHOT.jar Export-Package: au.com.bytecode.opencsv, au.com.bytecode.opencsv.bean, ch.qos.logback.classic, @@ -132,7 +133,6 @@ org.jiemamy.internal, org.jiemamy.internal.model, org.jiemamy.internal.model.attribute, - org.jiemamy.internal.model.datatype.adapter, org.jiemamy.internal.model.sql, org.jiemamy.model, org.jiemamy.model.attribute, @@ -140,6 +140,7 @@ org.jiemamy.model.connection, org.jiemamy.model.dataset, org.jiemamy.model.datatype, + org.jiemamy.model.datatype.adapter, org.jiemamy.model.entity, org.jiemamy.model.geometory, org.jiemamy.model.index, Modified: hestia/trunk/org.jiemamy.eclipse.core/build.properties =================================================================== --- hestia/trunk/org.jiemamy.eclipse.core/build.properties 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.core/build.properties 2009-04-06 17:15:35 UTC (rev 3141) @@ -26,7 +26,8 @@ LICENSE.txt,\ plugin.xml,\ lib/opencsv-1.8.jar,\ - lib/commons-lang-2.4.jar + lib/commons-lang-2.4.jar,\ + lib/jiemamy-commons-0.0.1-SNAPSHOT.jar output..=target/classes/ source..=src/main/java/,src/main/resources/,src/test/java/,src/test/resources/ bin.excludes=lib/sources/ Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/TypeOptionManager.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -38,15 +38,15 @@ import org.jiemamy.eclipse.ui.helper.TextSelectionAdapter; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.eclipse.utils.SwtUtil; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DataTypeHolder; import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.utils.LogMarker; /** Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -78,9 +78,6 @@ import org.jiemamy.editcommand.Command; import org.jiemamy.editcommand.CommandListener; import org.jiemamy.facade.JiemamyFacade; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.constraint.CheckConstraint; @@ -90,6 +87,9 @@ import org.jiemamy.model.datatype.DataType; import org.jiemamy.model.datatype.DataTypeMold; import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.LogMarker; import org.jiemamy.utils.model.DataTypeUtil; Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-04-06 11:24:58 UTC (rev 3140) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -83,9 +83,6 @@ import org.jiemamy.editcommand.CommandListener; import org.jiemamy.exception.ElementNotFoundException; import org.jiemamy.facade.JiemamyFacade; -import org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.internal.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; @@ -98,6 +95,9 @@ import org.jiemamy.model.datatype.DataTypeMold; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.entity.TableModel; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.Disablable; Modified: leto/jiemamy-commons/trunk/pom.xml =================================================================== --- leto/jiemamy-commons/trunk/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ leto/jiemamy-commons/trunk/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -6,7 +6,7 @@ <groupId>org.jiemamy</groupId> <artifactId>jiemamy-commons</artifactId> <name>Jiemamy Commons</name> - <version>0.1.1-SNAPSHOT</version> + <version>0.0.1-SNAPSHOT</version> <url>http://report.jiemamy.org/jiemamy-commons</url> <issueManagement> <system>JIRA</system> @@ -150,6 +150,16 @@ <artifactId>logback-classic</artifactId> <version>0.9.9</version> </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + <version>1.3.2</version> + </dependency> </dependencies> <reporting> <plugins> Added: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java (rev 0) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/AnnotationUtil.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,60 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/04 + * + * 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.utils; + +import java.lang.annotation.Annotation; + +import org.apache.commons.lang.Validate; + +/** + * アノテーションを処理するユーティリティクラス。 + * + * @author daisuke + */ +public class AnnotationUtil { + + /** + * target自身の型、及びそのインターフェイスのいずれかが持つアノテーションを取得する。 + * + * @param <T> アノテーションの型 + * @param target 調査対象オブジェクト + * @param annotationClass アノテーションの型 + * @return 取得したアノテーション + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <T extends Annotation>T getTypeAnnotation(Object target, Class<T> annotationClass) { + Validate.notNull(target); + Validate.notNull(annotationClass); + + Annotation classAnnotation = target.getClass().getAnnotation(annotationClass); + if (classAnnotation != null) { + return annotationClass.cast(classAnnotation); + } + for (Class<?> interf : target.getClass().getInterfaces()) { + Annotation interfaceAnnotation = interf.getAnnotation(annotationClass); + if (interfaceAnnotation != null) { + return annotationClass.cast(interfaceAnnotation); + } + } + return null; + } + + private AnnotationUtil() { + } +} Added: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java (rev 0) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/CollectionsUtil.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,182 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/09 + * + * 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.utils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; + +import org.apache.commons.lang.Validate; + +/** + * Java5のgenericsや可変長を活用する、コレクションのためのユーティリティ。 + * + * <p>org.seasar.framework.util.tiger.CollectionsUtil のサブセット</p> + * + * @author daisuke + */ +public class CollectionsUtil { + + /** + * {@link ArrayList}の新しいインスタンスを生成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList() + */ + public static <E>ArrayList<E> newArrayList() { + return new ArrayList<E>(); + } + + /** + * {@link ArrayList}の新しいインスタンスを生成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @param c 要素がリストに配置されるコレクション + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList(Collection) + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <E>ArrayList<E> newArrayList(final Collection<? extends E> c) { + Validate.notNull(c); + return new ArrayList<E>(c); + } + + /** + * {@link ArrayList}の新しいインスタンスを生成する。 + * + * @param <E> {@link ArrayList}の要素型 + * @param initialCapacity リストの初期容量 + * @return {@link ArrayList}の新しいインスタンス + * @see ArrayList#ArrayList(int) + */ + public static <E>ArrayList<E> newArrayList(final int initialCapacity) { + return new ArrayList<E>(initialCapacity); + } + + /** + * {@link HashMap}の新しいインスタンスを生成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap() + */ + public static <K, V>HashMap<K, V> newHashMap() { + return new HashMap<K, V>(); + } + + /** + * {@link HashMap}の新しいインスタンスを生成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param initialCapacity 初期容量 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int) + */ + public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity) { + return new HashMap<K, V>(initialCapacity); + } + + /** + * {@link HashMap}の新しいインスタンスを生成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param initialCapacity 初期容量 + * @param loadFactor サイズ変更の制御に使用される負荷係数のしきい値 + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int, float) + */ + public static <K, V>HashMap<K, V> newHashMap(final int initialCapacity, final float loadFactor) { + return new HashMap<K, V>(initialCapacity, loadFactor); + } + + /** + * {@link HashMap}の新しいインスタンスを生成する。 + * + * @param <K> {@link HashMap}のキーの型 + * @param <V> {@link HashMap}の値の型 + * @param m 作成されるマップに配置されるマップ + * @return {@link HashMap}の新しいインスタンス + * @see HashMap#HashMap(int, float) + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <K, V>HashMap<K, V> newHashMap(final Map<? extends K, ? extends V> m) { + Validate.notNull(m); + return new HashMap<K, V>(m); + } + + /** + * {@link HashSet}の新しいインスタンスを生成する。 + * + * @param <E> {@link HashSet}の要素型 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet() { + return new HashSet<E>(); + } + + /** + * {@link HashSet}の新しいインスタンスを生成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param c 要素がセットに配置されるコレクション + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public static <E>HashSet<E> newHashSet(final Collection<? extends E> c) { + Validate.notNull(c); + return new HashSet<E>(c); + } + + /** + * {@link HashSet}の新しいインスタンスを生成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param initialCapacity 初期容量 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet(final int initialCapacity) { + return new HashSet<E>(initialCapacity); + } + + /** + * {@link HashSet}の新しいインスタンスを生成する。 + * + * @param <E> {@link HashSet}の要素型 + * @param initialCapacity 初期容量 + * @param loadFactor 負荷係数 + * @return {@link HashSet}の新しいインスタンス + * @see HashSet#HashSet() + */ + public static <E>HashSet<E> newHashSet(final int initialCapacity, final float loadFactor) { + return new HashSet<E>(initialCapacity, loadFactor); + } + + private CollectionsUtil() { + } + +} Modified: leto/jiemamy-test-helper/trunk/trunk/pom.xml =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/pom.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ leto/jiemamy-test-helper/trunk/trunk/pom.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -6,7 +6,7 @@ <groupId>org.jiemamy</groupId> <artifactId>jiemamy-test-helper</artifactId> <name>Jiemamy Test Helper</name> - <version>0.1.1-SNAPSHOT</version> + <version>0.0.1-SNAPSHOT</version> <url>http://report.jiemamy.org/jiemamy-test-helper</url> <issueManagement> <system>JIRA</system> @@ -122,13 +122,11 @@ <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> - <scope>test</scope> </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-library</artifactId> <version>1.1</version> - <scope>test</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -150,6 +148,21 @@ <artifactId>logback-classic</artifactId> <version>0.9.9</version> </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-spec-core</artifactId> + <version>0.2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-spec-view</artifactId> + <version>0.2-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.jiemamy</groupId> + <artifactId>jiemamy-commons</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> </dependencies> <reporting> <plugins> Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,778 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * 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.internal.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jiemamy.InstanceProvider; +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.RepresentationAdapter; +import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.NotNullConstraint; +import org.jiemamy.model.attribute.constraint.PrimaryKey; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.model.index.IndexColumnModel; +import org.jiemamy.model.index.IndexModel; +import org.jiemamy.model.index.IndexColumnModel.SortOrder; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.Disablable; + +/** + * Jiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class CoreTestModelBuilder implements TestModelBuilder { + + private static final String ID_1 = "1"; + + private static final String ID_2 = "2"; + + private static final String ID_3 = "3"; + + private static final String ID_4 = "4"; + + private static final String DIALECT_CLASS_NAME = "org.jiemamy.dialect.mysql.MySqlDialect"; + + // ---- basics + + /** UUID生成戦略 */ + public final UuidStrategy uuid; + + /** 生成方針 */ + public final Instruction instruction; + + /** 生成するモデルのインスタンス空間 */ + public final Jiemamy jiemamy; + + /** 生成に使用するファクトリ */ + public final JiemamyFactory factory; + + // ---- models + + /** 生成したモデル */ + public final RootModel rootModel; + + /** 生成したモデル */ + public DomainModel domainId; + + // dept + + /** 生成したモデル */ + public DomainModel domainName; + + /** 生成したモデル */ + public TableModel tableDept; + + /** 生成したモデル */ + public ColumnModel deptId; + + /** 生成したモデル */ + public ColumnModel deptDeptNo; + + /** 生成したモデル */ + public ColumnModel deptDeptName; + + /** 生成したモデル */ + public ColumnModel deptLoc; + + // emp + + /** 生成したモデル */ + public PrimaryKey deptPk; + + /** 生成したモデル */ + public TableModel tableEmp; + + /** 生成したモデル */ + public ColumnModel empId; + + /** 生成したモデル */ + public ColumnModel empEmpNo; + + /** 生成したモデル */ + + public ColumnModel empEmpName; + + /** 生成したモデル */ + public ColumnModel empMgrId; + + /** 生成したモデル */ + public ColumnModel empHiredate; + + /** 生成したモデル */ + public ColumnModel empSal; + + /** 生成したモデル */ + public ColumnModel empDeptId; + + // highSal + + /** 生成したモデル */ + public PrimaryKey empPk; + + // fk + + /** 生成したモデル */ + public ViewModel viewHighSal; + + /** 生成したモデル */ + public ForeignKey fkEmpEmp; + + /** 生成したモデル */ + public ForeignKey fkEmpDept; + + private IndexModel empNameIndex; + + + /** + * インスタンスを生成する。 + */ + public CoreTestModelBuilder() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param dialectProvider SQL方言プロバイダ + */ + public CoreTestModelBuilder(InstanceProvider<Dialect> dialectProvider) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance(dialectProvider)); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public CoreTestModelBuilder(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + this.uuid = uuid; + this.instruction = instruction; + this.jiemamy = jiemamy; + factory = jiemamy.getFactory(); + + if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { + throw new IllegalArgumentException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + public Jiemamy build() { + rootModel.setDialectClassName(DIALECT_CLASS_NAME); + rootModel.setBeginScript("BEGIN;"); + rootModel.setEndScript("COMMIT;"); + rootModel.setDescription("Jiemamyテストモデル1"); + rootModel.setSchemaName("FOO"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + + return jiemamy; + } + + /** + * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 + * + * @return Jiemamyオブジェクト + */ + public Jiemamy getJiemamy() { + return jiemamy; + } + + /** + * データセットを生成する。 + */ + protected void createDataSets() { + if (instruction.supressUseDataSet) { + return; + } + // データセットの生成・追加(1) + DataSetModel dataSetEn = factory.newModel(DataSetModel.class, uuid.get("b73100b5-2d70-4b48-a825-311eacb63b2f")); + dataSetEn.setName("データ群en"); + dataSetEn.getRecords().put(factory.newReference(tableDept), createDataSetEnDept()); + dataSetEn.getRecords().put(factory.newReference(tableEmp), createDataSetEnEmp()); + rootModel.getDataSets().add(dataSetEn); + + // データセットの生成・追加(2) + DataSetModel dataSetJa = factory.newModel(DataSetModel.class, uuid.get("91246ed4-1ef3-440e-bf12-40fa4439a71b")); + dataSetJa.setName("データ群ja"); + dataSetJa.getRecords().put(factory.newReference(tableDept), createDataSetJaDept()); + dataSetJa.getRecords().put(factory.newReference(tableEmp), createDataSetJaEmp()); + rootModel.getDataSets().add(dataSetJa); + } + + /** + * ドメインを生成する。 + */ + protected void createDomains() { + if (instruction.supressUseDomain) { + return; + } + + domainId = factory.newModel(DomainModel.class, uuid.get("2eec0aa0-5122-4eb7-833d-9f5a43e7abe9")); + domainId.setName("ID"); + domainId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); + domainId.setNotNullConstraint(notNull); + ColumnCheckConstraint check = + factory.newModel(ColumnCheckConstraint.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); + check.setName("hoge"); + check.setExpression("VALUE > 0"); + domainId.setCheckConstraint(check); + domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true); + rootModel.getDomains().add(domainId); + + domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7")); + domainName.setName("NAME"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); + domainName.setDataType(dataType); + domainName.setDescription("人名用の型です。"); + rootModel.getDomains().add(domainName); + } + + /** + * エンティティを生成する。 + */ + protected void createEntities() { + createTableDept(); + rootModel.getEntities().add(tableDept); + createTableEmp(); + rootModel.getEntities().add(tableEmp); + createViewHighSal(); + rootModel.getEntities().add(viewHighSal); + } + + /** + * 外部キーを生成する。 + */ + protected void createForeignKeys() { + if (instruction.supressUseForeignKey) { + return; + } + + int pkIndex = tableEmp.getAttributes().indexOf(empPk); + + fkEmpEmp = factory.newModel(ForeignKey.class, uuid.get("e43d3c43-33c8-4b02-aa42-83f2d868cfe6")); + fkEmpEmp.setName("emp_mgr_id_fkey"); + fkEmpEmp.getKeyColumns().add(factory.newReference(empMgrId)); + fkEmpEmp.getReferenceColumns().add(factory.newReference(empId)); + fkEmpEmp.setOnDelete(ReferentialAction.SET_NULL); + Deferrability deferrability = + factory.newModel(Deferrability.class, uuid.get("9af096ba-8841-41ba-9dd4-02628b800bf0")); + deferrability.setDeferrable(true); + deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); + fkEmpEmp.setDeferrability(deferrability); + tableEmp.getAttributes().add(pkIndex + 1, fkEmpEmp); + + fkEmpDept = factory.newModel(ForeignKey.class, uuid.get("e7dd92b4-1d97-4be6-bab6-fa9fe26eb6ed")); + fkEmpDept.setName("emp_dept_id_fkey"); + fkEmpDept.getKeyColumns().add(factory.newReference(empDeptId)); + fkEmpDept.getReferenceColumns().add(factory.newReference(deptId)); + tableEmp.getAttributes().add(pkIndex + 2, fkEmpDept); + } + + private List<RecordModel> createDataSetEnDept() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("176bfb08-99cb-4c76-bf8e-6979e0c7afb9")); + ModelUtil.addValue(record, deptId, ID_1); + ModelUtil.addValue(record, deptDeptNo, "10"); + ModelUtil.addValue(record, deptDeptName, "ACCOUNTING"); + ModelUtil.addValue(record, deptLoc, "NEW YORK"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3971430b-ef1d-4e5a-b996-f2acfa7536c0")); + ModelUtil.addValue(record, deptId, ID_2); + ModelUtil.addValue(record, deptDeptNo, "20"); + ModelUtil.addValue(record, deptDeptName, "RESEARCH"); + ModelUtil.addValue(record, deptLoc, "DALLAS"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0591cc1e-45a6-4598-b85a-20fae51b7991")); + ModelUtil.addValue(record, deptId, ID_3); + ModelUtil.addValue(record, deptDeptNo, "30"); + ModelUtil.addValue(record, deptDeptName, "SALES"); + ModelUtil.addValue(record, deptLoc, "CHICAGO"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("ac275955-4710-484a-b694-f7acc6ded08f")); + ModelUtil.addValue(record, deptId, ID_4); + ModelUtil.addValue(record, deptDeptNo, "40"); + ModelUtil.addValue(record, deptDeptName, "OPERATIONS"); + ModelUtil.addValue(record, deptLoc, "BOSTON"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnEmp() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("6ce22d69-bd75-4822-946f-a51221fd45eb")); + ModelUtil.addValue(record, empId, ID_1); + ModelUtil.addValue(record, empEmpNo, "10"); + ModelUtil.addValue(record, empEmpName, "SMITH"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2003-02-01"); + ModelUtil.addValue(record, empSal, "40"); + ModelUtil.addValue(record, empDeptId, ID_3); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); + ModelUtil.addValue(record, empId, ID_2); + ModelUtil.addValue(record, empEmpNo, "20"); + ModelUtil.addValue(record, empEmpName, "ALLEN"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2000-03-04"); + ModelUtil.addValue(record, empSal, "50"); + ModelUtil.addValue(record, empDeptId, ID_4); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); + ModelUtil.addValue(record, empId, ID_3); + ModelUtil.addValue(record, empEmpNo, "30"); + ModelUtil.addValue(record, empEmpName, "WARD"); +// ModelUtil.addValue(record, empMgrId, null); + ModelUtil.addValue(record, empHiredate, "1993-12-05"); + ModelUtil.addValue(record, empSal, "60"); + ModelUtil.addValue(record, empDeptId, ID_4); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); + ModelUtil.addValue(record, empId, ID_4); + ModelUtil.addValue(record, empEmpNo, "40"); + ModelUtil.addValue(record, empEmpName, "JONES"); + ModelUtil.addValue(record, empMgrId, ID_2); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "36"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("4206acce-b31f-4c2e-8682-4796254a4dca")); + ModelUtil.addValue(record, empId, "5"); + ModelUtil.addValue(record, empEmpNo, "50"); + ModelUtil.addValue(record, empEmpName, "MARTIN"); + ModelUtil.addValue(record, empMgrId, ID_1); + ModelUtil.addValue(record, empHiredate, "2002-05-30"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, ID_3); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("6748ce0e-462d-44df-a536-18f14a3c2643")); + ModelUtil.addValue(record, empId, "6"); + ModelUtil.addValue(record, empEmpNo, "60"); + ModelUtil.addValue(record, empEmpName, "BLAKE"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f8564bdf-f61c-4711-b606-69aed74324a6")); + ModelUtil.addValue(record, empId, "7"); + ModelUtil.addValue(record, empEmpNo, "70"); + ModelUtil.addValue(record, empEmpName, "CLARK"); + ModelUtil.addValue(record, empMgrId, ID_1); + ModelUtil.addValue(record, empHiredate, "2004-09-01"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, ID_1); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("dd1cc8e1-7562-4539-86d8-5390d043325a")); + ModelUtil.addValue(record, empId, "8"); + ModelUtil.addValue(record, empEmpNo, "80"); + ModelUtil.addValue(record, empEmpName, "SCOTT"); + ModelUtil.addValue(record, empMgrId, ID_4); + ModelUtil.addValue(record, empHiredate, "2008-03-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaDept() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("61671217-d61c-4f42-9985-4f6b2c970171")); + ModelUtil.addValue(record, deptId, ID_1); + ModelUtil.addValue(record, deptDeptNo, "10"); + ModelUtil.addValue(record, deptDeptName, "経理部"); + ModelUtil.addValue(record, deptLoc, "広島"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("171d019e-163f-42f6-82dc-15340798fdf4")); + ModelUtil.addValue(record, deptId, ID_2); + ModelUtil.addValue(record, deptDeptNo, "20"); + ModelUtil.addValue(record, deptDeptName, "研究開発部"); + ModelUtil.addValue(record, deptLoc, "京都"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("838344e6-093d-4202-aaca-bacf1a7ff376")); + ModelUtil.addValue(record, deptId, ID_3); + ModelUtil.addValue(record, deptDeptNo, "30"); + ModelUtil.addValue(record, deptDeptName, "営業部"); + ModelUtil.addValue(record, deptLoc, "東京"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2f29bb19-0a20-4251-8052-568194e6101c")); + ModelUtil.addValue(record, deptId, ID_4); + ModelUtil.addValue(record, deptDeptNo, "40"); + ModelUtil.addValue(record, deptDeptName, "経営本部"); + // locは指定せず、特定しない状態 + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaEmp() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("9365e670-1eff-4a23-90bd-f794b9742b10")); + ModelUtil.addValue(record, empId, ID_1); + ModelUtil.addValue(record, empEmpNo, "10"); + ModelUtil.addValue(record, empEmpName, "鈴木 茂"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2003-02-01"); + ModelUtil.addValue(record, empSal, "40"); + ModelUtil.addValue(record, empDeptId, ID_3); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); + ModelUtil.addValue(record, empId, ID_2); + ModelUtil.addValue(record, empEmpNo, "20"); + ModelUtil.addValue(record, empEmpName, "内海 透"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2000-03-04"); + ModelUtil.addValue(record, empSal, "50"); + ModelUtil.addValue(record, empDeptId, ID_4); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); + ModelUtil.addValue(record, empId, ID_3); + ModelUtil.addValue(record, empEmpNo, "30"); + ModelUtil.addValue(record, empEmpName, "村瀬 武彦"); +// ModelUtil.addValue(record, empMgrId, null); + ModelUtil.addValue(record, empHiredate, "1993-12-05"); + ModelUtil.addValue(record, empSal, "60"); + ModelUtil.addValue(record, empDeptId, ID_4); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); + ModelUtil.addValue(record, empId, ID_4); + ModelUtil.addValue(record, empEmpNo, "40"); + ModelUtil.addValue(record, empEmpName, "近藤 美樹"); + ModelUtil.addValue(record, empMgrId, ID_2); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "36"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("c10562ee-4ab9-40a5-8a21-83f331df5c85")); + ModelUtil.addValue(record, empId, "5"); + ModelUtil.addValue(record, empEmpNo, "50"); + ModelUtil.addValue(record, empEmpName, "榊 美子"); + ModelUtil.addValue(record, empMgrId, ID_1); + ModelUtil.addValue(record, empHiredate, "2002-05-30"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, ID_3); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("29c9a655-f4ed-4753-aea6-1e21cb28f891")); + ModelUtil.addValue(record, empId, "6"); + ModelUtil.addValue(record, empEmpNo, "60"); + ModelUtil.addValue(record, empEmpName, "三浦 佑"); + ModelUtil.addValue(record, empMgrId, ID_3); + ModelUtil.addValue(record, empHiredate, "2007-04-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("b65b9b12-bb68-4845-a514-a57f0bd57616")); + ModelUtil.addValue(record, empId, "7"); + ModelUtil.addValue(record, empEmpNo, "70"); + ModelUtil.addValue(record, empEmpName, "前島 孝幸"); + ModelUtil.addValue(record, empMgrId, ID_1); + ModelUtil.addValue(record, empHiredate, "2004-09-01"); + ModelUtil.addValue(record, empSal, "30"); + ModelUtil.addValue(record, empDeptId, ID_1); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0eb27151-323a-4679-bde4-0b01f561139f")); + ModelUtil.addValue(record, empId, "8"); + ModelUtil.addValue(record, empEmpNo, "80"); + ModelUtil.addValue(record, empEmpName, "島崎 由比"); + ModelUtil.addValue(record, empMgrId, ID_4); + ModelUtil.addValue(record, empHiredate, "2008-03-01"); + ModelUtil.addValue(record, empSal, "25"); + ModelUtil.addValue(record, empDeptId, ID_2); + result.add(record); + + return result; + } + + private void createTableDept() { + tableDept = factory.newModel(TableModel.class, uuid.get("d7489ed6-0add-443d-95cf-234376eb0455")); + tableDept.setName("T_DEPT"); + tableDept.setBeginScript("/* test begin script */"); + tableDept.setDescription("部署マスタです。"); + + deptId = factory.newModel(ColumnModel.class, uuid.get("c7ed225d-92a6-4cc2-90de-60531804464e")); + deptId.setName("ID"); + if (instruction.supressUseDomain) { + deptId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(domainId); + deptId.setDataType(ref); + } + deptId.setLogicalName("部署ID"); + deptPk = factory.newModel(PrimaryKey.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); + deptPk.setName("dept_pkey"); + deptPk.getKeyColumns().add(factory.newReference(deptId)); + deptId.setPrimaryKey(deptPk); + tableDept.getAttributes().add(deptId); + + deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); + deptDeptNo.setName("DEPT_NO"); + deptDeptNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + deptDeptNo.setLogicalName("部署番号"); + tableDept.getAttributes().add(deptDeptNo); + + deptDeptName = factory.newModel(ColumnModel.class, uuid.get("1fcd63d3-974e-4d2e-a0d8-3b9c233104d9")); + deptDeptName.setName("DEPT_NAME"); + BuiltinDataType deptDeptNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + deptDeptNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + deptDeptName.setDataType(deptDeptNameDataType); + deptDeptName.setLogicalName("部署名"); + deptDeptName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableDept.getAttributes().add(deptDeptName); + + deptLoc = factory.newModel(ColumnModel.class, uuid.get("7bf79e76-07b8-43b6-a993-b8ef374a31f5")); + deptLoc.setName("LOC"); + BuiltinDataType deptLocDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + deptLocDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + deptLoc.setDataType(deptLocDataType); + deptLoc.setLogicalName("ロケーション"); + deptLoc.setDefaultValue("secret"); + tableDept.getAttributes().add(deptLoc); + + Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); + columnNotNullMap.put(deptDeptNo.getId(), uuid.get("cc709f63-a886-4207-a316-58ad7f279e10")); + columnNotNullMap.put(deptDeptName.getId(), uuid.get("fab2f883-0489-4661-bd57-f04286188eef")); + + for (ColumnModel columnModel : Arrays.asList(deptDeptNo, deptDeptName)) { + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableEmp() { + tableEmp = factory.newModel(TableModel.class, uuid.get("9f522e56-809c-45fd-8416-39201014218b")); + tableEmp.setName("T_EMP"); + tableEmp.setLogicalName("従業員"); + tableEmp.setBeginScript("/* test end script */"); + tableEmp.setDescription("従業員マスタです。"); + + empId = factory.newModel(ColumnModel.class, uuid.get("44c8e93d-b7ad-46cc-9b29-88c3a7d6c33e")); + empId.setName("ID"); + if (instruction.supressUseDomain) { + empId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(domainId); + empId.setDataType(ref); + } + empId.setLogicalName("従業員ID"); + tableEmp.getAttributes().add(empId); + + empEmpNo = factory.newModel(ColumnModel.class, uuid.get("248a429b-2159-4ebd-a791-eee42a059374")); + empEmpNo.setName("EMP_NO"); + empEmpNo.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + empEmpNo.setLogicalName("従業員番号"); + NotNullConstraint notNullEmpEmpNo = + factory.newModel(NotNullConstraint.class, uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); + notNullEmpEmpNo.getAdapter(Disablable.class).setDisabled(true); + empEmpNo.setNotNullConstraint(notNullEmpEmpNo); + tableEmp.getAttributes().add(empEmpNo); + + empEmpName = factory.newModel(ColumnModel.class, uuid.get("0e51b6df-43ab-408c-90ef-de13c6aab881")); + empEmpName.setName("EMP_NAME"); + if (instruction.supressUseDomain) { + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); + empEmpName.setDataType(dataType); + } else { + DomainRef ref = factory.newReference(domainName); + empEmpName.setDataType(ref); + } + empEmpName.setLogicalName("従業員名"); + empEmpName.setDefaultValue("no name"); + empEmpName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableEmp.getAttributes().add(empEmpName); + + empMgrId = factory.newModel(ColumnModel.class, uuid.get("3d21a85a-72de-41b3-99dd-f4cb94e58d84")); + empMgrId.setName("MGR_ID"); + empMgrId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + empMgrId.setLogicalName("上司ID"); + tableEmp.getAttributes().add(empMgrId); + + empHiredate = factory.newModel(ColumnModel.class, uuid.get("f0b57eed-98ab-4c21-9855-218c592814dc")); + empHiredate.setName("HIREDATE"); + empHiredate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.DATE)); + tableEmp.getAttributes().add(empHiredate); + + empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); + empSal.setName("SAL"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.NUMERIC); + dataType.getAdapter(PrecisionedDataTypeAdapter.class).setPrecision(7); + dataType.getAdapter(PrecisionedDataTypeAdapter.class).setScale(2); + empSal.setDataType(dataType); + 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(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableEmp.getAttributes().add(empDeptId); + + empPk = factory.newModel(PrimaryKey.class, uuid.get("6145e6a0-9ff7-4033-999d-99d80392a48f")); + empPk.setName("emp_pkey"); + empPk.getKeyColumns().add(factory.newReference(empId)); + tableEmp.getAttributes().add(empPk); + + Map<UUID, UUID> columnNotNullMap = CollectionsUtil.newHashMap(); + columnNotNullMap.put(empEmpName.getId(), uuid.get("41f178b9-2cb5-4dad-a6c0-48df2d5b1300")); + columnNotNullMap.put(empHiredate.getId(), uuid.get("2d66fd73-8d6b-41d8-b6b8-daec7d6c0c53")); + columnNotNullMap.put(empSal.getId(), uuid.get("a446779a-4fb6-4a0f-8262-22daae856e85")); + columnNotNullMap.put(empDeptId.getId(), uuid.get("b9a0fdce-a965-4118-ae71-5dc7150f6d4e")); + + for (ColumnModel columnModel : Arrays.asList(empEmpName, empHiredate, empSal, empDeptId)) { + NotNullConstraint notNull = + factory.newModel(NotNullConstraint.class, columnNotNullMap.get(columnModel.getId())); + columnModel.setNotNullConstraint(notNull); + } + + empNameIndex = factory.newModel(IndexModel.class, uuid.get("9abc9e01-4cdb-42fe-a495-93b56af35a1d")); + empNameIndex.setName("IDX_EMP_NAME"); + IndexColumnModel indexColumnModel = + factory.newModel(IndexColumnModel.class, uuid.get("52d2b6aa-fff7-4c33-af13-f4d0b63e8e58")); + indexColumnModel.setColumnRef(factory.newReference(empEmpName)); + indexColumnModel.setSortOrder(SortOrder.DESC); + empNameIndex.getIndexColumns().add(indexColumnModel); + tableEmp.getIndexes().add(empNameIndex); + } + + private void createViewHighSal() { + viewHighSal = factory.newModel(ViewModel.class, uuid.get("516f7961-cb7b-48e2-990b-7fb0c750c3a4")); + viewHighSal.setName("V_HIGH_SAL_EMP"); + viewHighSal.setDefinition("SELECT * FROM T_EMP WHERE SAL > 2000;"); + viewHighSal.setLogicalName("高給取り"); + } +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder2.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,834 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * 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.internal.test; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.RepresentationAdapter; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.NotNullConstraint; +import org.jiemamy.model.attribute.constraint.PrimaryKey; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKey.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; + +/** + * Jiemamyテストモデル1(ORDERテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class CoreTestModelBuilder2 implements TestModelBuilder { + + private static final String ID_1 = "1"; + + private static final String ID_2 = "2"; + + private static final String ID_3 = "3"; + + private static final String ID_4 = "4"; + + private static final String DIALECT_CLASS_NAME = "org.jiemamy.dialect.mysql.MySqlDialect"; + + // ---- basics + + /** UUID生成戦略 */ + public final UuidStrategy uuid; + + /** 生成方針 */ + public final Instruction instruction; + + /** 生成するモデルのインスタンス空間 */ + public final Jiemamy jiemamy; + + /** 生成に使用するファクトリ */ + public final JiemamyFactory factory; + + /** 生成したモデル */ + public final RootModel rootModel; + + // ---- models + + /** 生成したモデル */ + public DomainModel idDomain; + + /** 生成したモデル */ + public DomainModel nameDomain; + + // item + + /** 生成したモデル */ + public TableModel tableItem; + + /** 生成したモデル */ + public ColumnModel itemId; + + /** 生成したモデル */ + public ColumnModel itemName; + + /** 生成したモデル */ + public ColumnModel itemPrice; + + /** 生成したモデル */ + public PrimaryKey itemPk; + + // user + + /** 生成したモデル */ + public TableModel tableUser; + + /** 生成したモデル */ + public ColumnModel userId; + + /** 生成したモデル */ + public ColumnModel userName; + + /** 生成したモデル */ + public PrimaryKey userPk; + + // order + + /** 生成したモデル */ + public TableModel tableOrder; + + /** 生成したモデル */ + public ColumnModel orderId; + + /** 生成したモデル */ + public ColumnModel orderUserId; + + /** 生成したモデル */ + public ColumnModel orderDate; + + /** 生成したモデル */ + public PrimaryKey orderPk; + + // detail + + /** 生成したモデル */ + public TableModel tableDetail; + + /** 生成したモデル */ + public ColumnModel detailId; + + /** 生成したモデル */ + public ColumnModel detailOrderId; + + /** 生成したモデル */ + public ColumnModel detailItemId; + + /** 生成したモデル */ + public ColumnModel detailQuantity; + + /** 生成したモデル */ + public PrimaryKey detailPk; + + // fk + + /** 生成したモデル */ + public ForeignKey fkDetailItem; + + /** 生成したモデル */ + public ForeignKey fkDetailOrder; + + /** 生成したモデル */ + public ForeignKey fkOrderUser; + + + /** + * インスタンスを生成する。 + */ + public CoreTestModelBuilder2() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder2(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public CoreTestModelBuilder2(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + this.uuid = uuid; + this.instruction = instruction; + this.jiemamy = jiemamy; + factory = jiemamy.getFactory(); + + if (factory.hasRootModel() && uuid == UuidStrategy.FIXED) { + throw new IllegalArgumentException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public CoreTestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + public Jiemamy build() { + rootModel.setDialectClassName(DIALECT_CLASS_NAME); + rootModel.setBeginScript("BEGIN;"); + rootModel.setEndScript("COMMIT;"); + rootModel.setDescription("Jiemamyテストモデル2"); + rootModel.setSchemaName("BAR"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + + return jiemamy; + } + + /** + * ビルドしたモデルを持つJiemamyオブジェクトを取得する。 + * + * @return Jiemamyオブジェクト + */ + public Jiemamy getJiemamy() { + return jiemamy; + } + + /** + * データセットを生成する。 + */ + protected void createDataSets() { + if (instruction.supressUseDataSet) { + return; + } + // データセットの生成・追加(1) + DataSetModel dataSetEn = factory.newModel(DataSetModel.class); + dataSetEn.setName("データ群en"); + dataSetEn.getRecords().put(factory.newReference(tableItem), createDataSetEnItem()); + dataSetEn.getRecords().put(factory.newReference(tableUser), createDataSetEnUser()); + dataSetEn.getRecords().put(factory.newReference(tableOrder), createDataSetEnOrder()); + dataSetEn.getRecords().put(factory.newReference(tableDetail), createDataSetEnDetail()); + rootModel.getDataSets().add(dataSetEn); + + // データセットの生成・追加(2) + DataSetModel dataSetJa = factory.newModel(DataSetModel.class); + dataSetJa.setName("データ群ja"); + dataSetJa.getRecords().put(factory.newReference(tableItem), createDataSetJaItem()); + dataSetJa.getRecords().put(factory.newReference(tableUser), createDataSetJaUser()); + dataSetJa.getRecords().put(factory.newReference(tableOrder), createDataSetJaOrder()); + dataSetJa.getRecords().put(factory.newReference(tableDetail), createDataSetJaDetail()); + rootModel.getDataSets().add(dataSetJa); + } + + /** + * ドメインを生成する。 + */ + protected void createDomains() { + if (instruction.supressUseDomain) { + return; + } + + idDomain = factory.newModel(DomainModel.class, uuid.get("9a3ba23c-b328-4c70-a32d-3e4be3ee3f08")); + idDomain.setName("ID"); + idDomain.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + idDomain.setNotNullConstraint(factory.newModel(NotNullConstraint.class)); + idDomain.getAdapter(SerialDataTypeAdapter.class).setSerial(true); + rootModel.getDomains().add(idDomain); + + nameDomain = factory.newModel(DomainModel.class, uuid.get("e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193")); + nameDomain.setName("NAME"); + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); + nameDomain.setDataType(dataType); + nameDomain.setDescription("人名用の型です。"); + rootModel.getDomains().add(nameDomain); + } + + /** + * エンティティを生成する。 + */ + protected void createEntities() { + createTableItem(); + rootModel.getEntities().add(tableItem); + createTableUser(); + rootModel.getEntities().add(tableUser); + createTableOrder(); + rootModel.getEntities().add(tableOrder); + createTableDetail(); + rootModel.getEntities().add(tableDetail); + } + + /** + * 外部キーを生成する。 + */ + protected void createForeignKeys() { + if (instruction.supressUseForeignKey) { + return; + } + + fkDetailItem = factory.newModel(ForeignKey.class, uuid.get("df781ad0-112a-4db7-a76c-4395b15600b2")); + fkDetailItem.getKeyColumns().add(factory.newReference(detailItemId)); + fkDetailItem.getReferenceColumns().add(factory.newReference(itemId)); + fkDetailItem.setOnDelete(ReferentialAction.RESTRICT); + tableDetail.getAttributes().add(fkDetailItem); + + fkDetailOrder = factory.newModel(ForeignKey.class, uuid.get("fca97c96-db8c-44b4-8427-6207601eaa94")); + fkDetailOrder.getKeyColumns().add(factory.newReference(detailOrderId)); + fkDetailOrder.getReferenceColumns().add(factory.newReference(orderId)); + fkDetailOrder.setOnDelete(ReferentialAction.CASCADE); + Deferrability deferrability = + factory.newModel(Deferrability.class, uuid.get("1726a29c-0984-4042-b2c3-c601671892a1")); + deferrability.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); + fkDetailOrder.setDeferrability(deferrability); + tableDetail.getAttributes().add(fkDetailOrder); + + fkOrderUser = factory.newModel(ForeignKey.class, uuid.get("325b5aa9-821e-4791-aac5-2d3eb64f9392")); + fkOrderUser.getKeyColumns().add(factory.newReference(orderUserId)); + fkOrderUser.getReferenceColumns().add(factory.newReference(userId)); + fkOrderUser.setOnDelete(ReferentialAction.RESTRICT); + Deferrability deferrability2 = + factory.newModel(Deferrability.class, uuid.get("899f5889-ac30-44dc-b078-35a1b1edc8f0")); + deferrability2.setInitiallyCheckTime(InitiallyCheckTime.IMMEDIATE); + fkOrderUser.setDeferrability(deferrability2); + tableOrder.getAttributes().add(fkOrderUser); + } + + private List<RecordModel> createDataSetEnDetail() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("546244f5-afa2-4e7e-bde0-5a811ced77af")); + ModelUtil.addValue(record, detailId, ID_1); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_1); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("943fda94-a3f2-4c47-b19f-9e8655b47362")); + ModelUtil.addValue(record, detailId, ID_2); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d11db81a-2d53-42b4-9f10-17f98f1f7081")); + ModelUtil.addValue(record, detailId, ID_3); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("0aa0dd6f-5656-4994-abfe-05f05aec7275")); + ModelUtil.addValue(record, detailId, ID_4); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_3); + ModelUtil.addValue(record, detailQuantity, "6"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("4b9be90a-886f-47d8-89f0-da03d7ad419e")); + ModelUtil.addValue(record, detailId, "5"); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "12"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("23665133-7f4e-4f65-af7c-0de1b655f7c9")); + ModelUtil.addValue(record, detailId, "6"); + ModelUtil.addValue(record, detailOrderId, ID_3); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnItem() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("7162b83a-1815-4b08-8c11-8e6400c05a9e")); + ModelUtil.addValue(record, itemId, ID_1); + ModelUtil.addValue(record, itemName, "DIAMOND"); + ModelUtil.addValue(record, itemPrice, "100000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("a3d6480d-9088-49d8-a500-872262a635d5")); + ModelUtil.addValue(record, itemId, ID_2); + ModelUtil.addValue(record, itemName, "EMERALD"); + ModelUtil.addValue(record, itemPrice, "75000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("bf4556ff-fb81-472c-945d-14067945e7c2")); + ModelUtil.addValue(record, itemId, ID_3); + ModelUtil.addValue(record, itemName, "RUBY"); + ModelUtil.addValue(record, itemPrice, "30000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("fc30dd3e-495d-4f7c-9237-dd9f84c14eb5")); + ModelUtil.addValue(record, itemId, ID_4); + ModelUtil.addValue(record, itemName, "SAPPHIRE"); + ModelUtil.addValue(record, itemPrice, "10000"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnOrder() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("bf813157-8690-4eb3-9168-cd4906f13f27")); + ModelUtil.addValue(record, orderId, ID_1); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("645b241d-a6ba-4821-8682-448f59949b3e")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_3); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("654ceb1b-b6eb-406d-8eac-aa07c7c41e62")); + ModelUtil.addValue(record, orderId, ID_3); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetEnUser() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("c60fb4ba-e3d6-415e-a22c-20fbaf4e04e6")); + ModelUtil.addValue(record, userId, ID_1); + ModelUtil.addValue(record, userName, "SMITH"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("83d5c923-7c61-4393-8185-ac95042f6476")); + ModelUtil.addValue(record, userId, ID_2); + ModelUtil.addValue(record, userName, "ALLEN"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2ddd8857-3fca-4020-bb23-49d0126af6fc")); + ModelUtil.addValue(record, userId, ID_3); + ModelUtil.addValue(record, userName, "WARD"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2b9aeb38-97de-439e-b96b-40a1c82d249e")); + ModelUtil.addValue(record, userId, ID_4); + ModelUtil.addValue(record, userName, "JONES"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("a6242c24a-b415-4a93-867b-16a68c2fe884")); + ModelUtil.addValue(record, userId, "5"); + ModelUtil.addValue(record, userName, "MARTIN"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3b9d3161-a613-4090-a095-708433b23491")); + ModelUtil.addValue(record, userId, "6"); + ModelUtil.addValue(record, userName, "BLAKE"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("aeaad211-b62e-4a35-b410-d107753469e9")); + ModelUtil.addValue(record, userId, "7"); + ModelUtil.addValue(record, userName, "CLARK"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("8c7c220d-ff7f-48c4-9ce7-1395ed1816fa")); + ModelUtil.addValue(record, userId, "8"); + ModelUtil.addValue(record, userName, "SCOTT"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaDetail() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("5a6604ce-6ed2-4542-b009-2a3264b0946a")); + ModelUtil.addValue(record, detailId, ID_1); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_1); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("db883c9c-b7d3-44f4-88ba-d9753eeae58a")); + ModelUtil.addValue(record, detailId, ID_2); + ModelUtil.addValue(record, detailOrderId, ID_1); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("04e92727-483c-42ad-b671-c1e4661c1844")); + ModelUtil.addValue(record, detailId, ID_3); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "2"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f5147476-8bc6-4656-9d0c-fd883a24a18c")); + ModelUtil.addValue(record, detailId, ID_4); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_3); + ModelUtil.addValue(record, detailQuantity, "6"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d849f188-9940-4ecc-98a8-868dac5b3b4e")); + ModelUtil.addValue(record, detailId, "5"); + ModelUtil.addValue(record, detailOrderId, ID_2); + ModelUtil.addValue(record, detailItemId, ID_4); + ModelUtil.addValue(record, detailQuantity, "12"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2abef8cc-bfb7-4565-ba4e-afca3bf98811")); + ModelUtil.addValue(record, detailId, "6"); + ModelUtil.addValue(record, detailOrderId, ID_3); + ModelUtil.addValue(record, detailItemId, ID_2); + ModelUtil.addValue(record, detailQuantity, "1"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaItem() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("5fd803d4-5a05-496b-813e-6399955a79bb")); + ModelUtil.addValue(record, itemId, ID_1); + ModelUtil.addValue(record, itemName, "ダイヤモンド"); + ModelUtil.addValue(record, itemPrice, "100000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d59e426b-e5ed-433e-8d5a-e748dc75af60")); + ModelUtil.addValue(record, itemId, ID_2); + ModelUtil.addValue(record, itemName, "エメラルド"); + ModelUtil.addValue(record, itemPrice, "75000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("59e0a554-162a-4c48-b13d-1dda7fc936e0")); + ModelUtil.addValue(record, itemId, ID_3); + ModelUtil.addValue(record, itemName, "ルビー"); + ModelUtil.addValue(record, itemPrice, "30000"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("1c86858f-1e8b-4fc5-807f-f0548e1811e4")); + ModelUtil.addValue(record, itemId, ID_4); + ModelUtil.addValue(record, itemName, "サファイヤ"); + ModelUtil.addValue(record, itemPrice, "10000"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaOrder() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("2bdf3969-c2e5-4e3e-a939-2907ca3a5b6a")); + ModelUtil.addValue(record, orderId, ID_1); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:11:22"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("cca67c6f-a3b2-4b43-a466-be72ccd66e8f")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_3); + ModelUtil.addValue(record, orderDate, "2009-01-23 00:22:33"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("1f74ab8a-3191-464b-89c3-f4f3dddb8ce8")); + ModelUtil.addValue(record, orderId, ID_2); + ModelUtil.addValue(record, orderUserId, ID_2); + ModelUtil.addValue(record, orderDate, "2009-01-24 00:33:44"); + result.add(record); + + return result; + } + + private List<RecordModel> createDataSetJaUser() { + List<RecordModel> result = new ArrayList<RecordModel>(); + + RecordModel record = factory.newModel(RecordModel.class, uuid.get("25288a67-b4c7-4296-8113-835afeb15c9d")); + ModelUtil.addValue(record, userId, ID_1); + ModelUtil.addValue(record, userName, "鈴木 茂"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); + ModelUtil.addValue(record, userId, ID_2); + ModelUtil.addValue(record, userName, "内海 透"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); + ModelUtil.addValue(record, userId, ID_3); + ModelUtil.addValue(record, userName, "村瀬 武彦"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); + ModelUtil.addValue(record, userId, ID_4); + ModelUtil.addValue(record, userName, "近藤 美樹"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("2f09b9fe-78fd-4f8a-abf2-f077040f45f2")); + ModelUtil.addValue(record, userId, "5"); + ModelUtil.addValue(record, userName, "榊 美子"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("e3431be3-462c-4419-a2a0-e821597490cc")); + ModelUtil.addValue(record, userId, "6"); + ModelUtil.addValue(record, userName, "三浦 佑"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("c50a3e24-dd00-4969-aae9-69cf9be7f035")); + ModelUtil.addValue(record, userId, "7"); + ModelUtil.addValue(record, userName, "前島 孝幸"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("890bf55f-8bfd-420c-a9df-801da73bc46d")); + ModelUtil.addValue(record, userId, "8"); + ModelUtil.addValue(record, userName, "島崎 由比"); + result.add(record); + + return result; + } + + private void createTableDetail() { + tableDetail = factory.newModel(TableModel.class, uuid.get("5705ed1a-f329-4f21-9956-94caf4863fba")); + tableDetail.setName("T_DETAIL"); + tableDetail.setLogicalName("明細"); + tableDetail.setDescription("明細テーブルです。"); + + detailId = factory.newModel(ColumnModel.class, uuid.get("d3571020-4e1b-4158-958d-b5460fa6c32c")); + detailId.setName("ID"); + if (instruction.supressUseDomain) { + detailId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + detailId.setDataType(ref); + } + detailId.setLogicalName("ユーザID"); + tableDetail.getAttributes().add(detailId); + + detailOrderId = factory.newModel(ColumnModel.class, uuid.get("a28c64c6-b379-41a4-9563-b774f5bce165")); + detailOrderId.setName("ORDER_ID"); + detailOrderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailOrderId); + + detailItemId = factory.newModel(ColumnModel.class, uuid.get("b4d50786-3b3e-4557-baa3-b739159f0530")); + detailItemId.setName("ITEM_ID"); + detailItemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailItemId); + + detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); + detailQuantity.setName("QUANTITY"); + detailQuantity.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + tableDetail.getAttributes().add(detailQuantity); + + detailPk = factory.newModel(PrimaryKey.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); + detailPk.getKeyColumns().add(factory.newReference(detailId)); + tableDetail.getAttributes().add(detailPk); + + for (ColumnModel columnModel : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableItem() { + tableItem = factory.newModel(TableModel.class, uuid.get("7ecf5ba1-e80c-472c-b19b-bef2649d7974")); + tableItem.setName("T_ITEM"); + tableItem.setBeginScript("/* test begin script of T_ITEM */"); + tableItem.setEndScript("/* test end script of T_ITEM */"); + tableItem.setDescription("商品マスタです。"); + + itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); + itemId.setName("ID"); + if (instruction.supressUseDomain) { + itemId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + itemId.setDataType(ref); + } + itemId.setLogicalName("商品ID"); + tableItem.getAttributes().add(itemId); + + itemName = factory.newModel(ColumnModel.class, uuid.get("5c9b38e1-2cc9-45f9-ad3f-20b02471cc40")); + itemName.setName("NAME"); + BuiltinDataType itemNameDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + itemNameDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + itemName.setDataType(itemNameDataType); + itemName.setLogicalName("商品名"); + itemName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableItem.getAttributes().add(itemName); + + itemPrice = factory.newModel(ColumnModel.class, uuid.get("7a0cabe3-d382-4e5d-845b-dadd1b637a5f")); + itemPrice.setName("PRICE"); + BuiltinDataType itemPriceDataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + itemPriceDataType.getAdapter(SizedDataTypeAdapter.class).setSize(20); + itemPrice.setDataType(itemPriceDataType); + itemPrice.setLogicalName("価格"); + tableItem.getAttributes().add(itemPrice); + + itemPk = factory.newModel(PrimaryKey.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); + itemPk.getKeyColumns().add(factory.newReference(itemId)); + tableItem.getAttributes().add(itemPk); + + for (ColumnModel columnModel : Arrays.asList(itemName, itemPrice)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableOrder() { + tableOrder = factory.newModel(TableModel.class, uuid.get("cefee0d9-d23f-441b-986a-66660354ec74")); + tableOrder.setName("T_ORDER"); + tableOrder.setLogicalName("注文"); + tableOrder.setDescription("注文テーブルです。"); + + orderId = factory.newModel(ColumnModel.class, uuid.get("b647212a-4d8f-4d18-88e4-5397e54ebe67")); + orderId.setName("ID"); + if (instruction.supressUseDomain) { + orderId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + orderId.setDataType(ref); + } + orderId.setLogicalName("注文ID"); + tableOrder.getAttributes().add(orderId); + + orderUserId = factory.newModel(ColumnModel.class, uuid.get("db7a2f62-9658-406a-9dc1-8b90ae2da47c")); + orderUserId.setName("USER_ID"); + orderUserId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + orderUserId.setLogicalName("オーダーユーザID"); + tableOrder.getAttributes().add(orderUserId); + + orderDate = factory.newModel(ColumnModel.class, uuid.get("4ce761b0-137b-4105-ad2a-2efcba5e6bc4")); + orderDate.setName("ORDER_DATE"); + orderDate.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.TIMESTAMP)); + tableOrder.getAttributes().add(orderDate); + + orderPk = factory.newModel(PrimaryKey.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); + orderPk.getKeyColumns().add(factory.newReference(orderId)); + tableOrder.getAttributes().add(orderPk); + + for (ColumnModel columnModel : Arrays.asList(orderUserId, orderDate)) { + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + columnModel.setNotNullConstraint(notNull); + } + } + + private void createTableUser() { + tableUser = factory.newModel(TableModel.class, uuid.get("0802ef7b-b2da-4fc4-8104-0c99a1e472d5")); + tableUser.setName("T_USER"); + tableUser.setLogicalName("ユーザ"); + tableUser.setDescription("ユーザマスタです。"); + + userId = factory.newModel(ColumnModel.class, uuid.get("6b022a79-45a6-4be4-9d3d-cfb27042a08e")); + userId.setName("ID"); + if (instruction.supressUseDomain) { + userId.setDataType(ModelUtil.createDataType(jiemamy, DataTypeCategory.INTEGER)); + } else { + DomainRef ref = factory.newReference(idDomain); + userId.setDataType(ref); + } + userId.setLogicalName("ユーザID"); + tableUser.getAttributes().add(userId); + + userName = factory.newModel(ColumnModel.class, uuid.get("dacc68d2-fe32-4f4b-8082-9d55232ba7da")); + userName.setName("NAME"); + if (instruction.supressUseDomain) { + BuiltinDataType dataType = ModelUtil.createDataType(jiemamy, DataTypeCategory.VARCHAR); + dataType.getAdapter(SizedDataTypeAdapter.class).setSize(32); + userName.setDataType(dataType); + } else { + DomainRef ref = factory.newReference(nameDomain); + userName.setDataType(ref); + } + userName.setLogicalName("ユーザ名"); + userName.setDefaultValue("no name"); + userName.getAdapter(RepresentationAdapter.class).setRepresentation(true); + tableUser.getAttributes().add(userName); + + userPk = factory.newModel(PrimaryKey.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); + userPk.getKeyColumns().add(factory.newReference(userId)); + tableUser.getAttributes().add(userPk); + + NotNullConstraint notNull = factory.newModel(NotNullConstraint.class); + userName.setNotNullConstraint(notNull); + } +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/Instruction.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/Instruction.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/Instruction.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,37 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/23 + * + * 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.internal.test; + +/** + * {@link CoreTestModelBuilder}等に対する指示クラス。 + * + * @author daisuke + */ +public class Instruction { + + /** ドメインを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseDomain; + + /** 外部キーを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseForeignKey; + + /** DataSetを使用しない場合は{@code true}、そうでない場合は{@code false}を設定する */ + public boolean supressUseDataSet; + +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ModelUtil.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ModelUtil.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ModelUtil.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,244 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/06 + * + * 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.internal.test; + +import java.util.List; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.BuiltinDataTypeMold; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.exception.ElementNotFoundException; +import org.jiemamy.exception.TooManyElementsException; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.constraint.ForeignKey; +import org.jiemamy.model.attribute.constraint.PrimaryKey; +import org.jiemamy.model.attribute.constraint.UniqueKey; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.utils.CollectionsUtil; + +/** + * TODO for daisuke + * + * @author daisuke + */ +final class ModelUtil { + + static void addValue(RecordModel recordModel, ColumnModel columnModel, String value) { + Validate.notNull(recordModel); + Validate.notNull(columnModel); + + JiemamyFactory factory = columnModel.getJiemamy().getFactory(); + ColumnRef ref = factory.newReference(columnModel); + recordModel.getValues().put(ref, value); + } + + static BuiltinDataType createDataType(Jiemamy jiemamy, DataTypeCategory category) { + JiemamyFactory factory = jiemamy.getFactory(); + RootModel rootModel = factory.getRootModel(); + try { + Dialect dialect = jiemamy.getDialect(rootModel); + BuiltinDataTypeMold mold = dialect.findDataTypeMold(category); + return factory.newDataType(mold); + } catch (ClassNotFoundException e) { + throw new UnexpectedConditionError("", e); // TODO doc + } + } + + /** + * 指定した型を持つ属性を取得する。 + * + * @param <T> 属性の型 + * @param tableModel 対象のテーブル + * @param clazz 属性の型 + * @param columnAttr カラム属性も検索対象とする場合は{@code true}、そうでない場合は{@code false} + * @return 属性 + * @throws TooManyElementsException 複数の属性が見つかった場合 + * @throws ElementNotFoundException 属性が見つからなかった場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static <T extends AttributeModel>T getAttribute(TableModel tableModel, Class<T> clazz, boolean columnAttr) { + List<T> attributes = getAttributes(tableModel, clazz, columnAttr); + if (attributes.size() == 0) { + throw new ElementNotFoundException(tableModel, clazz); + } else if (attributes.size() > 1) { + throw new TooManyElementsException(tableModel, clazz, attributes); + } + return attributes.get(0); + } + + /** + * 指定した型を持つ属性のリストを取得する。 + * + * @param <T> 属性の型 + * @param tableModel 対象のテーブル + * @param clazz 検索する型 + * @return 属性のリスト + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static <T extends AttributeModel>List<T> getAttributes(TableModel tableModel, Class<T> clazz) { + return getAttributes(tableModel, clazz, false); + } + + /** + * 属性のうち、指定した型を持つもののリストを取得する。 + * + * @param <T> 対象属性の型 + * @param tableModel 対象のテーブル + * @param clazz 対象属性の型 + * @param columnAttr カラムに付随するモデルも対象とする場合は{@code true}、そうでない場合は{@code false} + * @return 属性のリスト + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static <T extends AttributeModel>List<T> getAttributes(TableModel tableModel, Class<T> clazz, boolean columnAttr) { + Validate.notNull(tableModel); + Validate.notNull(clazz); + + List<T> result = CollectionsUtil.newArrayList(); + for (AttributeModel attribute : tableModel.getAttributes()) { + if (clazz.isAssignableFrom(attribute.getClass())) { + result.add(clazz.cast(attribute)); + } + if (columnAttr && attribute instanceof ColumnModel) { + ColumnModel columnModel = (ColumnModel) attribute; + UniqueKey uniqueKey = columnModel.getUniqueKey(); + if (uniqueKey != null && clazz.isAssignableFrom(uniqueKey.getClass())) { + result.add(clazz.cast(uniqueKey)); + } + PrimaryKey primaryKey = columnModel.getPrimaryKey(); + if (primaryKey != null && clazz.isAssignableFrom(primaryKey.getClass())) { + result.add(clazz.cast(primaryKey)); + } + // column chek と not null は attributeじゃないので処理しない + } + } + return result; + } + + /** + * テーブルから、指定した名前を持つカラムを取得する。 + * + * @param tableModel 検索対象のテーブル + * @param columnName カラム名 + * @return 見つかったカラム + * @throws TooManyElementsException 同名のカラムが複数見つかった場合 + * @throws ElementNotFoundException カラムが見つからなかった場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static ColumnModel getColumn(TableModel tableModel, String columnName) { + Validate.notNull(tableModel); + Validate.notNull(columnName); + + List<ColumnModel> columns = CollectionsUtil.newArrayList(); + for (ColumnModel columnModel : getAttributes(tableModel, ColumnModel.class)) { + if (columnName.equals(columnModel.getName())) { + columns.add(columnModel); + } + } + if (columns.size() == 0) { + throw new ElementNotFoundException(tableModel, columnName); + } else if (columns.size() > 1) { + throw new TooManyElementsException(tableModel, columnName, columns); + } + return columns.get(0); + } + + /** + * カラムのリストを取得する。 + * + * @param tableModel 対象のテーブル + * @return カラムのリスト + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static List<ColumnModel> getColumns(TableModel tableModel) { + return getAttributes(tableModel, ColumnModel.class); + } + + /** + * 指定した名前を持つエンティティを取得する。 + * + * <p>エンティティ名の大文字・小文字は区別されない。</p> + * + * @param <T> エンティティの種類を表すクラス + * @param rootModel 操作対象{@link RootModel} + * @param clazz エンティティの種類を表すクラス. {@code null}の場合、エンティティの種類を限定しないことを表す + * @param entityName エンティティ名 + * @return 見つかったエンティティ + * @throws TooManyElementsException 同名のエンティティが複数見つかった場合 + * @throws ElementNotFoundException エンティティが見つからなかった場合 + * @throws IllegalArgumentException 引数rootModel, entityNameに{@code null}を与えた場合 + */ + @SuppressWarnings("unchecked") + static <T extends EntityModel>T getEntity(RootModel rootModel, Class<T> clazz, String entityName) { + Validate.notNull(rootModel); + Validate.notNull(entityName); + + List<T> entities = CollectionsUtil.newArrayList(); + for (EntityModel entityModel : rootModel.getEntities()) { + if (entityName.equalsIgnoreCase(entityModel.getName()) + && (clazz == null || clazz.isAssignableFrom(entityModel.getClass()))) { + entities.add((T) entityModel); + } + } + if (entities.size() == 0) { + throw new ElementNotFoundException(rootModel, entityName); + } else if (entities.size() > 1) { + throw new TooManyElementsException(rootModel, entityName, entities); + } + return entities.get(0); + } + + /** + * 外部キー制約のリストを取得する。 + * + * @param tableModel 対象のテーブル + * @return 外部キー制約のリスト + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static List<ForeignKey> getForeignKeys(TableModel tableModel) { + return getAttributes(tableModel, ForeignKey.class); + } + + /** + * 主キーを取得する。 + * + * @param tableModel 対象のテーブル + * @return 主キー + * @throws TooManyElementsException 複数の主キーが見つかった場合 + * @throws ElementNotFoundException 主キーが存在しない場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + static PrimaryKey getPrimaryKey(TableModel tableModel) { + return getAttribute(tableModel, PrimaryKey.class, true); + } + + private ModelUtil() { + throw new UnexpectedConditionError("不到達ポイント"); + } +} Property changes on: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ModelUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ReflectionDialectProvider.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,50 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/10 + * + * 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.internal.test; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; + +import org.jiemamy.Jiemamy; +import org.jiemamy.dialect.Dialect; +import org.jiemamy.exception.UnexpectedConditionError; + +/** + * 相対パスから強引にDialectを取得するための、テスト用インスタンス取得戦略クラス。 + * @author daisuke + */ +public class ReflectionDialectProvider extends Jiemamy.DefaultInstanceProvider<Dialect> { + + /** + * インスタンスを生成する。 + */ + public ReflectionDialectProvider() { + try { + classLoader = new URLClassLoader(new URL[] { + new File("../jiemamy-dialect-mysql/target/classes").toURL(), + new File("../jiemamy-dialect-postgresql/target/classes").toURL(), + new File("../jiemamy-dialect-sql99/target/classes").toURL() + }); + } catch (MalformedURLException e) { + throw new UnexpectedConditionError("spell miss?", e); + } + } +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,36 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * 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.internal.test; + +import org.jiemamy.Jiemamy; + +/** + * テストモデルを構築するテスト用ロジックのインターフェイス。 + * + * @author daisuke + */ +public interface TestModelBuilder { + + /** + * モデルをビルドする。 + * + * @return ビルドしたモデルのJiemamyコンテキスト + */ + Jiemamy build(); +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelBuilders.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,77 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * 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.internal.test; + +import java.io.InputStream; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.CharEncoding; + +import org.jiemamy.Jiemamy; +import org.jiemamy.exception.UnexpectedConditionError; + +/** + * テスト用モデルの構築を行うビルダを供給するプロバイダ。 + * + * @author daisuke + */ +public enum TestModelBuilders { + + /** */ + EMP_DEPT(new CoreTestModelBuilder(newJiemamy()), getXml("/sample.xml")), + + /** */ + ORDER(new CoreTestModelBuilder2(newJiemamy()), getXml("/sample.xml")); + + private static String getXml(String path) { + InputStream in = TestModelBuilders.class.getResourceAsStream(path); + String xml; + try { + xml = IOUtils.toString(in, CharEncoding.UTF_8); + } catch (Exception e) { + throw new UnexpectedConditionError("リソースにアクセスできない", e); + } + return xml; + } + + private static Jiemamy newJiemamy() { + return Jiemamy.newInstance(new ReflectionDialectProvider()); + } + + + private final TestModelBuilder builder; + + private final String xml; + + + TestModelBuilders(TestModelBuilder builder, String xml) { + this.builder = builder; + this.xml = xml; + } + + /** + * TODO for daisuke + * + * @return + */ + public Jiemamy getBuiltModel() { + return builder.build(); + } + +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/TestModelsTestBase.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,55 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/04/04 + * + * 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.internal.test; + +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * {@link TestModelBuilder}で生成したモデルを使用してテストを行う為の基底クラス。 + * + * @author daisuke + */ +public abstract class TestModelsTestBase { + + private static Logger logger = LoggerFactory.getLogger(TestModelsTestBase.class); + + + /** + * テストを行う。 + * + * @param entry テストモデルのエントリ + * @throws Exception 例外が発生した場合 + */ + public abstract void doTest(TestModelBuilders entry) throws Exception; + + /** + * 全ての {@link TestModelBuilder}でテストを行うテストメソッド。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testAllEntries() throws Exception { + for (TestModelBuilders entry : TestModelBuilders.values()) { + logger.info("==== Test Model: " + entry.name()); + doTest(entry); + } + } +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/UuidStrategy.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/UuidStrategy.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/UuidStrategy.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,49 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/23 + * + * 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.internal.test; + +import java.util.UUID; + +/** + * テストモデルを組み立てる際、モデルIDをランダム生成するか、毎回固定で生成するかを決める戦略クラス。 + * + * @author daisuke + */ +public enum UuidStrategy { + + /** 固定 */ + FIXED { + + @Override + UUID get(String name) { + return UUID.fromString(name); + } + }, + + /** 都度生成 */ + GENERATE { + + @Override + UUID get(String name) { + return UUID.randomUUID(); + } + }; + + abstract UUID get(String name); +} Added: leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java =================================================================== --- leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java (rev 0) +++ leto/jiemamy-test-helper/trunk/trunk/src/main/java/org/jiemamy/internal/test/ViewTestModelBuilder.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,207 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/22 + * + * 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.internal.test; + +import java.util.List; + +import org.jiemamy.Jiemamy; +import org.jiemamy.OfficialSpecs; +import org.jiemamy.model.ConnectionProfile; +import org.jiemamy.model.DiagramPresentationModel; +import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.NodeProfile; +import org.jiemamy.model.connection.ConnectionAdapter; +import org.jiemamy.model.geometory.JmColor; +import org.jiemamy.model.geometory.JmPoint; +import org.jiemamy.model.geometory.JmRectangle; +import org.jiemamy.model.node.NodeAdapter; +import org.jiemamy.model.node.StickyModel; + +/** + * Jiemamy VIEW仕様範囲を含めたJiemamyテストモデル1(EMP-DEPTテーブル)を組み立てるビルダ。 + * + * @author daisuke + */ +public class ViewTestModelBuilder extends CoreTestModelBuilder { + + /** StickyModel for Test */ + protected StickyModel sticky; + + private static final int OFFSET = 50; + + + /** + * インスタンスを生成する。 + */ + public ViewTestModelBuilder() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + */ + public ViewTestModelBuilder(Instruction instruction) { + super(instruction); + } + + /** + * インスタンスを生成する。 + * + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(Instruction instruction, Jiemamy jiemamy) { + super(instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(Jiemamy jiemamy) { + super(jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + */ + public ViewTestModelBuilder(UuidStrategy uuid) { + super(uuid); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction) { + super(uuid, instruction); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param instruction 設定オブジェクト + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Instruction instruction, Jiemamy jiemamy) { + super(uuid, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid UUID生成ストラテジ + * @param jiemamy コンテキスト + */ + public ViewTestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { + super(uuid, jiemamy); + } + + @Override + public Jiemamy build() { + Jiemamy jiemamy = super.build(); + createPresentations(); + + return jiemamy; + } + + @Override + protected void createEntities() { + super.createEntities(); + if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { + sticky = factory.newModel(StickyModel.class, uuid.get("43beb884-2562-4480-8030-bb797f701783")); + sticky.setContents("メモーー"); + } + } + + private void createPresentations() { + if (factory.getSupportedSpecs().contains(OfficialSpecs.VIEW)) { + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + + // ダイアグラム表現の生成・追加(1) + DiagramPresentationModel presentation1 = + factory.newModel(DiagramPresentationModel.class, uuid.get("1deca0e8-6153-47ad-abe8-ac764f768d96")); + presentation1.setName("全部表示する"); + + NodeProfile empProfile = + factory.newModel(NodeProfile.class, uuid.get("aa7caa23-7958-4bd0-a356-8f09d4b74f08")); + presentation1.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), empProfile); + empProfile.setBoundary(new JmRectangle(360, 60)); + + NodeProfile deptProfile = + factory.newModel(NodeProfile.class, uuid.get("eb6506ef-4a25-4296-b6d7-c08741f19d5a")); + presentation1.getNodeProfiles().put(tableDept.getAdapter(NodeAdapter.class), deptProfile); + deptProfile.setBoundary(new JmRectangle(60, 60)); + + NodeProfile viewProfile = + factory.newModel(NodeProfile.class, uuid.get("2387bfd0-7106-44ad-a34e-24231bbea6d5")); + presentation1.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), viewProfile); + viewProfile.setBoundary(new JmRectangle(60, 270)); + + NodeProfile stickyProfile = + factory.newModel(NodeProfile.class, uuid.get("2689d193-52a1-4fd4-a14c-9857274518c5")); + presentation1.getNodeProfiles().put(sticky, stickyProfile); + stickyProfile.setBoundary(new JmRectangle(360, 270)); + stickyProfile.setColor(new JmColor(10, 11, 12)); + + ConnectionProfile connectionProfile1 = + factory.newModel(ConnectionProfile.class, uuid.get("366b547f-a2a6-42b2-a3a4-38745436c425")); + List<JmPoint> bendpoints = connectionProfile1.getBendpoints(); + NodeProfile nodeProf = presentation1.getNodeProfiles().get(tableEmp.getAdapter(NodeAdapter.class)); + JmRectangle boundary = nodeProf.getBoundary(); + bendpoints.add(0, new JmPoint(Math.max(boundary.x - OFFSET, 0), boundary.y)); + bendpoints.add(1, new JmPoint(boundary.x, Math.max(boundary.y - OFFSET, 0))); + presentation1.getConnectionProfiles().put(fkEmpEmp.getAdapter(ConnectionAdapter.class), connectionProfile1); + + ConnectionProfile connectionProfile2 = + factory.newModel(ConnectionProfile.class, uuid.get("e5b3d709-2aea-4e26-a90c-b8f438d2da9d")); + presentation1.getConnectionProfiles() + .put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile2); + diagramPresentations.add(presentation1); + + // ダイアグラム表現の生成・追加(2) + DiagramPresentationModel presentation2 = + factory.newModel(DiagramPresentationModel.class, uuid.get("53c7cdb7-1512-46c7-8ee3-aadec6007896")); + presentation2.setName("一部表示する"); + + NodeProfile nodeProfile1 = + factory.newModel(NodeProfile.class, uuid.get("d71ff015-101c-4669-8745-312d1da34efe")); + presentation2.getNodeProfiles().put(tableEmp.getAdapter(NodeAdapter.class), nodeProfile1); + nodeProfile1.setBoundary(new JmRectangle(60, 60)); + + NodeProfile nodeProfile2 = + factory.newModel(NodeProfile.class, uuid.get("2df7718f-d71e-4dbf-8327-e0ad36f03d5d")); + presentation2.getNodeProfiles().put(viewHighSal.getAdapter(NodeAdapter.class), nodeProfile2); + nodeProfile2.setBoundary(new JmRectangle(270, 270)); + + ConnectionProfile connectionProfile = + factory.newModel(ConnectionProfile.class, uuid.get("b615f111-5143-4b12-bfdb-9a06806a9ace")); + presentation2.getConnectionProfiles().put(fkEmpDept.getAdapter(ConnectionAdapter.class), connectionProfile); + diagramPresentations.add(presentation2); + } + } +} Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java 2009-04-06 11:24:58 UTC (rev 3140) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/Jiemamy.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -84,9 +84,34 @@ * <table style="border:1px solid black; border-collapse: collapse;"> * <tr> * <td style="border:1px solid black">{@link JiemamyFactory}で使用されるデフォルトのJiemamy実装</td> + * <td style="border:1px solid black">Artemis</td> + * </tr> + * <tr> + * <td style="border:1px solid black">デフォルトの{@link Dialect}プロバイダ</td> * <td style="border:1px solid black">引数に指定したもの</td> * </tr> + * </table> + * + * @param defaultDialectProvider {@link JiemamyFactory}で使用されるデフォルトの{@link Dialect}インスタンス取得戦略 + * @return Jiemamyインスタンス + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + * @since 0.2 + */ + public static Jiemamy newInstance(InstanceProvider<Dialect> defaultDialectProvider) { + return new Jiemamy(findDefaultImplementation(), defaultDialectProvider); + } + + /** + * Jiemamyインスタンスを生成する。 + * + * <p>このメソッドで初期化を行った場合、各動作のデフォルトは下記の通りとなる。</p> + * + * <table style="border:1px solid black; border-collapse: collapse;"> * <tr> + * <td style="border:1px solid black">{@link JiemamyFactory}で使用されるデフォルトのJiemamy実装</td> + * <td style="border:1px solid black">引数に指定したもの</td> + * </tr> + * <tr> * <td style="border:1px solid black">デフォルトの{@link Dialect}プロバイダ</td> * <td style="border:1px solid black">{@link DefaultInstanceProvider}</td> * </tr> Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java 2009-04-06 11:24:58 UTC (rev 3140) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -133,7 +133,7 @@ /** * 鋳型情報から、新しい{@link DataType}型のインスタンスを生成する。 * - * @param <T> + * @param <T> データ型の型 * @param mold 鋳型情報 * @return {@link DataType}型のインスタンス * @throws IllegalImplementationException moldに不正なアダプタが登録されている場合 Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,89 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/26 + * + * 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.model.attribute; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; + +/** + * 代表カラムかどうかを表すアラプタ。 + * + * <p>例えばEMP, DEPTテーブルがあり、EMPがDEPTを外部キー参照しているとする。 + * EMPのINSERT文用データを入力中に、ユーザは「DEPT_ID = 3 の部署」ではなく「経理部」をイメージするのが自然である。 + * SQL的には 3 を出力すべきだが、入力・選択は「経理部」で行いたい。このように、DEPTテーブルを代表するカラムを代表カラムと呼ぶ。</p> + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class RepresentationAdapter { + + private Boolean representation; + + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final RepresentationAdapter other = (RepresentationAdapter) obj; + if (representation == null) { + if (other.representation != null) { + return false; + } + } else if (!representation.equals(other.representation)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((representation == null) ? 0 : representation.hashCode()); + return result; + } + + /** + * 代表カラムかどうかを取得する。 + * @return 代表カラムかどうか + */ + public Boolean isRepresentation() { + return representation; + } + + /** + * 代表カラムかどうかを設定する。 + * @param representation 代表カラムかどうか + */ + public void setRepresentation(Boolean representation) { + this.representation = representation; + } + + @Override + public String toString() { + return "RepresentationAdapter[" + representation + "]"; + } +} Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,141 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/07/20 + * + * 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.model.datatype.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; +import org.jiemamy.model.datatype.DataTypeAdapter; + +/** + * 精度とスケールを持つDataType用のアダプタ。 + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class PrecisionedDataTypeAdapter implements DataTypeAdapter { + + /** 精度 */ + private Integer precision; + + /** スケール */ + private Integer scale; + + + public void copy(DataTypeAdapter src) { + if (src == null) { + throw new IllegalArgumentException("The validated object is null"); + } + if (src instanceof PrecisionedDataTypeAdapter) { + precision = ((PrecisionedDataTypeAdapter) src).precision; + scale = ((PrecisionedDataTypeAdapter) src).scale; + } else { + throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() + + ")"); + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PrecisionedDataTypeAdapter other = (PrecisionedDataTypeAdapter) obj; + if (precision == null) { + if (other.precision != null) { + return false; + } + } else if (!precision.equals(other.precision)) { + return false; + } + if (scale == null) { + if (other.scale != null) { + return false; + } + } else if (!scale.equals(other.scale)) { + return false; + } + return true; + } + + /** + * 精度を取得する。 + * + * @return 精度 + */ + public Integer getPrecision() { + return precision; + } + + /** + * スケールを取得する。 + * + * @return スケール + */ + public Integer getScale() { + return scale; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((precision == null) ? 0 : precision.hashCode()); + result = prime * result + ((scale == null) ? 0 : scale.hashCode()); + return result; + } + + /** + * 精度を設定する。 + * + * @param precision 精度 + */ + public void setPrecision(Integer precision) { + this.precision = precision; + } + + /** + * スケールを設定する。 + * + * @param scale スケール + */ + public void setScale(Integer scale) { + this.scale = scale; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (precision != null) { + sb.append("("); + sb.append(precision); + if (scale != null) { + sb.append(", "); + sb.append(scale); + } + sb.append(")"); + } + return sb.toString(); + } +} Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,97 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/10 + * + * 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.model.datatype.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; +import org.jiemamy.model.datatype.DataTypeAdapter; + +/** + * シリアル(通し番号)型であることを表すアダプタ。 + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class SerialDataTypeAdapter implements DataTypeAdapter { + + /** シリアル(通し番号)型であるどうか */ + private Boolean serial; + + + public void copy(DataTypeAdapter src) { + // nothing to do + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SerialDataTypeAdapter other = (SerialDataTypeAdapter) obj; + if (serial == null) { + if (other.serial != null) { + return false; + } + } else if (!serial.equals(other.serial)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((serial == null) ? 0 : serial.hashCode()); + return result; + } + + /** + * シリアル(通し番号)型であるどうかを取得する。 + * + * @return シリアル(通し番号)型であれば{@code true} + */ + public Boolean isSerial() { + return serial; + } + + /** + * シリアル(通し番号)型であるどうかを設定する。 + * + * @param serial シリアル(通し番号)型であるどうか + */ + public void setSerial(Boolean serial) { + this.serial = serial; + } + + @Override + public String toString() { + if (serial != null && serial) { + return "SERIAL"; + } + return ""; + } + +} Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,106 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/07/20 + * + * 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.model.datatype.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; +import org.jiemamy.model.datatype.DataTypeAdapter; + +/** + * サイズを持つDataType用のアダプタ。 + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class SizedDataTypeAdapter implements DataTypeAdapter { + + /** サイズ */ + private Integer size; + + + public void copy(DataTypeAdapter src) { + if (src == null) { + throw new IllegalArgumentException("The validated object is null"); + } + if (src instanceof SizedDataTypeAdapter) { + size = ((SizedDataTypeAdapter) src).size; + } else { + throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() + + ")"); + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SizedDataTypeAdapter other = (SizedDataTypeAdapter) obj; + if (size == null) { + if (other.size != null) { + return false; + } + } else if (!size.equals(other.size)) { + return false; + } + return true; + } + + /** + * サイズを取得する。 + * + * @return サイズ + */ + public Integer getSize() { + return size; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((size == null) ? 0 : size.hashCode()); + return result; + } + + /** + * サイズを設定する。 + * + * @param size サイズ + */ + public void setSize(Integer size) { + this.size = size; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (size != null) { + sb.append("("); + sb.append(size); + sb.append(")"); + } + return sb.toString(); + } +} Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,107 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/07/20 + * + * 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.model.datatype.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; +import org.jiemamy.model.datatype.DataTypeAdapter; + +/** + * タイムゾーン管理の有無を持つDataType用のアダプタ。 + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class TimezonedDataTypeAdapter implements DataTypeAdapter { + + /** タイムゾーンを管理するかどうか */ + private Boolean withTimezone; + + + public void copy(DataTypeAdapter src) { + if (src == null) { + throw new IllegalArgumentException("The validated object is null"); + } + if (src instanceof TimezonedDataTypeAdapter) { + withTimezone = ((TimezonedDataTypeAdapter) src).withTimezone; + } else { + throw new IllegalArgumentException(src.getClass().toString() + " (expected is " + this.getClass().getName() + + ")"); + } + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final TimezonedDataTypeAdapter other = (TimezonedDataTypeAdapter) obj; + if (withTimezone == null) { + if (other.withTimezone != null) { + return false; + } + } else if (!withTimezone.equals(other.withTimezone)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((withTimezone == null) ? 0 : withTimezone.hashCode()); + return result; + } + + /** + * タイムゾーンを管理するかどうかを取得する。 + * + * @return 精度 + */ + public Boolean isWithTimezone() { + return withTimezone; + } + + /** + * タイムゾーンを管理するかどうかを設定する。 + * + * @param withTimezone 精度 + */ + public void setWithTimezone(Boolean withTimezone) { + this.withTimezone = withTimezone; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (withTimezone != null) { + sb.append(" "); + sb.append(withTimezone ? "WITH" : "WITHOUT"); + sb.append(" TIMEZONE"); + } + return sb.toString(); + } +} Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/package-info.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/package-info.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/package-info.java 2009-04-06 17:15:35 UTC (rev 3141) @@ -0,0 +1,9 @@ +/** + * Jiemamyモデルの「データ型」に対する基本的なアダプタの実装を提供するパッケージ。 + * + * <p>このパッケージは、データ型に対する拡張を行うアダプタクラスを含む。</p> + * + * @author daisuke + */ +package org.jiemamy.model.datatype.adapter; + Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-04-06 11:24:58 UTC (rev 3140) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-04-06 17:15:35 UTC (rev 3141) @@ -11,7 +11,7 @@ <dataType> <typeCategory>INTEGER</typeCategory> <typeName>INTEGER</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SerialDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter"> <serial>true</serial> </adapter> </dataType> @@ -27,7 +27,7 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>32</size> </adapter> </dataType> @@ -64,7 +64,7 @@ <dataType ref="62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7"/> <defaultValue>no name</defaultValue> <notNull id="41f178b9-2cb5-4dad-a6c0-48df2d5b1300"/> - <adapter class="org.jiemamy.internal.model.attribute.RepresentationAdapter"> + <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> <representation>true</representation> </adapter> </column> @@ -89,7 +89,7 @@ <dataType> <typeCategory>NUMERIC</typeCategory> <typeName>NUMERIC</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.PrecisionedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter"> <precision>7</precision> <scale>2</scale> </adapter> @@ -179,12 +179,12 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>20</size> </adapter> </dataType> <notNull id="fab2f883-0489-4661-bd57-f04286188eef"/> - <adapter class="org.jiemamy.internal.model.attribute.RepresentationAdapter"> + <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> <representation>true</representation> </adapter> </column> @@ -194,7 +194,7 @@ <dataType> <typeCategory>VARCHAR</typeCategory> <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.internal.model.datatype.adapter.SizedDataTypeAdapter"> + <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> <size>20</size> </adapter> </dataType>