svnno****@sourc*****
svnno****@sourc*****
2009年 2月 20日 (金) 18:58:49 JST
Revision: 2694 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2694 Author: daisuke_m Date: 2009-02-20 18:58:49 +0900 (Fri, 20 Feb 2009) Log Message: ----------- 表示モードまわりのAPIを整備。 / デフォルトのDialectをGenericDialectに設定。 / vestaからUnexpectedConditionErrorをスローしていたので別の処理に変更。 / javadoc / refactor Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/SqlEmitter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/TokenResolver.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/TableCheckModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DateUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/ColumnBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/ColumnUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/KeyConstraintUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/TableUtil.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/AbstractTraversalValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/IdCollisionValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceCollisionValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/RootModelImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlDialectTest.java artemis/trunk/jiemamy-dialect-postgresql/src/test/java/org/jiemamy/dialect/postgresql/PostgresqlDialectTest.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/NodeAdapterImpl.java artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/DiagramPresentationModelImplTest.java vesta/trunk/org.jiemamy.eclipse/META-INF/MANIFEST.MF vesta/trunk/org.jiemamy.eclipse/plugin.xml vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseDialectProvider.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseExporterProvider.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseImporterProvider.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DirectEditNodeCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/TableEditorConfigurator.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.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 zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/RootModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeCategory.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/Token.java zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/DiagramPresentationModel.java zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayStatus.java zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Level.java zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Mode.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayMode.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/extraprocessor/ zeus/trunk/jiemamy-spec-core/src/main/resources/sample2.xml -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/FileCommentTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -102,8 +102,13 @@ public void tearDown() throws Exception { } + /** + * 全てのjavaファイルにライセンスコメントがついていること。 + * + * @throws Exception + */ @Test - public void test01_ライセンスコメントがついていること() throws Exception { + public void test01_全てのjavaファイルにライセンスコメントがついていること() throws Exception { List<File> errFiles = CollectionsUtil.newArrayList(); for (String path : projects) { logger.info(">>> Start Project " + path); Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseReader.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -26,8 +26,6 @@ import org.apache.commons.lang.Validate; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.jiemamy.dialect.Dialect; import org.jiemamy.utils.CollectionsUtil; @@ -47,8 +45,6 @@ */ class DatabaseReader { - private static Logger logger = LoggerFactory.getLogger(DatabaseReader.class); - // THINK DBを読み込んだ結果、modelを「出力する」主体はReaderである為、現在の実装のようにDialectに丸投げ委譲、 // というのは責務の重心がおかしい。Dialectは必要な部分のみReaderから問い合わせられるだけの立場であり、 // 基本的にモデルを組み立てる責務はReader側にあるものではないか? @@ -123,9 +119,6 @@ return result; } - /** - * {@inheritDoc} - */ @Override public String toString() { return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -40,7 +40,6 @@ import org.jiemamy.model.attribute.RepresentationAdapter; import org.jiemamy.model.attribute.constraint.ColumnCheckModel; import org.jiemamy.model.attribute.constraint.ColumnCheckModelImpl; -import org.jiemamy.model.attribute.constraint.ColumnConstraint; import org.jiemamy.model.attribute.constraint.Deferrability; import org.jiemamy.model.attribute.constraint.DeferrabilityImpl; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; @@ -240,7 +239,6 @@ @Override public <T>T newInstance(Jiemamy jiemamy, UUID id) { ColumnModelImpl columnModel = new ColumnModelImpl(jiemamy, id); - columnModel.setColumnConstraints(new ArrayList<ColumnConstraint>()); columnModel.registerAdapter(new RepresentationAdapter()); columnModel.registerAdapter(new DisablableImpl()); return (T) columnModel; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -138,7 +138,7 @@ } } else if (fieldValue instanceof Iterable) { // Iterableだった場合は要素に対して再起して調査する。 - Iterable<? extends Object> iterable = (Iterable) fieldValue; + Iterable<? extends Object> iterable = (Iterable<? extends Object>) fieldValue; for (Object element : iterable) { if (isDescendFromFieldValue(element, uuid)) { return true; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/SqlEmitter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/SqlEmitter.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/SqlEmitter.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -24,18 +24,18 @@ import org.jiemamy.model.sql.SqlStatement; /** - * TODO for daisuke + * RootModelからSQLのリストを生成するインターフェイス。 * * @author daisuke */ public interface SqlEmitter { /** - * TODO for daisuke + * RootModelからSQLのリストを生成する。 * - * @param rootModel - * @param instrunction - * @return + * @param rootModel 対象RootModel + * @param instrunction 設定 + * @return SQLのリスト */ List<SqlStatement> emit(RootModel rootModel, EmitConfig instrunction); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/TokenResolver.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/TokenResolver.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/TokenResolver.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -26,7 +26,7 @@ import org.jiemamy.model.sql.Token; /** - * TODO for daisuke + * Enumをトークンシーケンスに変換するリゾルバ。 * * @author daisuke */ @@ -35,24 +35,24 @@ /** * TODO for daisuke * - * @param initiallyCheckTime - * @return + * @param initiallyCheckTime 変換対象 + * @return トークンシーケンス */ List<Token> resolve(InitiallyCheckTime initiallyCheckTime); /** * TODO for daisuke * - * @param matchType - * @return + * @param matchType 変換対象 + * @return トークンシーケンス */ List<Token> resolve(MatchType matchType); /** * TODO for daisuke * - * @param onDelete - * @return + * @param onDelete 変換対象 + * @return トークンシーケンス */ List<Token> resolve(ReferentialAction onDelete); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -27,6 +27,7 @@ import org.apache.commons.lang.builder.ToStringStyle; import org.jiemamy.Jiemamy; +import org.jiemamy.dialect.generic.GenericDialect; import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.dataset.DataSetModel; import org.jiemamy.model.datatype.DomainModel; @@ -35,13 +36,13 @@ /** * 1つのDBスキーマ・データ全体を表す。 + * * @author daisuke */ - @ SuppressWarnings("serial") public class RootModelImpl extends AbstractJiemamyElement implements RootModel { /** SQL方言ID */ - private String dialectClassName; + private String dialectClassName = GenericDialect.class.getName(); /** 開始スクリプト */ private String beginScript; @@ -181,6 +182,7 @@ * {@inheritDoc} */ public void setDialectClassName(String dialectClassName) { + Validate.notNull(dialectClassName); this.dialectClassName = dialectClassName; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -18,7 +18,6 @@ */ package org.jiemamy.model.attribute; -import java.util.Collection; import java.util.UUID; import org.apache.commons.lang.builder.ToStringBuilder; @@ -26,12 +25,10 @@ import org.jiemamy.Jiemamy; import org.jiemamy.model.attribute.constraint.ColumnCheckModel; -import org.jiemamy.model.attribute.constraint.ColumnConstraint; import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; import org.jiemamy.model.attribute.constraint.UniqueKeyModel; import org.jiemamy.model.datatype.DataType; -import org.jiemamy.utils.ValidateUtil; /** * カラム定義モデル。Artemisにおける{@link ColumnModel}の実装クラス。 @@ -46,9 +43,6 @@ /** デフォルト値 */ private String defaultValue; - /** カラム制約の集合 */ - private Collection<ColumnConstraint> constraints; - private ColumnCheckModel check; private NotNullConstraintModel notNull; @@ -78,13 +72,6 @@ /** * {@inheritDoc} */ - public Collection<ColumnConstraint> getConstraints() { - return constraints; - } - - /** - * {@inheritDoc} - */ public synchronized DataType getDataType() { return dataType; } @@ -125,15 +112,6 @@ } /** - * TODO for daisuke - * @param columnConstraints the columnConstraints to set - */ - public void setColumnConstraints(Collection<ColumnConstraint> columnConstraints) { - ValidateUtil.injectionSetter(constraints); - constraints = columnConstraints; - } - - /** * {@inheritDoc} */ public synchronized void setDataType(DataType dataType) { Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/ForeignKeyModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -33,7 +33,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class ForeignKeyModelImpl extends AbstractKeyConstraintModel implements ForeignKeyModel { /** マッチ型 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/PrimaryKeyModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -26,7 +26,6 @@ * PRIMARY KEY制約モデル。 * @author daisuke */ - @ SuppressWarnings("serial") public class PrimaryKeyModelImpl extends AbstractKeyConstraintModel implements PrimaryKeyModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/TableCheckModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/TableCheckModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/TableCheckModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -27,7 +27,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class TableCheckModelImpl extends AbstractConstraintModel implements TableCheckModel { /** CHEKC制約定義式 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/constraint/UniqueKeyModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -26,7 +26,6 @@ * UNIQUE制約モデル。 * @author daisuke */ - @ SuppressWarnings("serial") public class UniqueKeyModelImpl extends AbstractKeyConstraintModel implements UniqueKeyModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/DataSetModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -33,7 +33,6 @@ * INSERT文用データセット。 * @author daisuke */ - @ SuppressWarnings("serial") public class DataSetModelImpl extends AbstractJiemamyElement implements DataSetModel { /** データセット名 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/dataset/RecordModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -32,7 +32,6 @@ * レコード(INSERT文1つ分)モデル。 * @author daisuke */ - @ SuppressWarnings("serial") public class RecordModelImpl extends AbstractJiemamyElement implements RecordModel { /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -28,7 +28,6 @@ * 精度とスケールを持つDataType用のアダプタ。 * @author daisuke */ - @ SuppressWarnings("serial") @Adapter(AdapterType.MODEL) public class PrecisionedDataTypeAdapter implements DataTypeAdapter { Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -28,7 +28,6 @@ * サイズを持つDataType用のアダプタ。 * @author daisuke */ - @ SuppressWarnings("serial") @Adapter(AdapterType.MODEL) public class SizedDataTypeAdapter implements DataTypeAdapter { Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -28,7 +28,6 @@ * タイムゾーン管理の有無を持つDataType用のアダプタ。 * @author daisuke */ - @ SuppressWarnings("serial") @Adapter(AdapterType.MODEL) public class TimezonedDataTypeAdapter implements DataTypeAdapter { Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -32,7 +32,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class TableModelImpl extends AbstractEntityModel implements TableModel { /** 属性のリスト */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -27,7 +27,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class ViewModelImpl extends AbstractEntityModel implements ViewModel { /** VIEW定義SELECT文 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexColumnModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -31,7 +31,6 @@ * インデックスカラムのモデル。 * @author daisuke */ - @ SuppressWarnings("serial") public class IndexColumnModelImpl extends AbstractJiemamyElement implements IndexColumnModel { /** インデックス対象カラム */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/index/IndexModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -32,7 +32,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class IndexModelImpl extends AbstractJiemamyElement implements IndexModel { /** インデックス名 */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -21,17 +21,20 @@ /** * 識別子クラス。 * + * <p>このクラスはイミュータブルである。</p> + * * @author daisuke */ public class Identifier implements Token { + /** 識別子文字列 */ private final String identifier; /** * インスタンスを生成する。 * - * @param identifier + * @param identifier 識別子文字列 */ public Identifier(String identifier) { this.identifier = identifier; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Keyword.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -21,6 +21,8 @@ /** * キーワードクラス。 * + * <p>このクラスはイミュータブルである。</p> + * * @author daisuke */ public class Keyword implements Token { @@ -129,26 +131,29 @@ /** - * TODO for daisuke + * インスタンスを生成する。 * - * @param keyword - * @return + * @param keyword キーワード文字列 + * @return インスタンス */ public static Keyword of(String keyword) { return new Keyword(keyword); } + /** キーワード文字列 */ private final String string; + /** + * インスタンスを生成する。 + * + * @param string キーワード文字列 + */ Keyword(String string) { this.string = string; } - /** - * {@inheritDoc} - */ @Override public String toString() { return string; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -25,6 +25,8 @@ /** * リテラルクラス。 * + * <p>このクラスはイミュータブルである。</p> + * * @author daisuke */ public class Literal implements Token { @@ -32,14 +34,30 @@ /** NULL */ public static final Literal NULL = new Literal("NULL", LiteralType.NULL); + /** TRUE */ + public static final Literal TRUE = new Literal(true); + + /** FALSE */ + public static final Literal FALSE = new Literal(false); + + /** 必要な場合クオートも含んだ文字列 */ private final String string; /** * インスタンスを生成する。 * - * @param number + * @param bool 値 */ + public Literal(boolean bool) { + this(Boolean.valueOf(bool).toString(), LiteralType.BOOLEAN); + } + + /** + * インスタンスを生成する。 + * + * @param number 値 + */ public Literal(Number number) { this(number.toString(), LiteralType.NUMERIC); } @@ -47,17 +65,14 @@ /** * インスタンスを生成する。 * - * @param string - * @param type + * @param string クオートを含まない、値をあらわす文字列 + * @param type リテラルの種類 */ public Literal(String string, LiteralType type) { Validate.notNull(string); this.string = type.convert(string); } - /** - * {@inheritDoc} - */ @Override public String toString() { return string; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Operator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -23,6 +23,8 @@ /** * 演算子クラス。 * + * <p>このクラスはイミュータブルである。</p> + * * @author daisuke */ public class Operator implements Token { @@ -33,6 +35,7 @@ /** NOT 演算子 */ public static final Operator NOT = new Operator("NOT"); + /** 演算子をあらわす文字列 */ private final String string; Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -1,469 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/15 - * - * 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.serializer; - -import static org.jiemamy.xml.CoreQName.ADAPTER; -import static org.jiemamy.xml.CoreQName.ATTRIBUTES; -import static org.jiemamy.xml.CoreQName.BEGIN_SCRIPT; -import static org.jiemamy.xml.CoreQName.COLUMN_CHECK_CONSTRAINT; -import static org.jiemamy.xml.CoreQName.COLUMN_PRIMARY_KEY; -import static org.jiemamy.xml.CoreQName.COLUMN_REF; -import static org.jiemamy.xml.CoreQName.COLUMN_REFS; -import static org.jiemamy.xml.CoreQName.COLUMN_UNIQUE_KEY; -import static org.jiemamy.xml.CoreQName.DATASET; -import static org.jiemamy.xml.CoreQName.DATASETS; -import static org.jiemamy.xml.CoreQName.DATA_TYPE; -import static org.jiemamy.xml.CoreQName.DEFAULT_VALUE; -import static org.jiemamy.xml.CoreQName.DEFERRABILITY; -import static org.jiemamy.xml.CoreQName.DEFERRABLE; -import static org.jiemamy.xml.CoreQName.DEFINITION; -import static org.jiemamy.xml.CoreQName.DESCRIPTION; -import static org.jiemamy.xml.CoreQName.DIALECT; -import static org.jiemamy.xml.CoreQName.DOMAIN; -import static org.jiemamy.xml.CoreQName.DOMAINS; -import static org.jiemamy.xml.CoreQName.END_SCRIPT; -import static org.jiemamy.xml.CoreQName.ENTITIES; -import static org.jiemamy.xml.CoreQName.EXPRESSION; -import static org.jiemamy.xml.CoreQName.INITIALLY_CHECK_TIME; -import static org.jiemamy.xml.CoreQName.LOGICAL_NAME; -import static org.jiemamy.xml.CoreQName.MATCH_TYPE; -import static org.jiemamy.xml.CoreQName.NAME; -import static org.jiemamy.xml.CoreQName.NOT_NULL; -import static org.jiemamy.xml.CoreQName.ON_DELETE; -import static org.jiemamy.xml.CoreQName.ON_UPDATE; -import static org.jiemamy.xml.CoreQName.RECORD; -import static org.jiemamy.xml.CoreQName.REFERENCE_COLUMNS; -import static org.jiemamy.xml.CoreQName.SCHEMA_NAME; -import static org.jiemamy.xml.CoreQName.TABLE; -import static org.jiemamy.xml.CoreQName.TABLE_CHECK_CONSTRAINT; -import static org.jiemamy.xml.CoreQName.TABLE_REF; -import static org.jiemamy.xml.CoreQName.TYPE_CATEGORY; -import static org.jiemamy.xml.CoreQName.TYPE_NAME; -import static org.jiemamy.xml.CoreQName.VIEW; - -import java.lang.reflect.Field; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.UUID; -import java.util.Map.Entry; - -import javax.xml.namespace.QName; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.commons.collections15.list.UnmodifiableList; -import org.apache.commons.lang.BooleanUtils; -import org.apache.commons.lang.ObjectUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import org.jiemamy.ReferenceResolver; -import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.model.Adapter; -import org.jiemamy.model.AdapterType; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.AttributeModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.model.attribute.constraint.ColumnCheckModel; -import org.jiemamy.model.attribute.constraint.ColumnConstraint; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel; -import org.jiemamy.model.attribute.constraint.KeyConstraintModel; -import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; -import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; -import org.jiemamy.model.attribute.constraint.TableCheckModel; -import org.jiemamy.model.attribute.constraint.UniqueKeyModel; -import org.jiemamy.model.dataset.DataSetModel; -import org.jiemamy.model.dataset.RecordModel; -import org.jiemamy.model.datatype.BuiltinDataType; -import org.jiemamy.model.datatype.DataType; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.DomainRef; -import org.jiemamy.model.entity.EntityModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.TableRef; -import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.utils.AnnotationUtil; -import org.jiemamy.utils.CollectionsUtil; -import org.jiemamy.utils.DomUtil; -import org.jiemamy.utils.model.TableUtil; -import org.jiemamy.xml.CoreNamespace; -import org.jiemamy.xml.CoreQName; -import org.jiemamy.xml.JiemamyQName; - -/** - * {@link RootModel}からJiemamy XMLモデルのDOMを生成するクラス。 - * - * @author daisuke - */ -class DomBuilder { - - private static Logger logger = LoggerFactory.getLogger(DomBuilder.class); - - - private static Element newColumnConstraintsElement(Element parentElement, ColumnConstraint columnConstraint) { - if (columnConstraint == null) { - return null; - } - Element element = null; - if (columnConstraint instanceof NotNullConstraintModel) { - NotNullConstraintModel nnModel = (NotNullConstraintModel) columnConstraint; - element = DomUtil.newChild(parentElement, NOT_NULL); - element.setAttribute(CoreQName.ID.getQNameString(), nnModel.getId().toString()); - DomUtil.newChild(element, NAME, nnModel.getName()); - writeAdapters(element, nnModel.getAdapters()); - } else if (columnConstraint instanceof ColumnCheckModel) { - ColumnCheckModel columnCheckModel = (ColumnCheckModel) columnConstraint; - writeColumnCheckConstrait(parentElement, columnCheckModel); - } else if (columnConstraint instanceof UniqueKeyModel) { - UniqueKeyModel ukModel = (UniqueKeyModel) columnConstraint; - element = DomUtil.newChild(parentElement, COLUMN_UNIQUE_KEY); - element.setAttribute(CoreQName.ID.getQNameString(), ukModel.getId().toString()); - DomUtil.newChild(element, NAME, ukModel.getName()); - writeAdapters(element, ukModel.getAdapters()); - } else if (columnConstraint instanceof PrimaryKeyModel) { - PrimaryKeyModel pkModel = (PrimaryKeyModel) columnConstraint; - element = DomUtil.newChild(parentElement, COLUMN_PRIMARY_KEY); - element.setAttribute(CoreQName.ID.getQNameString(), pkModel.getId().toString()); - DomUtil.newChild(element, NAME, pkModel.getName()); - writeAdapters(element, pkModel.getAdapters()); - } - return element; - } - - private static Element newDataTypeElement(Element parentElement, DataType dataType) { - Element dataTypeElement = DomUtil.newChild(parentElement, DATA_TYPE); - if (dataType instanceof DomainRef) { - DomainRef domainRef = (DomainRef) dataType; - dataTypeElement.setAttribute(CoreQName.REF.getQNameString(), domainRef.getReferenceId().toString()); - } else if (dataType instanceof BuiltinDataType) { - BuiltinDataType builtinDataType = (BuiltinDataType) dataType; - DomUtil.newChild(dataTypeElement, TYPE_CATEGORY, builtinDataType.getCategory()); - DomUtil.newChild(dataTypeElement, TYPE_NAME, builtinDataType.getTypeName()); - writeAdapters(dataTypeElement, builtinDataType.getAdapters()); - } else if (dataType == null) { - // nothing to do - } else { - throw new UnexpectedConditionError("unknown DataType: " + dataType.getClass().getName()); - } - return dataTypeElement; - } - - private static SortedSet<Entry<ColumnRef, String>> sortDataEntry(EntityModel entity, RecordModel recordModel) { - SortedSet<Entry<ColumnRef, String>> treeSet = - new TreeSet<Map.Entry<ColumnRef, String>>(new RecordSetComparator(TableUtil - .getColumns((TableModel) entity))); - for (Map.Entry<ColumnRef, String> entry2 : recordModel.getValues().entrySet()) { - treeSet.add(entry2); - } - return treeSet; - } - - private static void writeAdapters(Element parentElement, List<Object> adapters) { - for (Object adapter : adapters) { - Adapter annotation = AnnotationUtil.getTypeAnnotation(adapter, Adapter.class); - assert annotation != null; - if (annotation.value() == AdapterType.MODEL) { - Element adapterElement = DomUtil.newChild(parentElement, ADAPTER); - adapterElement.setAttribute(CoreQName.CLASS.getQNameString(), adapter.getClass().getName()); - boolean existSpecificValue = false; - for (Field field : adapter.getClass().getDeclaredFields()) { - String value = null; - try { - field.setAccessible(true); - value = ObjectUtils.toString(field.get(adapter), null); - } catch (IllegalArgumentException e) { - logger.error(e.getMessage()); - throw new UnexpectedConditionError("フィールドは必ず存在するはず", e); - } catch (IllegalAccessException e) { - logger.error(e.getMessage()); - throw new UnexpectedConditionError("setAccessible(true)しているのでアクセスできるはず", e); - } - if (value != null) { - DomUtil.newChild(adapterElement, new QName(CoreNamespace.NS_CORE.getNamespaceURI(), field - .getName()), value); - existSpecificValue = true; - } - } - if (existSpecificValue == false) { - parentElement.removeChild(adapterElement); - } - } - } - } - - private static void writeColumnCheckConstrait(Element parentElement, ColumnCheckModel checkConstraintModel) { - Element checkElement = DomUtil.newChild(parentElement, COLUMN_CHECK_CONSTRAINT); - checkElement.setAttribute(CoreQName.ID.getQNameString(), checkConstraintModel.getId().toString()); - DomUtil.newChild(checkElement, NAME, checkConstraintModel.getName()); - DomUtil.newChild(checkElement, EXPRESSION, checkConstraintModel.getExpression()); - writeAdapters(checkElement, checkConstraintModel.getAdapters()); - } - - private static void writeTableCheckConstrait(Element parentElement, TableCheckModel checkConstraintModel) { - Element checkElement = DomUtil.newChild(parentElement, TABLE_CHECK_CONSTRAINT); - checkElement.setAttribute(CoreQName.ID.getQNameString(), checkConstraintModel.getId().toString()); - DomUtil.newChild(checkElement, NAME, checkConstraintModel.getName()); - DomUtil.newChild(checkElement, LOGICAL_NAME, checkConstraintModel.getLogicalName()); - DomUtil.newChild(checkElement, DESCRIPTION, checkConstraintModel.getDescription()); - DomUtil.newChild(checkElement, EXPRESSION, checkConstraintModel.getExpression()); - writeAdapters(checkElement, checkConstraintModel.getAdapters()); - } - - - private RootModel rootModel; - - - /** - * インスタンスを生成する。 - * - * @param rootModel - */ - public DomBuilder(RootModel rootModel) { - this.rootModel = rootModel; - } - - /** - * DOM Documentを構築する。 - * - * @return DOM Document - * @throws ParserConfigurationException - */ - public Document build() throws ParserConfigurationException { - DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); - documentBuilderFactory.setNamespaceAware(true); - DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); - Document document = documentBuilder.newDocument(); - - Element rootElement = DomUtil.newElement(document, CoreQName.ROOT_MODEL); - rootElement.setAttribute(CoreQName.ID.getQNameString(), rootModel.getId().toString()); - rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - // FIXME locationを正式なURLに - rootElement.setAttribute("xsi:schemaLocation", "" - + "http://jiemamy.org/xml/ns/core ../../main/resources/jiemamy-core.xsd"); - document.appendChild(rootElement); - - buildMiscSection(rootElement); - buildDomainSection(rootElement); - buildNodeSection(rootElement); - buildDataSetSection(rootElement); - - return document; - } - - private void buildDataSetSection(Element rootElement) { - Element insertDataSetElement = DomUtil.newChild(rootElement, DATASETS); - for (DataSetModel insertDataSetModel : rootModel.getDataSets()) { - Element insertDataSet = DomUtil.newChild(insertDataSetElement, DATASET); - insertDataSet.setAttribute(CoreQName.ID.getQNameString(), insertDataSetModel.getId().toString()); - DomUtil.newChild(insertDataSet, NAME, insertDataSetModel.getName()); - for (Map.Entry<TableRef, List<RecordModel>> entry : insertDataSetModel.getRecords().entrySet()) { - TableRef tableRef = entry.getKey(); - ReferenceResolver resolver = insertDataSetModel.getJiemamy().getReferenceResolver(); - EntityModel resolved = resolver.resolve(tableRef); - Element entityElement = DomUtil.newChild(insertDataSet, TABLE_REF); - entityElement.setAttribute(CoreQName.REF.getQNameString(), tableRef.getReferenceId().toString()); - for (RecordModel recordModel : entry.getValue()) { - Element recordElement = DomUtil.newChild(entityElement, RECORD); - recordElement.setAttribute(CoreQName.ID.getQNameString(), recordModel.getId().toString()); - SortedSet<Entry<ColumnRef, String>> treeSet = sortDataEntry(resolved, recordModel); - for (Map.Entry<ColumnRef, String> entry2 : treeSet) { - String value = entry2.getValue(); - Element columnDataElement; - columnDataElement = DomUtil.newChild(recordElement, COLUMN_REF, value); - if (columnDataElement != null) { - columnDataElement.setAttribute(CoreQName.REF.getQNameString(), entry2.getKey() - .getReferenceId().toString()); - } - } - } - } - } - } - - private void buildDomainSection(Element rootElement) { - Element domainsElement = DomUtil.newChild(rootElement, DOMAINS); - for (DomainModel domainModel : rootModel.getDomains()) { - Element domainElement = DomUtil.newChild(domainsElement, DOMAIN); - domainElement.setAttribute(CoreQName.ID.getQNameString(), domainModel.getId().toString()); - DomUtil.newChild(domainElement, NAME, domainModel.getName()); - DomUtil.newChild(domainElement, LOGICAL_NAME, domainModel.getLogicalName()); - DomUtil.newChild(domainElement, DESCRIPTION, domainModel.getDescription()); - newDataTypeElement(domainElement, domainModel.getDataType()); - - NotNullConstraintModel notNull = domainModel.getNotNull(); - if (notNull != null) { - Element notNullElement = DomUtil.newChild(domainElement, NOT_NULL); - notNullElement.setAttribute(CoreQName.ID.getQNameString(), notNull.getId().toString()); - DomUtil.newChild(notNullElement, NAME, notNull.getName()); - writeAdapters(notNullElement, notNull.getAdapters()); - } - - ColumnCheckModel check = domainModel.getCheck(); - if (check != null) { - writeColumnCheckConstrait(domainElement, check); - } - } - } - - private void buildMiscSection(Element rootElement) { - DomUtil.newChild(rootElement, DIALECT, rootModel.getDialectClassName()); - DomUtil.newChild(rootElement, SCHEMA_NAME, rootModel.getSchemaName()); - DomUtil.newChild(rootElement, DESCRIPTION, rootModel.getDescription()); - DomUtil.newChild(rootElement, BEGIN_SCRIPT, rootModel.getBeginScript()); - DomUtil.newChild(rootElement, END_SCRIPT, rootModel.getEndScript()); - } - - private void buildNodeSection(Element rootElement) { - Element entitiesElement = DomUtil.newChild(rootElement, ENTITIES); - for (EntityModel entityModel : rootModel.getEntities()) { - Element entityElement = null; - - if (entityModel instanceof TableModel) { - TableModel tableModel = (TableModel) entityModel; - entityElement = DomUtil.newChild(entitiesElement, TABLE); - DomUtil.newChild(entityElement, NAME, tableModel.getName()); - DomUtil.newChild(entityElement, LOGICAL_NAME, tableModel.getLogicalName()); - DomUtil.newChild(entityElement, DESCRIPTION, tableModel.getDescription()); - DomUtil.newChild(entityElement, BEGIN_SCRIPT, tableModel.getBeginScript()); - DomUtil.newChild(entityElement, END_SCRIPT, tableModel.getEndScript()); - - Element attributesElement = DomUtil.newChild(entityElement, ATTRIBUTES); - for (AttributeModel attributeModel : tableModel.getAttributes()) { - Element attributeElement = DomUtil.newChild(attributesElement, getQName(attributeModel)); - attributeElement.setAttribute(CoreQName.ID.getQNameString(), attributeModel.getId().toString()); - DomUtil.newChild(attributeElement, NAME, attributeModel.getName()); - DomUtil.newChild(attributeElement, LOGICAL_NAME, attributeModel.getLogicalName()); - DomUtil.newChild(attributeElement, DESCRIPTION, attributeModel.getDescription()); - if (attributeModel instanceof ColumnModel) { - ColumnModel columnModel = (ColumnModel) attributeModel; - newDataTypeElement(attributeElement, columnModel.getDataType()); - DomUtil.newChild(attributeElement, DEFAULT_VALUE, columnModel.getDefaultValue()); - newColumnConstraintsElement(attributeElement, columnModel.getNotNull()); - newColumnConstraintsElement(attributeElement, columnModel.getUniqueKey()); - newColumnConstraintsElement(attributeElement, columnModel.getPrimaryKey()); - newColumnConstraintsElement(attributeElement, columnModel.getCheck()); - } else if (attributeModel instanceof KeyConstraintModel) { - KeyConstraintModel keyeyModel = (KeyConstraintModel) attributeModel; - Element columnRefsElement = DomUtil.newChild(attributeElement, COLUMN_REFS); - for (ColumnRef pkColumn : keyeyModel.getKeyColumns()) { - Element columnRefElement = DomUtil.newChild(columnRefsElement, COLUMN_REF); - columnRefElement.setAttribute(CoreQName.REF.getQNameString(), pkColumn.getReferenceId() - .toString()); - } - - if (attributeModel instanceof ForeignKeyModel) { - ForeignKeyModel foreignKeyModel = (ForeignKeyModel) keyeyModel; - - Element kyColumnsElement = DomUtil.newChild(attributeElement, REFERENCE_COLUMNS); - for (ColumnRef keyColumnRef : foreignKeyModel.getReferenceColumns()) { - Element columnRefElement = DomUtil.newChild(kyColumnsElement, COLUMN_REF); - columnRefElement.setAttribute(CoreQName.REF.getQNameString(), keyColumnRef - .getReferenceId().toString()); - } - - if (foreignKeyModel.getDeferrability() != null) { - Deferrability deferrability = foreignKeyModel.getDeferrability(); - Element deferrabilityElement = DomUtil.newChild(attributeElement, DEFERRABILITY); - deferrabilityElement.setAttribute(CoreQName.ID.getQNameString(), deferrability.getId() - .toString()); - DomUtil.newChild(deferrabilityElement, DEFERRABLE, BooleanUtils - .toStringTrueFalse(deferrability.isDeferrable())); - DomUtil.newChild(deferrabilityElement, INITIALLY_CHECK_TIME, deferrability - .getInitiallyCheckTime()); - } - - DomUtil.newChild(attributeElement, MATCH_TYPE, foreignKeyModel.getMatchType()); - DomUtil.newChild(attributeElement, ON_DELETE, foreignKeyModel.getOnDelete()); - DomUtil.newChild(attributeElement, ON_UPDATE, foreignKeyModel.getOnUpdate()); - } - } else if (attributeModel instanceof TableCheckModel) { - TableCheckModel tableCheckModel = (TableCheckModel) attributeModel; - writeTableCheckConstrait(attributeElement, tableCheckModel); - } - writeAdapters(attributeElement, attributeModel.getAdapters()); - } - } else if (entityModel instanceof ViewModel) { - ViewModel viewModel = (ViewModel) entityModel; - entityElement = DomUtil.newChild(entitiesElement, VIEW); - DomUtil.newChild(entityElement, NAME, viewModel.getName()); - DomUtil.newChild(entityElement, LOGICAL_NAME, viewModel.getLogicalName()); - DomUtil.newChild(entityElement, DESCRIPTION, viewModel.getDescription()); - DomUtil.newChild(entityElement, BEGIN_SCRIPT, viewModel.getBeginScript()); - DomUtil.newChild(entityElement, END_SCRIPT, viewModel.getEndScript()); - DomUtil.newChild(entityElement, DEFINITION, viewModel.getDefinition()); - } else { - throw new UnexpectedConditionError("unknown entity:" + entityModel.getClass().getName()); - } - writeAdapters(entityElement, entityModel.getAdapters()); - entityElement.setAttribute(CoreQName.ID.getQNameString(), entityModel.getId().toString()); - entitiesElement.appendChild(entityElement); - } - } - - private JiemamyQName getQName(AttributeModel attributeModel) { - if (attributeModel instanceof ColumnModel) { - return CoreQName.COLUMN; - } else if (attributeModel instanceof PrimaryKeyModel) { - return CoreQName.PRIMARY_KEY; - } else if (attributeModel instanceof UniqueKeyModel) { - return CoreQName.UNIQUE_KEY; - } else if (attributeModel instanceof ForeignKeyModel) { - return CoreQName.FOREIGN_KEY; - } else if (attributeModel instanceof TableCheckModel) { - return CoreQName.TABLE_CHECK_CONSTRAINT; - } else { - return null; - } - } - - - /** - * 出力レコードの並び順を、カラム定義順に合わせるコンパレータ。 - * - * @author daisuke - */ - private static class RecordSetComparator implements Comparator<Entry<ColumnRef, String>> { - - private final List<UUID> order; - - - RecordSetComparator(List<ColumnModel> columns) { - List<UUID> tmpOrder = CollectionsUtil.newArrayList(); - for (ColumnModel columnModel : columns) { - tmpOrder.add(columnModel.getId()); - } - order = UnmodifiableList.decorate(tmpOrder); - } - - public int compare(Entry<ColumnRef, String> o1, Entry<ColumnRef, String> o2) { - int i1 = order.indexOf(o1.getKey().getReferenceId()); - int i2 = order.indexOf(o2.getKey().getReferenceId()); - return i1 - i2; - } - - } -} Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -1,550 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/15 - * - * 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.serializer; - -import static org.jiemamy.xml.CoreQName.TABLE; -import static org.jiemamy.xml.CoreQName.VIEW; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpressionException; - -import org.apache.commons.lang.BooleanUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import org.jiemamy.Jiemamy; -import org.jiemamy.JiemamyFactory; -import org.jiemamy.dialect.BuiltinDataTypeMoldImpl; -import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; -import org.jiemamy.exception.UnexpectedConditionError; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.attribute.ColumnModel; -import org.jiemamy.model.attribute.ColumnRef; -import org.jiemamy.model.attribute.ColumnRefImpl; -import org.jiemamy.model.attribute.constraint.ColumnCheckModel; -import org.jiemamy.model.attribute.constraint.Deferrability; -import org.jiemamy.model.attribute.constraint.ForeignKeyModel; -import org.jiemamy.model.attribute.constraint.KeyConstraintModel; -import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; -import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; -import org.jiemamy.model.attribute.constraint.TableCheckModel; -import org.jiemamy.model.attribute.constraint.UniqueKeyModel; -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.BuiltinDataType; -import org.jiemamy.model.datatype.DataType; -import org.jiemamy.model.datatype.DataTypeCategory; -import org.jiemamy.model.datatype.DomainModel; -import org.jiemamy.model.datatype.DomainRefImpl; -import org.jiemamy.model.entity.EntityModel; -import org.jiemamy.model.entity.TableModel; -import org.jiemamy.model.entity.TableRef; -import org.jiemamy.model.entity.TableRefImpl; -import org.jiemamy.model.entity.ViewModel; -import org.jiemamy.utils.Adaptable; -import org.jiemamy.utils.DomUtil; -import org.jiemamy.utils.IterableNodeList; -import org.jiemamy.utils.XpathUtil; -import org.jiemamy.xml.CoreQName; - -/** - * Jiemamy XMLモデルのDOMから{@link RootModel}を生成するクラス。 - * - * @author daisuke - */ -class DomParser { - - private static Logger logger = LoggerFactory.getLogger(DomParser.class); - - - private static void readAdapter(Element element, Adaptable jiemamyElement) { - NodeList adapterNodeList = XpathUtil.getNodes(element, "core:adapter"); - Iterable<Node> adapterIterator = new IterableNodeList(adapterNodeList); - - for (Node adapterNode : adapterIterator) { - String className = DomUtil.getAttributeString((Element) adapterNode, CoreQName.CLASS); - try { - Class<?> clazz = Class.forName(className); - Object adapter; - if (jiemamyElement.hasAdapter(clazz)) { - adapter = jiemamyElement.getAdapter(clazz); - } else { - try { - adapter = clazz.newInstance(); - jiemamyElement.registerAdapter(adapter); - } catch (InstantiationException e) { - logger.warn("ModelAdapter must have default constructor.", e); - continue; - } catch (IllegalAccessException e) { - logger.warn("ModelAdapter must be public.", e); - continue; - } - } - NodeList propertyNodes = adapterNode.getChildNodes(); - Iterable<Node> propertyNodesIterator = new IterableNodeList(propertyNodes); - - for (Node propertyNode : propertyNodesIterator) { - if ((propertyNode instanceof Element) == false) { - continue; - } - Element propertyElement = (Element) propertyNode; - String fieldName = null; - try { - fieldName = propertyElement.getTagName(); - Field field = adapter.getClass().getDeclaredField(fieldName); - field.setAccessible(true); - String value = propertyElement.getTextContent(); - Class<?> type = field.getType(); - if (type == Integer.class || type == int.class) { - field.set(adapter, NumberUtils.toInt(value)); - } else if (type == Long.class || type == long.class) { - field.set(adapter, NumberUtils.toLong(value)); - } else if (type == Float.class || type == float.class) { - field.set(adapter, NumberUtils.toFloat(value)); - } else if (type == Double.class || type == double.class) { - field.set(adapter, NumberUtils.toDouble(value)); - } else if (type == Boolean.class || type == boolean.class) { - field.set(adapter, BooleanUtils.toBoolean(value)); - } else if (type == String.class) { - field.set(adapter, value); - } else { - logger.warn("unsupported model adapter field data type: " + field.getType().getName()); - } - } catch (SecurityException e) { - logger.warn("TODO", e); // TODO - } catch (NoSuchFieldException e) { - logger.warn("no such field " + fieldName + " in " + className, e); - } catch (IllegalArgumentException e) { - logger.warn("TODO", e); // TODO - } catch (IllegalAccessException e) { - throw new UnexpectedConditionError("setAccessible(true)したハズ。", e); - } - } - - } catch (ClassNotFoundException e) { - logger.warn("class not found (ignored): " + className, e); - } - } - } - - - private final Jiemamy jiemamy; - - private final JiemamyFactory factory; - - private final Document document; - - - /** - * インスタンスを生成する。 - * @param jiemamy - * @param document - */ - public DomParser(Jiemamy jiemamy, Document document) { - this.jiemamy = jiemamy; - factory = jiemamy.getFactory(); - this.document = document; - } - - /** - * DOMを解析し、{@link RootModel}を生成する。 - * @return 生成した{@link RootModel} - */ - public RootModel parse() { - RootModel rootModel = parseRoot(); - parseDomainSection(rootModel); - parseEntitiesSection(rootModel); - parseDataSetSection(rootModel); - - return rootModel; - } - - private DataType getDataType(Element element) { - try { - if (element.getChildNodes().getLength() == 0 && StringUtils.isEmpty(element.getAttribute("ref")) == false) { - return new DomainRefImpl(jiemamy, DomUtil.getUUID(element, CoreQName.REF)); - } else { - String typeCategoryString = - (String) XpathUtil.XPATH.evaluate("core:typeCategory/text()", element, XPathConstants.STRING); - String typeName = - (String) XpathUtil.XPATH.evaluate("core:typeName/text()", element, XPathConstants.STRING); - - BuiltinDataTypeMold mold; - if (StringUtils.isEmpty(typeCategoryString) == false) { - // FIXME ここでモールド生成していいんか - mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.valueOf(typeCategoryString), typeName); - } else { - DataTypeCategory category; - try { - category = DataTypeCategory.valueOf(typeName); - } catch (IllegalArgumentException e) { - category = DataTypeCategory.INTEGER; - } - // FIXME ここでモールド生成していいんか - mold = new BuiltinDataTypeMoldImpl(category, typeName); - } - BuiltinDataType dataType = factory.newBuiltinDataType(mold); - dataType.setTypeName(typeName); - - readAdapter(element, dataType); - - return dataType; - } - } catch (XPathExpressionException e) { - throw new UnexpectedConditionError("XPath expression error", e); - } - } - - /** - * TODO for daisuke - * - * @param tableElement - * @param tableModel - */ - private void parseAttributes(Element tableElement, TableModel tableModel) { - NodeList attributeNodeList = XpathUtil.getNodes(tableElement, "core:attributes/*"); - Iterable<Node> attributeIterableNodeList = new IterableNodeList(attributeNodeList); - for (Node attributeNode : attributeIterableNodeList) { - if ((attributeNode instanceof Element) == false) { - continue; - } - Element attributeElement = (Element) attributeNode; - if (DomUtil.equalsElement(attributeElement, CoreQName.COLUMN)) { - parseColumn(attributeElement, tableModel); - } else if (DomUtil.equalsElement(attributeElement, CoreQName.PRIMARY_KEY)) { - parsePrimaryKey(attributeElement, tableModel); - } else if (DomUtil.equalsElement(attributeElement, CoreQName.UNIQUE_KEY)) { - parseUniqueKey(attributeElement, tableModel); - } else if (DomUtil.equalsElement(attributeElement, CoreQName.FOREIGN_KEY)) { - parseForeignKey(attributeElement, tableModel); - } else if (DomUtil.equalsElement(attributeElement, CoreQName.TABLE_CHECK_CONSTRAINT)) { - parseTableCheckConstraint(attributeElement, tableModel); - } else { - logger.warn("unknown attribute"); - } - } - } - - private void parseColumn(Element columnElement, TableModel tableModel) { - ColumnModel columnModel = factory.newModel(ColumnModel.class, DomUtil.getUUID(columnElement, CoreQName.ID)); - columnModel.setName(XpathUtil.getText(columnElement, "core:name/text()")); - columnModel.setLogicalName(XpathUtil.getTextContent(columnElement, "core:logicalName")); - columnModel.setDataType(getDataType((Element) XpathUtil.getNode(columnElement, "core:dataType"))); - columnModel.setDefaultValue(XpathUtil.getTextContent(columnElement, "core:defaultValue")); - - Element nnElement = (Element) XpathUtil.getNode(columnElement, "core:notNull"); - if (nnElement != null) { - NotNullConstraintModel nnModel = - factory.newModel(NotNullConstraintModel.class, DomUtil.getUUID(nnElement, CoreQName.ID)); - nnModel.setName(XpathUtil.getText(nnElement, "core:name/text()")); - readAdapter(nnElement, nnModel); - columnModel.setNotNull(nnModel); - } - - Element ukElement = (Element) XpathUtil.getNode(columnElement, "core:columnUniqueKey"); - if (ukElement != null) { - UniqueKeyModel ukModel = factory.newModel(UniqueKeyModel.class, DomUtil.getUUID(ukElement, CoreQName.ID)); - ukModel.setName(XpathUtil.getText(ukElement, "core:name/text()")); - ukModel.getKeyColumns().add(factory.newReference(columnModel)); - readAdapter(ukElement, ukModel); - columnModel.setUniqueKey(ukModel); - } - - Element pkElement = (Element) XpathUtil.getNode(columnElement, "core:columnPrimaryKey"); - if (pkElement != null) { - PrimaryKeyModel pkModel = factory.newModel(PrimaryKeyModel.class, DomUtil.getUUID(pkElement, CoreQName.ID)); - pkModel.setName(XpathUtil.getText(pkElement, "core:name/text()")); - pkModel.getKeyColumns().add(factory.newReference(columnModel)); - readAdapter(pkElement, pkModel); - columnModel.setPrimaryKey(pkModel); - } - - Element checkElement = (Element) XpathUtil.getNode(columnElement, "core:columnCheck"); - if (checkElement != null) { - ColumnCheckModel checkModel = - factory.newModel(ColumnCheckModel.class, DomUtil.getUUID(checkElement, CoreQName.ID)); - checkModel.setName(XpathUtil.getText(checkElement, "core:name/text()")); - checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); - readAdapter(checkElement, checkModel); - columnModel.setCheck(checkModel); - } - - columnModel.setDescription(XpathUtil.getTextContent(columnElement, "core:description")); - readAdapter(columnElement, columnModel); - tableModel.getAttributes().add(columnModel); - } - - private void parseDataSetSection(RootModel rootModel) { - NodeList dataSetNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:dataSets/core:dataSet"); - Iterable<Node> dataSetIterableNodeList = new IterableNodeList(dataSetNodeList); - for (Node dataSetNode : dataSetIterableNodeList) { - - DataSetModel dataSetModel = - factory.newModel(DataSetModel.class, DomUtil.getUUID(dataSetNode, CoreQName.ID)); - dataSetModel.setName(XpathUtil.getText(dataSetNode, "core:name/text()")); - - NodeList tableRefNodeList = XpathUtil.getNodes(dataSetNode, "core:tableRef"); - Iterable<Node> tableRefIterableNodeList = new IterableNodeList(tableRefNodeList); - for (Node tableRefNode : tableRefIterableNodeList) { - - TableRef tableRef = new TableRefImpl(jiemamy, DomUtil.getUUID(tableRefNode, CoreQName.REF)); - List<RecordModel> recordModels = dataSetModel.getRecords().get(tableRef); - if (recordModels == null) { - recordModels = new ArrayList<RecordModel>(); - } - - NodeList recordNodeList = XpathUtil.getNodes(tableRefNode, "core:record"); - Iterable<Node> recordIterableNodeList = new IterableNodeList(recordNodeList); - for (Node recordNode : recordIterableNodeList) { - RecordModel recordModel = - factory.newModel(RecordModel.class, DomUtil.getUUID(recordNode, CoreQName.ID)); - - NodeList columnRefNodeList = XpathUtil.getNodes(recordNode, "core:columnRef"); - Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); - for (Node columnRefNode : columnRefIterableNodeList) { - ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF)); - recordModel.getValues().put(columnRef, columnRefNode.getTextContent()); - } - recordModels.add(recordModel); - } - - dataSetModel.getRecords().put(tableRef, recordModels); - } - rootModel.getDataSets().add(dataSetModel); - } - } - - private void parseDeferrability(Element keyElement, KeyConstraintModel keyModel) { - Node deferrabilityElement = XpathUtil.getNode(keyElement, "core:deferrability"); - - if (deferrabilityElement != null) { - Deferrability deferrability = - factory.newModel(Deferrability.class, DomUtil.getUUID(deferrabilityElement, CoreQName.ID)); - String deferrableString = XpathUtil.getTextContent(deferrabilityElement, "core:deferrable"); - deferrability.setDeferrable(BooleanUtils.toBoolean(deferrableString)); - - String initiallyCheckTimeString = XpathUtil.getTextContent(deferrabilityElement, "core:initiallyCheckTime"); - if (StringUtils.isEmpty(initiallyCheckTimeString) == false) { - deferrability.setInitiallyCheckTime(InitiallyCheckTime.valueOf(initiallyCheckTimeString)); - } - - readAdapter((Element) deferrabilityElement, deferrability); - keyModel.setDeferrability(deferrability); - } - } - - private void parseDomainSection(RootModel rootModel) { - NodeList domainsNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:domains/core:domain"); - Iterable<Node> domainsIterableNodeList = new IterableNodeList(domainsNodeList); - for (Node domainNode : domainsIterableNodeList) { - DomainModel domainModel = factory.newModel(DomainModel.class, DomUtil.getUUID(domainNode, CoreQName.ID)); - domainModel.setName(XpathUtil.getTextContent(domainNode, "core:name")); - domainModel.setLogicalName(XpathUtil.getTextContent(domainNode, "core:logicalName")); - domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode, - "core:dataType"))); - - Node nnNode = XpathUtil.getNode(domainNode, "core:notNull"); - if (nnNode != null) { - Element nnElement = (Element) nnNode; - NotNullConstraintModel nnModel = - factory.newModel(NotNullConstraintModel.class, DomUtil.getUUID(nnNode, CoreQName.ID)); - nnModel.setName(XpathUtil.getTextContent(nnElement, "core:name")); - readAdapter(nnElement, nnModel); - domainModel.setNotNull(nnModel); - } - - Node checkNode = XpathUtil.getNode(domainNode, "core:columnCheck"); - if (checkNode != null) { - Element checkElement = (Element) checkNode; - ColumnCheckModel checkModel = - factory.newModel(ColumnCheckModel.class, DomUtil.getUUID(checkNode, CoreQName.ID)); - checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); - readAdapter(checkElement, checkModel); - checkModel.setName(XpathUtil.getTextContent(checkElement, "core:name")); - domainModel.setCheck(checkModel); - } - - domainModel.setDescription(XpathUtil.getTextContent(domainNode, "core:description")); - - readAdapter((Element) domainNode, domainModel); - rootModel.getDomains().add(domainModel); - } - } - - private void parseEntitiesSection(RootModel rootModel) { - NodeList entitityNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:entities/*"); - Iterable<Node> entitityIterableNodeList = new IterableNodeList(entitityNodeList); - for (Node entityNode : entitityIterableNodeList) { - if ((entityNode instanceof Element) == false) { - logger.warn("unexpected node (ignored): " + entityNode.getNodeType()); - continue; - } - Element entitiesElement = (Element) entityNode; - EntityModel entityModel; - if (entitiesElement.getNodeName().equals(TABLE.getQName().getLocalPart())) { - entityModel = parseTable(entitiesElement); - } else if (entitiesElement.getNodeName().equals(VIEW.getQName().getLocalPart())) { - entityModel = parseView(entitiesElement); - } else { - logger.warn("unknown entity (ignored): " + entitiesElement.getNodeName()); - continue; - } - - readAdapter(entitiesElement, entityModel); - - rootModel.getEntities().add(entityModel); - } - } - - private void parseForeignKey(Element fkElement, TableModel tableModel) { - ForeignKeyModel fkModel = factory.newModel(ForeignKeyModel.class, DomUtil.getUUID(fkElement, CoreQName.ID)); - fkModel.setName(XpathUtil.getTextContent(fkElement, "core:name")); - fkModel.setLogicalName(XpathUtil.getTextContent(fkElement, "core:logicalName")); - NodeList columnRefNodeList = XpathUtil.getNodes(fkElement, "core:columnRefs/core:columnRef"); - Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); - for (Node node : columnRefIterableNodeList) { - ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); - fkModel.getKeyColumns().add(columnRef); - } - NodeList referenceColumnRefNodeList = XpathUtil.getNodes(fkElement, "core:referenceColumns/core:columnRef"); - Iterable<Node> referenceColumnRefIterableNodeList = new IterableNodeList(referenceColumnRefNodeList); - for (Node node : referenceColumnRefIterableNodeList) { - ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); - fkModel.getReferenceColumns().add(columnRef); - } - - parseDeferrability(fkElement, fkModel); - - String onDeleteString = XpathUtil.getTextContent(fkElement, "core:onDelete"); - if (StringUtils.isEmpty(onDeleteString) == false) { - fkModel.setOnDelete(ReferentialAction.valueOf(onDeleteString)); - } - - String onUpdateString = XpathUtil.getTextContent(fkElement, "core:onUpdate"); - if (StringUtils.isEmpty(onUpdateString) == false) { - fkModel.setOnUpdate(ReferentialAction.valueOf(onUpdateString)); - } - - readAdapter(fkElement, fkModel); - tableModel.getAttributes().add(fkModel); - } - - private void parsePrimaryKey(Element pkElement, TableModel tableModel) { - PrimaryKeyModel pkModel = factory.newModel(PrimaryKeyModel.class, DomUtil.getUUID(pkElement, CoreQName.ID)); - pkModel.setName(XpathUtil.getTextContent(pkElement, "core:name")); - pkModel.setLogicalName(XpathUtil.getTextContent(pkElement, "core:logicalName")); - NodeList columnRefNodeList = XpathUtil.getNodes(pkElement, "core:columnRefs/core:columnRef"); - Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); - for (Node node : columnRefIterableNodeList) { - ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); - pkModel.getKeyColumns().add(columnRef); - } - - parseDeferrability(pkElement, pkModel); - - readAdapter(pkElement, pkModel); - tableModel.getAttributes().add(pkModel); - } - - private RootModel parseRoot() { - Element rootElement = document.getDocumentElement(); - - RootModel rootModel = factory.getRootModel(DomUtil.getUUID(rootElement, CoreQName.ID)); - rootModel.setDialectClassName(XpathUtil.getText(document, "/core:rootModel/core:dialect/text()")); - rootModel.setSchemaName(XpathUtil.getTextContent(document, "/core:rootModel/core:schemaName")); - rootModel.setBeginScript(XpathUtil.getTextContent(document, "/core:rootModel/core:beginScript")); - rootModel.setEndScript(XpathUtil.getTextContent(document, "/core:rootModel/core:endScript")); - rootModel.setDescription(XpathUtil.getTextContent(document, "/core:rootModel/core:description")); - - return rootModel; - } - - private TableModel parseTable(Element tableElement) { - TableModel tableModel = factory.newModel(TableModel.class, DomUtil.getUUID(tableElement, CoreQName.ID)); - tableModel.setName(XpathUtil.getText(tableElement, "core:name/text()")); - tableModel.setLogicalName(XpathUtil.getTextContent(tableElement, "core:logicalName")); - tableModel.setBeginScript(XpathUtil.getTextContent(tableElement, "core:beginScript")); - tableModel.setEndScript(XpathUtil.getTextContent(tableElement, "core:endScript")); - tableModel.setDescription(XpathUtil.getTextContent(tableElement, "core:description")); - - parseAttributes(tableElement, tableModel); - -// parseColumns(tableElement, tableModel); -// parsePrimaryKeys(tableElement, tableModel); -// parseUniqueKeys(tableElement, tableModel); -// parseForeignKeys(tableElement, tableModel); -// parseNotNullConstraints(tableElement, tableModel); -// parseCheckConstraints(tableElement, tableModel); - - readAdapter(tableElement, tableModel); - return tableModel; - } - - private void parseTableCheckConstraint(Element checkElement, TableModel tableModel) { - TableCheckModel checkModel = - factory.newModel(TableCheckModel.class, DomUtil.getUUID(checkElement, CoreQName.ID)); - checkModel.setName(XpathUtil.getTextContent(checkElement, "core:name")); - checkModel.setLogicalName(XpathUtil.getTextContent(checkElement, "core:logicalName")); - checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); - readAdapter(checkElement, checkModel); - tableModel.getAttributes().add(checkModel); - } - - private void parseUniqueKey(Element ukElement, TableModel tableModel) { - UniqueKeyModel ukModel = factory.newModel(UniqueKeyModel.class, DomUtil.getUUID(ukElement, CoreQName.ID)); - ukModel.setName(XpathUtil.getTextContent(ukElement, "core:name")); - ukModel.setLogicalName(XpathUtil.getTextContent(ukElement, "core:logicalName")); - NodeList columnRefNodeList = XpathUtil.getNodes(ukElement, "core:columnRefs/columnRef"); - Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); - for (Node node : columnRefIterableNodeList) { - ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); - ukModel.getKeyColumns().add(columnRef); - } - - parseDeferrability(ukElement, ukModel); - - readAdapter(ukElement, ukModel); - tableModel.getAttributes().add(ukModel); - } - - private ViewModel parseView(Element viewElement) { - ViewModel viewModel = factory.newModel(ViewModel.class, DomUtil.getUUID(viewElement, CoreQName.ID)); - viewModel.setName(XpathUtil.getText(viewElement, "core:name/text()")); - viewModel.setLogicalName(XpathUtil.getTextContent(viewElement, "core:logicalName")); - viewModel.setBeginScript(XpathUtil.getTextContent(viewElement, "core:beginScript")); - viewModel.setEndScript(XpathUtil.getTextContent(viewElement, "core:endScript")); - viewModel.setDescription(XpathUtil.getTextContent(viewElement, "core:description")); - viewModel.setDefinition(XpathUtil.getText(viewElement, "core:definition/text()")); - readAdapter(viewElement, viewModel); - return viewModel; - } - -} Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java (from rev 2693, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomBuilder.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -0,0 +1,469 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/15 + * + * 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.serializer; + +import static org.jiemamy.xml.CoreQName.ADAPTER; +import static org.jiemamy.xml.CoreQName.ATTRIBUTES; +import static org.jiemamy.xml.CoreQName.BEGIN_SCRIPT; +import static org.jiemamy.xml.CoreQName.COLUMN_CHECK_CONSTRAINT; +import static org.jiemamy.xml.CoreQName.COLUMN_PRIMARY_KEY; +import static org.jiemamy.xml.CoreQName.COLUMN_REF; +import static org.jiemamy.xml.CoreQName.COLUMN_REFS; +import static org.jiemamy.xml.CoreQName.COLUMN_UNIQUE_KEY; +import static org.jiemamy.xml.CoreQName.DATASET; +import static org.jiemamy.xml.CoreQName.DATASETS; +import static org.jiemamy.xml.CoreQName.DATA_TYPE; +import static org.jiemamy.xml.CoreQName.DEFAULT_VALUE; +import static org.jiemamy.xml.CoreQName.DEFERRABILITY; +import static org.jiemamy.xml.CoreQName.DEFERRABLE; +import static org.jiemamy.xml.CoreQName.DEFINITION; +import static org.jiemamy.xml.CoreQName.DESCRIPTION; +import static org.jiemamy.xml.CoreQName.DIALECT; +import static org.jiemamy.xml.CoreQName.DOMAIN; +import static org.jiemamy.xml.CoreQName.DOMAINS; +import static org.jiemamy.xml.CoreQName.END_SCRIPT; +import static org.jiemamy.xml.CoreQName.ENTITIES; +import static org.jiemamy.xml.CoreQName.EXPRESSION; +import static org.jiemamy.xml.CoreQName.INITIALLY_CHECK_TIME; +import static org.jiemamy.xml.CoreQName.LOGICAL_NAME; +import static org.jiemamy.xml.CoreQName.MATCH_TYPE; +import static org.jiemamy.xml.CoreQName.NAME; +import static org.jiemamy.xml.CoreQName.NOT_NULL; +import static org.jiemamy.xml.CoreQName.ON_DELETE; +import static org.jiemamy.xml.CoreQName.ON_UPDATE; +import static org.jiemamy.xml.CoreQName.RECORD; +import static org.jiemamy.xml.CoreQName.REFERENCE_COLUMNS; +import static org.jiemamy.xml.CoreQName.SCHEMA_NAME; +import static org.jiemamy.xml.CoreQName.TABLE; +import static org.jiemamy.xml.CoreQName.TABLE_CHECK_CONSTRAINT; +import static org.jiemamy.xml.CoreQName.TABLE_REF; +import static org.jiemamy.xml.CoreQName.TYPE_CATEGORY; +import static org.jiemamy.xml.CoreQName.TYPE_NAME; +import static org.jiemamy.xml.CoreQName.VIEW; + +import java.lang.reflect.Field; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; +import java.util.UUID; +import java.util.Map.Entry; + +import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.commons.collections15.list.UnmodifiableList; +import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.ObjectUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import org.jiemamy.ReferenceResolver; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.Adapter; +import org.jiemamy.model.AdapterType; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.constraint.ColumnCheckModel; +import org.jiemamy.model.attribute.constraint.ColumnConstraint; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.attribute.constraint.KeyConstraintModel; +import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; +import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.attribute.constraint.TableCheckModel; +import org.jiemamy.model.attribute.constraint.UniqueKeyModel; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.dataset.RecordModel; +import org.jiemamy.model.datatype.BuiltinDataType; +import org.jiemamy.model.datatype.DataType; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRef; +import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.TableRef; +import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.utils.AnnotationUtil; +import org.jiemamy.utils.CollectionsUtil; +import org.jiemamy.utils.DomUtil; +import org.jiemamy.utils.model.TableUtil; +import org.jiemamy.xml.CoreNamespace; +import org.jiemamy.xml.CoreQName; +import org.jiemamy.xml.JiemamyQName; + +/** + * {@link RootModel}からJiemamy XMLモデルのDOMを生成するクラス。 + * + * @author daisuke + */ +class JiemamyDomBuilder { + + private static Logger logger = LoggerFactory.getLogger(JiemamyDomBuilder.class); + + + private static Element newColumnConstraintsElement(Element parentElement, ColumnConstraint columnConstraint) { + if (columnConstraint == null) { + return null; + } + Element element = null; + if (columnConstraint instanceof NotNullConstraintModel) { + NotNullConstraintModel nnModel = (NotNullConstraintModel) columnConstraint; + element = DomUtil.newChild(parentElement, NOT_NULL); + element.setAttribute(CoreQName.ID.getQNameString(), nnModel.getId().toString()); + DomUtil.newChild(element, NAME, nnModel.getName()); + writeAdapters(element, nnModel.getAdapters()); + } else if (columnConstraint instanceof ColumnCheckModel) { + ColumnCheckModel columnCheckModel = (ColumnCheckModel) columnConstraint; + writeColumnCheckConstrait(parentElement, columnCheckModel); + } else if (columnConstraint instanceof UniqueKeyModel) { + UniqueKeyModel ukModel = (UniqueKeyModel) columnConstraint; + element = DomUtil.newChild(parentElement, COLUMN_UNIQUE_KEY); + element.setAttribute(CoreQName.ID.getQNameString(), ukModel.getId().toString()); + DomUtil.newChild(element, NAME, ukModel.getName()); + writeAdapters(element, ukModel.getAdapters()); + } else if (columnConstraint instanceof PrimaryKeyModel) { + PrimaryKeyModel pkModel = (PrimaryKeyModel) columnConstraint; + element = DomUtil.newChild(parentElement, COLUMN_PRIMARY_KEY); + element.setAttribute(CoreQName.ID.getQNameString(), pkModel.getId().toString()); + DomUtil.newChild(element, NAME, pkModel.getName()); + writeAdapters(element, pkModel.getAdapters()); + } + return element; + } + + private static Element newDataTypeElement(Element parentElement, DataType dataType) { + Element dataTypeElement = DomUtil.newChild(parentElement, DATA_TYPE); + if (dataType instanceof DomainRef) { + DomainRef domainRef = (DomainRef) dataType; + dataTypeElement.setAttribute(CoreQName.REF.getQNameString(), domainRef.getReferenceId().toString()); + } else if (dataType instanceof BuiltinDataType) { + BuiltinDataType builtinDataType = (BuiltinDataType) dataType; + DomUtil.newChild(dataTypeElement, TYPE_CATEGORY, builtinDataType.getCategory()); + DomUtil.newChild(dataTypeElement, TYPE_NAME, builtinDataType.getTypeName()); + writeAdapters(dataTypeElement, builtinDataType.getAdapters()); + } else if (dataType == null) { + // nothing to do + } else { + throw new UnexpectedConditionError("unknown DataType: " + dataType.getClass().getName()); + } + return dataTypeElement; + } + + private static SortedSet<Entry<ColumnRef, String>> sortDataEntry(EntityModel entity, RecordModel recordModel) { + SortedSet<Entry<ColumnRef, String>> treeSet = + new TreeSet<Map.Entry<ColumnRef, String>>(new RecordSetComparator(TableUtil + .getColumns((TableModel) entity))); + for (Map.Entry<ColumnRef, String> entry2 : recordModel.getValues().entrySet()) { + treeSet.add(entry2); + } + return treeSet; + } + + private static void writeAdapters(Element parentElement, List<Object> adapters) { + for (Object adapter : adapters) { + Adapter annotation = AnnotationUtil.getTypeAnnotation(adapter, Adapter.class); + assert annotation != null; + if (annotation.value() == AdapterType.MODEL) { + Element adapterElement = DomUtil.newChild(parentElement, ADAPTER); + adapterElement.setAttribute(CoreQName.CLASS.getQNameString(), adapter.getClass().getName()); + boolean existSpecificValue = false; + for (Field field : adapter.getClass().getDeclaredFields()) { + String value = null; + try { + field.setAccessible(true); + value = ObjectUtils.toString(field.get(adapter), null); + } catch (IllegalArgumentException e) { + logger.error(e.getMessage()); + throw new UnexpectedConditionError("フィールドは必ず存在するはず", e); + } catch (IllegalAccessException e) { + logger.error(e.getMessage()); + throw new UnexpectedConditionError("setAccessible(true)しているのでアクセスできるはず", e); + } + if (value != null) { + DomUtil.newChild(adapterElement, new QName(CoreNamespace.NS_CORE.getNamespaceURI(), field + .getName()), value); + existSpecificValue = true; + } + } + if (existSpecificValue == false) { + parentElement.removeChild(adapterElement); + } + } + } + } + + private static void writeColumnCheckConstrait(Element parentElement, ColumnCheckModel checkConstraintModel) { + Element checkElement = DomUtil.newChild(parentElement, COLUMN_CHECK_CONSTRAINT); + checkElement.setAttribute(CoreQName.ID.getQNameString(), checkConstraintModel.getId().toString()); + DomUtil.newChild(checkElement, NAME, checkConstraintModel.getName()); + DomUtil.newChild(checkElement, EXPRESSION, checkConstraintModel.getExpression()); + writeAdapters(checkElement, checkConstraintModel.getAdapters()); + } + + private static void writeTableCheckConstrait(Element parentElement, TableCheckModel checkConstraintModel) { + Element checkElement = DomUtil.newChild(parentElement, TABLE_CHECK_CONSTRAINT); + checkElement.setAttribute(CoreQName.ID.getQNameString(), checkConstraintModel.getId().toString()); + DomUtil.newChild(checkElement, NAME, checkConstraintModel.getName()); + DomUtil.newChild(checkElement, LOGICAL_NAME, checkConstraintModel.getLogicalName()); + DomUtil.newChild(checkElement, DESCRIPTION, checkConstraintModel.getDescription()); + DomUtil.newChild(checkElement, EXPRESSION, checkConstraintModel.getExpression()); + writeAdapters(checkElement, checkConstraintModel.getAdapters()); + } + + + private RootModel rootModel; + + + /** + * インスタンスを生成する。 + * + * @param rootModel + */ + public JiemamyDomBuilder(RootModel rootModel) { + this.rootModel = rootModel; + } + + /** + * DOM Documentを構築する。 + * + * @return DOM Document + * @throws ParserConfigurationException + */ + public Document build() throws ParserConfigurationException { + DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); + documentBuilderFactory.setNamespaceAware(true); + DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); + Document document = documentBuilder.newDocument(); + + Element rootElement = DomUtil.newElement(document, CoreQName.ROOT_MODEL); + rootElement.setAttribute(CoreQName.ID.getQNameString(), rootModel.getId().toString()); + rootElement.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); + // FIXME locationを正式なURLに + rootElement.setAttribute("xsi:schemaLocation", "" + + "http://jiemamy.org/xml/ns/core ../../main/resources/jiemamy-core.xsd"); + document.appendChild(rootElement); + + buildMiscSection(rootElement); + buildDomainSection(rootElement); + buildNodeSection(rootElement); + buildDataSetSection(rootElement); + + return document; + } + + private void buildDataSetSection(Element rootElement) { + Element insertDataSetElement = DomUtil.newChild(rootElement, DATASETS); + for (DataSetModel insertDataSetModel : rootModel.getDataSets()) { + Element insertDataSet = DomUtil.newChild(insertDataSetElement, DATASET); + insertDataSet.setAttribute(CoreQName.ID.getQNameString(), insertDataSetModel.getId().toString()); + DomUtil.newChild(insertDataSet, NAME, insertDataSetModel.getName()); + for (Map.Entry<TableRef, List<RecordModel>> entry : insertDataSetModel.getRecords().entrySet()) { + TableRef tableRef = entry.getKey(); + ReferenceResolver resolver = insertDataSetModel.getJiemamy().getReferenceResolver(); + EntityModel resolved = resolver.resolve(tableRef); + Element entityElement = DomUtil.newChild(insertDataSet, TABLE_REF); + entityElement.setAttribute(CoreQName.REF.getQNameString(), tableRef.getReferenceId().toString()); + for (RecordModel recordModel : entry.getValue()) { + Element recordElement = DomUtil.newChild(entityElement, RECORD); + recordElement.setAttribute(CoreQName.ID.getQNameString(), recordModel.getId().toString()); + SortedSet<Entry<ColumnRef, String>> treeSet = sortDataEntry(resolved, recordModel); + for (Map.Entry<ColumnRef, String> entry2 : treeSet) { + String value = entry2.getValue(); + Element columnDataElement; + columnDataElement = DomUtil.newChild(recordElement, COLUMN_REF, value); + if (columnDataElement != null) { + columnDataElement.setAttribute(CoreQName.REF.getQNameString(), entry2.getKey() + .getReferenceId().toString()); + } + } + } + } + } + } + + private void buildDomainSection(Element rootElement) { + Element domainsElement = DomUtil.newChild(rootElement, DOMAINS); + for (DomainModel domainModel : rootModel.getDomains()) { + Element domainElement = DomUtil.newChild(domainsElement, DOMAIN); + domainElement.setAttribute(CoreQName.ID.getQNameString(), domainModel.getId().toString()); + DomUtil.newChild(domainElement, NAME, domainModel.getName()); + DomUtil.newChild(domainElement, LOGICAL_NAME, domainModel.getLogicalName()); + DomUtil.newChild(domainElement, DESCRIPTION, domainModel.getDescription()); + newDataTypeElement(domainElement, domainModel.getDataType()); + + NotNullConstraintModel notNull = domainModel.getNotNull(); + if (notNull != null) { + Element notNullElement = DomUtil.newChild(domainElement, NOT_NULL); + notNullElement.setAttribute(CoreQName.ID.getQNameString(), notNull.getId().toString()); + DomUtil.newChild(notNullElement, NAME, notNull.getName()); + writeAdapters(notNullElement, notNull.getAdapters()); + } + + ColumnCheckModel check = domainModel.getCheck(); + if (check != null) { + writeColumnCheckConstrait(domainElement, check); + } + } + } + + private void buildMiscSection(Element rootElement) { + DomUtil.newChild(rootElement, DIALECT, rootModel.getDialectClassName()); + DomUtil.newChild(rootElement, SCHEMA_NAME, rootModel.getSchemaName()); + DomUtil.newChild(rootElement, DESCRIPTION, rootModel.getDescription()); + DomUtil.newChild(rootElement, BEGIN_SCRIPT, rootModel.getBeginScript()); + DomUtil.newChild(rootElement, END_SCRIPT, rootModel.getEndScript()); + } + + private void buildNodeSection(Element rootElement) { + Element entitiesElement = DomUtil.newChild(rootElement, ENTITIES); + for (EntityModel entityModel : rootModel.getEntities()) { + Element entityElement = null; + + if (entityModel instanceof TableModel) { + TableModel tableModel = (TableModel) entityModel; + entityElement = DomUtil.newChild(entitiesElement, TABLE); + DomUtil.newChild(entityElement, NAME, tableModel.getName()); + DomUtil.newChild(entityElement, LOGICAL_NAME, tableModel.getLogicalName()); + DomUtil.newChild(entityElement, DESCRIPTION, tableModel.getDescription()); + DomUtil.newChild(entityElement, BEGIN_SCRIPT, tableModel.getBeginScript()); + DomUtil.newChild(entityElement, END_SCRIPT, tableModel.getEndScript()); + + Element attributesElement = DomUtil.newChild(entityElement, ATTRIBUTES); + for (AttributeModel attributeModel : tableModel.getAttributes()) { + Element attributeElement = DomUtil.newChild(attributesElement, getQName(attributeModel)); + attributeElement.setAttribute(CoreQName.ID.getQNameString(), attributeModel.getId().toString()); + DomUtil.newChild(attributeElement, NAME, attributeModel.getName()); + DomUtil.newChild(attributeElement, LOGICAL_NAME, attributeModel.getLogicalName()); + DomUtil.newChild(attributeElement, DESCRIPTION, attributeModel.getDescription()); + if (attributeModel instanceof ColumnModel) { + ColumnModel columnModel = (ColumnModel) attributeModel; + newDataTypeElement(attributeElement, columnModel.getDataType()); + DomUtil.newChild(attributeElement, DEFAULT_VALUE, columnModel.getDefaultValue()); + newColumnConstraintsElement(attributeElement, columnModel.getNotNull()); + newColumnConstraintsElement(attributeElement, columnModel.getUniqueKey()); + newColumnConstraintsElement(attributeElement, columnModel.getPrimaryKey()); + newColumnConstraintsElement(attributeElement, columnModel.getCheck()); + } else if (attributeModel instanceof KeyConstraintModel) { + KeyConstraintModel keyeyModel = (KeyConstraintModel) attributeModel; + Element columnRefsElement = DomUtil.newChild(attributeElement, COLUMN_REFS); + for (ColumnRef pkColumn : keyeyModel.getKeyColumns()) { + Element columnRefElement = DomUtil.newChild(columnRefsElement, COLUMN_REF); + columnRefElement.setAttribute(CoreQName.REF.getQNameString(), pkColumn.getReferenceId() + .toString()); + } + + if (attributeModel instanceof ForeignKeyModel) { + ForeignKeyModel foreignKeyModel = (ForeignKeyModel) keyeyModel; + + Element kyColumnsElement = DomUtil.newChild(attributeElement, REFERENCE_COLUMNS); + for (ColumnRef keyColumnRef : foreignKeyModel.getReferenceColumns()) { + Element columnRefElement = DomUtil.newChild(kyColumnsElement, COLUMN_REF); + columnRefElement.setAttribute(CoreQName.REF.getQNameString(), keyColumnRef + .getReferenceId().toString()); + } + + if (foreignKeyModel.getDeferrability() != null) { + Deferrability deferrability = foreignKeyModel.getDeferrability(); + Element deferrabilityElement = DomUtil.newChild(attributeElement, DEFERRABILITY); + deferrabilityElement.setAttribute(CoreQName.ID.getQNameString(), deferrability.getId() + .toString()); + DomUtil.newChild(deferrabilityElement, DEFERRABLE, BooleanUtils + .toStringTrueFalse(deferrability.isDeferrable())); + DomUtil.newChild(deferrabilityElement, INITIALLY_CHECK_TIME, deferrability + .getInitiallyCheckTime()); + } + + DomUtil.newChild(attributeElement, MATCH_TYPE, foreignKeyModel.getMatchType()); + DomUtil.newChild(attributeElement, ON_DELETE, foreignKeyModel.getOnDelete()); + DomUtil.newChild(attributeElement, ON_UPDATE, foreignKeyModel.getOnUpdate()); + } + } else if (attributeModel instanceof TableCheckModel) { + TableCheckModel tableCheckModel = (TableCheckModel) attributeModel; + writeTableCheckConstrait(attributeElement, tableCheckModel); + } + writeAdapters(attributeElement, attributeModel.getAdapters()); + } + } else if (entityModel instanceof ViewModel) { + ViewModel viewModel = (ViewModel) entityModel; + entityElement = DomUtil.newChild(entitiesElement, VIEW); + DomUtil.newChild(entityElement, NAME, viewModel.getName()); + DomUtil.newChild(entityElement, LOGICAL_NAME, viewModel.getLogicalName()); + DomUtil.newChild(entityElement, DESCRIPTION, viewModel.getDescription()); + DomUtil.newChild(entityElement, BEGIN_SCRIPT, viewModel.getBeginScript()); + DomUtil.newChild(entityElement, END_SCRIPT, viewModel.getEndScript()); + DomUtil.newChild(entityElement, DEFINITION, viewModel.getDefinition()); + } else { + throw new UnexpectedConditionError("unknown entity:" + entityModel.getClass().getName()); + } + writeAdapters(entityElement, entityModel.getAdapters()); + entityElement.setAttribute(CoreQName.ID.getQNameString(), entityModel.getId().toString()); + entitiesElement.appendChild(entityElement); + } + } + + private JiemamyQName getQName(AttributeModel attributeModel) { + if (attributeModel instanceof ColumnModel) { + return CoreQName.COLUMN; + } else if (attributeModel instanceof PrimaryKeyModel) { + return CoreQName.PRIMARY_KEY; + } else if (attributeModel instanceof UniqueKeyModel) { + return CoreQName.UNIQUE_KEY; + } else if (attributeModel instanceof ForeignKeyModel) { + return CoreQName.FOREIGN_KEY; + } else if (attributeModel instanceof TableCheckModel) { + return CoreQName.TABLE_CHECK_CONSTRAINT; + } else { + return null; + } + } + + + /** + * 出力レコードの並び順を、カラム定義順に合わせるコンパレータ。 + * + * @author daisuke + */ + private static class RecordSetComparator implements Comparator<Entry<ColumnRef, String>> { + + private final List<UUID> order; + + + RecordSetComparator(List<ColumnModel> columns) { + List<UUID> tmpOrder = CollectionsUtil.newArrayList(); + for (ColumnModel columnModel : columns) { + tmpOrder.add(columnModel.getId()); + } + order = UnmodifiableList.decorate(tmpOrder); + } + + public int compare(Entry<ColumnRef, String> o1, Entry<ColumnRef, String> o2) { + int i1 = order.indexOf(o1.getKey().getReferenceId()); + int i2 = order.indexOf(o2.getKey().getReferenceId()); + return i1 - i2; + } + + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java (from rev 2693, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/DomParser.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -0,0 +1,550 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/15 + * + * 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.serializer; + +import static org.jiemamy.xml.CoreQName.TABLE; +import static org.jiemamy.xml.CoreQName.VIEW; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathExpressionException; + +import org.apache.commons.lang.BooleanUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import org.jiemamy.Jiemamy; +import org.jiemamy.JiemamyFactory; +import org.jiemamy.dialect.BuiltinDataTypeMoldImpl; +import org.jiemamy.dialect.Dialect.BuiltinDataTypeMold; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.ColumnRef; +import org.jiemamy.model.attribute.ColumnRefImpl; +import org.jiemamy.model.attribute.constraint.ColumnCheckModel; +import org.jiemamy.model.attribute.constraint.Deferrability; +import org.jiemamy.model.attribute.constraint.ForeignKeyModel; +import org.jiemamy.model.attribute.constraint.KeyConstraintModel; +import org.jiemamy.model.attribute.constraint.NotNullConstraintModel; +import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.attribute.constraint.TableCheckModel; +import org.jiemamy.model.attribute.constraint.UniqueKeyModel; +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.BuiltinDataType; +import org.jiemamy.model.datatype.DataType; +import org.jiemamy.model.datatype.DataTypeCategory; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.datatype.DomainRefImpl; +import org.jiemamy.model.entity.EntityModel; +import org.jiemamy.model.entity.TableModel; +import org.jiemamy.model.entity.TableRef; +import org.jiemamy.model.entity.TableRefImpl; +import org.jiemamy.model.entity.ViewModel; +import org.jiemamy.utils.Adaptable; +import org.jiemamy.utils.DomUtil; +import org.jiemamy.utils.IterableNodeList; +import org.jiemamy.utils.XpathUtil; +import org.jiemamy.xml.CoreQName; + +/** + * Jiemamy XMLモデルのDOMから{@link RootModel}を生成するクラス。 + * + * @author daisuke + */ +class JiemamyDomParser { + + private static Logger logger = LoggerFactory.getLogger(JiemamyDomParser.class); + + + private static void readAdapter(Element element, Adaptable jiemamyElement) { + NodeList adapterNodeList = XpathUtil.getNodes(element, "core:adapter"); + Iterable<Node> adapterIterator = new IterableNodeList(adapterNodeList); + + for (Node adapterNode : adapterIterator) { + String className = DomUtil.getAttributeString((Element) adapterNode, CoreQName.CLASS); + try { + Class<?> clazz = Class.forName(className); + Object adapter; + if (jiemamyElement.hasAdapter(clazz)) { + adapter = jiemamyElement.getAdapter(clazz); + } else { + try { + adapter = clazz.newInstance(); + jiemamyElement.registerAdapter(adapter); + } catch (InstantiationException e) { + logger.warn("ModelAdapter must have default constructor.", e); + continue; + } catch (IllegalAccessException e) { + logger.warn("ModelAdapter must be public.", e); + continue; + } + } + NodeList propertyNodes = adapterNode.getChildNodes(); + Iterable<Node> propertyNodesIterator = new IterableNodeList(propertyNodes); + + for (Node propertyNode : propertyNodesIterator) { + if ((propertyNode instanceof Element) == false) { + continue; + } + Element propertyElement = (Element) propertyNode; + String fieldName = null; + try { + fieldName = propertyElement.getTagName(); + Field field = adapter.getClass().getDeclaredField(fieldName); + field.setAccessible(true); + String value = propertyElement.getTextContent(); + Class<?> type = field.getType(); + if (type == Integer.class || type == int.class) { + field.set(adapter, NumberUtils.toInt(value)); + } else if (type == Long.class || type == long.class) { + field.set(adapter, NumberUtils.toLong(value)); + } else if (type == Float.class || type == float.class) { + field.set(adapter, NumberUtils.toFloat(value)); + } else if (type == Double.class || type == double.class) { + field.set(adapter, NumberUtils.toDouble(value)); + } else if (type == Boolean.class || type == boolean.class) { + field.set(adapter, BooleanUtils.toBoolean(value)); + } else if (type == String.class) { + field.set(adapter, value); + } else { + logger.warn("unsupported model adapter field data type: " + field.getType().getName()); + } + } catch (SecurityException e) { + logger.warn("TODO", e); // TODO + } catch (NoSuchFieldException e) { + logger.warn("no such field " + fieldName + " in " + className, e); + } catch (IllegalArgumentException e) { + logger.warn("TODO", e); // TODO + } catch (IllegalAccessException e) { + throw new UnexpectedConditionError("setAccessible(true)したハズ。", e); + } + } + + } catch (ClassNotFoundException e) { + logger.warn("class not found (ignored): " + className, e); + } + } + } + + + private final Jiemamy jiemamy; + + private final JiemamyFactory factory; + + private final Document document; + + + /** + * インスタンスを生成する。 + * @param jiemamy + * @param document + */ + public JiemamyDomParser(Jiemamy jiemamy, Document document) { + this.jiemamy = jiemamy; + factory = jiemamy.getFactory(); + this.document = document; + } + + /** + * DOMを解析し、{@link RootModel}を生成する。 + * @return 生成した{@link RootModel} + */ + public RootModel parse() { + RootModel rootModel = parseRoot(); + parseDomainSection(rootModel); + parseEntitiesSection(rootModel); + parseDataSetSection(rootModel); + + return rootModel; + } + + private DataType getDataType(Element element) { + try { + if (element.getChildNodes().getLength() == 0 && StringUtils.isEmpty(element.getAttribute("ref")) == false) { + return new DomainRefImpl(jiemamy, DomUtil.getUUID(element, CoreQName.REF)); + } else { + String typeCategoryString = + (String) XpathUtil.XPATH.evaluate("core:typeCategory/text()", element, XPathConstants.STRING); + String typeName = + (String) XpathUtil.XPATH.evaluate("core:typeName/text()", element, XPathConstants.STRING); + + BuiltinDataTypeMold mold; + if (StringUtils.isEmpty(typeCategoryString) == false) { + // FIXME ここでモールド生成していいんか + mold = new BuiltinDataTypeMoldImpl(DataTypeCategory.valueOf(typeCategoryString), typeName); + } else { + DataTypeCategory category; + try { + category = DataTypeCategory.valueOf(typeName); + } catch (IllegalArgumentException e) { + category = DataTypeCategory.INTEGER; + } + // FIXME ここでモールド生成していいんか + mold = new BuiltinDataTypeMoldImpl(category, typeName); + } + BuiltinDataType dataType = factory.newBuiltinDataType(mold); + dataType.setTypeName(typeName); + + readAdapter(element, dataType); + + return dataType; + } + } catch (XPathExpressionException e) { + throw new UnexpectedConditionError("XPath expression error", e); + } + } + + /** + * TODO for daisuke + * + * @param tableElement + * @param tableModel + */ + private void parseAttributes(Element tableElement, TableModel tableModel) { + NodeList attributeNodeList = XpathUtil.getNodes(tableElement, "core:attributes/*"); + Iterable<Node> attributeIterableNodeList = new IterableNodeList(attributeNodeList); + for (Node attributeNode : attributeIterableNodeList) { + if ((attributeNode instanceof Element) == false) { + continue; + } + Element attributeElement = (Element) attributeNode; + if (DomUtil.equalsElement(attributeElement, CoreQName.COLUMN)) { + parseColumn(attributeElement, tableModel); + } else if (DomUtil.equalsElement(attributeElement, CoreQName.PRIMARY_KEY)) { + parsePrimaryKey(attributeElement, tableModel); + } else if (DomUtil.equalsElement(attributeElement, CoreQName.UNIQUE_KEY)) { + parseUniqueKey(attributeElement, tableModel); + } else if (DomUtil.equalsElement(attributeElement, CoreQName.FOREIGN_KEY)) { + parseForeignKey(attributeElement, tableModel); + } else if (DomUtil.equalsElement(attributeElement, CoreQName.TABLE_CHECK_CONSTRAINT)) { + parseTableCheckConstraint(attributeElement, tableModel); + } else { + logger.warn("unknown attribute"); + } + } + } + + private void parseColumn(Element columnElement, TableModel tableModel) { + ColumnModel columnModel = factory.newModel(ColumnModel.class, DomUtil.getUUID(columnElement, CoreQName.ID)); + columnModel.setName(XpathUtil.getText(columnElement, "core:name/text()")); + columnModel.setLogicalName(XpathUtil.getTextContent(columnElement, "core:logicalName")); + columnModel.setDataType(getDataType((Element) XpathUtil.getNode(columnElement, "core:dataType"))); + columnModel.setDefaultValue(XpathUtil.getTextContent(columnElement, "core:defaultValue")); + + Element nnElement = (Element) XpathUtil.getNode(columnElement, "core:notNull"); + if (nnElement != null) { + NotNullConstraintModel nnModel = + factory.newModel(NotNullConstraintModel.class, DomUtil.getUUID(nnElement, CoreQName.ID)); + nnModel.setName(XpathUtil.getText(nnElement, "core:name/text()")); + readAdapter(nnElement, nnModel); + columnModel.setNotNull(nnModel); + } + + Element ukElement = (Element) XpathUtil.getNode(columnElement, "core:columnUniqueKey"); + if (ukElement != null) { + UniqueKeyModel ukModel = factory.newModel(UniqueKeyModel.class, DomUtil.getUUID(ukElement, CoreQName.ID)); + ukModel.setName(XpathUtil.getText(ukElement, "core:name/text()")); + ukModel.getKeyColumns().add(factory.newReference(columnModel)); + readAdapter(ukElement, ukModel); + columnModel.setUniqueKey(ukModel); + } + + Element pkElement = (Element) XpathUtil.getNode(columnElement, "core:columnPrimaryKey"); + if (pkElement != null) { + PrimaryKeyModel pkModel = factory.newModel(PrimaryKeyModel.class, DomUtil.getUUID(pkElement, CoreQName.ID)); + pkModel.setName(XpathUtil.getText(pkElement, "core:name/text()")); + pkModel.getKeyColumns().add(factory.newReference(columnModel)); + readAdapter(pkElement, pkModel); + columnModel.setPrimaryKey(pkModel); + } + + Element checkElement = (Element) XpathUtil.getNode(columnElement, "core:columnCheck"); + if (checkElement != null) { + ColumnCheckModel checkModel = + factory.newModel(ColumnCheckModel.class, DomUtil.getUUID(checkElement, CoreQName.ID)); + checkModel.setName(XpathUtil.getText(checkElement, "core:name/text()")); + checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); + readAdapter(checkElement, checkModel); + columnModel.setCheck(checkModel); + } + + columnModel.setDescription(XpathUtil.getTextContent(columnElement, "core:description")); + readAdapter(columnElement, columnModel); + tableModel.getAttributes().add(columnModel); + } + + private void parseDataSetSection(RootModel rootModel) { + NodeList dataSetNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:dataSets/core:dataSet"); + Iterable<Node> dataSetIterableNodeList = new IterableNodeList(dataSetNodeList); + for (Node dataSetNode : dataSetIterableNodeList) { + + DataSetModel dataSetModel = + factory.newModel(DataSetModel.class, DomUtil.getUUID(dataSetNode, CoreQName.ID)); + dataSetModel.setName(XpathUtil.getText(dataSetNode, "core:name/text()")); + + NodeList tableRefNodeList = XpathUtil.getNodes(dataSetNode, "core:tableRef"); + Iterable<Node> tableRefIterableNodeList = new IterableNodeList(tableRefNodeList); + for (Node tableRefNode : tableRefIterableNodeList) { + + TableRef tableRef = new TableRefImpl(jiemamy, DomUtil.getUUID(tableRefNode, CoreQName.REF)); + List<RecordModel> recordModels = dataSetModel.getRecords().get(tableRef); + if (recordModels == null) { + recordModels = new ArrayList<RecordModel>(); + } + + NodeList recordNodeList = XpathUtil.getNodes(tableRefNode, "core:record"); + Iterable<Node> recordIterableNodeList = new IterableNodeList(recordNodeList); + for (Node recordNode : recordIterableNodeList) { + RecordModel recordModel = + factory.newModel(RecordModel.class, DomUtil.getUUID(recordNode, CoreQName.ID)); + + NodeList columnRefNodeList = XpathUtil.getNodes(recordNode, "core:columnRef"); + Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); + for (Node columnRefNode : columnRefIterableNodeList) { + ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(columnRefNode, CoreQName.REF)); + recordModel.getValues().put(columnRef, columnRefNode.getTextContent()); + } + recordModels.add(recordModel); + } + + dataSetModel.getRecords().put(tableRef, recordModels); + } + rootModel.getDataSets().add(dataSetModel); + } + } + + private void parseDeferrability(Element keyElement, KeyConstraintModel keyModel) { + Node deferrabilityElement = XpathUtil.getNode(keyElement, "core:deferrability"); + + if (deferrabilityElement != null) { + Deferrability deferrability = + factory.newModel(Deferrability.class, DomUtil.getUUID(deferrabilityElement, CoreQName.ID)); + String deferrableString = XpathUtil.getTextContent(deferrabilityElement, "core:deferrable"); + deferrability.setDeferrable(BooleanUtils.toBoolean(deferrableString)); + + String initiallyCheckTimeString = XpathUtil.getTextContent(deferrabilityElement, "core:initiallyCheckTime"); + if (StringUtils.isEmpty(initiallyCheckTimeString) == false) { + deferrability.setInitiallyCheckTime(InitiallyCheckTime.valueOf(initiallyCheckTimeString)); + } + + readAdapter((Element) deferrabilityElement, deferrability); + keyModel.setDeferrability(deferrability); + } + } + + private void parseDomainSection(RootModel rootModel) { + NodeList domainsNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:domains/core:domain"); + Iterable<Node> domainsIterableNodeList = new IterableNodeList(domainsNodeList); + for (Node domainNode : domainsIterableNodeList) { + DomainModel domainModel = factory.newModel(DomainModel.class, DomUtil.getUUID(domainNode, CoreQName.ID)); + domainModel.setName(XpathUtil.getTextContent(domainNode, "core:name")); + domainModel.setLogicalName(XpathUtil.getTextContent(domainNode, "core:logicalName")); + domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode, + "core:dataType"))); + + Node nnNode = XpathUtil.getNode(domainNode, "core:notNull"); + if (nnNode != null) { + Element nnElement = (Element) nnNode; + NotNullConstraintModel nnModel = + factory.newModel(NotNullConstraintModel.class, DomUtil.getUUID(nnNode, CoreQName.ID)); + nnModel.setName(XpathUtil.getTextContent(nnElement, "core:name")); + readAdapter(nnElement, nnModel); + domainModel.setNotNull(nnModel); + } + + Node checkNode = XpathUtil.getNode(domainNode, "core:columnCheck"); + if (checkNode != null) { + Element checkElement = (Element) checkNode; + ColumnCheckModel checkModel = + factory.newModel(ColumnCheckModel.class, DomUtil.getUUID(checkNode, CoreQName.ID)); + checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); + readAdapter(checkElement, checkModel); + checkModel.setName(XpathUtil.getTextContent(checkElement, "core:name")); + domainModel.setCheck(checkModel); + } + + domainModel.setDescription(XpathUtil.getTextContent(domainNode, "core:description")); + + readAdapter((Element) domainNode, domainModel); + rootModel.getDomains().add(domainModel); + } + } + + private void parseEntitiesSection(RootModel rootModel) { + NodeList entitityNodeList = XpathUtil.getNodes(document, "/core:rootModel/core:entities/*"); + Iterable<Node> entitityIterableNodeList = new IterableNodeList(entitityNodeList); + for (Node entityNode : entitityIterableNodeList) { + if ((entityNode instanceof Element) == false) { + logger.warn("unexpected node (ignored): " + entityNode.getNodeType()); + continue; + } + Element entitiesElement = (Element) entityNode; + EntityModel entityModel; + if (entitiesElement.getNodeName().equals(TABLE.getQName().getLocalPart())) { + entityModel = parseTable(entitiesElement); + } else if (entitiesElement.getNodeName().equals(VIEW.getQName().getLocalPart())) { + entityModel = parseView(entitiesElement); + } else { + logger.warn("unknown entity (ignored): " + entitiesElement.getNodeName()); + continue; + } + + readAdapter(entitiesElement, entityModel); + + rootModel.getEntities().add(entityModel); + } + } + + private void parseForeignKey(Element fkElement, TableModel tableModel) { + ForeignKeyModel fkModel = factory.newModel(ForeignKeyModel.class, DomUtil.getUUID(fkElement, CoreQName.ID)); + fkModel.setName(XpathUtil.getTextContent(fkElement, "core:name")); + fkModel.setLogicalName(XpathUtil.getTextContent(fkElement, "core:logicalName")); + NodeList columnRefNodeList = XpathUtil.getNodes(fkElement, "core:columnRefs/core:columnRef"); + Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); + for (Node node : columnRefIterableNodeList) { + ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); + fkModel.getKeyColumns().add(columnRef); + } + NodeList referenceColumnRefNodeList = XpathUtil.getNodes(fkElement, "core:referenceColumns/core:columnRef"); + Iterable<Node> referenceColumnRefIterableNodeList = new IterableNodeList(referenceColumnRefNodeList); + for (Node node : referenceColumnRefIterableNodeList) { + ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); + fkModel.getReferenceColumns().add(columnRef); + } + + parseDeferrability(fkElement, fkModel); + + String onDeleteString = XpathUtil.getTextContent(fkElement, "core:onDelete"); + if (StringUtils.isEmpty(onDeleteString) == false) { + fkModel.setOnDelete(ReferentialAction.valueOf(onDeleteString)); + } + + String onUpdateString = XpathUtil.getTextContent(fkElement, "core:onUpdate"); + if (StringUtils.isEmpty(onUpdateString) == false) { + fkModel.setOnUpdate(ReferentialAction.valueOf(onUpdateString)); + } + + readAdapter(fkElement, fkModel); + tableModel.getAttributes().add(fkModel); + } + + private void parsePrimaryKey(Element pkElement, TableModel tableModel) { + PrimaryKeyModel pkModel = factory.newModel(PrimaryKeyModel.class, DomUtil.getUUID(pkElement, CoreQName.ID)); + pkModel.setName(XpathUtil.getTextContent(pkElement, "core:name")); + pkModel.setLogicalName(XpathUtil.getTextContent(pkElement, "core:logicalName")); + NodeList columnRefNodeList = XpathUtil.getNodes(pkElement, "core:columnRefs/core:columnRef"); + Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); + for (Node node : columnRefIterableNodeList) { + ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); + pkModel.getKeyColumns().add(columnRef); + } + + parseDeferrability(pkElement, pkModel); + + readAdapter(pkElement, pkModel); + tableModel.getAttributes().add(pkModel); + } + + private RootModel parseRoot() { + Element rootElement = document.getDocumentElement(); + + RootModel rootModel = factory.getRootModel(DomUtil.getUUID(rootElement, CoreQName.ID)); + rootModel.setDialectClassName(XpathUtil.getText(document, "/core:rootModel/core:dialect/text()")); + rootModel.setSchemaName(XpathUtil.getTextContent(document, "/core:rootModel/core:schemaName")); + rootModel.setBeginScript(XpathUtil.getTextContent(document, "/core:rootModel/core:beginScript")); + rootModel.setEndScript(XpathUtil.getTextContent(document, "/core:rootModel/core:endScript")); + rootModel.setDescription(XpathUtil.getTextContent(document, "/core:rootModel/core:description")); + + return rootModel; + } + + private TableModel parseTable(Element tableElement) { + TableModel tableModel = factory.newModel(TableModel.class, DomUtil.getUUID(tableElement, CoreQName.ID)); + tableModel.setName(XpathUtil.getText(tableElement, "core:name/text()")); + tableModel.setLogicalName(XpathUtil.getTextContent(tableElement, "core:logicalName")); + tableModel.setBeginScript(XpathUtil.getTextContent(tableElement, "core:beginScript")); + tableModel.setEndScript(XpathUtil.getTextContent(tableElement, "core:endScript")); + tableModel.setDescription(XpathUtil.getTextContent(tableElement, "core:description")); + + parseAttributes(tableElement, tableModel); + +// parseColumns(tableElement, tableModel); +// parsePrimaryKeys(tableElement, tableModel); +// parseUniqueKeys(tableElement, tableModel); +// parseForeignKeys(tableElement, tableModel); +// parseNotNullConstraints(tableElement, tableModel); +// parseCheckConstraints(tableElement, tableModel); + + readAdapter(tableElement, tableModel); + return tableModel; + } + + private void parseTableCheckConstraint(Element checkElement, TableModel tableModel) { + TableCheckModel checkModel = + factory.newModel(TableCheckModel.class, DomUtil.getUUID(checkElement, CoreQName.ID)); + checkModel.setName(XpathUtil.getTextContent(checkElement, "core:name")); + checkModel.setLogicalName(XpathUtil.getTextContent(checkElement, "core:logicalName")); + checkModel.setExpression(XpathUtil.getText(checkElement, "core:expression/text()")); + readAdapter(checkElement, checkModel); + tableModel.getAttributes().add(checkModel); + } + + private void parseUniqueKey(Element ukElement, TableModel tableModel) { + UniqueKeyModel ukModel = factory.newModel(UniqueKeyModel.class, DomUtil.getUUID(ukElement, CoreQName.ID)); + ukModel.setName(XpathUtil.getTextContent(ukElement, "core:name")); + ukModel.setLogicalName(XpathUtil.getTextContent(ukElement, "core:logicalName")); + NodeList columnRefNodeList = XpathUtil.getNodes(ukElement, "core:columnRefs/columnRef"); + Iterable<Node> columnRefIterableNodeList = new IterableNodeList(columnRefNodeList); + for (Node node : columnRefIterableNodeList) { + ColumnRef columnRef = new ColumnRefImpl(jiemamy, DomUtil.getUUID(node, CoreQName.REF)); + ukModel.getKeyColumns().add(columnRef); + } + + parseDeferrability(ukElement, ukModel); + + readAdapter(ukElement, ukModel); + tableModel.getAttributes().add(ukModel); + } + + private ViewModel parseView(Element viewElement) { + ViewModel viewModel = factory.newModel(ViewModel.class, DomUtil.getUUID(viewElement, CoreQName.ID)); + viewModel.setName(XpathUtil.getText(viewElement, "core:name/text()")); + viewModel.setLogicalName(XpathUtil.getTextContent(viewElement, "core:logicalName")); + viewModel.setBeginScript(XpathUtil.getTextContent(viewElement, "core:beginScript")); + viewModel.setEndScript(XpathUtil.getTextContent(viewElement, "core:endScript")); + viewModel.setDescription(XpathUtil.getTextContent(viewElement, "core:description")); + viewModel.setDefinition(XpathUtil.getText(viewElement, "core:definition/text()")); + readAdapter(viewElement, viewModel); + return viewModel; + } + +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/serializer/JiemamyDomSerializer.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -156,7 +156,7 @@ * @throws ParserConfigurationException */ protected Document toDom(RootModel rootModel) throws ParserConfigurationException { - return new DomBuilder(rootModel).build(); + return new JiemamyDomBuilder(rootModel).build(); } /** @@ -166,7 +166,7 @@ * @return {@link RootModel} */ protected RootModel toRootModel(Document document) { - return new DomParser(jiemamy, document).parse(); + return new JiemamyDomParser(jiemamy, document).parse(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DateUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DateUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DateUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -29,9 +29,15 @@ */ public class DateUtil { - public static java.sql.Date toSqlDate(java.util.Date d) { + /** + * {@link java.util.Date}を{@link java.sql.Date}に変換する。 + * + * @param date {@link java.util.Date} + * @return {@link java.sql.Date} + */ + public static java.sql.Date toSqlDate(java.util.Date date) { Calendar cal = Calendar.getInstance(); - cal.setTime(d); + cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); @@ -39,9 +45,15 @@ return new java.sql.Date(cal.getTimeInMillis()); } - public static java.sql.Time toSqlTime(java.util.Date d) { + /** + * {@link java.util.Date}を{@link java.sql.Time}に変換する。 + * + * @param date {@link java.util.Date} + * @return {@link java.sql.Time} + */ + public static java.sql.Time toSqlTime(java.util.Date date) { Calendar cal = Calendar.getInstance(); - cal.setTime(d); + cal.setTime(date); cal.set(Calendar.YEAR, 1970); cal.set(Calendar.MONTH, Calendar.JANUARY); cal.set(Calendar.DATE, 1); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DomUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -86,17 +86,6 @@ public static UUID getUUID(Node domNode, String attributeName) { String uuidStr = XpathUtil.getAttr(domNode, "@" + attributeName).getValue(); return UUIDUtil.valueOfOrRandom(uuidStr); - -// NamedNodeMap attributes = domNode.getAttributes(); -// -// for (int i = 0; i < attributes.getLength(); i++) { -// Node node = attributes.item(i); -// if (node.getNodeName().equals(attributeName)) { -// return UUIDUtil.valueOfOrRandom(node.getNodeValue()); -// } -// } -// logger.error("uuid attribute not found in this element: " + domNode.getNodeName()); -// return null; } /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ListUtils.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -28,10 +28,22 @@ */ public class ListUtils { + /** + * リストの指定したindexの要素を、次の要素と入れ替える。 + * + * @param list 対象リスト + * @param index インデックス + */ public static void moveDown(List<?> list, int index) { Collections.swap(list, index, index + 1); } + /** + * リストの指定したindexの要素を、前の要素と入れ替える。 + * + * @param list 対象リスト + * @param index インデックス + */ public static void moveUp(List<?> list, int index) { Collections.swap(list, index, index - 1); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/XpathUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -97,7 +97,9 @@ * @param root 対象ノード * @param strExpr XPath式 * @return 取得した文字列 + * @deprecated use {@link #getTextContent(Node, String)} */ + @Deprecated public static String getText(Node root, String strExpr) { try { String str = (String) XPATH.evaluate(strExpr, root, XPathConstants.STRING); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/ColumnBuilder.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/ColumnBuilder.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/builder/ColumnBuilder.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,6 +22,7 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.model.attribute.ColumnModel; +import org.jiemamy.model.attribute.constraint.ColumnConstraint; import org.jiemamy.model.attribute.constraint.ConstraintModel; import org.jiemamy.model.datatype.DataType; @@ -46,7 +47,13 @@ model.setDataType(type); } - protected ConstraintModel newConstraint(Class<? extends ConstraintModel> clazz) { + /** + * 制約モデルを生成する。 + * + * @param clazz 制約モデルの型 + * @return 制約モデル + */ + protected ConstraintModel newConstraint(Class<? extends ColumnConstraint> clazz) { return factory.newModel(clazz); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/ColumnUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/ColumnUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/ColumnUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -20,9 +20,6 @@ import java.util.List; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import org.jiemamy.JiemamyFactory; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; @@ -39,9 +36,6 @@ */ public final class ColumnUtil { - private static Logger logger = LoggerFactory.getLogger(ColumnUtil.class); - - /** * このカラムが定義されているテーブルを取得する。 * @@ -58,6 +52,12 @@ return null; } + /** + * カラムが主キー制約を構成するカラムであるかどうか調べる。 + * + * @param columnModel 対象カラム + * @return 主キー制約構成カラムである場合{@code true} + */ public static boolean isPartOfPrimaryKeyColumns(ColumnModel columnModel) { TableModel tableModel = getDefinedTable(columnModel); PrimaryKeyModel primaryKey = TableUtil.getPrimaryKey(tableModel); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/EqualsUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -65,11 +65,11 @@ /** - * TODO for daisuke + * 2つのオブジェクトのプロパティが等しいかどうか調べる。 * * @param left * @param right - * @return + * @return 等しい場合{@code true} */ public static boolean equals(Object left, Object right) { Validate.notNull(left); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/KeyConstraintUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/KeyConstraintUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/KeyConstraintUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -47,11 +47,11 @@ } /** - * TODO for daisuke + * キー制約の構成カラムに、指定したカラムが含まれるかどうか調べる。 * - * @param keyModel - * @param column - * @return + * @param keyModel 対象キー制約 + * @param column カラム + * @return 含まれる場合{@code true} */ public static boolean containsKeyColumn(KeyConstraintModel keyModel, ColumnModel column) { List<ColumnRef> keyColumns = keyModel.getKeyColumns(); @@ -63,6 +63,12 @@ return false; } + /** + * キー制約の構成カラムから、指定したカラムを削除する。 + * + * @param keyModel 対象キー制約 + * @param column カラム + */ public static void removeKeyColumn(KeyConstraintModel keyModel, ColumnModel column) { List<ColumnRef> keyColumns = keyModel.getKeyColumns(); List<ColumnRef> toRemove = CollectionsUtil.newArrayList(); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/RootModelUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -62,10 +62,11 @@ public final class RootModelUtil { /** - * TODO for daisuke - * @param rootModel - * @param refId - * @return + * {@link RootModel}をトラバースし、指定したIDを持つモデルを取得する。 + * + * @param rootModel 対象RootModel + * @param refId ID + * @return 見つかったモデル。見つからなかった場合は{@code null} */ public static JiemamyElement findJiemamyElement(RootModel rootModel, UUID refId) { Validate.notNull(refId); @@ -159,11 +160,11 @@ } /** - * TODO for daisuke + * SQL方言を取得する。 * - * @param rootModel - * @return - * @throws ClassNotFoundException + * @param rootModel 対象RootModel + * @return SQL方言 + * @throws ClassNotFoundException 設定されたクラスが見つからなかった場合 */ public static Dialect getDialect(RootModel rootModel) throws ClassNotFoundException { Jiemamy jiemamy = rootModel.getJiemamy(); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/TableUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/TableUtil.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/TableUtil.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -43,6 +43,7 @@ /** * 指定した型を持つ属性を取得する。 + * * @param <T> 属性の型 * @param tableModel 対象のテーブル * @param clazz 属性の型 @@ -54,6 +55,17 @@ return getAttribute(tableModel, clazz, false); } + /** + * 指定した型を持つ属性を取得する。 + * + * @param <T> 属性の型 + * @param tableModel 対象のテーブル + * @param clazz 属性の型 + * @param columnAttr カラム属性も検索対象とする場合{@code true} + * @return 属性 + * @throws TooManyElementsException + * @throws ElementNotFoundException + */ public static <T extends AttributeModel>T getAttribute(TableModel tableModel, Class<T> clazz, boolean columnAttr) { List<T> attributes = getAttributes(tableModel, clazz, columnAttr); if (attributes.size() == 0) { @@ -76,13 +88,13 @@ } /** - * TODO for daisuke + * 属性のうち、指定した型を持つもののリストを取得する。 * - * @param <T> - * @param tableModel - * @param clazz - * @param columnAttr - * @return + * @param <T> 対象属性の型 + * @param tableModel 対象テーブル + * @param clazz 対象属性の型 + * @param columnAttr カラムに付随するモデルも対象とする場合{@code true} + * @return 属性のリスト */ public static <T extends AttributeModel>List<T> getAttributes(TableModel tableModel, Class<T> clazz, boolean columnAttr) { @@ -122,10 +134,11 @@ } /** - * TODO for daisuke + * カラムに設定された主キー制約を取得する。 * - * @param tableModel - * @return + * @param tableModel 対象テーブル + * @return 主キー制約 + * @throws TooManyElementsException */ public static PrimaryKeyModel getColumnPrimaryKey(TableModel tableModel) { Collection<PrimaryKeyModel> pks = CollectionsUtil.newArrayList(); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/AbstractTraversalValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/AbstractTraversalValidator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/AbstractTraversalValidator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -47,9 +47,10 @@ /** * 全モデルをトラバースするバリデータの骨格実装。 * + * @param <T> 識別子として使用する型 * @author daisuke */ -public abstract class AbstractTraversalValidator extends AbstractValidator { +public abstract class AbstractTraversalValidator<T> extends AbstractValidator { private static final String TABLE = "table"; @@ -61,9 +62,11 @@ } + /** 結果として出力する問題点の集合 */ protected Collection<Problem> result; - protected Map<Object, String> ids; + /** 識別子:位置情報文字列のマップ */ + protected Map<T, String> ids; @Override Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/IdCollisionValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/IdCollisionValidator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/IdCollisionValidator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -34,7 +34,7 @@ * * @author daisuke */ -public class IdCollisionValidator extends AbstractTraversalValidator { +public class IdCollisionValidator extends AbstractTraversalValidator<UUID> { private static Logger logger = LoggerFactory.getLogger(IdCollisionValidator.class); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceCollisionValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceCollisionValidator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceCollisionValidator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -32,7 +32,7 @@ * * @author daisuke */ -public class InstanceCollisionValidator extends AbstractTraversalValidator { +public class InstanceCollisionValidator extends AbstractTraversalValidator<Integer> { private static Logger logger = LoggerFactory.getLogger(InstanceCollisionValidator.class); Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/InstanceSpaceValidator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -33,7 +33,7 @@ * * @author daisuke */ -public class InstanceSpaceValidator extends AbstractTraversalValidator { +public class InstanceSpaceValidator extends AbstractTraversalValidator<Void> { private Jiemamy jiemamy; 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-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/validator/impl/ReferenceValidator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -37,16 +37,13 @@ * * @author daisuke */ -public class ReferenceValidator extends AbstractTraversalValidator { +public class ReferenceValidator extends AbstractTraversalValidator<Void> { private static Logger logger = LoggerFactory.getLogger(ReferenceValidator.class); private ReferenceResolver referenceResolver; - /** - * {@inheritDoc} - */ @Override void check(Object element, String pos) { if (StringUtils.equals(pos, "rootModel")) { Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -68,8 +68,13 @@ sqlEmitter = null; } + /** + * 正常にSQLが出力されること。 + * + * @throws Exception + */ @Test - public void test01_() throws Exception { + public void test01_正常にSQLが出力されること() throws Exception { List<SqlStatement> statements = sqlEmitter.emit(jiemamy.getFactory().getRootModel(), null); for (SqlStatement sqlStatement : statements) { logger.info(sqlStatement.toString()); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/RootModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/RootModelImplTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/model/RootModelImplTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -85,13 +85,13 @@ assertThat(rootModel.getEndScript(), is(nullValue())); assertThat(rootModel.getDescription(), is(nullValue())); assertThat(rootModel.getSchemaName(), is(nullValue())); - assertThat(rootModel.getDialectClassName(), is(nullValue())); assertThat(rootModel.getId(), is(notNullValue())); assertThat(rootModel.getAdapters(), is(notNullValue())); assertThat(rootModel.getDomains(), is(notNullValue())); assertThat(rootModel.getEntities(), is(notNullValue())); assertThat(rootModel.getDataSets(), is(notNullValue())); + assertThat(rootModel.getDialectClassName(), is(notNullValue())); assertThat(rootModel.getDomains().size(), is(0)); assertThat(rootModel.getEntities().size(), is(0)); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/XpathUtilTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -112,15 +112,25 @@ assertThat(XpathUtil.getText(document, "/core:root/view:hogefuga[2]/text()"), is("fuga")); } + /** + * 属性値が取得できる。 + * + * @throws Exception + */ @Test - public void test03_() throws Exception { + public void test03_属性値が取得できる() throws Exception { assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[1]/@id").getTextContent(), is("1")); assertThat(XpathUtil.getNode(document, "/core:root/core:foobar[2]/@id").getTextContent(), is("2")); assertThat(XpathUtil.getNode(document, "/core:root/view:hogefuga[1]/@id").getTextContent(), is("3")); } + /** + * 要素の値が取得できる。 + * + * @throws Exception + */ @Test - public void test04() throws Exception { + public void test04_要素の値が取得できる() throws Exception { assertThat(XpathUtil.getText(document, "/core:root/core:content/text()"), is("unba")); assertThat(XpathUtil.getText(document, "/core:root/core:empty/text()"), is(nullValue())); assertThat(XpathUtil.getText(document, "/core:root/core:nul/text()"), is(nullValue())); Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/xml/JiemamyNamespaceContextTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -55,8 +55,13 @@ ctx = null; } + /** + * prefixからURIが、URIからprefixが相互変換できる。 + * + * @throws Exception + */ @Test - public void testname() throws Exception { + public void test01_prefixからURIが_URIからprefixが相互変換できる() throws Exception { assertThat(ctx.getNamespaceURI(""), is("http://jiemamy.org/xml/ns/core")); assertThat(ctx.getNamespaceURI("core"), is("http://jiemamy.org/xml/ns/core")); assertThat(ctx.getPrefix("http://jiemamy.org/xml/ns/core"), is("")); Modified: artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlDialectTest.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlDialectTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlDialectTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -55,6 +55,11 @@ dialect = null; } + /** + * toStringがFQCNを返す。 + * + * @throws Exception + */ @Test public void test01_toStringがFQCNを返す() throws Exception { assertThat(dialect.toString(), is("org.jiemamy.dialect.mysql.MySqlDialect")); Modified: artemis/trunk/jiemamy-dialect-postgresql/src/test/java/org/jiemamy/dialect/postgresql/PostgresqlDialectTest.java =================================================================== --- artemis/trunk/jiemamy-dialect-postgresql/src/test/java/org/jiemamy/dialect/postgresql/PostgresqlDialectTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-dialect-postgresql/src/test/java/org/jiemamy/dialect/postgresql/PostgresqlDialectTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -34,8 +34,6 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.jiemamy.Artemis; import org.jiemamy.Jiemamy; @@ -50,8 +48,6 @@ */ public class PostgresqlDialectTest { - private static Logger logger = LoggerFactory.getLogger(PostgresqlDialectTest.class); - /** {@link XADataSource} */ public XADataSource xaDataSource; Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewDomSerializerEnhancer.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,6 +22,7 @@ import javax.xml.parsers.ParserConfigurationException; +import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Attr; @@ -33,6 +34,8 @@ import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.Level; +import org.jiemamy.model.Mode; import org.jiemamy.model.NodeProfile; import org.jiemamy.model.RootModel; import org.jiemamy.model.connection.ConnectionAdapter; @@ -57,11 +60,10 @@ */ public class ViewDomSerializerEnhancer implements InvocationHandler { - @SuppressWarnings("unchecked") public Object handle(Invocation invocation) throws Throwable { // new FactoryExtension() -> new ExtensionEnhancer.ViewExtention(); Jiemamy jiemamy = (Jiemamy) invocation.getArguments()[0]; - return new ViewDomSerializerEnhancer.ViewDomSerializer(jiemamy); + return new ViewDomSerializerEnhancer.JiemamyViewDomSerializer(jiemamy); } @@ -70,9 +72,9 @@ * * @author daisuke */ - public static class ViewDomSerializer extends JiemamyDomSerializer { + public static class JiemamyViewDomSerializer extends JiemamyDomSerializer { - private static Logger logger = LoggerFactory.getLogger(ViewDomSerializer.class); + private static Logger logger = LoggerFactory.getLogger(JiemamyViewDomSerializer.class); private Jiemamy jiemamy; @@ -82,7 +84,7 @@ * * @param jiemamy */ - public ViewDomSerializer(Jiemamy jiemamy) { + public JiemamyViewDomSerializer(Jiemamy jiemamy) { super(jiemamy); this.jiemamy = jiemamy; logger.info("JiemamyDomSerializer extended by Jiemamy VIEW Specification"); @@ -105,21 +107,25 @@ Element diagramPresentationsElement = DomUtil.newChild(document.getDocumentElement(), ViewQName.DIAGRAM_PRESENTATIONS); - logger.info("diagramPresentations"); + logger.trace("diagramPresentations"); for (DiagramPresentationModel presentation : diagramPresentations) { - logger.info(" diagramPresentation: id=" + presentation.getId()); + logger.trace(" diagramPresentation: id=" + presentation.getId()); Element presentationElement = DomUtil.newChild(diagramPresentationsElement, ViewQName.DIAGRAM_PRESENTATION); presentationElement.setAttribute("id", presentation.getId().toString()); - logger.info(" name: " + presentation.getName()); + logger.trace(" name: " + presentation.getName()); DomUtil.newChild(presentationElement, CoreQName.NAME, presentation.getName()); - logger.info(" nodeLayouts"); + logger.trace(" mode: " + presentation.getMode()); + DomUtil.newChild(presentationElement, ViewQName.MODE, presentation.getMode()); + logger.trace(" level: " + presentation.getLevel()); + DomUtil.newChild(presentationElement, ViewQName.LEVEL, presentation.getLevel()); + logger.trace(" nodeLayouts"); Element nodeLayoutsElement = DomUtil.newChild(presentationElement, ViewQName.NODE_LAYOUTS); for (Map.Entry<NodeAdapter, NodeProfile> entry : presentation.getFigureProfiles().entrySet()) { NodeAdapter node = entry.getKey(); NodeProfile nodeProfile = entry.getValue(); - logger.info(" nodeLayout"); + logger.trace(" nodeLayout"); Element nodeLayoutElement = DomUtil.newChild(nodeLayoutsElement, ViewQName.NODE_LAYOUT); nodeLayoutElement.setAttribute("id", nodeProfile.getId().toString()); Element nodeElement; @@ -128,11 +134,11 @@ StickyModel stickyModel = (StickyModel) node; nodeElement.setAttribute("id", stickyModel.getId().toString()); DomUtil.newChild(nodeElement, ViewQName.CONTENTS, stickyModel.getContents()); - logger.info(" sticky: " + stickyModel.getContents()); + logger.trace(" sticky: " + stickyModel.getContents()); } else { nodeElement = DomUtil.newChild(nodeLayoutElement, ViewQName.NODE_OBJECT_REF); nodeElement.setAttribute("ref", node.unwrap().getId().toString()); - logger.info(" node ref: " + node.unwrap().getId().toString()); + logger.trace(" node ref: " + node.unwrap().getId().toString()); } Element boundaryElement = DomUtil.newChild(nodeLayoutElement, ViewQName.BOUNDARY); boundaryElement.setAttribute("x", Integer.toString(nodeProfile.getLayout().x)); @@ -143,12 +149,12 @@ if (color != null) { boundaryElement.setAttribute("color", color.toString()); } - logger.info(" boundary: " + boundaryElement); + logger.trace(" boundary: " + boundaryElement); } Element connectionLayoutsElement = DomUtil.newChild(presentationElement, ViewQName.CONNECTION_LAYOUTS); - logger.info(" connectionLayouts"); + logger.trace(" connectionLayouts"); for (Map.Entry<ConnectionAdapter, List<JmPoint>> entry : presentation.getConnectionLayouts().entrySet()) { - logger.info(" connectionLayout"); + logger.trace(" connectionLayout"); ConnectionAdapter connection = entry.getKey(); List<JmPoint> points = entry.getValue(); Element connectionLayoutElement = @@ -161,16 +167,16 @@ Element connectionObjectRef = DomUtil.newChild(connectionLayoutElement, ViewQName.CONNECTION_OBJECT_REF); connectionObjectRef.setAttribute("ref", connection.unwrap().getId().toString()); - logger.info(" FK"); + logger.trace(" FK"); } if (points.size() > 0) { Element bendpointsElement = DomUtil.newChild(connectionLayoutElement, ViewQName.BENDPOINTS); - logger.info(" bendpoints"); + logger.trace(" bendpoints"); for (JmPoint point : points) { Element bendpointElement = DomUtil.newChild(bendpointsElement, ViewQName.BENDPOINT); bendpointElement.setAttribute("x", Integer.toString(point.x)); bendpointElement.setAttribute("y", Integer.toString(point.y)); - logger.info(" bendpoint: " + bendpointElement); + logger.trace(" bendpoint: " + bendpointElement); } } } @@ -196,8 +202,18 @@ Element dpElement = (Element) dpNode; DiagramPresentationModel presentation = factory.newModel(DiagramPresentationModel.class, DomUtil.getUUID(dpElement, CoreQName.ID)); - presentation.setName(XpathUtil.getText(dpElement, "core:name/text()")); + presentation.setName(XpathUtil.getTextContent(dpElement, "core:name")); + String modeString = XpathUtil.getTextContent(dpElement, "view:mode"); + if (StringUtils.isEmpty(modeString) == false) { + presentation.setMode(Mode.valueOf(modeString)); + } + + String levelString = XpathUtil.getTextContent(dpElement, "view:level"); + if (StringUtils.isEmpty(levelString) == false) { + presentation.setLevel(Level.valueOf(levelString)); + } + NodeList nodeLayoutNodeList = XpathUtil.getNodes(dpElement, "view:nodeLayouts/view:nodeLayout"); Iterable<Node> nodeLayoutNodeListIterable = new IterableNodeList(nodeLayoutNodeList); for (Node nodeLayoutNode : nodeLayoutNodeListIterable) { Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/ViewFactoryExtensionEnhancer.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Comparator; -import java.util.HashSet; import java.util.List; import java.util.TreeMap; import java.util.UUID; @@ -27,7 +26,6 @@ import org.jiemamy.model.DiagramPresentationsImpl; import org.jiemamy.model.NodeProfile; import org.jiemamy.model.RootModel; -import org.jiemamy.model.DiagramPresentationModel.DisplayItem; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.model.connection.ConnectionAdapterImpl; @@ -80,7 +78,6 @@ DiagramPresentationModelImpl presentation = new DiagramPresentationModelImpl(jiemamy, id); presentation.setConnectionLayouts(new TreeMap<ConnectionAdapter, List<JmPoint>>( ConnectionComparator.INSTANCE)); - presentation.setDisplayTargetSet(new HashSet<DisplayItem>()); presentation.setNodeLayouts(new TreeMap<NodeAdapter, NodeProfile>(NodeComparator.INSTANCE)); product = clazz.cast(presentation); } else if (clazz == NodeProfile.class) { Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/DiagramPresentationModelImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import org.apache.commons.lang.Validate; @@ -37,15 +36,11 @@ * ダイアグラム表現(レイアウト等)モデル。 * @author daisuke */ - @ SuppressWarnings("serial") public class DiagramPresentationModelImpl extends AbstractJiemamyElement implements DiagramPresentationModel { /** プレゼンテーション名 */ private String name; - /** 表示モード */ - private Set<DisplayItem> displayTargetSet; - /** * ノードのレイアウト情報 * @@ -60,6 +55,12 @@ */ private Map<ConnectionAdapter, List<JmPoint>> connectionLayouts; + /** 論理モデルかどうか */ + private Mode mode = Mode.PHYSICAL; + + /** 表示レベル */ + private Level level = Level.ATTRTYPE; + /** * インスタンスを生成する。 @@ -71,49 +72,34 @@ super(jiemamy, id); } - /** - * {@inheritDoc} - */ public Map<ConnectionAdapter, List<JmPoint>> getConnectionLayouts() { assert connectionLayouts != null; return connectionLayouts; } - /** - * {@inheritDoc} - */ - public Set<DisplayItem> getDisplayTargetSet() { - assert displayTargetSet != null; - return displayTargetSet; - } - - /** - * {@inheritDoc} - */ public Map<NodeAdapter, NodeProfile> getFigureProfiles() { assert nodeProfiles != null; return nodeProfiles; } - /** - * {@inheritDoc} - */ + public Level getLevel() { + return level; + } + + public Mode getMode() { + return mode; + } + public String getName() { return name; } - /** - * {@inheritDoc} - */ @Deprecated public void resetBendpoints(ConnectionAdapter connection) { Validate.notNull(connection); ProcessorUtil.process(this, new ResetBendpointProcessor(connection)); } - /** - * {@inheritDoc} - */ @Deprecated public void setBendpoints(ConnectionAdapter connection, List<JmPoint> bendpoints) { assert connectionLayouts != null; @@ -134,20 +120,16 @@ this.connectionLayouts = connectionLayouts; } - /** - * 表示モードを設定する。 - * @param displayTargetSet 表示モード - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public void setDisplayTargetSet(Set<DisplayItem> displayTargetSet) { - Validate.notNull(displayTargetSet); - ValidateUtil.injectionSetter(this.displayTargetSet); - this.displayTargetSet = displayTargetSet; + public void setLevel(Level level) { + Validate.notNull(mode); + this.level = level; } - /** - * {@inheritDoc} - */ + public void setMode(Mode mode) { + Validate.notNull(mode); + this.mode = mode; + } + public void setName(String name) { this.name = name; } @@ -162,5 +144,4 @@ ValidateUtil.injectionSetter(this.nodeProfiles); this.nodeProfiles = nodeProfiles; } - } Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/NodeAdapterImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/NodeAdapterImpl.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/model/node/NodeAdapterImpl.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -42,7 +42,6 @@ * * @author daisuke */ - @ SuppressWarnings("serial") public class NodeAdapterImpl implements NodeAdapter { private final EntityModel wrapped; Modified: artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/DiagramPresentationModelImplTest.java =================================================================== --- artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/DiagramPresentationModelImplTest.java 2009-02-19 15:39:29 UTC (rev 2693) +++ artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/model/DiagramPresentationModelImplTest.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -78,11 +78,10 @@ public void test01_各プロパティが正常に初期化されていること() throws Exception { assertThat(presentation.getFigureProfiles(), is(notNullValue())); assertThat(presentation.getConnectionLayouts(), is(notNullValue())); - assertThat(presentation.getDisplayTargetSet(), is(notNullValue())); + assertThat(presentation.getMode(), is(notNullValue())); + assertThat(presentation.getLevel(), is(notNullValue())); assertThat(presentation.getName(), is("testPresentation")); assertThat(presentation.getFigureProfiles().size(), is(0)); - assertThat(presentation.getConnectionLayouts().size(), is(0)); - assertThat(presentation.getDisplayTargetSet().size(), is(0)); } } Modified: vesta/trunk/org.jiemamy.eclipse/META-INF/MANIFEST.MF =================================================================== --- vesta/trunk/org.jiemamy.eclipse/META-INF/MANIFEST.MF 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/META-INF/MANIFEST.MF 2009-02-20 09:58:49 UTC (rev 2694) @@ -58,7 +58,6 @@ org.jiemamy.eclipse.editor.editpart.diagram, org.jiemamy.eclipse.editor.editpart.outlinetree, org.jiemamy.eclipse.editor.editpolicy, - org.jiemamy.eclipse.editor.extraprocessor, org.jiemamy.eclipse.editor.figure, org.jiemamy.eclipse.editor.utils, org.jiemamy.eclipse.extension, Modified: vesta/trunk/org.jiemamy.eclipse/plugin.xml =================================================================== --- vesta/trunk/org.jiemamy.eclipse/plugin.xml 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/plugin.xml 2009-02-20 09:58:49 UTC (rev 2694) @@ -8,6 +8,8 @@ <extension point="org.jiemamy.eclipse.dialects"> <dialect + class="org.jiemamy.dialect.generic.GenericDialect"/> + <dialect class="org.jiemamy.dialect.postgresql.PostgresqlDialect"/> <dialect class="org.jiemamy.dialect.sql99.Sql99Dialect"/> Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseDialectProvider.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseDialectProvider.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseDialectProvider.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,7 +22,6 @@ import org.jiemamy.InstanceProvider; import org.jiemamy.dialect.Dialect; -import org.jiemamy.exception.UnexpectedConditionError; /** * Eclipse環境においての{@link Dialect}インスタンス取得戦略クラス。 @@ -37,8 +36,9 @@ try { return JiemamyPlugin.getDialectResolver().getInstance(fqcn); } catch (CoreException e) { - throw new UnexpectedConditionError("something wrong...", e); + JiemamyPlugin.log(e); } + return null; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseExporterProvider.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseExporterProvider.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseExporterProvider.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,7 +22,6 @@ import org.jiemamy.InstanceProvider; import org.jiemamy.composer.Exporter; -import org.jiemamy.exception.UnexpectedConditionError; /** * Eclipse環境においての{@link Exporter}インスタンス取得戦略クラス。 @@ -37,8 +36,9 @@ try { return JiemamyPlugin.getExporterResolver().getInstance(fqcn); } catch (CoreException e) { - throw new UnexpectedConditionError("something wrong...", e); + JiemamyPlugin.log(e); } + return null; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseImporterProvider.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseImporterProvider.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/EclipseImporterProvider.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,7 +22,6 @@ import org.jiemamy.InstanceProvider; import org.jiemamy.composer.Importer; -import org.jiemamy.exception.UnexpectedConditionError; /** * Eclipse環境においての{@link Importer}インスタンス取得戦略クラス。 @@ -37,8 +36,9 @@ try { return JiemamyPlugin.getImporterResolver().getInstance(fqcn); } catch (CoreException e) { - throw new UnexpectedConditionError("something wrong...", e); + JiemamyPlugin.log(e); } + return null; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/JiemamyPlugin.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -22,15 +22,19 @@ import java.util.ResourceBundle; import org.apache.commons.lang.Validate; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; import org.seasar.eclipse.common.util.ImageManager; +import org.seasar.eclipse.common.util.StatusUtil; import org.jiemamy.composer.Exporter; import org.jiemamy.composer.Importer; @@ -150,6 +154,42 @@ } /** + * TODO for daisuke + * + * @param msg + */ + public static void log(String msg) { + log(msg, Status.INFO); + } + + /** + * TODO for daisuke + * + * @param msg + * @param intStatus + */ + public static void log(String msg, int intStatus) { + IStatus status = StatusUtil.create(plugin, intStatus, 0, msg, null); + plugin.getLog().log(status); + } + + /** + * TODO for daisuke + * + * @param throwable + */ + public static void log(Throwable throwable) { + IStatus status = null; + if (throwable instanceof CoreException) { + CoreException e = (CoreException) throwable; + status = e.getStatus(); + } else { + status = StatusUtil.createError(plugin, Status.ERROR, throwable); + } + plugin.getLog().log(status); + } + + /** * {@inheritDoc} */ @Override Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -86,7 +86,7 @@ for (Object obj : editParts) { if (obj instanceof AbstractJmNodeEditPart) { AbstractJmNodeEditPart editPart = (AbstractJmNodeEditPart) obj; - NodeAdapter model = (NodeAdapter) editPart.getModel(); + NodeAdapter model = editPart.getModel(); EntityNode node = new EntityNode(); node.model = model; node.width = editPart.getFigure().getSize().width; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -67,7 +67,7 @@ RGB rgb = colorDialog.open(); if (rgb != null) { for (AbstractJmNodeEditPart editPart : editParts) { - NodeAdapter nodeAdapter = (NodeAdapter) editPart.getModel(); + NodeAdapter nodeAdapter = editPart.getModel(); CommandStack stack = getViewer().getEditDomain().getCommandStack(); Command command = new ChangeNodeColorCommand(rootModel, nodeAdapter, ConvertUtil.convert(rgb)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -37,7 +37,6 @@ import org.eclipse.draw2d.PositionConstants; import org.eclipse.draw2d.Viewport; import org.eclipse.draw2d.parts.ScrollableThumbnail; -import org.eclipse.gef.ContextMenuProvider; import org.eclipse.gef.DefaultEditDomain; import org.eclipse.gef.EditPartViewer; import org.eclipse.gef.GraphicalViewer; @@ -397,8 +396,7 @@ viewer.setKeyHandler(keyHandler); // configure the context menu provider - ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry()); - viewer.setContextMenu(cmProvider); + viewer.setContextMenu(new DiagramEditorContextMenuProvider(viewer, this, getActionRegistry())); getSite().setSelectionProvider(viewer); } @@ -483,9 +481,6 @@ selectionActions.add(action.getId()); } - /** - * {@inheritDoc} - */ @Override protected PaletteRoot getPaletteRoot() { if (paletteModel == null) { @@ -495,9 +490,6 @@ return paletteModel; } - /** - * {@inheritDoc} - */ @Override protected void initializeGraphicalViewer() { super.initializeGraphicalViewer(); @@ -509,7 +501,6 @@ try { rootModel = jiemamy.getSerializer().deserialize(file.getContents()); RootModelUtil.normalize(rootModel); -// rootModel.setDisplayMode(DatabaseModel.MODE_PHYSICAL_ATTRTYPE); } catch (SerializationException e) { ExceptionHandler.handleException(e, "Data file is broken."); } catch (Exception e) { @@ -541,9 +532,6 @@ }); } - /** - * {@inheritDoc} - */ @Override protected void setInput(IEditorInput input) { super.setInput(input); Deleted: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayMode.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayMode.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayMode.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -1,110 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/07/29 - * - * 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.eclipse.editor; - -/** - * ディスプレイモードを表す型。 - * @author daisuke - */ -public enum DisplayMode { - - /** 物理モデル:属性/型レベル */ - PHYSICAL_ATTRTYPE(false, Level.ATTRTYPE, Messages.Physical_AttrAndType), - - /** 物理モデル:属性レベル */ - PHYSICAL_ATTR(false, Level.ATTR, Messages.Physical_Attribute), - - /** 物理モデル:識別子レベル */ - PHYSICAL_KEY(false, Level.KEY, Messages.Physical_Key), - - /** 物理モデル:エンティティレベル */ - PHYSICAL_ENTITY(false, Level.ENTITY, Messages.Physical_Entity), - - /** 論理モデル:属性/型レベル */ - LOGICAL_ATTRTYPE(true, Level.ATTRTYPE, Messages.Logical_AttrAndType), - - /** 論理モデル:属性レベル */ - LOGICAL_ATTR(true, Level.ATTR, Messages.Logical_Attribute), - - /** 論理モデル:識別子レベル */ - LOGICAL_KEY(true, Level.KEY, Messages.Logical_Key), - - /** 論理モデル:エンティティレベル */ - LOGICAL_ENTITY(true, Level.ENTITY, Messages.Logical_Entity); - - /** 論理モデルかどうか */ - private boolean logical; - - /** 表示レベル */ - private Level level; - - /** ラベル文字列 */ - private String label; - - - DisplayMode(boolean logical, Level level, String label) { - this.logical = logical; - this.level = level; - this.label = label; - } - - /** - * ラベル文字列を取得する。 - * @return ラベル文字列 - */ - protected String getLabel() { - return label; - } - - /** - * 表示レベルを取得する。 - * @return 表示レベル - */ - protected Level getLevel() { - return level; - } - - /** - * 論理モデルかどうかを取得する。 - * @return 論理モデルかどうか - */ - protected boolean isLogical() { - return logical; - } - - - /** - * 表示レベルを表す型。 - * @author daisuke - */ - static enum Level { - /** エンティティレベル */ - ENTITY, - - /** 識別子レベル */ - KEY, - - /** 属性レベル */ - ATTR, - - /** 属性+型レベル */ - ATTRTYPE - } - -} Copied: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayStatus.java (from rev 2693, vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayMode.java) =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayStatus.java (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayStatus.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -0,0 +1,93 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/07/29 + * + * 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.eclipse.editor; + +import org.jiemamy.model.Level; +import org.jiemamy.model.Mode; + +/** + * ディスプレイモードを表す型。 + * @author daisuke + */ +public enum DisplayStatus { + + /** 物理モデル:属性/型レベル */ + PHYSICAL_ATTRTYPE(Mode.PHYSICAL, Level.ATTRTYPE, Messages.Physical_AttrAndType), + + /** 物理モデル:属性レベル */ + PHYSICAL_ATTR(Mode.PHYSICAL, Level.ATTR, Messages.Physical_Attribute), + + /** 物理モデル:識別子レベル */ + PHYSICAL_KEY(Mode.PHYSICAL, Level.KEY, Messages.Physical_Key), + + /** 物理モデル:エンティティレベル */ + PHYSICAL_ENTITY(Mode.PHYSICAL, Level.ENTITY, Messages.Physical_Entity), + + /** 論理モデル:属性/型レベル */ + LOGICAL_ATTRTYPE(Mode.LOGICAL, Level.ATTRTYPE, Messages.Logical_AttrAndType), + + /** 論理モデル:属性レベル */ + LOGICAL_ATTR(Mode.LOGICAL, Level.ATTR, Messages.Logical_Attribute), + + /** 論理モデル:識別子レベル */ + LOGICAL_KEY(Mode.LOGICAL, Level.KEY, Messages.Logical_Key), + + /** 論理モデル:エンティティレベル */ + LOGICAL_ENTITY(Mode.LOGICAL, Level.ENTITY, Messages.Logical_Entity); + + /** 論理モデルかどうか */ + private Mode mode; + + /** 表示レベル */ + private Level level; + + /** ラベル文字列 */ + private String label; + + + DisplayStatus(Mode mode, Level level, String label) { + this.mode = mode; + this.level = level; + this.label = label; + } + + /** + * ラベル文字列を取得する。 + * @return ラベル文字列 + */ + public String getLabel() { + return label; + } + + /** + * 表示レベルを取得する。 + * @return 表示レベル + */ + public Level getLevel() { + return level; + } + + /** + * 論理モデルかどうかを取得する。 + * @return 論理モデルかどうか + */ + public Mode getMode() { + return mode; + } +} Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/DisplayStatus.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/JmContributor.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -39,8 +39,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -53,55 +51,31 @@ import org.eclipse.update.core.VersionedIdentifier; import org.osgi.framework.Bundle; import org.seasar.eclipse.common.util.LogUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.jiemamy.Migration; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.eclipse.utils.ExceptionHandler; +import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; /** - * エディタのコントリビュータ + * エディタのコントリビュータ。 + * * @author daisuke */ public class JmContributor extends ActionBarContributor { + private static Logger logger = LoggerFactory.getLogger(JmContributor.class); + private static final String JIEMAMY_UPDATE_SITE_URL = "http://jiemamy.sourceforge.jp/eclipse/"; - private Combo combo; + private Combo cmbDisplayStatus; - /** - * 更新サイトをチェックして、アップデートアラートを表示する。 - * @param parent - */ - @SuppressWarnings("deprecation") - public void checkUpdate(Composite parent) { - try { - ISite rs = SiteManager.getSite(new URL(JIEMAMY_UPDATE_SITE_URL), new NullProgressMonitor()); - IFeatureReference[] frs = rs.getFeatureReferences(); - VersionedIdentifier frsVi = frs[frs.length - 1].getVersionedIdentifier(); - org.eclipse.core.runtime.PluginVersionIdentifier latestVer = frsVi.getVersion(); - - Bundle bundle = JiemamyPlugin.getDefault().getBundle(); - String version = (String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); - org.eclipse.core.runtime.PluginVersionIdentifier currentVer = - new org.eclipse.core.runtime.PluginVersionIdentifier(version); - - if (latestVer.isGreaterThan(currentVer)) { - Label label = new Label(parent, SWT.NONE); - label.setText("New version is available."); // RESOURCE - } - } catch (CoreException e) { - LogUtil.log(JiemamyPlugin.getDefault(), "Network is not connected."); // RESOURCE - } catch (MalformedURLException e) { - ExceptionHandler.handleException(e); - } - } - - /** - * {@inheritDoc} - */ @Override public void contributeToToolBar(IToolBarManager toolBarManager) { // コピペ関連アクションの追加 @@ -133,71 +107,35 @@ toolBarManager.add(new Separator()); // 表示モード切替コンボの追加 - toolBarManager.add(new ControlContribution("jp.xet.jiemamy.eclipse.displayMode") { - - /** - * {@inheritDoc} - */ - @Override - protected Control createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(2, false)); - composite.setLayoutData(new GridData()); - - combo = new Combo(composite, SWT.READ_ONLY); - for (DisplayMode mode : DisplayMode.values()) { - combo.add(mode.getLabel()); - } - - combo.addSelectionListener(new SelectionAdapter() { - - /** - * {@inheritDoc} - */ - @Override - public void widgetSelected(SelectionEvent e) { - int index = combo.getSelectionIndex(); - if (index != -1) { - IEditorPart editor = EditorUtil.getActiveEditor(); - if (editor instanceof JiemamyEditor) { - RootModel rootModel = ((JiemamyEditor) editor).getRootModel(); - DiagramPresentations presentations = rootModel.getAdapter(DiagramPresentations.class); - // FIXME display mode設定 -// rootModel.setDisplayMode(modeNumber.get(index)); - } - } - } - }); - - IEditorPart editor = EditorUtil.getActiveEditor(); - if (editor instanceof DiagramEditor) { - RootModel rootModel = ((DiagramEditor) editor).getRootModel(); - if (rootModel != null) { - selectCombo(rootModel); - } - } - -// checkUpdate(composite); - - return composite; - } - }); + toolBarManager.add(new JiemamyDiagramEditorContribution()); } /** - * 表示モード設定コンボに、現在の表示モードを設定する。 Thanks to Naokiさん + * 表示モード設定コンボに、現在の表示モードを設定する。 + * + * <p>Thanks to Naokiさん</p> + * * @param rootModel 現在編集中のルートモデル */ public void selectCombo(RootModel rootModel) { - if (combo != null && combo.isDisposed() == false) { - // FIXME display mode設定 -// combo.select(modeNumber.indexOf(rootModel.getDisplayMode())); + if (cmbDisplayStatus == null || cmbDisplayStatus.isDisposed()) { + logger.error("combo is null or disposed"); + return; } + + DiagramPresentations presentations = rootModel.getAdapter(DiagramPresentations.class); + DiagramPresentationModel presentation = presentations.get(Migration.DIAGRAM_INDEX); + for (DisplayStatus displayStatus : DisplayStatus.values()) { + if (presentation.getMode() == displayStatus.getMode() + && presentation.getLevel() == displayStatus.getLevel()) { + cmbDisplayStatus.select(displayStatus.ordinal()); + return; + } + } + logger.error("matched DisplayStatus is not found"); + cmbDisplayStatus.select(0); } - /** - * {@inheritDoc} - */ @Override protected void buildActions() { addRetargetAction(new UndoRetargetAction()); @@ -215,12 +153,98 @@ addRetargetAction(new AlignmentRetargetAction(PositionConstants.BOTTOM)); } - /** - * {@inheritDoc} - */ @Override protected void declareGlobalActionKeys() { addGlobalActionKey(ActionFactory.SELECT_ALL.getId()); } + + private class JiemamyDiagramEditorContribution extends ControlContribution { + + /** + * インスタンスを生成する。 + */ + private JiemamyDiagramEditorContribution() { + super("org.jiemamy.eclipse.displayMode"); + } + + /** + * 更新サイトをチェックして、アップデートアラートを表示する。 + * @param parent + */ + @SuppressWarnings("deprecation") + public void checkUpdate(Composite parent) { + try { + ISite rs = SiteManager.getSite(new URL(JIEMAMY_UPDATE_SITE_URL), new NullProgressMonitor()); + IFeatureReference[] frs = rs.getFeatureReferences(); + VersionedIdentifier frsVi = frs[frs.length - 1].getVersionedIdentifier(); + org.eclipse.core.runtime.PluginVersionIdentifier latestVer = frsVi.getVersion(); + + Bundle bundle = JiemamyPlugin.getDefault().getBundle(); + String version = (String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION); + org.eclipse.core.runtime.PluginVersionIdentifier currentVer = + new org.eclipse.core.runtime.PluginVersionIdentifier(version); + + if (latestVer.isGreaterThan(currentVer)) { + Label label = new Label(parent, SWT.NONE); + label.setText("New version is available."); // RESOURCE + } + } catch (CoreException e) { + LogUtil.log(JiemamyPlugin.getDefault(), "Network is not connected."); + } catch (MalformedURLException e) { + ExceptionHandler.handleException(e); + } + } + + @Override + protected Control createControl(Composite parent) { + cmbDisplayStatus = new Combo(parent, SWT.READ_ONLY); + for (DisplayStatus mode : DisplayStatus.values()) { + cmbDisplayStatus.add(mode.getLabel()); + } + + cmbDisplayStatus.addSelectionListener(new ComboSelectionListener()); + + IEditorPart editor = EditorUtil.getActiveEditor(); + if (editor instanceof DiagramEditor) { + RootModel rootModel = ((DiagramEditor) editor).getRootModel(); + if (rootModel != null) { + selectCombo(rootModel); + } + } + +// checkUpdate(parent); + + return cmbDisplayStatus; + } + + + private class ComboSelectionListener extends SelectionAdapter { + + @Override + public void widgetSelected(SelectionEvent e) { + logger.debug("DisplayStatus changed"); + int index = cmbDisplayStatus.getSelectionIndex(); + if (index == -1) { + return; + } + IEditorPart editor = EditorUtil.getActiveEditor(); + if ((editor instanceof JiemamyEditor) == false) { + return; + } + RootModel rootModel = ((JiemamyEditor) editor).getRootModel(); + DiagramPresentations presentations = rootModel.getAdapter(DiagramPresentations.class); + DiagramPresentationModel presentation = presentations.get(Migration.DIAGRAM_INDEX); + for (DisplayStatus displayStatus : DisplayStatus.values()) { + if (displayStatus.ordinal() == index) { + presentation.setMode(displayStatus.getMode()); + presentation.setLevel(displayStatus.getLevel()); + break; + } + } + } + } + + } + } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DirectEditNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DirectEditNodeCommand.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DirectEditNodeCommand.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -18,11 +18,15 @@ */ package org.jiemamy.eclipse.editor.command; +import ch.qos.logback.core.status.Status; + import org.apache.commons.lang.Validate; import org.eclipse.gef.commands.Command; -import org.jiemamy.eclipse.editor.DisplayMode; +import org.jiemamy.eclipse.JiemamyPlugin; +import org.jiemamy.eclipse.editor.DisplayStatus; import org.jiemamy.exception.IllegalImplementationException; +import org.jiemamy.model.Mode; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.node.NodeAdapter; import org.jiemamy.model.node.StickyModel; @@ -42,7 +46,7 @@ /** 編集対象 */ private NodeAdapter nodeAdapter; - private DisplayMode displayMode; + private DisplayStatus displayStatus; /** @@ -53,15 +57,15 @@ public void execute() { EntityModel entityModel = nodeAdapter.unwrap(); if (entityModel != null) { -// if ((displayMode & DatabaseModel.MODE_PHYSICAL) != 0) { - oldValue = entityModel.getName(); - entityModel.setName(newValue); -// } else if ((displayMode & DatabaseModel.MODE_LOGICAL) != 0) { -// oldValue = entityModel.getLogicalName(); -// entityModel.setLogicalName(newValue); -// } else { -// throw new JiemamyRuntimeException(); -// } + if (displayStatus.getMode() == Mode.PHYSICAL) { + oldValue = entityModel.getName(); + entityModel.setName(newValue); + } else if (displayStatus.getMode() == Mode.LOGICAL) { + oldValue = entityModel.getLogicalName(); + entityModel.setLogicalName(newValue); + } else { + JiemamyPlugin.log("想定外のenum要素", Status.ERROR); + } } else if (nodeAdapter instanceof StickyModel) { StickyModel stickyModel = (StickyModel) nodeAdapter; stickyModel.setContents(newValue); @@ -72,10 +76,10 @@ /** * displayModeを設定する。 - * @param displayMode displayMode + * @param displayStatus displayMode */ - public void setDisplayMode(DisplayMode displayMode) { - this.displayMode = displayMode; + public void setDisplayMode(DisplayStatus displayStatus) { + this.displayStatus = displayStatus; } /** @@ -103,13 +107,13 @@ public void undo() { if (nodeAdapter instanceof EntityModel) { EntityModel entityModel = (EntityModel) nodeAdapter; -// if ((displayMode & DatabaseModel.MODE_PHYSICAL) != 0) { - entityModel.setName(oldValue); -// } else if ((displayMode & DatabaseModel.MODE_LOGICAL) != 0) { -// entityModel.setLogicalName(oldValue); -// } else { -// throw new JiemamyRuntimeException(); -// } + if (displayStatus.getMode() == Mode.PHYSICAL) { + entityModel.setName(oldValue); + } else if (displayStatus.getMode() == Mode.LOGICAL) { + entityModel.setLogicalName(oldValue); + } else { + JiemamyPlugin.log("想定外のenum要素", Status.ERROR); + } } else if (nodeAdapter instanceof StickyModel) { StickyModel stickyModel = (StickyModel) nodeAdapter; stickyModel.setContents(oldValue); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -374,6 +374,15 @@ domainEditor.refreshTable(); } }); + txtCheckName.addFocusListener(new TextSelectionAdapter(txtCheckName)); + txtCheckName.addKeyListener(new KeyAdapter() { + + @Override + public void keyReleased(KeyEvent e) { + updateModel(); + domainEditor.refreshTable(); + } + }); txtCheckExpression.addFocusListener(new TextSelectionAdapter(txtCheckExpression)); txtCheckExpression.addKeyListener(new KeyAdapter() { @@ -483,6 +492,12 @@ txtCheckExpression = new Text(cmpTypes, SWT.BORDER); txtCheckExpression.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + label = new Label(cmpTypes, SWT.NULL); + label.setText("チェック制約名"); // RESOURCE + + txtCheckName = new Text(cmpTypes, SWT.BORDER); + txtCheckName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Composite cmpDesc = new Composite(parent, SWT.NULL); cmpDesc.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); layout = new GridLayout(2, false); @@ -529,6 +544,7 @@ txtDomainName.setText(StringUtils.EMPTY); cmbColumnType.setText(StringUtils.EMPTY); txtColumnSize.setText(StringUtils.EMPTY); + txtCheckName.setText(StringUtils.EMPTY); txtCheckExpression.setText(StringUtils.EMPTY); txtDescription.setText(StringUtils.EMPTY); chkIsNotNull.setSelection(false); @@ -536,6 +552,7 @@ txtDomainName.setEnabled(false); cmbColumnType.setEnabled(false); txtColumnSize.setEnabled(false); + txtCheckName.setEnabled(false); txtCheckExpression.setEnabled(false); txtDescription.setEnabled(false); chkIsNotNull.setEnabled(false); @@ -553,6 +570,7 @@ txtDescription.setText(StringUtils.defaultIfEmpty(domain.getDescription(), "")); chkIsNotNull.setSelection(domain.getNotNull() != null); CheckConstraintModel checkConstraintModel = domain.getCheck(); + txtCheckName.setText(StringUtils.defaultIfEmpty(checkConstraintModel.getName(), "")); txtCheckExpression.setText(checkConstraintModel.getExpression()); txtDomainName.setEnabled(true); @@ -560,6 +578,7 @@ txtColumnSize.setEnabled(true); txtDescription.setEnabled(true); chkIsNotNull.setEnabled(true); + txtCheckName.setEnabled(true); txtCheckExpression.setEnabled(true); // 現在値の設定 } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -299,7 +299,6 @@ * * @param parent * @param style - * @param tableModel */ public ColumnTableEditor(Composite parent, int style) { super(parent, style, new TableEditorConfigurator() { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/DiagramEditPartFactory.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -18,16 +18,16 @@ */ package org.jiemamy.eclipse.editor.editpart; -import org.apache.commons.lang.Validate; +import org.eclipse.core.runtime.Status; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; +import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.editpart.diagram.ForeignKeyEditPart; import org.jiemamy.eclipse.editor.editpart.diagram.RootEditPart; import org.jiemamy.eclipse.editor.editpart.diagram.StickyEditPart; import org.jiemamy.eclipse.editor.editpart.diagram.TableEditPart; import org.jiemamy.eclipse.editor.editpart.diagram.ViewEditPart; -import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.connection.ConnectionAdapter; @@ -43,12 +43,8 @@ */ public class DiagramEditPartFactory implements EditPartFactory { - /** - * {@inheritDoc} - */ public EditPart createEditPart(EditPart context, Object model) { - Validate.notNull(model); - EditPart part; + EditPart part = null; if (model instanceof RootModel) { part = new RootEditPart((RootModel) model); @@ -63,10 +59,10 @@ if (nodeAdapter instanceof StickyModel) { part = new StickyEditPart((StickyModel) nodeAdapter); } else { - throw new UnexpectedConditionError("unknown node: " + model.getClass().getName()); + JiemamyPlugin.log("unknown node: " + model.getClass().getName(), Status.ERROR); } } else { - throw new UnexpectedConditionError("unknown entity: " + model.getClass().getName()); + JiemamyPlugin.log("unknown entity: " + model.getClass().getName(), Status.ERROR); } } else if (model instanceof ConnectionAdapter) { ConnectionAdapter connectionAdapter = (ConnectionAdapter) model; @@ -74,12 +70,16 @@ if (foreignKeyModel != null) { part = new ForeignKeyEditPart(connectionAdapter); } else { - throw new UnexpectedConditionError("unknown connection: " + model.getClass().getName()); + JiemamyPlugin.log("unknown connection: " + model.getClass().getName(), Status.ERROR); } } else { - throw new UnexpectedConditionError("unknown model: " + model.getClass().getName()); + JiemamyPlugin.log("unknown model: " + model.getClass().getName(), Status.ERROR); } + if (part == null) { + JiemamyPlugin.log("Cannot create EditPart for unknown model.", Status.ERROR); + } + return part; } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/OutlineTreeEditPartFactory.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -18,10 +18,11 @@ */ package org.jiemamy.eclipse.editor.editpart; -import org.apache.commons.lang.Validate; +import org.eclipse.core.runtime.Status; import org.eclipse.gef.EditPart; import org.eclipse.gef.EditPartFactory; +import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.ModelContainer; import org.jiemamy.eclipse.editor.editpart.outlinetree.AttributeTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.DomainTreeEditPart; @@ -29,7 +30,6 @@ import org.jiemamy.eclipse.editor.editpart.outlinetree.RootTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.TableTreeEditPart; import org.jiemamy.eclipse.editor.editpart.outlinetree.ViewTreeEditPart; -import org.jiemamy.exception.UnexpectedConditionError; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.datatype.DomainModel; @@ -42,12 +42,8 @@ */ public class OutlineTreeEditPartFactory implements EditPartFactory { - /** - * {@inheritDoc} - */ public EditPart createEditPart(EditPart context, Object model) { - Validate.notNull(model); - EditPart part; + EditPart part = null; if (model instanceof RootModel) { RootModel rootModel = (RootModel) model; @@ -68,7 +64,7 @@ ViewModel viewModel = (ViewModel) model; part = new ViewTreeEditPart(viewModel); } else { - throw new UnexpectedConditionError("unknown model: " + model.getClass().getName()); + JiemamyPlugin.log("unknown model: " + model.getClass().getName(), Status.ERROR); } return part; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -35,7 +35,6 @@ import org.jiemamy.eclipse.editor.DisplayPlace; import org.jiemamy.eclipse.editor.DisplayTarget; import org.jiemamy.eclipse.editor.dialog.table.TableEditDialog; -import org.jiemamy.eclipse.editor.extraprocessor.IsDisplayedProcessor; import org.jiemamy.eclipse.editor.figure.ColumnFigure; import org.jiemamy.eclipse.editor.figure.TableFigure; import org.jiemamy.eclipse.editor.utils.LabelStringUtil; @@ -44,16 +43,15 @@ import org.jiemamy.exception.TooManyElementsException; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; +import org.jiemamy.model.Level; import org.jiemamy.model.NodeProfile; import org.jiemamy.model.RootModel; -import org.jiemamy.model.DiagramPresentationModel.DisplayItem; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; import org.jiemamy.model.entity.TableModel; import org.jiemamy.model.geometory.JmColor; import org.jiemamy.model.geometory.JmRectangle; import org.jiemamy.model.node.NodeAdapter; -import org.jiemamy.utils.ProcessorUtil; import org.jiemamy.utils.model.TableUtil; /** @@ -196,9 +194,10 @@ // ignore } - if (pkColumn - && ProcessorUtil.process(rootModel, new IsDisplayedProcessor(Migration.DIAGRAM_INDEX, - DisplayItem.PRIMARY_KEY)) == false) { + DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class); + DiagramPresentationModel presentation = diagramPresentations.get(Migration.DIAGRAM_INDEX); + + if (presentation.getLevel() == Level.ENTITY) { return new ColumnFigure[0]; } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/ViewTreeEditPart.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -49,32 +49,21 @@ setModel(model); } - /** - * {@inheritDoc} - */ + @Override public void doubleClicked() { openEditDialog(); } - /** - * {@inheritDoc} - */ @Override public ViewModel getModel() { return (ViewModel) super.getModel(); } - /** - * {@inheritDoc} - */ public JiemamyElement getTargetModel() { ViewModel model = getModel(); return model; } - /** - * {@inheritDoc} - */ public void openEditDialog() { ViewModel viewModel = getModel(); @@ -96,9 +85,6 @@ // } } - /** - * {@inheritDoc} - */ @Override public void setModel(Object model) { if (model instanceof ViewModel) { @@ -108,17 +94,11 @@ } } - /** - * {@inheritDoc} - */ @Override protected void createEditPolicies() { installEditPolicy(EditPolicy.COMPONENT_ROLE, new JmTreeComponentEditPolicy()); } - /** - * {@inheritDoc} - */ @Override protected void refreshVisuals() { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/TableEditorConfigurator.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/TableEditorConfigurator.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/TableEditorConfigurator.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -18,8 +18,10 @@ */ package org.jiemamy.eclipse.ui; +import org.eclipse.swt.custom.TableEditor; + /** - * TODO for daisuke + * {@link TableEditor}の設定インターフェイス。 * * @author daisuke */ @@ -33,9 +35,9 @@ String getAddLabel(); /** - * TODO for daisuke + * 編集エリアのタイトルを取得する。 * - * @return + * @return 編集エリアのタイトル */ String getEditorTitle(); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/AbstractTab.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -48,9 +48,9 @@ } /** - * TODO for daisuke + * タブ要素を取得する。 * - * @return + * @return タブ要素 */ public TabItem getTabItem() { return tabItem; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java 2009-02-19 15:39:29 UTC (rev 2693) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/ui/tab/TextEditTab.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -51,9 +51,9 @@ } /** - * TODO for daisuke + * 子として作られたTextウィジェットを取得する。 * - * @return + * @return 子として作られたTextウィジェット */ public Text getTextWidget() { return text; 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-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyFactory.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -92,6 +92,12 @@ */ <M, B extends PrematureBuilder<M>>B newBuilder(Class<B> clazz); + /** + * 鋳型情報から、 {@link BuiltinDataType}のインスタンスを生成する。 + * + * @param mold 鋳型情報 + * @return {@link BuiltinDataType}のインスタンス + */ 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-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -25,6 +25,7 @@ import java.util.List; import org.jiemamy.model.RootModel; +import org.jiemamy.model.datatype.BuiltinDataType; import org.jiemamy.model.datatype.DataTypeCategory; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.sql.SqlStatement; @@ -131,30 +132,30 @@ /** - * TODO for daisuke + * {@link BuiltinDataType}インスタンスを生成する鋳型情報インターフェイス。 * * @author daisuke */ public interface BuiltinDataTypeMold { /** - * TODO for daisuke + * データ型カテゴリを取得する。 * - * @return + * @return データ型カテゴリ */ DataTypeCategory getCategory(); /** - * TODO for daisuke + * 型がサポートするアダプタクラスの集合を取得する。 * - * @return + * @return 型がサポートするアダプタクラスの集合 */ Collection<Class<?>> getSupportedAdapterClasses(); /** - * TODO for daisuke + * 型名を取得する。 * - * @return + * @return 型名 */ String getTypeName(); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -19,23 +19,23 @@ package org.jiemamy.dialect; /** - * TODO for daisuke + * SQL出力にあたっての設定情報インターフェイス。 * * @author daisuke */ public interface EmitConfig { /** - * TODO for daisuke + * DML(INSERT文)を出力するかどうかを取得する。 * - * @return + * @return 出力する場合は{@code true} */ boolean createDML(); /** - * TODO for daisuke + * CREATE文の前にDROP文を出力するかどうかを取得する。 * - * @return + * @return 出力する場合は{@code true} */ boolean createDrop(); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/RootModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/RootModel.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/RootModel.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -50,6 +50,12 @@ String getBeginScript(); /** + * INSERTデータセットのリストを取得する。 + * @return INSERTデータセットのリスト + */ + List<DataSetModel> getDataSets(); + + /** * 説明文を取得する。 * * <p>未設定の場合、{@code null}を返してもよい(MAY)。</p> @@ -86,12 +92,6 @@ SortedSet<EntityModel> getEntities(); /** - * INSERTデータセットのリストを取得する。 - * @return INSERTデータセットのリスト - */ - List<DataSetModel> getDataSets(); - - /** * スキーマ名を取得する。 * * <p>未設定の場合、{@code null}を返してもよい(MAY)。</p> @@ -115,6 +115,7 @@ /** * SQL方言を設定する。 * @param dialectClassName SQL方言クラス名 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ void setDialectClassName(String dialectClassName); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -30,6 +30,11 @@ */ public interface ColumnModel extends AttributeModel { + /** + * チェック制約を取得する。 + * + * @return チェック制約 + */ ColumnCheckModel getCheck(); /** @@ -44,12 +49,32 @@ */ String getDefaultValue(); + /** + * NOT NULL制約を取得する。 + * + * @return NOT NULL制約 + */ NotNullConstraintModel getNotNull(); + /** + * 主キー制約を取得する。 + * + * @return 主キー制約 + */ PrimaryKeyModel getPrimaryKey(); + /** + * 一意キー制約を取得する。 + * + * @return 一意キー制約 + */ UniqueKeyModel getUniqueKey(); + /** + * チェック制約を設定する。 + * + * @param check チェック制約 + */ void setCheck(ColumnCheckModel check); /** @@ -64,10 +89,25 @@ */ void setDefaultValue(String defaultValue); + /** + * NOT NULL制約を設定する。 + * + * @param notNull NOT NULL制約 + */ void setNotNull(NotNullConstraintModel notNull); + /** + * 主キー制約を設定する。 + * + * @param primaryKey 主キー制約 + */ void setPrimaryKey(PrimaryKeyModel primaryKey); + /** + * 一意キー制約を設定する。 + * + * @param uniqueKey 一意キー制約 + */ void setUniqueKey(UniqueKeyModel uniqueKey); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeCategory.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeCategory.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeCategory.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -21,7 +21,7 @@ import java.sql.Types; /** - * 代表的なデータ型を表す列挙型 + * データ型のカテゴリを表す列挙型。 * * @author daisuke */ Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -42,6 +42,11 @@ */ List<Object> getAdapters(); + /** + * チェック制約を取得する。 + * + * @return チェック制約 + */ ColumnCheckModel getCheck(); /** @@ -68,6 +73,11 @@ */ String getName(); + /** + * NOT NULL制約を取得する。 + * + * @return NOT NULL制約 + */ NotNullConstraintModel getNotNull(); /** @@ -82,6 +92,11 @@ */ void registerAdapter(Object adapter); + /** + * チェック制約を設定する。 + * + * @param check チェック制約 + */ void setCheck(ColumnCheckModel check); /** @@ -108,6 +123,11 @@ */ void setName(String name); + /** + * NOT NULL制約を設定する。 + * + * @param notNull NOT NULL制約 + */ void setNotNull(NotNullConstraintModel notNull); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/Token.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/Token.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/sql/Token.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -19,11 +19,18 @@ package org.jiemamy.model.sql; /** - * TODO for daisuke + * トークンをあらわすインターフェイス。 * + * <p>このインターフェイスの実装は、イミュータブルでなければならない。</p> + * * @author daisuke */ public interface Token { + /** + * トークンを文字列に変換する。 + * + * @return 文字列 + */ String toString(); } Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-core.xsd 2009-02-20 09:58:49 UTC (rev 2694) @@ -12,9 +12,6 @@ <xsd:documentation source="description" xml:lang="ja-JP">Jiemamyモデルスキーマ</xsd:documentation> </xsd:annotation> - <!-- TODO nullValueの設定 --> - <xsd:element name="nullValue"/> - <xsd:element name="rootModel"> <xsd:complexType> <xsd:sequence maxOccurs="1" minOccurs="1"> Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/jiemamy-view.xsd 2009-02-20 09:58:49 UTC (rev 2694) @@ -28,6 +28,8 @@ <xsd:complexType> <xsd:sequence> <xsd:element ref="core:name" /> + <xsd:element name="mode" type="modeType" /> + <xsd:element name="level" type="levelType" /> <xsd:element name="nodeLayouts" minOccurs="0"> <xsd:complexType> <xsd:sequence minOccurs="0" maxOccurs="unbounded"> @@ -136,4 +138,20 @@ </xsd:restriction> </xsd:simpleType> + <xsd:simpleType name="modeType"> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="PHYSICAL" /> + <xsd:enumeration value="LOGICAL" /> + </xsd:restriction> + </xsd:simpleType> + + <xsd:simpleType name="levelType"> + <xsd:restriction base="xsd:token"> + <xsd:enumeration value="ENTITY" /> + <xsd:enumeration value="KEY" /> + <xsd:enumeration value="ATTR" /> + <xsd:enumeration value="ATTRTYPE" /> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> \ No newline at end of file Modified: zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample.xml 2009-02-20 09:58:49 UTC (rev 2694) @@ -400,6 +400,8 @@ <view:diagramPresentations xmlns:view="http://jiemamy.org/xml/ns/view"> <view:diagramPresentation id="1deca0e8-6153-47ad-abe8-ac764f768d96"> <name>全部表示する</name> + <view:mode>PHYSICAL</view:mode> + <view:level>ATTRTYPE</view:level> <view:nodeLayouts> <view:nodeLayout id="aa7caa23-7958-4bd0-a356-8f09d4b74f08"> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> @@ -435,6 +437,8 @@ </view:diagramPresentation> <view:diagramPresentation id="53c7cdb7-1512-46c7-8ee3-aadec6007896"> <name>一部表示する</name> + <view:mode>PHYSICAL</view:mode> + <view:level>ATTRTYPE</view:level> <view:nodeLayouts> <view:nodeLayout id="d71ff015-101c-4669-8745-312d1da34efe"> <view:nodeObjectRef ref="9f522e56-809c-45fd-8416-39201014218b"/> Deleted: zeus/trunk/jiemamy-spec-core/src/main/resources/sample2.xml =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/resources/sample2.xml 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-core/src/main/resources/sample2.xml 2009-02-20 09:58:49 UTC (rev 2694) @@ -1,554 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<rootModel xmlns="http://jiemamy.org/xml/ns/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="6cbba964-6809-4eb9-936d-ec318012322c" xsi:schemaLocation="http://jiemamy.org/xml/ns/core ../../main/resources/jiemamy-core.xsd http://jiemamy.org/xml/ns/view ../../main/resources/jiemamy-view.xsd"> - <dialect>org.jiemamy.dialect.mysql.MySqlDialect</dialect> - <schemaName>BAR</schemaName> - <description>Jiemamyテストモデル2</description> - <beginScript>BEGIN;</beginScript> - <endScript>COMMIT;</endScript> - <domains> - <domain id="9a3ba23c-b328-4c70-a32d-3e4be3ee3f08"> - <name>ID</name> - <dataType> - <typeCategory>INTEGER</typeCategory> - <typeName>INTEGER</typeName> - <adapter class="org.jiemamy.model.datatype.adapter.SerialDataTypeAdapter"> - <serial>true</serial> - </adapter> - </dataType> - <constraints> - <notNull id="587a7b83-5885-4736-8539-7d9526b6f5dd"/> - </constraints> - </domain> - <domain id="e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193"> - <name>NAME</name> - <description>人名用の型です。</description> - <dataType> - <typeCategory>VARCHAR</typeCategory> - <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> - <size>32</size> - </adapter> - </dataType> - </domain> - </domains> - <entities> - <table id="cefee0d9-d23f-441b-986a-66660354ec74"> - <name>T_ORDER</name> - <logicalName>注文</logicalName> - <description>注文テーブルです。</description> - <attributes> - <column id="b647212a-4d8f-4d18-88e4-5397e54ebe67"> - <name>ID</name> - <logicalName>注文ID</logicalName> - <dataType ref="9a3ba23c-b328-4c70-a32d-3e4be3ee3f08"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="db7a2f62-9658-406a-9dc1-8b90ae2da47c"> - <name>USER_ID</name> - <logicalName>オーダーユーザID</logicalName> - <dataType> - <typeCategory>INTEGER</typeCategory> - <typeName>INTEGER</typeName> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="4ce761b0-137b-4105-ad2a-2efcba5e6bc4"> - <name>ORDER_DATE</name> - <dataType> - <typeCategory>TIMESTAMP</typeCategory> - <typeName>TIMESTAMP</typeName> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <primaryKey id="b204ff42-537b-4e14-bf61-e9baf1b119dc"> - <columnRefs> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67"/> - </columnRefs> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </primaryKey> - <foreignKey id="325b5aa9-821e-4791-aac5-2d3eb64f9392"> - <columnRefs> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c"/> - </columnRefs> - <referenceColumns> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e"/> - </referenceColumns> - <deferrability id="899f5889-ac30-44dc-b078-35a1b1edc8f0"> - <deferrable>false</deferrable> - </deferrability> - <onDelete>RESTRICT</onDelete> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </foreignKey> - <notNull id="3930591d-8621-4809-9761-87a2e15716ab"> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - <notNull id="a1ba8dae-569a-4d79-ac80-3ad55e0cc0df"> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - </attributes> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </table> - <table id="0802ef7b-b2da-4fc4-8104-0c99a1e472d5"> - <name>T_USER</name> - <logicalName>ユーザ</logicalName> - <description>ユーザマスタです。</description> - <attributes> - <column id="6b022a79-45a6-4be4-9d3d-cfb27042a08e"> - <name>ID</name> - <logicalName>ユーザID</logicalName> - <dataType ref="9a3ba23c-b328-4c70-a32d-3e4be3ee3f08"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="dacc68d2-fe32-4f4b-8082-9d55232ba7da"> - <name>NAME</name> - <logicalName>ユーザ名</logicalName> - <dataType ref="e2ebf8a7-90d8-48d4-9b5d-8d2e2601b193"/> - <defaultValue>no name</defaultValue> - <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> - <representation>true</representation> - </adapter> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <primaryKey id="dac295e3-c390-46ee-9a5b-e89636ab9d7e"> - <columnRefs> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e"/> - </columnRefs> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </primaryKey> - <notNull id="2f8d3fa1-40fa-4ed6-b6a0-a11df597d1ce"> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - </attributes> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </table> - <table id="5705ed1a-f329-4f21-9956-94caf4863fba"> - <name>T_DETAIL</name> - <logicalName>明細</logicalName> - <description>明細テーブルです。</description> - <attributes> - <column id="d3571020-4e1b-4158-958d-b5460fa6c32c"> - <name>ID</name> - <logicalName>ユーザID</logicalName> - <dataType ref="9a3ba23c-b328-4c70-a32d-3e4be3ee3f08"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="a28c64c6-b379-41a4-9563-b774f5bce165"> - <name>ORDER_ID</name> - <dataType> - <typeCategory>INTEGER</typeCategory> - <typeName>INTEGER</typeName> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="b4d50786-3b3e-4557-baa3-b739159f0530"> - <name>ITEM_ID</name> - <dataType> - <typeCategory>INTEGER</typeCategory> - <typeName>INTEGER</typeName> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="77bb21f4-e793-4198-a695-42363dac2216"> - <name>QUANTITY</name> - <dataType> - <typeCategory>INTEGER</typeCategory> - <typeName>INTEGER</typeName> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <primaryKey id="90243681-19af-4bc0-9e6f-f814fbc58f85"> - <columnRefs> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c"/> - </columnRefs> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </primaryKey> - <foreignKey id="df781ad0-112a-4db7-a76c-4395b15600b2"> - <columnRefs> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530"/> - </columnRefs> - <referenceColumns> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c"/> - </referenceColumns> - <onDelete>RESTRICT</onDelete> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </foreignKey> - <foreignKey id="fca97c96-db8c-44b4-8427-6207601eaa94"> - <columnRefs> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165"/> - </columnRefs> - <referenceColumns> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67"/> - </referenceColumns> - <deferrability id="1726a29c-0984-4042-b2c3-c601671892a1"> - <deferrable>false</deferrable> - </deferrability> - <onDelete>CASCADE</onDelete> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </foreignKey> - <notNull id="6d607439-186e-47ac-b391-2ad931c2e8d6"> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - <notNull id="bc929c76-7aa4-44d9-9dbf-c0684136a796"> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - <notNull id="8bb593a4-dac4-4387-8f81-c35e0c8491d7"> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - </attributes> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </table> - <table id="7ecf5ba1-e80c-472c-b19b-bef2649d7974"> - <name>T_ITEM</name> - <description>商品マスタです。</description> - <beginScript>/* test begin script */</beginScript> - <attributes> - <column id="5a9585be-4b0d-4675-99aa-97b0417c816c"> - <name>ID</name> - <logicalName>商品ID</logicalName> - <dataType ref="9a3ba23c-b328-4c70-a32d-3e4be3ee3f08"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40"> - <name>NAME</name> - <logicalName>商品名</logicalName> - <dataType> - <typeCategory>VARCHAR</typeCategory> - <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> - <size>20</size> - </adapter> - </dataType> - <adapter class="org.jiemamy.model.attribute.RepresentationAdapter"> - <representation>true</representation> - </adapter> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <column id="7a0cabe3-d382-4e5d-845b-dadd1b637a5f"> - <name>PRICE</name> - <logicalName>価格</logicalName> - <dataType> - <typeCategory>VARCHAR</typeCategory> - <typeName>VARCHAR</typeName> - <adapter class="org.jiemamy.model.datatype.adapter.SizedDataTypeAdapter"> - <size>20</size> - </adapter> - </dataType> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </column> - <primaryKey id="32b2b2f3-e668-404b-9478-56f1e680f915"> - <columnRefs> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c"/> - </columnRefs> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </primaryKey> - <notNull id="1053a2c0-8a1b-4818-89ac-ceb572daab69"> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - <notNull id="83d4ee46-0699-4b15-8af1-0ec0fbdf4ed0"> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f"/> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </notNull> - </attributes> - <adapter class="org.jiemamy.utils.DisablableImpl"> - <disabled>false</disabled> - </adapter> - </table> - </entities> - <dataSets> - <dataSet id="3064f309-d5d3-4838-9dda-74ab818f323c"> - <name>データ群en</name> - <tableRef ref="cefee0d9-d23f-441b-986a-66660354ec74"> - <record id="bf813157-8690-4eb3-9168-cd4906f13f27"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">1</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">2</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-23 00:11:22</columnRef> - </record> - <record id="645b241d-a6ba-4821-8682-448f59949b3e"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">2</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">3</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-23 00:22:33</columnRef> - </record> - <record id="654ceb1b-b6eb-406d-8eac-aa07c7c41e62"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">2</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">2</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-24 00:33:44</columnRef> - </record> - </tableRef> - <tableRef ref="0802ef7b-b2da-4fc4-8104-0c99a1e472d5"> - <record id="c60fb4ba-e3d6-415e-a22c-20fbaf4e04e6"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">1</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">SMITH</columnRef> - </record> - <record id="83d5c923-7c61-4393-8185-ac95042f6476"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">2</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">ALLEN</columnRef> - </record> - <record id="2ddd8857-3fca-4020-bb23-49d0126af6fc"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">3</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">WARD</columnRef> - </record> - <record id="2b9aeb38-97de-439e-b96b-40a1c82d249e"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">4</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">JONES</columnRef> - </record> - <record id="6242c24a-b415-4a93-867b-16a68c2fe884"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">5</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">MARTIN</columnRef> - </record> - <record id="3b9d3161-a613-4090-a095-708433b23491"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">6</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">BLAKE</columnRef> - </record> - <record id="aeaad211-b62e-4a35-b410-d107753469e9"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">7</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">CLARK</columnRef> - </record> - <record id="8c7c220d-ff7f-48c4-9ce7-1395ed1816fa"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">8</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">SCOTT</columnRef> - </record> - </tableRef> - <tableRef ref="5705ed1a-f329-4f21-9956-94caf4863fba"> - <record id="546244f5-afa2-4e7e-bde0-5a811ced77af"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">1</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">1</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">1</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">1</columnRef> - </record> - <record id="943fda94-a3f2-4c47-b19f-9e8655b47362"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">2</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">1</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">4</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">3</columnRef> - </record> - <record id="d11db81a-2d53-42b4-9f10-17f98f1f7081"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">3</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">2</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">2</columnRef> - </record> - <record id="0aa0dd6f-5656-4994-abfe-05f05aec7275"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">4</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">3</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">6</columnRef> - </record> - <record id="4b9be90a-886f-47d8-89f0-da03d7ad419e"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">5</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">4</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">12</columnRef> - </record> - <record id="23665133-7f4e-4f65-af7c-0de1b655f7c9"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">5</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">3</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">2</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">1</columnRef> - </record> - </tableRef> - <tableRef ref="7ecf5ba1-e80c-472c-b19b-bef2649d7974"> - <record id="7162b83a-1815-4b08-8c11-8e6400c05a9e"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">1</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">DIAMOND</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">100000</columnRef> - </record> - <record id="a3d6480d-9088-49d8-a500-872262a635d5"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">2</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">EMERALD</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">75000</columnRef> - </record> - <record id="bf4556ff-fb81-472c-945d-14067945e7c2"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">3</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">RUBY</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">30000</columnRef> - </record> - <record id="fc30dd3e-495d-4f7c-9237-dd9f84c14eb5"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">4</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">SAPPHIRE</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">10000</columnRef> - </record> - </tableRef> - </dataSet> - <dataSet id="fa14d60b-06f1-490b-9fe0-2621277d7bff"> - <name>データ群ja</name> - <tableRef ref="cefee0d9-d23f-441b-986a-66660354ec74"> - <record id="2bdf3969-c2e5-4e3e-a939-2907ca3a5b6a"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">1</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">2</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-23 00:11:22</columnRef> - </record> - <record id="cca67c6f-a3b2-4b43-a466-be72ccd66e8f"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">2</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">3</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-23 00:22:33</columnRef> - </record> - <record id="1f74ab8a-3191-464b-89c3-f4f3dddb8ce8"> - <columnRef ref="b647212a-4d8f-4d18-88e4-5397e54ebe67">2</columnRef> - <columnRef ref="db7a2f62-9658-406a-9dc1-8b90ae2da47c">2</columnRef> - <columnRef ref="4ce761b0-137b-4105-ad2a-2efcba5e6bc4">2009-01-24 00:33:44</columnRef> - </record> - </tableRef> - <tableRef ref="0802ef7b-b2da-4fc4-8104-0c99a1e472d5"> - <record id="25288a67-b4c7-4296-8113-835afeb15c9d"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">1</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">鈴木 茂</columnRef> - </record> - <record id="20a62610-ad04-479f-85c6-a1340e26adb5"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">2</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">内海 透</columnRef> - </record> - <record id="d8fa5455-9791-46fc-9695-da7a5167f7ea"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">3</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">村瀬 武彦</columnRef> - </record> - <record id="3cc66837-d604-4af8-af01-343924e9f058"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">4</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">近藤 美樹</columnRef> - </record> - <record id="2f09b9fe-78fd-4f8a-abf2-f077040f45f2"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">5</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">榊 美子</columnRef> - </record> - <record id="e3431be3-462c-4419-a2a0-e821597490cc"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">6</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">三浦 佑</columnRef> - </record> - <record id="c50a3e24-dd00-4969-aae9-69cf9be7f035"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">7</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">前島 孝幸</columnRef> - </record> - <record id="890bf55f-8bfd-420c-a9df-801da73bc46d"> - <columnRef ref="6b022a79-45a6-4be4-9d3d-cfb27042a08e">8</columnRef> - <columnRef ref="dacc68d2-fe32-4f4b-8082-9d55232ba7da">島崎 由比</columnRef> - </record> - </tableRef> - <tableRef ref="5705ed1a-f329-4f21-9956-94caf4863fba"> - <record id="5a6604ce-6ed2-4542-b009-2a3264b0946a"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">1</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">1</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">1</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">1</columnRef> - </record> - <record id="db883c9c-b7d3-44f4-88ba-d9753eeae58a"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">2</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">1</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">4</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">3</columnRef> - </record> - <record id="04e92727-483c-42ad-b671-c1e4661c1844"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">3</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">2</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">2</columnRef> - </record> - <record id="f5147476-8bc6-4656-9d0c-fd883a24a18c"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">4</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">3</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">6</columnRef> - </record> - <record id="d849f188-9940-4ecc-98a8-868dac5b3b4e"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">5</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">2</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">4</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">12</columnRef> - </record> - <record id="2abef8cc-bfb7-4565-ba4e-afca3bf98811"> - <columnRef ref="d3571020-4e1b-4158-958d-b5460fa6c32c">5</columnRef> - <columnRef ref="a28c64c6-b379-41a4-9563-b774f5bce165">3</columnRef> - <columnRef ref="b4d50786-3b3e-4557-baa3-b739159f0530">2</columnRef> - <columnRef ref="77bb21f4-e793-4198-a695-42363dac2216">1</columnRef> - </record> - </tableRef> - <tableRef ref="7ecf5ba1-e80c-472c-b19b-bef2649d7974"> - <record id="5fd803d4-5a05-496b-813e-6399955a79bb"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">1</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">ダイヤモンド</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">100000</columnRef> - </record> - <record id="d59e426b-e5ed-433e-8d5a-e748dc75af60"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">2</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">エメラルド</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">75000</columnRef> - </record> - <record id="59e0a554-162a-4c48-b13d-1dda7fc936e0"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">3</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">ルビー</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">30000</columnRef> - </record> - <record id="1c86858f-1e8b-4fc5-807f-f0548e1811e4"> - <columnRef ref="5a9585be-4b0d-4675-99aa-97b0417c816c">4</columnRef> - <columnRef ref="5c9b38e1-2cc9-45f9-ad3f-20b02471cc40">サファイヤ</columnRef> - <columnRef ref="7a0cabe3-d382-4e5d-845b-dadd1b637a5f">10000</columnRef> - </record> - </tableRef> - </dataSet> - </dataSets> -</rootModel> Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/DiagramPresentationModel.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/DiagramPresentationModel.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/DiagramPresentationModel.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -20,7 +20,6 @@ import java.util.List; import java.util.Map; -import java.util.Set; import org.jiemamy.model.connection.ConnectionAdapter; import org.jiemamy.model.geometory.JmPoint; @@ -39,18 +38,24 @@ Map<ConnectionAdapter, List<JmPoint>> getConnectionLayouts(); /** - * 表示モードを取得する。 - * @return 表示モード - */ - Set<DisplayItem> getDisplayTargetSet(); - - /** * ノードのレイアウト情報を取得する。 * @return ノードのレイアウト情報 */ Map<NodeAdapter, NodeProfile> getFigureProfiles(); /** + * 表示レベルを取得する。 + * @return 表示レベル + */ + Level getLevel(); + + /** + * 物理/論理モードを取得する。 + * @return 物理/論理モード + */ + Mode getMode(); + + /** * プレゼンテーション名を取得する。 * @return プレゼンテーション名 */ @@ -82,32 +87,21 @@ void setBendpoints(ConnectionAdapter connection, List<JmPoint> bendpoints); /** + * 表示レベルを取得する。 + * @param level 表示レベル + */ + void setLevel(Level level); + + /** + * 物理/論理モードを取得する。 + * @param mode 物理/論理モード + */ + void setMode(Mode mode); + + /** * プレゼンテーション名を設定する。 * @param name プレゼンテーション名 */ void setName(String name); - - /** - * 表示対象の要素。 - * この型の組み合わせ(Set)で表示内容が決定する。 - * @author daisuke - */ - public static enum DisplayItem { - - /** 物理名を表示することを示す。 */ - PHYSICAL, - - /** 論理名を表示することを示す。 */ - LOGICAL, - - /** 主キーカラム名を表示することを示す。 */ - PRIMARY_KEY, - - /** 主キー以外のカラム名を表示することを示す。 */ - NON_KEY, - - /** カラム型を表示することを示す。 */ - TYPE - } } Added: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Level.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Level.java (rev 0) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Level.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -0,0 +1,38 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/20 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.model; + +/** + * 表示レベルを表す列挙型。 + * + * @author daisuke + */ +public enum Level { + /** エンティティレベル */ + ENTITY, + + /** 識別子レベル */ + KEY, + + /** 属性レベル */ + ATTR, + + /** 属性+型レベル */ + ATTRTYPE +} Property changes on: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Level.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Mode.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Mode.java (rev 0) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Mode.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -0,0 +1,35 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/20 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.model; + +/** + * 物理/論理モード表示をあらわす列挙型。 + * + * @author daisuke + */ +public enum Mode { + + /** 物理モデルモード */ + PHYSICAL, + + /** 論理モデルモード */ + LOGICAL, + +// BOTH +} Property changes on: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/Mode.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java 2009-02-19 15:39:29 UTC (rev 2693) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/xml/ViewQName.java 2009-02-20 09:58:49 UTC (rev 2694) @@ -64,7 +64,13 @@ BENDPOINTS(CoreNamespace.NS_VIEW, "bendpoints"), /***/ - BENDPOINT(CoreNamespace.NS_VIEW, "bendpoint"); + BENDPOINT(CoreNamespace.NS_VIEW, "bendpoint"), + + /***/ + MODE(CoreNamespace.NS_VIEW, "mode"), + + /***/ + LEVEL(CoreNamespace.NS_VIEW, "level"); /** XML仕様における完全修飾名 */ private final QName qName;