svnno****@sourc*****
svnno****@sourc*****
2009年 2月 2日 (月) 16:09:11 JST
Revision: 2598 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2598 Author: daisuke_m Date: 2009-02-02 16:09:11 +0900 (Mon, 02 Feb 2009) Log Message: ----------- TestModelBuilderの配置を修正。 Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/.project artemis/trunk/jiemamy-artemis-test/pom.xml artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java artemis/trunk/jiemamy-composer/.project artemis/trunk/jiemamy-composer/pom.xml artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ForeignKeyValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java artemis/trunk/jiemamy-dialect-mysql/.project artemis/trunk/jiemamy-dialect-mysql/pom.xml artemis/trunk/jiemamy-dialect-postgresql/.project artemis/trunk/jiemamy-dialect-postgresql/pom.xml artemis/trunk/jiemamy-dialect-sql99/pom.xml artemis/trunk/jiemamy-event/.project artemis/trunk/jiemamy-event/pom.xml artemis/trunk/jiemamy-view/.project artemis/trunk/jiemamy-view/pom.xml Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/AllValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/AllValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/Instruction.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder2.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/UuidStrategy.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/test/ Removed Paths: ------------- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/Instruction.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/UuidStrategy.java artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/test/ -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/.project =================================================================== --- artemis/trunk/jiemamy-artemis-test/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-artemis-test/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-artemis-test/pom.xml =================================================================== --- artemis/trunk/jiemamy-artemis-test/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-artemis-test/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -56,13 +56,6 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> <artifactId>jiemamy-event</artifactId> <version>${project.version}</version> </dependency> @@ -73,13 +66,6 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-view</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> - <dependency> - <groupId>${project.groupId}</groupId> <artifactId>jiemamy-dialect-postgresql</artifactId> <version>${project.version}</version> </dependency> Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/serializer/SerializationTest.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -50,9 +50,12 @@ import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.test.AllValidator; import org.jiemamy.test.ViewTestModelBuilder; import org.jiemamy.utils.model.EqualsUtil; import org.jiemamy.utils.model.RootModelUtil; +import org.jiemamy.validator.Problem; +import org.jiemamy.validator.Validator; /** * モデルのシリアライズ全体のテスト。 @@ -170,15 +173,20 @@ Jiemamy jiemamy2 = Jiemamy.newInstance(new Artemis(new ArtemisView())); JiemamySerializer serializer1 = jiemamy1.getSerializer(); JiemamySerializer serializer2 = jiemamy2.getSerializer(); + Validator validator = new AllValidator(); new ViewTestModelBuilder(jiemamy1).build(); RootModel rootModel1 = jiemamy1.getFactory().getRootModel(); + Collection<Problem> problems1 = validator.validate(rootModel1); + assertThat(problems1.size(), is(0)); // 一応バリデーションを行っておく // rootModel1 -> xml1 String xml1 = convertRootModelToXml(serializer1, rootModel1); // xml1 -> rootModel2 RootModel rootModel2 = convertXmlToRootModel(xml1, serializer2); + Collection<Problem> problems2 = validator.validate(rootModel2); + assertThat(problems2.size(), is(0)); // 一応バリデーションを行っておく // rootModel2 -> xml2 String xml2 = convertRootModelToXml(serializer2, rootModel2); @@ -200,17 +208,22 @@ Jiemamy jiemamy2 = Jiemamy.newInstance(new Artemis(new ArtemisView())); JiemamySerializer serializer1 = jiemamy1.getSerializer(); JiemamySerializer serializer2 = jiemamy2.getSerializer(); + Validator validator = new AllValidator(); String xml1 = IOUtils.toString(SerializationTest.class.getResourceAsStream("/sample.xml"), CharEncoding.UTF_8); // xml1 -> rootModel1 RootModel rootModel1 = convertXmlToRootModel(xml1, serializer1); + Collection<Problem> problems1 = validator.validate(rootModel1); + assertThat(problems1.size(), is(0)); // 一応バリデーションを行っておく // rootModel1 -> xml2 String xml2 = convertRootModelToXml(serializer2, rootModel1); // xml1 -> rootModel2 RootModel rootModel2 = convertXmlToRootModel(xml2, serializer2); + Collection<Problem> problems2 = validator.validate(rootModel2); + assertThat(problems2.size(), is(0)); // 一応バリデーションを行っておく // 参考のため、targetディレクトリに出力XMLを記録 FileUtils.writeStringToFile(new File("./target/" + ClassUtils.getShortClassName(this, "null") + "_2_xml1.xml"), Modified: artemis/trunk/jiemamy-composer/.project =================================================================== --- artemis/trunk/jiemamy-composer/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-composer/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-composer/pom.xml =================================================================== --- artemis/trunk/jiemamy-composer/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-composer/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -105,13 +105,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site> Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/AllValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/AllValidator.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/AllValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,56 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/02 + * + * 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; + +import java.util.List; + +import org.jiemamy.validator.CompositeValidator; +import org.jiemamy.validator.Validator; +import org.jiemamy.validator.impl.ColumnValidator; +import org.jiemamy.validator.impl.EntityNameCollisionValidator; +import org.jiemamy.validator.impl.ForeignKeyValidator; +import org.jiemamy.validator.impl.IdCollisionValidator; +import org.jiemamy.validator.impl.InstanceCollisionValidator; +import org.jiemamy.validator.impl.InstanceSpaceValidator; +import org.jiemamy.validator.impl.KeyConstraintValidator; +import org.jiemamy.validator.impl.PrimaryKeyValidator; +import org.jiemamy.validator.impl.ReferenceValidator; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class AllValidator extends CompositeValidator { + + public AllValidator() { + List<Validator> validators = getValidators(); + validators.add(new ColumnValidator()); + validators.add(new EntityNameCollisionValidator()); + validators.add(new ForeignKeyValidator()); + validators.add(new IdCollisionValidator()); + validators.add(new InstanceCollisionValidator()); + validators.add(new InstanceSpaceValidator()); + validators.add(new KeyConstraintValidator()); + validators.add(new PrimaryKeyValidator()); + validators.add(new ReferenceValidator()); + + } + +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/AllValidator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/AllValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/AllValidator.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/AllValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,58 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/02 + * + * 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.test; + +import java.util.List; + +import org.jiemamy.validator.CompositeValidator; +import org.jiemamy.validator.Validator; +import org.jiemamy.validator.impl.ColumnValidator; +import org.jiemamy.validator.impl.EntityNameCollisionValidator; +import org.jiemamy.validator.impl.ForeignKeyValidator; +import org.jiemamy.validator.impl.IdCollisionValidator; +import org.jiemamy.validator.impl.InstanceCollisionValidator; +import org.jiemamy.validator.impl.InstanceSpaceValidator; +import org.jiemamy.validator.impl.KeyConstraintValidator; +import org.jiemamy.validator.impl.PrimaryKeyValidator; +import org.jiemamy.validator.impl.ReferenceValidator; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public class AllValidator extends CompositeValidator { + + /** + * インスタンスを生成する。 + * + */ + public AllValidator() { + List<Validator> validators = getValidators(); + validators.add(new ColumnValidator()); + validators.add(new EntityNameCollisionValidator()); + validators.add(new ForeignKeyValidator()); + validators.add(new IdCollisionValidator()); + validators.add(new InstanceCollisionValidator()); + validators.add(new InstanceSpaceValidator()); + validators.add(new KeyConstraintValidator()); + validators.add(new PrimaryKeyValidator()); + validators.add(new ReferenceValidator()); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/AllValidator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/Instruction.java (from rev 2597, artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/Instruction.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/Instruction.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/Instruction.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,19 @@ +package org.jiemamy.test; + +/** + * {@link TestModelBuilder}等に対する指示クラス。 + * + * @author daisuke + */ +public class Instruction { + + /** ドメインを使用しない場合は{@code true}を設定する */ + public boolean supressUseDomain; + + /** 外部キーを使用しない場合は{@code true}を設定する */ + public boolean supressUseForeignKey; + + /** DataSetを使用しない場合は{@code true}を設定する */ + public boolean supressUseDataSet; + +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/Instruction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java (from rev 2597, artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,725 @@ +/* + * 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.test; + +import java.sql.Types; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.exception.JiemamyRuntimeException; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.RepresentationAdapter; +import org.jiemamy.model.attribute.constraint.CheckConstraintModel; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; +import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.builder.DataTypeBuilder; +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 TestModelBuilder { + + 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 PrimaryKeyModel 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 PrimaryKeyModel empPk; + + // highSal + + /** 生成したモデル */ + public ViewModel viewHighSal; + + // fk + + /** 生成したモデル */ + public ForeignKeyModel fkEmpEmp; + + /** 生成したモデル */ + public ForeignKeyModel fkEmpDept; + + + /** + * インスタンスを生成する。 + */ + public TestModelBuilder() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction + */ + public TestModelBuilder(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction + * @param jiemamy + */ + public TestModelBuilder(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy + */ + public TestModelBuilder(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + */ + public TestModelBuilder(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param instruction + */ + public TestModelBuilder(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param instruction + * @param jiemamy + */ + public TestModelBuilder(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 JiemamyRuntimeException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param jiemamy + */ + public TestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * モデルをビルドする。 + */ + public void build() { + rootModel.setDialectClassName(DIALECT_CLASS_NAME); + rootModel.setBeginScript("BEGIN;"); + rootModel.setEndScript("COMMIT;"); + rootModel.setDescription("Jiemamyテストモデル1"); + rootModel.setSchemaName("FOO"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + } + + /** + * ビルドしたモデルを持つ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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + NotNullConstraintModel notNull = + factory.newModel(NotNullConstraintModel.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); + domainId.getConstraints().add(notNull); + CheckConstraintModel check = + factory.newModel(CheckConstraintModel.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); + check.setName("hoge"); + check.setExpression("VALUE > 0"); + domainId.getConstraints().add(check); + domainId.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 DataTypeBuilder(factory, Types.VARCHAR, "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; + } + + fkEmpEmp = factory.newModel(ForeignKeyModel.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.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); + fkEmpEmp.setDeferrability(deferrability); + tableEmp.getAttributes().add(fkEmpEmp); + + fkEmpDept = factory.newModel(ForeignKeyModel.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(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, "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, "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, "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, "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, "1"); + RecordUtil.addValue(record, empEmpNo, "10"); + RecordUtil.addValue(record, empEmpName, "SMITH"); + RecordUtil.addValue(record, empMgrId, "3"); + RecordUtil.addValue(record, empHiredate, "2003-02-01"); + RecordUtil.addValue(record, empSal, "40"); + RecordUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); + RecordUtil.addValue(record, empId, "2"); + RecordUtil.addValue(record, empEmpNo, "20"); + RecordUtil.addValue(record, empEmpName, "ALLEN"); + RecordUtil.addValue(record, empMgrId, "3"); + RecordUtil.addValue(record, empHiredate, "2000-03-04"); + RecordUtil.addValue(record, empSal, "50"); + RecordUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); + RecordUtil.addValue(record, empId, "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, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); + RecordUtil.addValue(record, empId, "4"); + RecordUtil.addValue(record, empEmpNo, "40"); + RecordUtil.addValue(record, empEmpName, "JONES"); + RecordUtil.addValue(record, empMgrId, "2"); + RecordUtil.addValue(record, empHiredate, "2007-04-01"); + RecordUtil.addValue(record, empSal, "36"); + RecordUtil.addValue(record, empDeptId, "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, "1"); + RecordUtil.addValue(record, empHiredate, "2002-05-30"); + RecordUtil.addValue(record, empSal, "30"); + RecordUtil.addValue(record, empDeptId, "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, "3"); + RecordUtil.addValue(record, empHiredate, "2007-04-01"); + RecordUtil.addValue(record, empSal, "25"); + RecordUtil.addValue(record, empDeptId, "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, "1"); + RecordUtil.addValue(record, empHiredate, "2004-09-01"); + RecordUtil.addValue(record, empSal, "30"); + RecordUtil.addValue(record, empDeptId, "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, "4"); + RecordUtil.addValue(record, empHiredate, "2008-03-01"); + RecordUtil.addValue(record, empSal, "25"); + RecordUtil.addValue(record, empDeptId, "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, "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, "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, "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, "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, "1"); + RecordUtil.addValue(record, empEmpNo, "10"); + RecordUtil.addValue(record, empEmpName, "鈴木 茂"); + RecordUtil.addValue(record, empMgrId, "3"); + RecordUtil.addValue(record, empHiredate, "2003-02-01"); + RecordUtil.addValue(record, empSal, "40"); + RecordUtil.addValue(record, empDeptId, "3"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); + RecordUtil.addValue(record, empId, "2"); + RecordUtil.addValue(record, empEmpNo, "20"); + RecordUtil.addValue(record, empEmpName, "内海 透"); + RecordUtil.addValue(record, empMgrId, "3"); + RecordUtil.addValue(record, empHiredate, "2000-03-04"); + RecordUtil.addValue(record, empSal, "50"); + RecordUtil.addValue(record, empDeptId, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); + RecordUtil.addValue(record, empId, "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, "4"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); + RecordUtil.addValue(record, empId, "4"); + RecordUtil.addValue(record, empEmpNo, "40"); + RecordUtil.addValue(record, empEmpName, "近藤 美樹"); + RecordUtil.addValue(record, empMgrId, "2"); + RecordUtil.addValue(record, empHiredate, "2007-04-01"); + RecordUtil.addValue(record, empSal, "36"); + RecordUtil.addValue(record, empDeptId, "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, "1"); + RecordUtil.addValue(record, empHiredate, "2002-05-30"); + RecordUtil.addValue(record, empSal, "30"); + RecordUtil.addValue(record, empDeptId, "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, "3"); + RecordUtil.addValue(record, empHiredate, "2007-04-01"); + RecordUtil.addValue(record, empSal, "25"); + RecordUtil.addValue(record, empDeptId, "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, "1"); + RecordUtil.addValue(record, empHiredate, "2004-09-01"); + RecordUtil.addValue(record, empSal, "30"); + RecordUtil.addValue(record, empDeptId, "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, "4"); + RecordUtil.addValue(record, empHiredate, "2008-03-01"); + RecordUtil.addValue(record, empSal, "25"); + RecordUtil.addValue(record, empDeptId, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + } else { + ColumnUtil.setDataType(deptId, domainId); + } + deptId.setLogicalName("部署ID"); + tableDept.getAttributes().add(deptId); + + deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); + deptDeptNo.setName("DEPT_NO"); + deptDeptNo.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.VARCHAR, "VARCHAR").setSize(20).build()); + deptLoc.setLogicalName("ロケーション"); + deptLoc.setDefaultValue("secret"); + tableDept.getAttributes().add(deptLoc); + + deptPk = factory.newModel(PrimaryKeyModel.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); + deptPk.setName("dept_pkey"); + deptPk.getKeyColumns().add(factory.newReference(deptId)); + tableDept.getAttributes().add(deptPk); + + 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 column : Arrays.asList(deptDeptNo, deptDeptName)) { + NotNullConstraintModel notNull = + factory.newModel(NotNullConstraintModel.class, columnNotNullMap.get(column.getId())); + notNull.setColumn(factory.newReference(column)); + tableDept.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + empEmpNo.setLogicalName("従業員番号"); + 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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.TIMESTAMP, "TIMESTAMP").build()); + tableEmp.getAttributes().add(empHiredate); + + empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); + empSal.setName("SAL"); + empSal.setDataType(new DataTypeBuilder(factory, Types.NUMERIC, "NUMERIC").setPrecision(7).setScale(2).build()); + tableEmp.getAttributes().add(empSal); + + empDeptId = factory.newModel(ColumnModel.class, uuid.get("4ae69b7a-7a0e-422a-89dc-0f0cff77565b")); + empDeptId.setName("DEPT_ID"); + empDeptId.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + tableEmp.getAttributes().add(empDeptId); + + empPk = factory.newModel(PrimaryKeyModel.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(empEmpNo.getId(), uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); + 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 column : Arrays.asList(empEmpNo, empEmpName, empHiredate, empSal, empDeptId)) { + NotNullConstraintModel notNull = + factory.newModel(NotNullConstraintModel.class, columnNotNullMap.get(column.getId())); + notNull.setColumn(factory.newReference(column)); + tableEmp.getAttributes().add(notNull); + } + } + + 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("高給取り"); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder2.java (from rev 2597, artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder2.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder2.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,821 @@ +/* + * 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.test; + +import java.sql.Types; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.exception.JiemamyRuntimeException; +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.ForeignKeyModel; +import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; +import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel.ReferentialAction; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.utils.builder.DataTypeBuilder; +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 TestModelBuilder2 { + + 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 PrimaryKeyModel itemPk; + + // user + + /** 生成したモデル */ + public TableModel tableUser; + + /** 生成したモデル */ + public ColumnModel userId; + + /** 生成したモデル */ + public ColumnModel userName; + + /** 生成したモデル */ + public PrimaryKeyModel userPk; + + // order + + /** 生成したモデル */ + public TableModel tableOrder; + + /** 生成したモデル */ + public ColumnModel orderId; + + /** 生成したモデル */ + public ColumnModel orderUserId; + + /** 生成したモデル */ + public ColumnModel orderDate; + + /** 生成したモデル */ + public PrimaryKeyModel orderPk; + + // detail + + /** 生成したモデル */ + public TableModel tableDetail; + + /** 生成したモデル */ + public ColumnModel detailId; + + /** 生成したモデル */ + public ColumnModel detailOrderId; + + /** 生成したモデル */ + public ColumnModel detailItemId; + + /** 生成したモデル */ + public ColumnModel detailQuantity; + + /** 生成したモデル */ + public PrimaryKeyModel detailPk; + + // fk + + /** 生成したモデル */ + public ForeignKeyModel fkDetailItem; + + /** 生成したモデル */ + public ForeignKeyModel fkDetailOrder; + + /** 生成したモデル */ + public ForeignKeyModel fkOrderUser; + + + /** + * インスタンスを生成する。 + */ + public TestModelBuilder2() { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction + */ + public TestModelBuilder2(Instruction instruction) { + this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param instruction + * @param jiemamy + */ + public TestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, instruction, jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param jiemamy + */ + public TestModelBuilder2(Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), jiemamy); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + */ + public TestModelBuilder2(UuidStrategy uuid) { + this(uuid, new Instruction(), Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param instruction + */ + public TestModelBuilder2(UuidStrategy uuid, Instruction instruction) { + this(uuid, instruction, Jiemamy.newInstance()); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param instruction + * @param jiemamy + */ + public TestModelBuilder2(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 JiemamyRuntimeException(); + } + rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); + } + + /** + * インスタンスを生成する。 + * + * @param uuid + * @param jiemamy + */ + public TestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { + this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); + } + + /** + * モデルをビルドする。 + */ + public void build() { + rootModel.setDialectClassName(DIALECT_CLASS_NAME); + rootModel.setBeginScript("BEGIN;"); + rootModel.setEndScript("COMMIT;"); + rootModel.setDescription("Jiemamyテストモデル2"); + rootModel.setSchemaName("BAR"); + + createDomains(); + createEntities(); + createForeignKeys(); + createDataSets(); + } + + /** + * ビルドしたモデルを持つ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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + idDomain.getConstraints().add(factory.newModel(NotNullConstraintModel.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 DataTypeBuilder(factory, Types.VARCHAR, "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(ForeignKeyModel.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(ForeignKeyModel.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(ForeignKeyModel.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, "1"); + RecordUtil.addValue(record, detailOrderId, "1"); + RecordUtil.addValue(record, detailItemId, "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, "2"); + RecordUtil.addValue(record, detailOrderId, "1"); + RecordUtil.addValue(record, detailItemId, "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, "3"); + RecordUtil.addValue(record, detailOrderId, "2"); + RecordUtil.addValue(record, detailItemId, "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, "4"); + RecordUtil.addValue(record, detailOrderId, "2"); + RecordUtil.addValue(record, detailItemId, "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, "2"); + RecordUtil.addValue(record, detailItemId, "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, "5"); + RecordUtil.addValue(record, detailOrderId, "3"); + RecordUtil.addValue(record, detailItemId, "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, "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, "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, "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, "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, "1"); + RecordUtil.addValue(record, orderUserId, "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, "2"); + RecordUtil.addValue(record, orderUserId, "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, "2"); + RecordUtil.addValue(record, orderUserId, "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, "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, "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, "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, "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, "1"); + RecordUtil.addValue(record, detailOrderId, "1"); + RecordUtil.addValue(record, detailItemId, "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, "2"); + RecordUtil.addValue(record, detailOrderId, "1"); + RecordUtil.addValue(record, detailItemId, "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, "3"); + RecordUtil.addValue(record, detailOrderId, "2"); + RecordUtil.addValue(record, detailItemId, "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, "4"); + RecordUtil.addValue(record, detailOrderId, "2"); + RecordUtil.addValue(record, detailItemId, "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, "2"); + RecordUtil.addValue(record, detailItemId, "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, "5"); + RecordUtil.addValue(record, detailOrderId, "3"); + RecordUtil.addValue(record, detailItemId, "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, "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, "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, "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, "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, "1"); + RecordUtil.addValue(record, orderUserId, "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, "2"); + RecordUtil.addValue(record, orderUserId, "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, "2"); + RecordUtil.addValue(record, orderUserId, "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, "1"); + RecordUtil.addValue(record, userName, "鈴木 茂"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); + RecordUtil.addValue(record, userId, "2"); + RecordUtil.addValue(record, userName, "内海 透"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); + RecordUtil.addValue(record, userId, "3"); + RecordUtil.addValue(record, userName, "村瀬 武彦"); + result.add(record); + + record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); + RecordUtil.addValue(record, userId, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + tableDetail.getAttributes().add(detailItemId); + + detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); + detailQuantity.setName("QUANTITY"); + detailQuantity.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); + tableDetail.getAttributes().add(detailQuantity); + + detailPk = factory.newModel(PrimaryKeyModel.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); + detailPk.getKeyColumns().add(factory.newReference(detailId)); + tableDetail.getAttributes().add(detailPk); + + for (ColumnModel column : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { + NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); + notNull.setColumn(factory.newReference(column)); + tableDetail.getAttributes().add(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 */"); + tableItem.setDescription("商品マスタです。"); + + itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); + itemId.setName("ID"); + if (instruction.supressUseDomain) { + itemId.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.VARCHAR, "VARCHAR").setSize(20).build()); + itemPrice.setLogicalName("価格"); + tableItem.getAttributes().add(itemPrice); + + itemPk = factory.newModel(PrimaryKeyModel.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); + itemPk.getKeyColumns().add(factory.newReference(itemId)); + tableItem.getAttributes().add(itemPk); + + for (ColumnModel column : Arrays.asList(itemName, itemPrice)) { + NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); + notNull.setColumn(factory.newReference(column)); + tableItem.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.TIMESTAMP, "TIMESTAMP").build()); + tableOrder.getAttributes().add(orderDate); + + orderPk = factory.newModel(PrimaryKeyModel.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); + orderPk.getKeyColumns().add(factory.newReference(orderId)); + tableOrder.getAttributes().add(orderPk); + + for (ColumnModel column : Arrays.asList(orderUserId, orderDate)) { + NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); + notNull.setColumn(factory.newReference(column)); + tableOrder.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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(PrimaryKeyModel.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); + userPk.getKeyColumns().add(factory.newReference(userId)); + tableUser.getAttributes().add(userPk); + + NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); + notNull.setColumn(factory.newReference(userName)); + tableUser.getAttributes().add(notNull); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder2.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/UuidStrategy.java (from rev 2597, artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/UuidStrategy.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/UuidStrategy.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/UuidStrategy.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -0,0 +1,31 @@ +package org.jiemamy.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); +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/UuidStrategy.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ForeignKeyValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ForeignKeyValidator.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ForeignKeyValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -29,6 +29,7 @@ import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.model.ForeignKeyUtil; import org.jiemamy.utils.model.RootModelUtil; +import org.jiemamy.validator.AbstractProblem; import org.jiemamy.validator.AbstractValidator; import org.jiemamy.validator.Problem; @@ -55,11 +56,25 @@ if (fkModel.getKeyColumns().size() != fkModel.getReferenceColumns().size()) { logger.error("fk(" + fkModel.getId() + ") size error"); // TODO keyColumnsとreferenceColumnsのサイズ不一致 + result.add(new AbstractProblem("A") { + + public Severity getSeverity() { + return null; + } + + }); } if (ForeignKeyUtil.getReferenceKeyConstraint(fkModel) == null) { logger.error("fk(" + fkModel.getId() + ") reference error"); // TODO 対応するキーがないProblem + result.add(new AbstractProblem("B") { + + public Severity getSeverity() { + return null; + } + + }); } } return result; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/KeyConstraintValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -32,6 +32,7 @@ import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.utils.model.TableUtil; +import org.jiemamy.validator.AbstractProblem; import org.jiemamy.validator.AbstractValidator; import org.jiemamy.validator.Problem; @@ -62,6 +63,13 @@ if (columnIds.contains(columnRef.getReferenceId()) == false) { logger.error("key(" + keyModel.getId() + ") columns error"); // TODO keyColumnsに自テーブルのカラムでないものが含まれているProblem + result.add(new AbstractProblem("C") { + + public Severity getSeverity() { + return null; + } + + }); } } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -25,6 +25,7 @@ import org.jiemamy.ReferenceResolver; import org.jiemamy.model.ElementReference; import org.jiemamy.model.RootModel; +import org.jiemamy.validator.AbstractProblem; /** * {@link ElementReference}が全て正常に解決できるかどうか調べるバリデータ。 @@ -54,6 +55,14 @@ if (referenceResolver.resolve(elementReference) == null) { logger.error("reference(" + pos + ") resolve error"); // TODO 参照が解決できないProblem + result.add(new AbstractProblem("D") { + + public Severity getSeverity() { + return null; + } + + }); + } } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/TableValidator.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -32,6 +32,7 @@ import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.utils.model.TableUtil; +import org.jiemamy.validator.AbstractProblem; import org.jiemamy.validator.AbstractValidator; import org.jiemamy.validator.Problem; @@ -60,6 +61,14 @@ for (IndexColumnModel indexColumnModel : indexModel.getColumns()) { if (columnIds.contains(indexColumnModel.getColumn().getReferenceId()) == false) { logger.error("illegal index (" + indexColumnModel.getId() + ")"); + result.add(new AbstractProblem("E") { + + public Severity getSeverity() { + return null; + } + + }); + } } } Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/Instruction.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/Instruction.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/Instruction.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -1,19 +0,0 @@ -package org.jiemamy.test; - -/** - * {@link TestModelBuilder}等に対する指示クラス。 - * - * @author daisuke - */ -public class Instruction { - - /** ドメインを使用しない場合は{@code true}を設定する */ - public boolean supressUseDomain; - - /** 外部キーを使用しない場合は{@code true}を設定する */ - public boolean supressUseForeignKey; - - /** DataSetを使用しない場合は{@code true}を設定する */ - public boolean supressUseDataSet; - -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -1,725 +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.test; - -import java.sql.Types; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.exception.JiemamyRuntimeException; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.RepresentationAdapter; -import org.jiemamy.model.attribute.constraint.CheckConstraintModel; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel; -import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; -import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.builder.DataTypeBuilder; -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 TestModelBuilder { - - 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 PrimaryKeyModel 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 PrimaryKeyModel empPk; - - // highSal - - /** 生成したモデル */ - public ViewModel viewHighSal; - - // fk - - /** 生成したモデル */ - public ForeignKeyModel fkEmpEmp; - - /** 生成したモデル */ - public ForeignKeyModel fkEmpDept; - - - /** - * インスタンスを生成する。 - */ - public TestModelBuilder() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction - */ - public TestModelBuilder(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction - * @param jiemamy - */ - public TestModelBuilder(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy - */ - public TestModelBuilder(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - */ - public TestModelBuilder(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param instruction - */ - public TestModelBuilder(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param instruction - * @param jiemamy - */ - public TestModelBuilder(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 JiemamyRuntimeException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("d5a96af3-b1e9-4285-a8ef-c491ce5ae308")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param jiemamy - */ - public TestModelBuilder(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * モデルをビルドする。 - */ - public void build() { - rootModel.setDialectClassName(DIALECT_CLASS_NAME); - rootModel.setBeginScript("BEGIN;"); - rootModel.setEndScript("COMMIT;"); - rootModel.setDescription("Jiemamyテストモデル1"); - rootModel.setSchemaName("FOO"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - } - - /** - * ビルドしたモデルを持つ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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - NotNullConstraintModel notNull = - factory.newModel(NotNullConstraintModel.class, uuid.get("af4845dc-7f3a-434d-b5ac-2f25b74d7e76")); - domainId.getConstraints().add(notNull); - CheckConstraintModel check = - factory.newModel(CheckConstraintModel.class, uuid.get("48b76d76-b288-480a-afa4-111247379f8d")); - check.setName("hoge"); - check.setExpression("VALUE > 0"); - domainId.getConstraints().add(check); - domainId.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 DataTypeBuilder(factory, Types.VARCHAR, "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; - } - - fkEmpEmp = factory.newModel(ForeignKeyModel.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.setInitiallyCheckTime(InitiallyCheckTime.DEFERRED); - fkEmpEmp.setDeferrability(deferrability); - tableEmp.getAttributes().add(fkEmpEmp); - - fkEmpDept = factory.newModel(ForeignKeyModel.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(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, "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, "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, "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, "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, "1"); - RecordUtil.addValue(record, empEmpNo, "10"); - RecordUtil.addValue(record, empEmpName, "SMITH"); - RecordUtil.addValue(record, empMgrId, "3"); - RecordUtil.addValue(record, empHiredate, "2003-02-01"); - RecordUtil.addValue(record, empSal, "40"); - RecordUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03962eb2-90ab-4cff-8fac-14e52e117361")); - RecordUtil.addValue(record, empId, "2"); - RecordUtil.addValue(record, empEmpNo, "20"); - RecordUtil.addValue(record, empEmpName, "ALLEN"); - RecordUtil.addValue(record, empMgrId, "3"); - RecordUtil.addValue(record, empHiredate, "2000-03-04"); - RecordUtil.addValue(record, empSal, "50"); - RecordUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f5f16c1e-4a41-4ccd-9c87-00c09c0e7609")); - RecordUtil.addValue(record, empId, "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, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("03a9e57f-3010-4d46-8024-1915c262749e")); - RecordUtil.addValue(record, empId, "4"); - RecordUtil.addValue(record, empEmpNo, "40"); - RecordUtil.addValue(record, empEmpName, "JONES"); - RecordUtil.addValue(record, empMgrId, "2"); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "36"); - RecordUtil.addValue(record, empDeptId, "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, "1"); - RecordUtil.addValue(record, empHiredate, "2002-05-30"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, "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, "3"); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, "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, "1"); - RecordUtil.addValue(record, empHiredate, "2004-09-01"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, "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, "4"); - RecordUtil.addValue(record, empHiredate, "2008-03-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, "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, "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, "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, "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, "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, "1"); - RecordUtil.addValue(record, empEmpNo, "10"); - RecordUtil.addValue(record, empEmpName, "鈴木 茂"); - RecordUtil.addValue(record, empMgrId, "3"); - RecordUtil.addValue(record, empHiredate, "2003-02-01"); - RecordUtil.addValue(record, empSal, "40"); - RecordUtil.addValue(record, empDeptId, "3"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("90673863-ba77-461b-ab82-fffecd7e873b")); - RecordUtil.addValue(record, empId, "2"); - RecordUtil.addValue(record, empEmpNo, "20"); - RecordUtil.addValue(record, empEmpName, "内海 透"); - RecordUtil.addValue(record, empMgrId, "3"); - RecordUtil.addValue(record, empHiredate, "2000-03-04"); - RecordUtil.addValue(record, empSal, "50"); - RecordUtil.addValue(record, empDeptId, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("5bf32699-c2ff-4d96-9e26-2a3f3d7c7661")); - RecordUtil.addValue(record, empId, "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, "4"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("f164796f-ed85-48a0-98af-2f6045ee3a33")); - RecordUtil.addValue(record, empId, "4"); - RecordUtil.addValue(record, empEmpNo, "40"); - RecordUtil.addValue(record, empEmpName, "近藤 美樹"); - RecordUtil.addValue(record, empMgrId, "2"); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "36"); - RecordUtil.addValue(record, empDeptId, "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, "1"); - RecordUtil.addValue(record, empHiredate, "2002-05-30"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, "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, "3"); - RecordUtil.addValue(record, empHiredate, "2007-04-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, "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, "1"); - RecordUtil.addValue(record, empHiredate, "2004-09-01"); - RecordUtil.addValue(record, empSal, "30"); - RecordUtil.addValue(record, empDeptId, "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, "4"); - RecordUtil.addValue(record, empHiredate, "2008-03-01"); - RecordUtil.addValue(record, empSal, "25"); - RecordUtil.addValue(record, empDeptId, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - } else { - ColumnUtil.setDataType(deptId, domainId); - } - deptId.setLogicalName("部署ID"); - tableDept.getAttributes().add(deptId); - - deptDeptNo = factory.newModel(ColumnModel.class, uuid.get("2d951389-6bc7-49d7-8631-1d26fe17047e")); - deptDeptNo.setName("DEPT_NO"); - deptDeptNo.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.VARCHAR, "VARCHAR").setSize(20).build()); - deptLoc.setLogicalName("ロケーション"); - deptLoc.setDefaultValue("secret"); - tableDept.getAttributes().add(deptLoc); - - deptPk = factory.newModel(PrimaryKeyModel.class, uuid.get("8de55e65-ec48-467a-bac5-8eee2d71d41c")); - deptPk.setName("dept_pkey"); - deptPk.getKeyColumns().add(factory.newReference(deptId)); - tableDept.getAttributes().add(deptPk); - - 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 column : Arrays.asList(deptDeptNo, deptDeptName)) { - NotNullConstraintModel notNull = - factory.newModel(NotNullConstraintModel.class, columnNotNullMap.get(column.getId())); - notNull.setColumn(factory.newReference(column)); - tableDept.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - empEmpNo.setLogicalName("従業員番号"); - 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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.TIMESTAMP, "TIMESTAMP").build()); - tableEmp.getAttributes().add(empHiredate); - - empSal = factory.newModel(ColumnModel.class, uuid.get("80786549-dc2c-4c1c-bcbd-9f6fdec911d2")); - empSal.setName("SAL"); - empSal.setDataType(new DataTypeBuilder(factory, Types.NUMERIC, "NUMERIC").setPrecision(7).setScale(2).build()); - tableEmp.getAttributes().add(empSal); - - empDeptId = factory.newModel(ColumnModel.class, uuid.get("4ae69b7a-7a0e-422a-89dc-0f0cff77565b")); - empDeptId.setName("DEPT_ID"); - empDeptId.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - tableEmp.getAttributes().add(empDeptId); - - empPk = factory.newModel(PrimaryKeyModel.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(empEmpNo.getId(), uuid.get("05ee4c06-d8b5-4599-a7e9-1cda036ea2c7")); - 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 column : Arrays.asList(empEmpNo, empEmpName, empHiredate, empSal, empDeptId)) { - NotNullConstraintModel notNull = - factory.newModel(NotNullConstraintModel.class, columnNotNullMap.get(column.getId())); - notNull.setColumn(factory.newReference(column)); - tableEmp.getAttributes().add(notNull); - } - } - - 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/test/java/org/jiemamy/test/TestModelBuilder2.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -1,821 +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.test; - -import java.sql.Types; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.exception.JiemamyRuntimeException; -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.ForeignKeyModel; -import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; -import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; -import org.jiemamy.model.attribute.constraint.Deferrability.InitiallyCheckTime; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel.ReferentialAction; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.utils.builder.DataTypeBuilder; -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 TestModelBuilder2 { - - 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 PrimaryKeyModel itemPk; - - // user - - /** 生成したモデル */ - public TableModel tableUser; - - /** 生成したモデル */ - public ColumnModel userId; - - /** 生成したモデル */ - public ColumnModel userName; - - /** 生成したモデル */ - public PrimaryKeyModel userPk; - - // order - - /** 生成したモデル */ - public TableModel tableOrder; - - /** 生成したモデル */ - public ColumnModel orderId; - - /** 生成したモデル */ - public ColumnModel orderUserId; - - /** 生成したモデル */ - public ColumnModel orderDate; - - /** 生成したモデル */ - public PrimaryKeyModel orderPk; - - // detail - - /** 生成したモデル */ - public TableModel tableDetail; - - /** 生成したモデル */ - public ColumnModel detailId; - - /** 生成したモデル */ - public ColumnModel detailOrderId; - - /** 生成したモデル */ - public ColumnModel detailItemId; - - /** 生成したモデル */ - public ColumnModel detailQuantity; - - /** 生成したモデル */ - public PrimaryKeyModel detailPk; - - // fk - - /** 生成したモデル */ - public ForeignKeyModel fkDetailItem; - - /** 生成したモデル */ - public ForeignKeyModel fkDetailOrder; - - /** 生成したモデル */ - public ForeignKeyModel fkOrderUser; - - - /** - * インスタンスを生成する。 - */ - public TestModelBuilder2() { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction - */ - public TestModelBuilder2(Instruction instruction) { - this(UuidStrategy.FIXED, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param instruction - * @param jiemamy - */ - public TestModelBuilder2(Instruction instruction, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, instruction, jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param jiemamy - */ - public TestModelBuilder2(Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), jiemamy); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - */ - public TestModelBuilder2(UuidStrategy uuid) { - this(uuid, new Instruction(), Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param instruction - */ - public TestModelBuilder2(UuidStrategy uuid, Instruction instruction) { - this(uuid, instruction, Jiemamy.newInstance()); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param instruction - * @param jiemamy - */ - public TestModelBuilder2(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 JiemamyRuntimeException(); - } - rootModel = jiemamy.getFactory().getRootModel(uuid.get("6cbba964-6809-4eb9-936d-ec318012322c")); - } - - /** - * インスタンスを生成する。 - * - * @param uuid - * @param jiemamy - */ - public TestModelBuilder2(UuidStrategy uuid, Jiemamy jiemamy) { - this(UuidStrategy.FIXED, new Instruction(), Jiemamy.newInstance()); - } - - /** - * モデルをビルドする。 - */ - public void build() { - rootModel.setDialectClassName(DIALECT_CLASS_NAME); - rootModel.setBeginScript("BEGIN;"); - rootModel.setEndScript("COMMIT;"); - rootModel.setDescription("Jiemamyテストモデル2"); - rootModel.setSchemaName("BAR"); - - createDomains(); - createEntities(); - createForeignKeys(); - createDataSets(); - } - - /** - * ビルドしたモデルを持つ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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - idDomain.getConstraints().add(factory.newModel(NotNullConstraintModel.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 DataTypeBuilder(factory, Types.VARCHAR, "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(ForeignKeyModel.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(ForeignKeyModel.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(ForeignKeyModel.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, "1"); - RecordUtil.addValue(record, detailOrderId, "1"); - RecordUtil.addValue(record, detailItemId, "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, "2"); - RecordUtil.addValue(record, detailOrderId, "1"); - RecordUtil.addValue(record, detailItemId, "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, "3"); - RecordUtil.addValue(record, detailOrderId, "2"); - RecordUtil.addValue(record, detailItemId, "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, "4"); - RecordUtil.addValue(record, detailOrderId, "2"); - RecordUtil.addValue(record, detailItemId, "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, "2"); - RecordUtil.addValue(record, detailItemId, "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, "5"); - RecordUtil.addValue(record, detailOrderId, "3"); - RecordUtil.addValue(record, detailItemId, "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, "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, "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, "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, "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, "1"); - RecordUtil.addValue(record, orderUserId, "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, "2"); - RecordUtil.addValue(record, orderUserId, "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, "2"); - RecordUtil.addValue(record, orderUserId, "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, "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, "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, "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, "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, "1"); - RecordUtil.addValue(record, detailOrderId, "1"); - RecordUtil.addValue(record, detailItemId, "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, "2"); - RecordUtil.addValue(record, detailOrderId, "1"); - RecordUtil.addValue(record, detailItemId, "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, "3"); - RecordUtil.addValue(record, detailOrderId, "2"); - RecordUtil.addValue(record, detailItemId, "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, "4"); - RecordUtil.addValue(record, detailOrderId, "2"); - RecordUtil.addValue(record, detailItemId, "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, "2"); - RecordUtil.addValue(record, detailItemId, "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, "5"); - RecordUtil.addValue(record, detailOrderId, "3"); - RecordUtil.addValue(record, detailItemId, "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, "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, "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, "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, "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, "1"); - RecordUtil.addValue(record, orderUserId, "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, "2"); - RecordUtil.addValue(record, orderUserId, "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, "2"); - RecordUtil.addValue(record, orderUserId, "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, "1"); - RecordUtil.addValue(record, userName, "鈴木 茂"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("20a62610-ad04-479f-85c6-a1340e26adb5")); - RecordUtil.addValue(record, userId, "2"); - RecordUtil.addValue(record, userName, "内海 透"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("d8fa5455-9791-46fc-9695-da7a5167f7ea")); - RecordUtil.addValue(record, userId, "3"); - RecordUtil.addValue(record, userName, "村瀬 武彦"); - result.add(record); - - record = factory.newModel(RecordModel.class, uuid.get("3cc66837-d604-4af8-af01-343924e9f058")); - RecordUtil.addValue(record, userId, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - tableDetail.getAttributes().add(detailItemId); - - detailQuantity = factory.newModel(ColumnModel.class, uuid.get("77bb21f4-e793-4198-a695-42363dac2216")); - detailQuantity.setName("QUANTITY"); - detailQuantity.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "INTEGER").build()); - tableDetail.getAttributes().add(detailQuantity); - - detailPk = factory.newModel(PrimaryKeyModel.class, uuid.get("90243681-19af-4bc0-9e6f-f814fbc58f85")); - detailPk.getKeyColumns().add(factory.newReference(detailId)); - tableDetail.getAttributes().add(detailPk); - - for (ColumnModel column : Arrays.asList(detailOrderId, detailItemId, detailQuantity)) { - NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); - notNull.setColumn(factory.newReference(column)); - tableDetail.getAttributes().add(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 */"); - tableItem.setDescription("商品マスタです。"); - - itemId = factory.newModel(ColumnModel.class, uuid.get("5a9585be-4b0d-4675-99aa-97b0417c816c")); - itemId.setName("ID"); - if (instruction.supressUseDomain) { - itemId.setDataType(new DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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 DataTypeBuilder(factory, Types.VARCHAR, "VARCHAR").setSize(20).build()); - itemPrice.setLogicalName("価格"); - tableItem.getAttributes().add(itemPrice); - - itemPk = factory.newModel(PrimaryKeyModel.class, uuid.get("32b2b2f3-e668-404b-9478-56f1e680f915")); - itemPk.getKeyColumns().add(factory.newReference(itemId)); - tableItem.getAttributes().add(itemPk); - - for (ColumnModel column : Arrays.asList(itemName, itemPrice)) { - NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); - notNull.setColumn(factory.newReference(column)); - tableItem.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.TIMESTAMP, "TIMESTAMP").build()); - tableOrder.getAttributes().add(orderDate); - - orderPk = factory.newModel(PrimaryKeyModel.class, uuid.get("b204ff42-537b-4e14-bf61-e9baf1b119dc")); - orderPk.getKeyColumns().add(factory.newReference(orderId)); - tableOrder.getAttributes().add(orderPk); - - for (ColumnModel column : Arrays.asList(orderUserId, orderDate)) { - NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); - notNull.setColumn(factory.newReference(column)); - tableOrder.getAttributes().add(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 DataTypeBuilder(factory, Types.INTEGER, "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 DataTypeBuilder(factory, Types.VARCHAR, "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(PrimaryKeyModel.class, uuid.get("dac295e3-c390-46ee-9a5b-e89636ab9d7e")); - userPk.getKeyColumns().add(factory.newReference(userId)); - tableUser.getAttributes().add(userPk); - - NotNullConstraintModel notNull = factory.newModel(NotNullConstraintModel.class); - notNull.setColumn(factory.newReference(userName)); - tableUser.getAttributes().add(notNull); - } -} Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -23,7 +23,6 @@ import static org.junit.Assert.assertThat; import java.util.Collection; -import java.util.List; import org.junit.After; import org.junit.Before; @@ -36,18 +35,7 @@ import org.jiemamy.model.entity.TableModel; import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.utils.model.TableUtil; -import org.jiemamy.validator.CompositeValidator; import org.jiemamy.validator.Problem; -import org.jiemamy.validator.Validator; -import org.jiemamy.validator.impl.ColumnValidator; -import org.jiemamy.validator.impl.EntityNameCollisionValidator; -import org.jiemamy.validator.impl.ForeignKeyValidator; -import org.jiemamy.validator.impl.IdCollisionValidator; -import org.jiemamy.validator.impl.InstanceCollisionValidator; -import org.jiemamy.validator.impl.InstanceSpaceValidator; -import org.jiemamy.validator.impl.KeyConstraintValidator; -import org.jiemamy.validator.impl.PrimaryKeyValidator; -import org.jiemamy.validator.impl.ReferenceValidator; /** * {@link TestModelBuilder2}のテストクラス。 @@ -153,22 +141,10 @@ */ @Test public void test02_全ての標準バリデータを問題なく通過すること() throws Exception { - CompositeValidator compositeValidator = new CompositeValidator(); - List<Validator> validators = compositeValidator.getValidators(); - validators.add(new ColumnValidator()); - validators.add(new EntityNameCollisionValidator()); - validators.add(new ForeignKeyValidator()); - validators.add(new IdCollisionValidator()); - validators.add(new InstanceCollisionValidator()); - validators.add(new InstanceSpaceValidator()); - validators.add(new KeyConstraintValidator()); - validators.add(new PrimaryKeyValidator()); - validators.add(new ReferenceValidator()); - Jiemamy jiemamy = testModelBuilder2.getJiemamy(); RootModel rootModel = jiemamy.getFactory().getRootModel(); - Collection<Problem> problems = compositeValidator.validate(rootModel); + Collection<Problem> problems = new AllValidator().validate(rootModel); for (Problem problem : problems) { logger.error(problem.getMessage()); } Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/UuidStrategy.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/UuidStrategy.java 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/UuidStrategy.java 2009-02-02 07:09:11 UTC (rev 2598) @@ -1,31 +0,0 @@ -package org.jiemamy.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); -} Modified: artemis/trunk/jiemamy-dialect-mysql/.project =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-dialect-mysql/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-dialect-mysql/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-dialect-mysql/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -52,13 +52,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site> Modified: artemis/trunk/jiemamy-dialect-postgresql/.project =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-dialect-postgresql/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-dialect-postgresql/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-dialect-postgresql/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -52,13 +52,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site> Modified: artemis/trunk/jiemamy-dialect-sql99/pom.xml =================================================================== --- artemis/trunk/jiemamy-dialect-sql99/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-dialect-sql99/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -52,13 +52,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site> Modified: artemis/trunk/jiemamy-event/.project =================================================================== --- artemis/trunk/jiemamy-event/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-event/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-event/pom.xml =================================================================== --- artemis/trunk/jiemamy-event/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-event/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -81,13 +81,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site> Modified: artemis/trunk/jiemamy-view/.project =================================================================== --- artemis/trunk/jiemamy-view/.project 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-view/.project 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,14 +34,14 @@ </natures> <linkedResources> <link> - <name>.fbprefs</name> + <name>findbugs.xml</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> </link> <link> - <name>findbugs.xml</name> + <name>.fbprefs</name> <type>1</type> - <locationURI>DOCUMENTS/jiemamy-artemis/findbugs.xml</locationURI> + <locationURI>DOCUMENTS/jiemamy-artemis/.fbprefs</locationURI> </link> <link> <name>.checkstyle</name> Modified: artemis/trunk/jiemamy-view/pom.xml =================================================================== --- artemis/trunk/jiemamy-view/pom.xml 2009-02-01 16:37:35 UTC (rev 2597) +++ artemis/trunk/jiemamy-view/pom.xml 2009-02-02 07:09:11 UTC (rev 2598) @@ -34,20 +34,6 @@ <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/artemis/trunk/org.jiemamy.view</developerConnection> <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/artemis/trunk/org.jiemamy.view/?root=jiemamy</url> </scm> - <build> - <plugins> - <plugin> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> <dependencies> <dependency> <groupId>junit</groupId> @@ -81,13 +67,6 @@ <artifactId>jiemamy-core</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>jiemamy-core</artifactId> - <version>${project.version}</version> - <type>test-jar</type> - <scope>test</scope> - </dependency> </dependencies> <distributionManagement> <site>