svnno****@sourc*****
svnno****@sourc*****
2009年 2月 25日 (水) 02:12:10 JST
Revision: 2733 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2733 Author: daisuke_m Date: 2009-02-25 02:12:10 +0900 (Wed, 25 Feb 2009) Log Message: ----------- BuiltinDataType生成まわりの整備。 Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisJiemamyFactory.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilder.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/datatype/BuiltinDataTypeImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EqualsUtilTest.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/connection/ConnectionModelImplTest.java artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/node/NodeModelImplTest.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java Added Paths: ----------- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/CharsetAdapter.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/Unsigned.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisJiemamyFactory.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisJiemamyFactory.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ArtemisJiemamyFactory.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -18,12 +18,14 @@ */ package org.jiemamy; +import java.util.Collection; import java.util.Set; import java.util.UUID; import org.apache.commons.lang.Validate; import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; +import org.jiemamy.exception.IllegalImplementationException; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; @@ -32,10 +34,6 @@ import org.jiemamy.model.datatype.BuiltinDataTypeImpl; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.datatype.DomainRef; -import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.entity.TableRef; import org.jiemamy.serializer.JiemamyDomSerializer; @@ -114,10 +112,17 @@ public BuiltinDataType newBuiltinDataType(BuiltinDataTypeMold mold) { BuiltinDataTypeImpl dataType = new BuiltinDataTypeImpl(mold.getCategory(), mold.getTypeName()); - dataType.registerAdapter(new SizedDataTypeAdapter()); - dataType.registerAdapter(new PrecisionedDataTypeAdapter()); - dataType.registerAdapter(new SerialDataTypeAdapter()); - dataType.registerAdapter(new TimezonedDataTypeAdapter()); + Collection<Class<?>> supportedAdapterClasses = mold.getSupportedAdapterClasses(); + for (Class<?> supportedAdapterClass : supportedAdapterClasses) { + try { + Object adapter = supportedAdapterClass.newInstance(); + dataType.registerAdapter(adapter); + } catch (InstantiationException e) { + throw new IllegalImplementationException(supportedAdapterClass); + } catch (IllegalAccessException e) { + throw new IllegalImplementationException(supportedAdapterClass); + } + } return dataType; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -36,6 +36,7 @@ import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataTypeCategory; import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; @@ -65,7 +66,18 @@ /** エミッタ */ protected SqlEmitter emitter = new DefaultSqlEmitter(dataTypeResolver); + private final List<BuiltinDataTypeMold> allDataTypes; + + /** + * インスタンスを生成する。 + * + * @param allDataTypes + */ + public AbstractDialect(List<BuiltinDataTypeMold> allDataTypes) { + this.allDataTypes = allDataTypes; + } + public EntityModel createEntity(RootModel rootModel, ResultSet entity, DatabaseMetaData meta) throws SQLException { String type = entity.getString("TABLE_TYPE"); String name = entity.getString("TABLE_NAME"); @@ -90,11 +102,35 @@ return emitter.emit(rootModel, config); } + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getCategory() == category && mold.getTypeName().equals(typeName)) { + return mold; + } + } + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getTypeName().equals(typeName)) { + return mold; + } + } + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getCategory() == category) { + return mold; + } + } + // TODO 適当null返し + return null; + } + public ConnectionAdvisor getAdvisor() { assert advisor != null; return advisor; } + public List<BuiltinDataTypeMold> getAllDataTypes() { + return allDataTypes; + } + public DataTypeResolver getDataTypeResolver() { assert dataTypeResolver != null; return dataTypeResolver; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -109,8 +109,7 @@ } catch (IllegalArgumentException e) { category = DataTypeCategory.fromSqlType(sqlType); } - // FIXME ここでモールド生成していいんか - BuiltinDataTypeMold mold = new BuiltinDataTypeMoldImpl(category, typeName); + BuiltinDataTypeMold mold = dialect.findDataTypeMold(category, typeName); return factory.newBuiltinDataType(mold); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/generic/GenericDialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -87,6 +87,26 @@ throw new UnsupportedOperationException(); } + public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getCategory() == category && mold.getTypeName().equals(typeName)) { + return mold; + } + } + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getTypeName().equals(typeName)) { + return mold; + } + } + for (BuiltinDataTypeMold mold : allDataTypes) { + if (mold.getCategory() == category) { + return mold; + } + } + // TODO 適当null返し + return null; + } + public ConnectionAdvisor getAdvisor() { assert advisor != null; return advisor; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -41,6 +41,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.JiemamyFactory; import org.jiemamy.dialect.BuiltinDataTypeMoldImpl; +import org.jiemamy.dialect.Dialect; import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.RootModel; @@ -73,6 +74,7 @@ import org.jiemamy.utils.DomUtil; import org.jiemamy.utils.IterableNodeList; import org.jiemamy.utils.XpathUtil; +import org.jiemamy.utils.model.RootModelUtil; import org.jiemamy.xml.CoreQName; /** @@ -197,10 +199,20 @@ String typeName = (String) XpathUtil.XPATH.evaluate("core:typeName/text()", element, XPathConstants.STRING); + RootModel rootModel = factory.getRootModel(); + Dialect dialect; + try { + dialect = RootModelUtil.getDialect(rootModel); + } catch (ClassNotFoundException e) { + dialect = null; + } BuiltinDataTypeMold mold; if (StringUtils.isEmpty(typeCategoryString) == false) { - // FIXME ここでモールド生成していいんか - mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.valueOf(typeCategoryString), typeName); + if (dialect == null) { + mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.valueOf(typeCategoryString), typeName); + } else { + mold = dialect.findDataTypeMold(DataTypeCategory.valueOf(typeCategoryString), typeName); + } } else { DataTypeCategory category; try { @@ -208,8 +220,11 @@ } catch (IllegalArgumentException e) { category = DataTypeCategory.INTEGER; } - // FIXME ここでモールド生成していいんか - mold = new BuiltinDataTypeMoldImpl(category, typeName); + if (dialect == null) { + mold = new BuiltinDataTypeMoldImpl(category, typeName); + } else { + mold = dialect.findDataTypeMold(category, typeName); + } } BuiltinDataType dataType = factory.newBuiltinDataType(mold); dataType.setTypeName(typeName); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/test/TestModelBuilder.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -311,7 +311,7 @@ check.setName("hoge"); check.setExpression("VALUE > 0"); domainId.setCheck(check); - domainId.getAdapter(SerialDataTypeAdapter.class).setSerial(true); + domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true); rootModel.getDomains().add(domainId); domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7")); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilder.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/DataTypeBuilder.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -22,12 +22,15 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.dialect.BuiltinDataTypeMoldImpl; +import org.jiemamy.dialect.Dialect; import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; +import org.jiemamy.model.RootModel; import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; +import org.jiemamy.utils.model.RootModelUtil; /** * {@link BuiltinDataType}を生成するビルダ。 @@ -59,8 +62,18 @@ * @param typeName */ public DataTypeBuilder(JiemamyFactory factory, DataTypeCategory typeCategory, String typeName) { - // FIXME ここでモールド生成していいんか - mold = new BuiltinDataTypeMoldImpl(typeCategory, typeName); + RootModel rootModel = factory.getRootModel(); + Dialect dialect; + try { + dialect = RootModelUtil.getDialect(rootModel); + } catch (ClassNotFoundException e) { + dialect = null; + } + if (dialect == null) { + mold = new BuiltinDataTypeMoldImpl(typeCategory, typeName); + } else { + mold = dialect.findDataTypeMold(typeCategory, typeName); + } Validate.notNull(typeName); dataType = factory.newBuiltinDataType(mold); } Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/datatype/BuiltinDataTypeImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/datatype/BuiltinDataTypeImplTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/datatype/BuiltinDataTypeImplTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -74,7 +74,7 @@ */ @Test public void test01_インスタンス毎にアダプタは異なったインスタンスが設定されている() throws Exception { - BuiltinDataTypeMold mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER); + BuiltinDataTypeMold mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.VARCHAR, SizedDataTypeAdapter.class); BuiltinDataType dataType1 = factory.newBuiltinDataType(mold); BuiltinDataType dataType2 = factory.newBuiltinDataType(mold); 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-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/test/TestModelBuilder2Test.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; import org.jiemamy.AllValidator; +import org.jiemamy.Artemis; import org.jiemamy.Jiemamy; import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.TableModel; @@ -56,7 +57,7 @@ private static Logger logger = LoggerFactory.getLogger(TestModelBuilder2Test.class); - private TestModelBuilder2 testModelBuilder2; + private TestModelBuilder2 mb; /** @@ -66,8 +67,9 @@ */ @Before public void setUp() throws Exception { - testModelBuilder2 = new TestModelBuilder2(); - testModelBuilder2.build(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + mb = new TestModelBuilder2(jiemamy); + mb.build(); } /** @@ -77,7 +79,7 @@ */ @After public void tearDown() throws Exception { - testModelBuilder2 = null; + mb = null; } /** @@ -87,7 +89,7 @@ */ @Test public void test01_意図通りのモデル生成を確認する() throws Exception { - Jiemamy jiemamy = testModelBuilder2.getJiemamy(); + Jiemamy jiemamy = mb.getJiemamy(); RootModel rootModel = jiemamy.getFactory().getRootModel(); assertThat(rootModel, is(notNullValue())); @@ -95,50 +97,50 @@ TableModel user = RootModelUtil.getEntity(rootModel, TableModel.class, "T_USER"); assertThat(user, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(user), is(testModelBuilder2.userPk)); + assertThat(TableUtil.getPrimaryKey(user), is(mb.userPk)); assertThat(TableUtil.getPrimaryKey(user).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(user).getKeyColumns().get(0).getReferenceId(), is(testModelBuilder2.userId + assertThat(TableUtil.getPrimaryKey(user).getKeyColumns().get(0).getReferenceId(), is(mb.userId .getId())); assertThat(TableUtil.getColumns(user).size(), is(2)); - assertThat(TableUtil.getColumn(user, "ID"), is(testModelBuilder2.userId)); - assertThat(TableUtil.getColumn(user, "NAME"), is(testModelBuilder2.userName)); + assertThat(TableUtil.getColumn(user, "ID"), is(mb.userId)); + assertThat(TableUtil.getColumn(user, "NAME"), is(mb.userName)); assertThat(TableUtil.getForeignKeys(user).size(), is(0)); TableModel item = RootModelUtil.getEntity(rootModel, TableModel.class, "T_ITEM"); assertThat(item, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(item), is(testModelBuilder2.itemPk)); + assertThat(TableUtil.getPrimaryKey(item), is(mb.itemPk)); assertThat(TableUtil.getPrimaryKey(item).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(item).getKeyColumns().get(0).getReferenceId(), is(testModelBuilder2.itemId + assertThat(TableUtil.getPrimaryKey(item).getKeyColumns().get(0).getReferenceId(), is(mb.itemId .getId())); assertThat(TableUtil.getColumns(item).size(), is(3)); - assertThat(TableUtil.getColumn(item, "ID"), is(testModelBuilder2.itemId)); - assertThat(TableUtil.getColumn(item, "NAME"), is(testModelBuilder2.itemName)); - assertThat(TableUtil.getColumn(item, "PRICE"), is(testModelBuilder2.itemPrice)); + assertThat(TableUtil.getColumn(item, "ID"), is(mb.itemId)); + assertThat(TableUtil.getColumn(item, "NAME"), is(mb.itemName)); + assertThat(TableUtil.getColumn(item, "PRICE"), is(mb.itemPrice)); assertThat(TableUtil.getForeignKeys(item).size(), is(0)); TableModel order = RootModelUtil.getEntity(rootModel, TableModel.class, "T_ORDER"); assertThat(order, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(order), is(testModelBuilder2.orderPk)); + assertThat(TableUtil.getPrimaryKey(order), is(mb.orderPk)); assertThat(TableUtil.getPrimaryKey(order).getKeyColumns().size(), is(1)); - assertThat(TableUtil.getPrimaryKey(order).getKeyColumns().get(0).getReferenceId(), is(testModelBuilder2.orderId + assertThat(TableUtil.getPrimaryKey(order).getKeyColumns().get(0).getReferenceId(), is(mb.orderId .getId())); assertThat(TableUtil.getColumns(order).size(), is(3)); - assertThat(TableUtil.getColumn(order, "ID"), is(testModelBuilder2.orderId)); - assertThat(TableUtil.getColumn(order, "ORDER_DATE"), is(testModelBuilder2.orderDate)); - assertThat(TableUtil.getColumn(order, "USER_ID"), is(testModelBuilder2.orderUserId)); + assertThat(TableUtil.getColumn(order, "ID"), is(mb.orderId)); + assertThat(TableUtil.getColumn(order, "ORDER_DATE"), is(mb.orderDate)); + assertThat(TableUtil.getColumn(order, "USER_ID"), is(mb.orderUserId)); assertThat(TableUtil.getForeignKeys(order).size(), is(1)); TableModel detail = RootModelUtil.getEntity(rootModel, TableModel.class, "T_DETAIL"); assertThat(detail, is(notNullValue())); - assertThat(TableUtil.getPrimaryKey(detail), is(testModelBuilder2.detailPk)); + assertThat(TableUtil.getPrimaryKey(detail), is(mb.detailPk)); assertThat(TableUtil.getPrimaryKey(detail).getKeyColumns().size(), is(1)); assertThat(TableUtil.getPrimaryKey(detail).getKeyColumns().get(0).getReferenceId(), - is(testModelBuilder2.detailId.getId())); + is(mb.detailId.getId())); assertThat(TableUtil.getColumns(detail).size(), is(4)); - assertThat(TableUtil.getColumn(detail, "ID"), is(testModelBuilder2.detailId)); - assertThat(TableUtil.getColumn(detail, "ORDER_ID"), is(testModelBuilder2.detailOrderId)); - assertThat(TableUtil.getColumn(detail, "ITEM_ID"), is(testModelBuilder2.detailItemId)); - assertThat(TableUtil.getColumn(detail, "QUANTITY"), is(testModelBuilder2.detailQuantity)); + assertThat(TableUtil.getColumn(detail, "ID"), is(mb.detailId)); + assertThat(TableUtil.getColumn(detail, "ORDER_ID"), is(mb.detailOrderId)); + assertThat(TableUtil.getColumn(detail, "ITEM_ID"), is(mb.detailItemId)); + assertThat(TableUtil.getColumn(detail, "QUANTITY"), is(mb.detailQuantity)); assertThat(TableUtil.getForeignKeys(detail).size(), is(2)); } @@ -149,7 +151,7 @@ */ @Test public void test02_全ての標準バリデータを問題なく通過すること() throws Exception { - Jiemamy jiemamy = testModelBuilder2.getJiemamy(); + Jiemamy jiemamy = mb.getJiemamy(); RootModel rootModel = jiemamy.getFactory().getRootModel(); Collection<Problem> problems = new AllValidator().validate(rootModel); @@ -166,7 +168,7 @@ */ @Test public void xstream() throws Exception { - Jiemamy jiemamy = testModelBuilder2.getJiemamy(); + Jiemamy jiemamy = mb.getJiemamy(); RootModel rootModel = jiemamy.getFactory().getRootModel(); XStream xstream = new XStream(); xstream.addImmutableType(UUID.class); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/AttributeUtilTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -28,10 +28,13 @@ import org.junit.Before; import org.junit.Test; +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; /** @@ -51,7 +54,8 @@ */ @Before public void setUp() throws Exception { - mb = new TestModelBuilder(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + mb = new TestModelBuilder(jiemamy); mb.build(); } Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/ColumnUtilTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -26,6 +26,9 @@ import org.junit.Before; import org.junit.Test; +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; /** @@ -45,7 +48,8 @@ */ @Before public void setUp() throws Exception { - mb = new TestModelBuilder(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + mb = new TestModelBuilder(jiemamy); mb.build(); } Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EntityUtilTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -27,7 +27,10 @@ import org.junit.Before; import org.junit.Test; +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; import org.jiemamy.test.TestModelBuilder2; @@ -63,7 +66,8 @@ */ @Test public void test01_getReferenceEntities_empDept() throws Exception { - TestModelBuilder mb = new TestModelBuilder(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder mb = new TestModelBuilder(jiemamy); mb.build(); // /- EMP -> DEPT // `___^ @@ -87,7 +91,8 @@ */ @Test public void test02_getDependentEntities_empDept() throws Exception { - TestModelBuilder mb = new TestModelBuilder(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder mb = new TestModelBuilder(jiemamy); mb.build(); // /- EMP -> DEPT // `___^ @@ -111,7 +116,8 @@ */ @Test public void test03_getReferenceEntities_order() throws Exception { - TestModelBuilder2 mb = new TestModelBuilder2(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder2 mb = new TestModelBuilder2(jiemamy); mb.build(); // DETAIL +-> ORDER +-> USER // +-> ITEM @@ -141,7 +147,8 @@ */ @Test public void test04_getDependentEntities_order() throws Exception { - TestModelBuilder2 mb = new TestModelBuilder2(); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder2 mb = new TestModelBuilder2(jiemamy); mb.build(); // DETAIL +-> ORDER +-> USER // +-> ITEM Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EqualsUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EqualsUtilTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/model/EqualsUtilTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -25,7 +25,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.jiemamy.Artemis; +import org.jiemamy.Jiemamy; import org.jiemamy.model.RootModel; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; /** @@ -46,11 +49,13 @@ @Test public void test01_equals() throws Exception { // 同じモデルを2個作る - TestModelBuilder mb1 = new TestModelBuilder(); + Jiemamy jiemamy1 = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder mb1 = new TestModelBuilder(jiemamy1); mb1.build(); RootModel rootModel1 = mb1.getJiemamy().getFactory().getRootModel(); - TestModelBuilder mb2 = new TestModelBuilder(); + Jiemamy jiemamy2 = Jiemamy.newInstance(new Artemis(), new ReflectionDialectProvider()); + TestModelBuilder mb2 = new TestModelBuilder(jiemamy2); mb2.build(); RootModel rootModel2 = mb2.getJiemamy().getFactory().getRootModel(); Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlDialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -18,16 +18,33 @@ */ package org.jiemamy.dialect.mysql; +import static org.jiemamy.model.datatype.DataTypeCategory.BIT; +import static org.jiemamy.model.datatype.DataTypeCategory.BLOB; +import static org.jiemamy.model.datatype.DataTypeCategory.CHARACTER; +import static org.jiemamy.model.datatype.DataTypeCategory.CLOB; +import static org.jiemamy.model.datatype.DataTypeCategory.DATE; +import static org.jiemamy.model.datatype.DataTypeCategory.DECIMAL; +import static org.jiemamy.model.datatype.DataTypeCategory.DOUBLE; +import static org.jiemamy.model.datatype.DataTypeCategory.FLOAT; +import static org.jiemamy.model.datatype.DataTypeCategory.INTEGER; +import static org.jiemamy.model.datatype.DataTypeCategory.NUMERIC; +import static org.jiemamy.model.datatype.DataTypeCategory.OTHER; +import static org.jiemamy.model.datatype.DataTypeCategory.REAL; +import static org.jiemamy.model.datatype.DataTypeCategory.SMALLINT; +import static org.jiemamy.model.datatype.DataTypeCategory.TIME; +import static org.jiemamy.model.datatype.DataTypeCategory.TIMESTAMP; +import static org.jiemamy.model.datatype.DataTypeCategory.VARCHAR; + import java.util.List; import org.apache.commons.collections15.list.UnmodifiableList; import org.jiemamy.dialect.AbstractDialect; import org.jiemamy.dialect.BuiltinDataTypeMoldImpl; -import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.dialect.mysql.adapter.Unsigned; import org.jiemamy.model.datatype.adapter.PrecisionedDataTypeAdapter; +import org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter; import org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter; -import org.jiemamy.model.datatype.adapter.TimezonedDataTypeAdapter; import org.jiemamy.utils.CollectionsUtil; import org.jiemamy.validator.CompositeValidator; import org.jiemamy.validator.Validator; @@ -39,42 +56,57 @@ */ public class MySqlDialect extends AbstractDialect { - private final List<BuiltinDataTypeMold> allDataTypes; + private static List<BuiltinDataTypeMold> list; + static { + List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); + list.add(new BuiltinDataTypeMoldImpl(CHARACTER, SizedDataTypeAdapter.class)); + list.add(new BuiltinDataTypeMoldImpl(VARCHAR, SizedDataTypeAdapter.class)); + list.add(new BuiltinDataTypeMoldImpl(CLOB, "TEXT")); + list.add(new BuiltinDataTypeMoldImpl(CLOB, "TINYTEXT")); + list.add(new BuiltinDataTypeMoldImpl(CLOB, "MEDIUMTEXT")); + list.add(new BuiltinDataTypeMoldImpl(CLOB, "LONGTEXT")); + list.add(new BuiltinDataTypeMoldImpl(BLOB)); + list.add(new BuiltinDataTypeMoldImpl(BLOB, "TINYBLOB")); + list.add(new BuiltinDataTypeMoldImpl(BLOB, "MEDIUMBLOB")); + list.add(new BuiltinDataTypeMoldImpl(BLOB, "LONGBLOB")); + list.add(new BuiltinDataTypeMoldImpl(BIT, SizedDataTypeAdapter.class)); + list.add(new BuiltinDataTypeMoldImpl(NUMERIC, PrecisionedDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(DECIMAL, PrecisionedDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(INTEGER, SizedDataTypeAdapter.class, SerialDataTypeAdapter.class, + Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(INTEGER, "MEDIUMINT", SizedDataTypeAdapter.class, + SerialDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(INTEGER, "BIGINT", SizedDataTypeAdapter.class, + SerialDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(SMALLINT, SizedDataTypeAdapter.class, SerialDataTypeAdapter.class, + Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(SMALLINT, "TINYINT", SizedDataTypeAdapter.class, + SerialDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(FLOAT, PrecisionedDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(REAL, PrecisionedDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(DOUBLE, PrecisionedDataTypeAdapter.class, Unsigned.class)); + list.add(new BuiltinDataTypeMoldImpl(DATE)); + list.add(new BuiltinDataTypeMoldImpl(TIME)); + list.add(new BuiltinDataTypeMoldImpl(TIMESTAMP)); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "DATETIME")); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "YEAR")); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "BINARY")); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "VARBINARY")); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "ENUM")); + list.add(new BuiltinDataTypeMoldImpl(OTHER, "SET")); + MySqlDialect.list = UnmodifiableList.decorate(list); + } + /** * インスタンスを生成する。 */ public MySqlDialect() { - List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); - // FIXME 適当 - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CHARACTER, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARCHAR, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CLOB, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BLOB, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BIT, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARBIT, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.NUMERIC, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DECIMAL, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.SMALLINT)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.FLOAT, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.REAL, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DOUBLE, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BOOLEAN)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DATE)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIME, TimezonedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIMESTAMP, TimezonedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTERVAL)); - allDataTypes = UnmodifiableList.decorate(list); - + super(list); emitter = new MySqlEmitter(getDataTypeResolver()); } - public List<BuiltinDataTypeMold> getAllDataTypes() { - return allDataTypes; - } - @Override public Validator getValidator() { CompositeValidator validator = (CompositeValidator) super.getValidator(); Added: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/CharsetAdapter.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/CharsetAdapter.java (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/CharsetAdapter.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -0,0 +1,34 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/25 + * + * 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.dialect.mysql.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; + +/** + * TODO for daisuke + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class CharsetAdapter { + + // TODO + +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/CharsetAdapter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/Unsigned.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/Unsigned.java (rev 0) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/Unsigned.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -0,0 +1,52 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/25 + * + * 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.dialect.mysql.adapter; + +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; + +/** + * TODO for daisuke + * + * @author daisuke + */ + @ Adapter(AdapterType.MODEL) +public class Unsigned { + + private Boolean unsigned; + + + /** + * TODO for daisuke + * + * @return the unsigned + */ + public Boolean getUnsigned() { + return unsigned; + } + + /** + * TODO for daisuke + * + * @param unsigned the unsigned to set + */ + public void setUnsigned(Boolean unsigned) { + this.unsigned = unsigned; + } +} Property changes on: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/adapter/Unsigned.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-dialect-postgresql/src/main/java/org/jiemamy/dialect/postgresql/PostgresqlDialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -35,38 +35,53 @@ */ public class PostgresqlDialect extends AbstractDialect { - private final List<BuiltinDataTypeMold> allDataTypes; + private static List<BuiltinDataTypeMold> list; - - /** - * インスタンスを生成する。 - */ - public PostgresqlDialect() { + static { List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CHARACTER, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARCHAR, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CLOB, SizedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BLOB, SizedDataTypeAdapter.class)); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CLOB, "TEXT")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BLOB, "BYTEA")); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BIT, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARBIT, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.NUMERIC, PrecisionedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DECIMAL, PrecisionedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER)); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER, "SERIAL")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER, "BIGINT")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTEGER, "BIGSERIAL")); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.SMALLINT)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.FLOAT, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.REAL, PrecisionedDataTypeAdapter.class)); - list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DOUBLE, PrecisionedDataTypeAdapter.class)); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.FLOAT, "REAL")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.REAL)); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DOUBLE, "DOUBLE PRECISION")); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.BOOLEAN)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.DATE)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIME, TimezonedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIMESTAMP, TimezonedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTERVAL)); - allDataTypes = UnmodifiableList.decorate(list); - // FIXME 適当 + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "UUID")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "MACADDR")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "MONEY")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "INET")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "CIDR")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "XML")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "LINE")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "LSEG")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "CIRCLE")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "BOX")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "PATH")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "POINT")); + list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.OTHER, "POLYGON")); + PostgresqlDialect.list = UnmodifiableList.decorate(list); } - public List<BuiltinDataTypeMold> getAllDataTypes() { - return allDataTypes; + + /** + * インスタンスを生成する。 + */ + public PostgresqlDialect() { + super(list); } @Override Modified: artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java =================================================================== --- artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-dialect-sql99/src/main/java/org/jiemamy/dialect/sql99/Sql99Dialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -39,13 +39,9 @@ */ public class Sql99Dialect extends AbstractDialect { - private final List<BuiltinDataTypeMold> allDataTypes; + private static List<BuiltinDataTypeMold> list; - - /** - * インスタンスを生成する。 - */ - public Sql99Dialect() { + static { List<BuiltinDataTypeMold> list = CollectionsUtil.newArrayList(); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.CHARACTER, SizedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.VARCHAR, SizedDataTypeAdapter.class)); @@ -65,12 +61,16 @@ list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIME, TimezonedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.TIMESTAMP, TimezonedDataTypeAdapter.class)); list.add(new BuiltinDataTypeMoldImpl(DataTypeCategory.INTERVAL)); - allDataTypes = UnmodifiableList.decorate(list); + Sql99Dialect.list = UnmodifiableList.decorate(list); // FIXME 適当 } - public List<BuiltinDataTypeMold> getAllDataTypes() { - return allDataTypes; + + /** + * インスタンスを生成する。 + */ + public Sql99Dialect() { + super(list); } @Override Modified: artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/connection/ConnectionModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/connection/ConnectionModelImplTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/connection/ConnectionModelImplTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -31,6 +31,7 @@ import org.jiemamy.ArtemisView; import org.jiemamy.Jiemamy; import org.jiemamy.model.node.NodeAdapter; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; import org.jiemamy.test.TestModelBuilder2; @@ -66,7 +67,7 @@ */ @Test public void test01_FKからコネクションが取得でき_そのソースとターゲットが正常に取得できる_empDept() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new ReflectionDialectProvider()); TestModelBuilder mb = new TestModelBuilder(jiemamy); mb.build(); @@ -95,7 +96,7 @@ */ @Test public void test02_FKからコネクションが取得でき_そのソースとターゲットが正常に取得できる_order() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new ReflectionDialectProvider()); TestModelBuilder2 mb = new TestModelBuilder2(jiemamy); mb.build(); Modified: artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/node/NodeModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/node/NodeModelImplTest.java 2009-02-24 16:00:57 UTC (rev 2732) +++ artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/node/NodeModelImplTest.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -34,6 +34,7 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.test.ReflectionDialectProvider; import org.jiemamy.test.TestModelBuilder; import org.jiemamy.test.TestModelBuilder2; @@ -69,7 +70,7 @@ */ @Test public void test01_エンティティからノードが取得でき_そのソースConsとターゲットConsが正常に取得できる_empDept() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new ReflectionDialectProvider()); TestModelBuilder mb = new TestModelBuilder(jiemamy); mb.build(); @@ -101,7 +102,7 @@ */ @Test public void test02_エンティティからノードが取得でき_そのソースConsとターゲットConsが正常に取得できる_order() throws Exception { - Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView())); + Jiemamy jiemamy = Jiemamy.newInstance(new Artemis(new ArtemisView()), new ReflectionDialectProvider()); TestModelBuilder2 mb = new TestModelBuilder2(jiemamy); mb.build(); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java 2009-02-24 16:00:57 UTC (rev 2732) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -22,6 +22,7 @@ import java.util.UUID; import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; +import org.jiemamy.exception.IllegalImplementationException; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; @@ -102,6 +103,8 @@ * * @param mold 鋳型情報 * @return {@link BuiltinDataType}のインスタンス + * @throws IllegalImplementationException moldに不正なアダプタが登録されている場合。 + */ BuiltinDataType newBuiltinDataType(BuiltinDataTypeMold mold); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-24 16:00:57 UTC (rev 2732) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-24 17:12:10 UTC (rev 2733) @@ -52,6 +52,7 @@ * @return 生成された {@link EntityModel} * @throws SQLException * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + * @throws UnsupportedOperationException DBからのインポートをサポートしていない場合 */ EntityModel createEntity(RootModel rootModel, ResultSet entity, DatabaseMetaData meta) throws SQLException; @@ -63,11 +64,20 @@ * @param rootModel {@link RootModel} * @param config * @return SQL文のリスト - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException SQL文の出力をサポートしていない場合 */ List<SqlStatement> emitStatements(RootModel rootModel, EmitConfig config); /** + * TODO for daisuke + * + * @param category + * @param typeName + * @return + */ + BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName); + + /** * このSQL方言用の{@link ConnectionAdvisor}を取得する。 * * <p>{@code null}を返してはならない。</p>