svnno****@sourc*****
svnno****@sourc*****
2009年 2月 26日 (木) 18:17:10 JST
Revision: 2742 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2742 Author: daisuke_m Date: 2009-02-26 18:17:10 +0900 (Thu, 26 Feb 2009) Log Message: ----------- 仕様インターフェイスの整理。 / 編集Commandのリファクタリング。 / ModifyModelPropertyCommandにJiemamyPropertyを適用。 / javadoc / その他refactor Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultHtmlExportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.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/AbstractDialect.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractAdaptable.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/ColumnRefImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainRefImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.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/Literal.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ReflectionUtil.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyProperty.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ExportException.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ImportException.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.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/AttributeModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/Adaptable.java zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/connection/ConnectionAdapter.java zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/node/NodeAdapter.java Added Paths: ----------- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/JiemamyPropertyUtil.java vesta/trunk/org.jiemamy.eclipse/src/main/resources/logback.xml zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/AdapterNotFoundException.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; -import java.util.Stack; import org.junit.After; import org.junit.Before; @@ -98,13 +97,12 @@ public void test01_AdaptされたDiaglramPresentationModelに対する変更が通知される() throws Exception { RootModel rootModel = factory.getRootModel(); - Stack<Command> commandStack = new Stack<Command>(); TableModel table = factory.newModel(TableModel.class); - new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, table).execute(commandProcessor); ColumnModel column1 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column1).execute(commandProcessor, commandStack); + new AddColumnCommand(table, column1).execute(commandProcessor); ColumnModel column2 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column2).execute(commandProcessor, commandStack); + new AddColumnCommand(table, column2).execute(commandProcessor); DiagramPresentationModel presentation = factory.newModel(DiagramPresentationModel.class); presentation.setName("testPresentation"); @@ -115,7 +113,7 @@ eventBroker.addListener(rootModelListener); // DiagramPresentationModelを変更する。 - new ModifyModelPropertyCommand(presentation, "name", "newName").execute(commandProcessor, commandStack); + new ModifyModelPropertyCommand(presentation, "name", "newName").execute(commandProcessor); assertThat(rootModelListener.commandList.size(), is(1)); } Added: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java (rev 0) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,61 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.composer.exporter; + +import java.io.File; + +/** + * {@link HtmlExporter}に関する設定情報保持クラス。 + * + * @author daisuke + */ +public abstract class AbstractFileExportConfig implements FileExportConfig { + + private File outputFile; + + private boolean overwrite; + + + public File getOutputFile() { + return outputFile; + } + + public boolean isOverwrite() { + return overwrite; + } + + /** + * TODO for daisuke + * + * @param outputDir + */ + public void setOutputFile(File outputDir) { + outputFile = outputDir; + } + + /** + * TODO for daisuke + * + * @param overwrite + */ + public void setOverwrite(boolean overwrite) { + this.overwrite = overwrite; + } + +} Property changes on: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/AbstractFileExportConfig.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultHtmlExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultHtmlExportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultHtmlExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,44 +18,12 @@ */ package org.jiemamy.composer.exporter; -import java.io.File; /** * {@link HtmlExporter}に関する設定情報保持クラス。 * * @author daisuke */ -public class DefaultHtmlExportConfig implements HtmlExportConfig { +public class DefaultHtmlExportConfig extends AbstractFileExportConfig implements HtmlExportConfig { - private File outputDir; - - private boolean overwrite; - - - public File getOutputDir() { - return outputDir; - } - - public boolean isOverwirte() { - return overwrite; - } - - /** - * TODO for daisuke - * - * @param outputDir - */ - public void setOutputDir(File outputDir) { - this.outputDir = outputDir; - } - - /** - * TODO for daisuke - * - * @param overwrite - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - } Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,44 +18,12 @@ */ package org.jiemamy.composer.exporter; -import java.io.File; /** * {@link SqlExporter}に関する設定情報保持クラス。 * * @author daisuke */ -public class DefaultSqlExportConfig implements SqlExportConfig { +public class DefaultSqlExportConfig extends AbstractFileExportConfig implements SqlExportConfig { - private File outputFile; - - private boolean overwrite; - - - public File getOutputFile() { - return outputFile; - } - - public boolean isOverwrite() { - return overwrite; - } - - /** - * TODO for daisuke - * - * @param outputFile - */ - public void setOutputFile(File outputFile) { - this.outputFile = outputFile; - } - - /** - * TODO for daisuke - * - * @param overwrite - */ - public void setOverwrite(boolean overwrite) { - this.overwrite = overwrite; - } - } Added: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java (rev 0) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,47 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.composer.exporter; + +import java.io.File; + +import org.jiemamy.composer.ExportConfig; +import org.jiemamy.composer.Exporter; + +/** + * ファイルに対する{@link Exporter}に関する設定情報インターフェイス。 + * + * @author daisuke + */ +public interface FileExportConfig extends ExportConfig { + + /** + * 出力ファイルを取得する。 + * + * @return 出力ファイル + */ + File getOutputFile(); + + /** + * 出力ファイルが既に存在した場合、上書きするかどうか調べる。 + * + * @return 上書きする場合は{@code true} + */ + boolean isOverwrite(); + +} Property changes on: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/FileExportConfig.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,29 +18,12 @@ */ package org.jiemamy.composer.exporter; -import java.io.File; -import org.jiemamy.composer.ExportConfig; - /** * {@link HtmlExporter}に関する設定情報インターフェイス。 * * @author daisuke */ -public interface HtmlExportConfig extends ExportConfig { +public interface HtmlExportConfig extends FileExportConfig { - /** - * TODO for daisuke - * - * @return - */ - File getOutputDir(); - - /** - * TODO for daisuke - * - * @return - */ - boolean isOverwirte(); - } Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/HtmlExporter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -44,11 +44,11 @@ public boolean exportModel(RootModel rootModel, HtmlExportConfig ctx) throws ExportException { Validate.notNull(rootModel); Validate.notNull(ctx); - Validate.notNull(ctx.getOutputDir()); + Validate.notNull(ctx.getOutputFile()); - File outputDir = ctx.getOutputDir(); + File outputDir = ctx.getOutputFile(); if (outputDir.exists()) { - if (ctx.isOverwirte() == false) { + if (ctx.isOverwrite() == false) { return false; } Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/exporter/SqlExportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,29 +18,12 @@ */ package org.jiemamy.composer.exporter; -import java.io.File; -import org.jiemamy.composer.ExportConfig; - /** * {@link SqlExporter}に関する設定情報インターフェイス。 * * @author daisuke */ -public interface SqlExportConfig extends ExportConfig { +public interface SqlExportConfig extends FileExportConfig { - /** - * TODO for daisuke - * - * @return - */ - File getOutputFile(); - - /** - * TODO for daisuke - * - * @return - */ - boolean isOverwrite(); - } Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -35,6 +35,13 @@ * * @return */ + String getDatabaseName(); + + /** + * TODO for daisuke + * + * @return + */ Dialect getDialect(); /** @@ -70,6 +77,13 @@ * * @return */ + String getSchema(); + + /** + * TODO for daisuke + * + * @return + */ String[] getSelectedEntities(); /** Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -103,10 +103,9 @@ Validate.notNull(rootModel); Validate.notNull(ctx); - dialect = ctx.getDialect(); - Connection connection = null; try { + dialect = ctx.getDialect(); if (dialect instanceof GenericDialect) { throw new GenericModelingModeException(); } @@ -131,11 +130,7 @@ reader.readEnities(new EntityImportVisitor(meta, rootModel, ctx)); reader.readRelations(new RelationImportVisitor(meta, rootModel, ctx)); dialect.getAdvisor().tearDownRead(connection); - } catch (RuntimeException e) { - // ランタイムは再スロー - throw e; } catch (Exception e) { - //その他はラップしてスロー throw new ImportException(e); } finally { JmIOUtil.closeQuietly(connection); Modified: artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java =================================================================== --- artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-composer/src/main/java/org/jiemamy/composer/importer/DefaultDatabaseImportConfig.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -29,77 +29,57 @@ */ public class DefaultDatabaseImportConfig implements DatabaseImportConfig { + /** SQL方言 */ private Dialect dialect; + /** ドライバの完全就職クラス名 */ private String driverClassName; + /** ドライバJARファイルのパス配列 */ private URL[] driverJarPath; + /** インポートするエンティティの種類 */ private String[] entityTypes; + /** 接続パスワード */ private String password; + /** インポートするエンティティ名の配列 */ private String[] selectedEntities; + /** 接続URI */ private String uri; + /** 接続ユーザ名 */ private String username; + /** データベース名 */ private String databaseName; + /** スキーマ名 */ private String schema; - /** - * TODO for daisuke - * - * @return - */ public String getDatabaseName() { return databaseName; } - /** - * TODO for daisuke - * - * @return - */ public Dialect getDialect() { return dialect; } - /** - * TODO for daisuke - * - * @return - */ public String getDriverClassName() { return driverClassName; } - /** - * TODO for daisuke - * - * @return - */ public URL[] getDriverJarPath() { return driverJarPath; } - /** - * TODO for daisuke - * - * @return - */ public String[] getEntityTypes() { return entityTypes; } - /** - * TODO for daisuke - * - * @return - */ public String getPassword() { return password; } @@ -108,29 +88,14 @@ return schema; } - /** - * TODO for daisuke - * - * @return - */ public String[] getSelectedEntities() { return selectedEntities; } - /** - * TODO for daisuke - * - * @return - */ public String getUri() { return uri; } - /** - * TODO for daisuke - * - * @return - */ public String getUsername() { return username; } 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/FactoryExtension.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -28,6 +28,7 @@ import java.util.TreeSet; import java.util.UUID; +import org.jiemamy.dialect.generic.GenericDialect; import org.jiemamy.model.ElementReference; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; @@ -204,6 +205,7 @@ rootModel.setDomains(new ArrayList<DomainModel>()); rootModel.setEntities(new TreeSet<EntityModel>(JiemamyElementComparator.INSTANCE)); rootModel.setDataSets(new ArrayList<DataSetModel>()); + rootModel.setDialectClassName(GenericDialect.class.getName()); return (T) rootModel; } }, 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -133,22 +133,23 @@ } } } else if (fieldValue instanceof ElementReference) { + ElementReference<?> elementReferenceValue = (ElementReference<?>) fieldValue; // ElementReferenceだった場合は一階層だけ調査する。 - if (uuid.equals(((ElementReference<JiemamyElement>) fieldValue).getReferenceId())) { + if (uuid.equals(elementReferenceValue.getReferenceId())) { return true; } } else if (fieldValue instanceof Iterable) { + Iterable<?> iterable = (Iterable<?>) fieldValue; // Iterableだった場合は要素に対して再起して調査する。 - Iterable<? extends Object> iterable = (Iterable<? extends Object>) fieldValue; for (Object element : iterable) { if (isDescendFromFieldValue(element, uuid)) { return true; } } } else if (fieldValue instanceof Map) { + Map<?, ?> map = (Map<?, ?>) fieldValue; // Mapだった場合は要素に対して再起して調査する。 - Map<?, ? extends Object> collection = (Map<?, ? extends Object>) fieldValue; - for (Object element : collection.values()) { + for (Object element : map.values()) { if (isDescendFromFieldValue(element, uuid)) { return true; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -25,6 +25,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.Validate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -103,6 +104,8 @@ } public BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName) { + Validate.notNull(category); + Validate.notNull(typeName); for (BuiltinDataTypeMold mold : allDataTypes) { if (mold.getCategory() == category && mold.getTypeName().equals(typeName)) { return mold; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultDataTypeResolver.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -68,7 +68,7 @@ Integer size = builtinDataType.getAdapter(SizedDataTypeAdapter.class).getSize(); if (size != null) { tokens.add(Separator.LEFT_PAREN); - tokens.add(new Literal(size)); + tokens.add(Literal.of(size)); tokens.add(Separator.RIGHT_PAREN); } } @@ -80,10 +80,10 @@ Integer scale = adapter.getScale(); if (prec != null) { tokens.add(Separator.LEFT_PAREN); - tokens.add(new Literal(prec)); + tokens.add(Literal.of(prec)); if (scale != null) { tokens.add(Separator.COMMA); - tokens.add(new Literal(scale)); + tokens.add(Literal.of(scale)); } tokens.add(Separator.RIGHT_PAREN); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/DefaultSqlEmitter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -80,7 +80,7 @@ // THINK RootBeginScript と CreateSchemaStatement、どっちが先? if (StringUtils.isEmpty(rootModel.getBeginScript()) == false) { - result.add(new SqlStatementImpl(new Literal(rootModel.getBeginScript(), LiteralType.FRAGMENT))); + result.add(new SqlStatementImpl(Literal.of(rootModel.getBeginScript(), LiteralType.FRAGMENT))); } if (StringUtils.isEmpty(rootModel.getSchemaName()) == false) { @@ -89,18 +89,18 @@ for (EntityModel entity : EntityDependencyCalculator.getSortedEntityList(rootModel)) { if (StringUtils.isEmpty(entity.getBeginScript()) == false) { - result.add(new SqlStatementImpl(new Literal(entity.getBeginScript(), LiteralType.FRAGMENT))); + result.add(new SqlStatementImpl(Literal.of(entity.getBeginScript(), LiteralType.FRAGMENT))); } result.add(emitDdl(entity, config)); if (StringUtils.isEmpty(entity.getEndScript()) == false) { - result.add(new SqlStatementImpl(new Literal(entity.getEndScript(), LiteralType.FRAGMENT))); + result.add(new SqlStatementImpl(Literal.of(entity.getEndScript(), LiteralType.FRAGMENT))); } } if (StringUtils.isEmpty(rootModel.getEndScript()) == false) { - result.add(new SqlStatementImpl(new Literal(rootModel.getEndScript(), LiteralType.FRAGMENT))); + result.add(new SqlStatementImpl(Literal.of(rootModel.getEndScript(), LiteralType.FRAGMENT))); } return result; @@ -127,7 +127,7 @@ List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); tokens.add(Keyword.SCHEMA); - tokens.add(new Identifier(schemaName)); + tokens.add(Identifier.of(schemaName)); tokens.add(Separator.SEMICOLON); return new SqlStatementImpl(tokens); } @@ -149,22 +149,22 @@ ReferenceResolver referenceResolver = attributeModel.getJiemamy().getReferenceResolver(); ColumnModel columnModel = (ColumnModel) attributeModel; List<Token> tokens = CollectionsUtil.newArrayList(); - tokens.add(new Identifier(columnModel.getName())); + tokens.add(Identifier.of(columnModel.getName())); tokens.addAll(dataTypeResolver.resolveDataType(columnModel.getDataType(), referenceResolver)); if (StringUtils.isEmpty(columnModel.getDefaultValue()) == false) { BuiltinDataType builtinDataType = DataTypeUtil.toBuiltinDataType(columnModel.getDataType(), referenceResolver); tokens.add(Keyword.DEFAULT); - tokens.add(new Literal(columnModel.getDefaultValue(), builtinDataType.getCategory() - .getLiteralType())); + tokens.add(Literal + .of(columnModel.getDefaultValue(), builtinDataType.getCategory().getLiteralType())); } NotNullConstraintModel nnModel = columnModel.getNotNull(); if (nnModel != null) { if (StringUtils.isEmpty(nnModel.getName()) == false) { tokens.add(Keyword.CONSTRAINT); - tokens.add(new Identifier(nnModel.getName())); + tokens.add(Identifier.of(nnModel.getName())); } tokens.add(Keyword.NOT); tokens.add(Keyword.NULL); @@ -174,7 +174,7 @@ if (ukModel != null) { if (StringUtils.isEmpty(ukModel.getName()) == false) { tokens.add(Keyword.CONSTRAINT); - tokens.add(new Identifier(ukModel.getName())); + tokens.add(Identifier.of(ukModel.getName())); } tokens.add(Keyword.UNIQUE); } @@ -183,7 +183,7 @@ if (pkModel != null) { if (StringUtils.isEmpty(pkModel.getName()) == false) { tokens.add(Keyword.CONSTRAINT); - tokens.add(new Identifier(pkModel.getName())); + tokens.add(Identifier.of(pkModel.getName())); } tokens.add(Keyword.PRIMARY); tokens.add(Keyword.KEY); @@ -193,10 +193,10 @@ if (checkModel != null) { if (StringUtils.isEmpty(checkModel.getName()) == false) { tokens.add(Keyword.CONSTRAINT); - tokens.add(new Identifier(checkModel.getName())); + tokens.add(Identifier.of(checkModel.getName())); } tokens.add(Keyword.CHECK); - tokens.add(new Literal(checkModel.getExpression(), LiteralType.FRAGMENT)); + tokens.add(Literal.of(checkModel.getExpression(), LiteralType.FRAGMENT)); } return tokens; @@ -253,7 +253,7 @@ addColumnList(tokens, fkModel.getKeyColumns(), referenceResolver); tokens.add(Keyword.REFERENCES); EntityModel referenceEntity = ForeignKeyUtil.getReferenceEntity(fkModel); - tokens.add(new Identifier(referenceEntity.getName())); + tokens.add(Identifier.of(referenceEntity.getName())); addColumnList(tokens, fkModel.getReferenceColumns(), referenceResolver); if (fkModel.getMatchType() != null) { @@ -294,7 +294,7 @@ addConstraintNameDefinition(checkModel, tokens); tokens.add(Keyword.CHECK); tokens.add(Separator.LEFT_PAREN); - tokens.add(new Literal(checkModel.getExpression(), LiteralType.FRAGMENT)); + tokens.add(Literal.of(checkModel.getExpression(), LiteralType.FRAGMENT)); tokens.add(Separator.RIGHT_PAREN); return tokens; } @@ -325,7 +325,7 @@ tokens.add(Separator.LEFT_PAREN); for (ColumnRef columnRef : columnRefs) { ColumnModel columnModel = referenceResolver.resolve(columnRef); - tokens.add(new Identifier(columnModel.getName())); + tokens.add(Identifier.of(columnModel.getName())); tokens.add(Separator.COMMA); } tokens.remove(tokens.size() - 1); @@ -335,7 +335,7 @@ private static void addConstraintNameDefinition(ConstraintModel constraint, List<Token> tokens) { if (StringUtils.isEmpty(constraint.getName()) == false) { tokens.add(Keyword.CONSTRAINT); - tokens.add(new Identifier(constraint.getName())); + tokens.add(Identifier.of(constraint.getName())); } } @@ -376,7 +376,7 @@ List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); tokens.add(Keyword.TABLE); - tokens.add(new Identifier(tableModel.getName())); + tokens.add(Identifier.of(tableModel.getName())); tokens.add(Separator.LEFT_PAREN); for (AttributeModel attributeModel : tableModel.getAttributes()) { AttributeEmitStrategy strategy = AttributeEmitStrategy.fromAttribute(attributeModel); @@ -400,9 +400,9 @@ List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); tokens.add(Keyword.VIEW); - tokens.add(new Identifier(viewModel.getName())); + tokens.add(Identifier.of(viewModel.getName())); tokens.add(Keyword.AS); - tokens.add(new Literal(viewModel.getDefinition(), LiteralType.FRAGMENT)); + tokens.add(Literal.of(viewModel.getDefinition(), LiteralType.FRAGMENT)); tokens.add(Separator.SEMICOLON); return new SqlStatementImpl(tokens); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -22,6 +22,7 @@ import java.lang.reflect.Method; import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.lang.Validate; import org.jiemamy.EventBroker; import org.jiemamy.EventBrokerImpl; @@ -66,16 +67,22 @@ */ public class CommandProcessorImpl implements CommandProcessor { - /** サブクラスからも見える必要がある。 */ + /** + * ブローカ + * + * サブクラスからも見える必要がある。 + */ protected final EventBroker eventBroker; /** * インスタンスを生成する。 * - * @param eventBroker + * @param eventBroker ブローカ + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ public CommandProcessorImpl(EventBroker eventBroker) { + Validate.notNull(eventBroker); this.eventBroker = eventBroker; } @@ -100,12 +107,8 @@ */ public void process(AddColumnToColumnRefListCommand command) { int index = command.getIndex(); - if (index != -1) { - command.getColumnRefList().add(index, new ColumnRefImpl(command.getColumn())); - } else { - command.setIndex(command.getColumnRefList().size()); - command.getColumnRefList().add(new ColumnRefImpl(command.getColumn())); - } + command.getColumnRefList().add(index, new ColumnRefImpl(command.getColumn())); + // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 eventBroker.fireCommandProcessed(command); } @@ -143,7 +146,7 @@ * @param newForeignKeyCommand */ public void process(AddForeignKeyCommand newForeignKeyCommand) { - ForeignKeyModel fk = newForeignKeyCommand.getFk(); + ForeignKeyModel fk = newForeignKeyCommand.getForeignKey(); TableModel table = newForeignKeyCommand.getTable(); table.getAttributes().add(fk); @@ -166,7 +169,7 @@ } public void process(Command command) { - // 実行時に無理矢理ディスパッチする…。 + // HACK 実行時に無理矢理ディスパッチする…。 Method method; try { method = getClass().getMethod("process", command.getClass()); @@ -206,6 +209,7 @@ public void process(DeleteColumnFromColumnRefListCommand command) { int index = command.getIndex(); command.getColumnRefList().remove(index); + // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 eventBroker.fireCommandProcessed(command); } @@ -243,7 +247,7 @@ * @param deleteForeignKeyCommand */ public void process(DeleteForeignKeyCommand deleteForeignKeyCommand) { - ForeignKeyModel fk = deleteForeignKeyCommand.getFk(); + ForeignKeyModel fk = deleteForeignKeyCommand.getForeignKey(); TableModel table = deleteForeignKeyCommand.getTable(); table.getAttributes().remove(fk); @@ -272,12 +276,16 @@ */ public void process(ModifyModelPropertyCommand command) { JiemamyElement target = command.getTarget(); + String propertyName = command.getProperty().name(); + if (propertyName == null) { + propertyName = command.getPropertyName(); + } try { - BeanUtils.setProperty(target, command.getPropertyName(), command.getNewValue()); + BeanUtils.setProperty(target, propertyName, command.getNewValue()); } catch (IllegalAccessException e) { - throw new RuntimeException(e); + throw new JiemamyRuntimeException(e); } catch (InvocationTargetException e) { - throw new RuntimeException(e); + throw new JiemamyRuntimeException(e); } // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -19,74 +19,65 @@ package org.jiemamy.editcommand.impl; import java.util.Collection; -import java.util.Stack; -import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; /** * {@link RootModel}に{@link JiemamyElement}を追加するコマンドの抽象クラス。 * - * @param <T> - * @author shin1ogawa + * @param <T> 追加対象の要素の型 * @see AbstractDeleteFromRootCommand + * @author shin1ogawa */ -public abstract class AbstractAddToRootCommand<T extends JiemamyElement> extends AbstractCommand implements Command { +public abstract class AbstractAddToRootCommand<T extends JiemamyElement> extends AbstractCommand { + /** 追加対象の要素 */ private final T element; - /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ - private final RootModel root; + /** + * 対象{@link RootModel} + * + * イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 + */ + private final RootModel rootModel; /** * インスタンスを生成する。 * - * @param root - * @param element + * @param rootModel 対象{@link RootModel} + * @param element 追加する要素 */ - public AbstractAddToRootCommand(RootModel root, T element) { - super(); - this.root = root; + public AbstractAddToRootCommand(RootModel rootModel, T element) { + this.rootModel = rootModel; this.element = element; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = createDeleteFromRootCommand(root, element); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** - * return the element. + * 追加対象の要素を取得する。 * - * @return the element + * @return 追加対象の要素 */ public T getElement() { return element; } /** - * retuen the root. + * 対象{@link RootModel}を取得する。 * - * @return the root + * @return 対象{@link RootModel} */ - public RootModel getRoot() { - return root; + public RootModel getRootModel() { + return rootModel; } public JiemamyElement getTarget() { - return getRoot(); + return rootModel; } /** * @return {@link RootModel}が保持する、{@link JiemamyElement}のリスト */ public abstract Collection<? super T> getTargetList(); - - abstract AbstractDeleteFromRootCommand<T> createDeleteFromRootCommand(RootModel root, T element); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -19,6 +19,7 @@ package org.jiemamy.editcommand.impl; import org.jiemamy.editcommand.Command; +import org.jiemamy.editcommand.CommandProcessor; /** * {@link Command}を実装するための抽象クラス。 @@ -27,4 +28,8 @@ */ public abstract class AbstractCommand implements Command { + public void execute(CommandProcessor commandProcessor) { + commandProcessor.process(this); + } + } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -19,74 +19,65 @@ package org.jiemamy.editcommand.impl; import java.util.Collection; -import java.util.Stack; -import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; /** * {@link RootModel}から{@link JiemamyElement}を削除するコマンドの抽象クラス。 * - * @param <T> - * @author shin1ogawa + * @param <T> 削除対象の要素 * @see AbstractAddToRootCommand + * @author shin1ogawa */ -public abstract class AbstractDeleteFromRootCommand<T extends JiemamyElement> extends AbstractCommand implements - Command { +public abstract class AbstractDeleteFromRootCommand<T extends JiemamyElement> extends AbstractCommand { + /** 削除対象の要素 */ private final T element; - /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ - private final RootModel root; + /** + * 対象{@link RootModel} + * + * イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 + */ + private final RootModel rootModel; /** * インスタンスを生成する。 - * @param root - * @param element + * + * @param rootModel 対象{@link RootModel} + * @param element 削除対象の要素 */ - public AbstractDeleteFromRootCommand(RootModel root, T element) { - super(); - this.root = root; + public AbstractDeleteFromRootCommand(RootModel rootModel, T element) { + this.rootModel = rootModel; this.element = element; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = createAddToRootCommand(root, element); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** - * return the element. + * 削除対象の要素を取得する。 * - * @return the element + * @return 削除対象の要素 */ public T getElement() { return element; } /** - * retuen the root. + * 対象{@link RootModel}を取得する。 * - * @return the root + * @return 対象{@link RootModel} */ - public RootModel getRoot() { - return root; + public RootModel getRootModel() { + return rootModel; } public JiemamyElement getTarget() { - return getRoot(); + return rootModel; } /** * @return {@link RootModel}が保持する、{@link JiemamyElement}のリスト */ public abstract Collection<? super T> getTargetList(); - - abstract AbstractAddToRootCommand<T> createAddToRootCommand(RootModel root, T element); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.entity.TableModel; @@ -31,43 +28,42 @@ * * @author daisuke */ -public class AddColumnCommand extends AbstractCommand implements Command { +public class AddColumnCommand extends AbstractCommand { + /** 追加されるテーブル */ private final TableModel table; + /** 追加するカラム */ private final ColumnModel column; /** * インスタンスを生成する。 * - * @param table - * @param column + * @param table 追加されるテーブル + * @param column 追加するカラム */ public AddColumnCommand(TableModel table, ColumnModel column) { this.table = table; this.column = column; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new DeleteColumnCommand(table, column); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** - * column + * 追加するカラムを取得する。 * - * @return column + * @return 追加するカラム */ public ColumnModel getColumn() { return column; } + public Command getNegateCommand() { + return new DeleteColumnCommand(table, column); + } + /** - * @return {@link TableModel} + * 追加されるテーブルを取得する。 + * @return 追加されるテーブル */ public TableModel getTable() { return table; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -19,10 +19,8 @@ package org.jiemamy.editcommand.impl; import java.util.List; -import java.util.Stack; import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.ColumnRef; @@ -32,37 +30,38 @@ * * @author shin1ogawa */ -public class AddColumnToColumnRefListCommand extends AbstractCommand implements Command { +public class AddColumnToColumnRefListCommand extends AbstractCommand { private final JiemamyElement target; + /** 追加対象のリスト */ private final List<ColumnRef> columnRefList; + /** 追加されるカラム */ private final ColumnModel column; - private int index = -1; + /** 追加位置インデックス */ + private final int index; /** * インスタンスを生成する。 * * @param target - * @param columnRefList - * @param column + * @param columnRefList 追加対象のリスト + * @param column 追加されるカラム */ public AddColumnToColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList, ColumnModel column) { - this.target = target; - this.columnRefList = columnRefList; - this.column = column; + this(target, columnRefList, column, columnRefList.size()); } /** * インスタンスを生成する。 * * @param target - * @param columnRefList - * @param column - * @param index + * @param columnRefList 追加対象のリスト + * @param column 追加されるカラム + * @param index 追加位置インデックス */ public AddColumnToColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList, ColumnModel column, int index) { @@ -72,56 +71,38 @@ this.index = index; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new DeleteColumnFromColumnRefListCommand(target, columnRefList, column, index); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** - * column + * 追加されるカラムを取得する。 * - * @return column + * @return 追加されるカラム */ public ColumnModel getColumn() { return column; } /** - * columnRefList + * 追加対象のリストを取得する。 * - * @return columnRefList + * @return 追加対象のリスト */ public List<ColumnRef> getColumnRefList() { return columnRefList; } /** - * index + * 追加位置インデックスを取得する。 * - * @return index + * @return 追加位置インデックス */ public int getIndex() { return index; } - /** - * target - * - * @return target - */ + public Command getNegateCommand() { + return new DeleteColumnFromColumnRefListCommand(target, columnRefList, column, index); + } + public JiemamyElement getTarget() { return target; } - - /** - * index - * @param index index - */ - public void setIndex(int index) { - this.index = index; - } - } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.RootModel; import org.jiemamy.model.dataset.DataSetModel; @@ -34,20 +35,20 @@ /** * インスタンスを生成する。 * - * @param root - * @param element + * @param rootModel 追加される{@link RootModel} + * @param dataSet 追加する{@link DataSetModel} */ - public AddDataSetToRootCommand(RootModel root, DataSetModel element) { - super(root, element); + public AddDataSetToRootCommand(RootModel rootModel, DataSetModel dataSet) { + super(rootModel, dataSet); } + public Command getNegateCommand() { + return new DeleteDataSetFromRootCommand(getRootModel(), getElement()); + } + @Override public Collection<? super DataSetModel> getTargetList() { - return getRoot().getDataSets(); + return getRootModel().getDataSets(); } - @Override - AbstractDeleteFromRootCommand<DataSetModel> createDeleteFromRootCommand(RootModel root, DataSetModel element) { - return new DeleteDataSetFromRootCommand(root, element); - } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.RootModel; import org.jiemamy.model.datatype.DomainModel; @@ -34,20 +35,19 @@ /** * インスタンスを生成する。 * - * @param root - * @param element + * @param rootModel 追加される{@link RootModel} + * @param domain 追加する{@link DomainModel} */ - public AddDomainToRootCommand(RootModel root, DomainModel element) { - super(root, element); + public AddDomainToRootCommand(RootModel rootModel, DomainModel domain) { + super(rootModel, domain); } - @Override - public Collection<? super DomainModel> getTargetList() { - return getRoot().getDomains(); + public Command getNegateCommand() { + return new DeleteDomainFromRootCommand(getRootModel(), getElement()); } @Override - AbstractDeleteFromRootCommand<DomainModel> createDeleteFromRootCommand(RootModel root, DomainModel element) { - return new DeleteDomainFromRootCommand(root, element); + public Collection<? super DomainModel> getTargetList() { + return getRootModel().getDomains(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.AbstractEntityModel; import org.jiemamy.model.entity.EntityModel; @@ -35,21 +36,19 @@ /** * インスタンスを生成する。 * - * @param root - * @param element + * @param rootModel 追加される{@link RootModel} + * @param entityModel 追加する{@link EntityModel} */ - public AddEntityToRootCommand(RootModel root, EntityModel element) { - super(root, element); + public AddEntityToRootCommand(RootModel rootModel, EntityModel entityModel) { + super(rootModel, entityModel); } - @Override - public Collection<? super EntityModel> getTargetList() { - return getRoot().getEntities(); + public Command getNegateCommand() { + return new DeleteEntityFromRootCommand(getRootModel(), getElement()); } @Override - AbstractDeleteFromRootCommand<EntityModel> createDeleteFromRootCommand(RootModel root, EntityModel element) { - return new DeleteEntityFromRootCommand(root, element); + public Collection<? super EntityModel> getTargetList() { + return getRootModel().getEntities(); } - } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.entity.TableModel; @@ -31,43 +28,43 @@ * * @author daisuke */ -public class AddForeignKeyCommand extends AbstractCommand implements Command { +public class AddForeignKeyCommand extends AbstractCommand { + /** 追加されるテーブル */ private final TableModel table; - private final ForeignKeyModel fk; + /** 追加する外部キー */ + private final ForeignKeyModel foreignKey; /** * インスタンスを生成する。 * - * @param table - * @param fk + * @param table 追加されるテーブル + * @param foreignKey 追加する外部キー */ - public AddForeignKeyCommand(TableModel table, ForeignKeyModel fk) { + public AddForeignKeyCommand(TableModel table, ForeignKeyModel foreignKey) { this.table = table; - this.fk = fk; + this.foreignKey = foreignKey; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new DeleteForeignKeyCommand(table, fk); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** - * fk + * 追加する外部キーを取得する。 * - * @return fk + * @return 追加する外部キー */ - public ForeignKeyModel getFk() { - return fk; + public ForeignKeyModel getForeignKey() { + return foreignKey; } + public Command getNegateCommand() { + return new DeleteForeignKeyCommand(table, foreignKey); + } + /** - * @return {@link TableModel} + * 追加されるテーブルを取得する。 + * + * @return 追加されるテーブル */ public TableModel getTable() { return table; Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; import org.jiemamy.model.entity.TableModel; @@ -31,30 +28,28 @@ * * @author daisuke */ -public class AddPrimaryKeyCommand extends AbstractCommand implements Command { +public class AddPrimaryKeyCommand extends AbstractCommand { + /** 追加されるテーブル */ private final TableModel table; + /** 追加する主キー */ private final PrimaryKeyModel primaryKey; /** * インスタンスを生成する。 * - * @param table - * @param primaryKey + * @param table 追加されるテーブル + * @param primaryKey 追加する主キー */ public AddPrimaryKeyCommand(TableModel table, PrimaryKeyModel primaryKey) { this.table = table; this.primaryKey = primaryKey; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new DeletePrimaryKeyCommand(table, primaryKey); - if (commandStack != null) { - commandStack.push(undo); - } + public Command getNegateCommand() { + return new DeletePrimaryKeyCommand(table, primaryKey); } /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.entity.TableModel; @@ -31,18 +28,20 @@ * * @author daisuke */ -public class DeleteColumnCommand extends AbstractCommand implements Command { +public class DeleteColumnCommand extends AbstractCommand { + /** 削除元テーブル */ private final TableModel table; + /** 削除されるカラム */ private final ColumnModel column; /** * インスタンスを生成する。 * - * @param table - * @param column + * @param table 削除元テーブル + * @param column 削除されるカラム */ public DeleteColumnCommand(TableModel table, ColumnModel column) { this.table = table; @@ -50,14 +49,6 @@ } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new AddColumnCommand(table, column); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** * column * @return column @@ -66,6 +57,10 @@ return column; } + public Command getNegateCommand() { + return new AddColumnCommand(table, column); + } + /** * @return {@link TableModel} */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -19,10 +19,8 @@ package org.jiemamy.editcommand.impl; import java.util.List; -import java.util.Stack; import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.ColumnRef; @@ -32,14 +30,17 @@ * * @author shin1ogawa */ -public class DeleteColumnFromColumnRefListCommand extends AbstractCommand implements Command { +public class DeleteColumnFromColumnRefListCommand extends AbstractCommand { private final JiemamyElement target; + /** 削除元のリスト */ private final List<ColumnRef> columnRefList; + /** 削除されるカラム */ private final ColumnModel column; + /** 削除位置インデックス */ private final int index; @@ -87,14 +88,6 @@ this.index = index; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new AddColumnToColumnRefListCommand(target, columnRefList, column, index); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** * column * @@ -122,6 +115,10 @@ return index; } + public Command getNegateCommand() { + return new AddColumnToColumnRefListCommand(target, columnRefList, column, index); + } + /** * target * Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.RootModel; import org.jiemamy.model.dataset.DataSetModel; @@ -34,20 +35,19 @@ /** * インスタンスを生成する。 * - * @param root - * @param element + * @param rootModel + * @param dataSet */ - public DeleteDataSetFromRootCommand(RootModel root, DataSetModel element) { - super(root, element); + public DeleteDataSetFromRootCommand(RootModel rootModel, DataSetModel dataSet) { + super(rootModel, dataSet); } - @Override - public Collection<? super DataSetModel> getTargetList() { - return getRoot().getDataSets(); + public Command getNegateCommand() { + return new AddDataSetToRootCommand(getRootModel(), getElement()); } @Override - AbstractAddToRootCommand<DataSetModel> createAddToRootCommand(RootModel root, DataSetModel element) { - return new AddDataSetToRootCommand(root, element); + public Collection<? super DataSetModel> getTargetList() { + return getRootModel().getDataSets(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.RootModel; import org.jiemamy.model.datatype.DomainModel; @@ -35,19 +36,18 @@ * インスタンスを生成する。 * * @param root - * @param element + * @param domain */ - public DeleteDomainFromRootCommand(RootModel root, DomainModel element) { - super(root, element); + public DeleteDomainFromRootCommand(RootModel root, DomainModel domain) { + super(root, domain); } - @Override - public Collection<? super DomainModel> getTargetList() { - return getRoot().getDomains(); + public Command getNegateCommand() { + return new AddDomainToRootCommand(getRootModel(), getElement()); } @Override - AbstractAddToRootCommand<DomainModel> createAddToRootCommand(RootModel root, DomainModel element) { - return new AddDomainToRootCommand(root, element); + public Collection<? super DomainModel> getTargetList() { + return getRootModel().getDomains(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,6 +20,7 @@ import java.util.Collection; +import org.jiemamy.editcommand.Command; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.EntityModel; @@ -36,19 +37,18 @@ * インスタンスを生成する。 * * @param root - * @param element + * @param entityModel */ - public DeleteEntityFromRootCommand(RootModel root, EntityModel element) { - super(root, element); + public DeleteEntityFromRootCommand(RootModel root, EntityModel entityModel) { + super(root, entityModel); } - @Override - public Collection<? super EntityModel> getTargetList() { - return getRoot().getEntities(); + public Command getNegateCommand() { + return new AddEntityToRootCommand(getRootModel(), getElement()); } @Override - AbstractAddToRootCommand<EntityModel> createAddToRootCommand(RootModel root, EntityModel element) { - return new AddEntityToRootCommand(root, element); + public Collection<? super EntityModel> getTargetList() { + return getRootModel().getEntities(); } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.entity.TableModel; @@ -31,41 +28,36 @@ * * @author daisuke */ -public class DeleteForeignKeyCommand extends AbstractCommand implements Command { +public class DeleteForeignKeyCommand extends AbstractCommand { private final TableModel table; - private final ForeignKeyModel fk; + private final ForeignKeyModel foreignKey; /** * インスタンスを生成する。 * @param table - * @param fk + * @param foreignKey */ - public DeleteForeignKeyCommand(TableModel table, ForeignKeyModel fk) { + public DeleteForeignKeyCommand(TableModel table, ForeignKeyModel foreignKey) { this.table = table; - this.fk = fk; - + this.foreignKey = foreignKey; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new AddForeignKeyCommand(table, fk); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** * fk * * @return fk */ - public ForeignKeyModel getFk() { - return fk; + public ForeignKeyModel getForeignKey() { + return foreignKey; } + public Command getNegateCommand() { + return new AddForeignKeyCommand(table, foreignKey); + } + /** * @return {@link TableModel} */ Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,10 +18,7 @@ */ package org.jiemamy.editcommand.impl; -import java.util.Stack; - import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; import org.jiemamy.model.entity.TableModel; @@ -31,7 +28,7 @@ * * @author daisuke */ -public class DeletePrimaryKeyCommand extends AbstractCommand implements Command { +public class DeletePrimaryKeyCommand extends AbstractCommand { private final TableModel table; @@ -49,12 +46,8 @@ this.primaryKey = primaryKey; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new AddPrimaryKeyCommand(table, primaryKey); - if (commandStack != null) { - commandStack.push(undo); - } + public Command getNegateCommand() { + return new AddPrimaryKeyCommand(table, primaryKey); } /** Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,74 +18,117 @@ */ package org.jiemamy.editcommand.impl; -import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.util.Stack; import org.apache.commons.beanutils.BeanUtils; +import org.jiemamy.JiemamyProperty; import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.model.JiemamyElement; +import org.jiemamy.utils.model.JiemamyPropertyUtil; /** * モデルの属性を変更するコマンド。 * + * @param <T> * @author shin1ogawa + * @author daisuke */ -public class ModifyModelPropertyCommand extends AbstractCommand implements Command { +public class ModifyModelPropertyCommand<T extends JiemamyElement> extends AbstractCommand { /** 属性を変更する対象のモデル */ - private final JiemamyElement target; + private final T target; /** 変更する属性のフィールド名称 */ + @Deprecated private final String propertyName; + private final JiemamyProperty<T> property; + + /** 変更前の値 */ + private final Object oldValue; + /** 変更後の値 */ - private Object newValue; + private final Object newValue; /** * インスタンスを生成する。 * * @param target + * @param property + * @param newValue + */ + public ModifyModelPropertyCommand(T target, JiemamyProperty<T> property, Object newValue) { + this(target, property, newValue, null); + } + + /** + * インスタンスを生成する。 + * + * @param target + * @param property + * @param newValue + * @param oldValue + */ + public ModifyModelPropertyCommand(T target, JiemamyProperty<T> property, Object newValue, Object oldValue) { + this.target = target; + this.property = property; + propertyName = null; + this.newValue = newValue; + if (oldValue != null) { + this.oldValue = oldValue; + } else { + this.oldValue = JiemamyPropertyUtil.getProperty(target, property); + } + } + + /** + * インスタンスを生成する。 + * + * @param target * @param propertyName + * @param newValue 変更後の値 + */ + @Deprecated + public ModifyModelPropertyCommand(T target, String propertyName, Object newValue) { + this(target, propertyName, newValue, null); + } + + /** + * インスタンスを生成する。 + * + * @param target + * @param propertyName * @param newValue + * @param oldValue */ - public ModifyModelPropertyCommand(JiemamyElement target, String propertyName, Object newValue) { + @Deprecated + public ModifyModelPropertyCommand(T target, String propertyName, Object newValue, Object oldValue) { this.target = target; + property = null; this.propertyName = propertyName; this.newValue = newValue; + if (oldValue != null) { + this.oldValue = oldValue; + } else { + try { + this.oldValue = BeanUtils.getProperty(target, propertyName); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException(e); + } catch (InvocationTargetException e) { + throw new IllegalArgumentException(e); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException(e); + } + } } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - try { - Object oldValue = BeanUtils.getProperty(target, propertyName); - commandProcessor.process(this); - Constructor<? extends ModifyModelPropertyCommand> constructor = - getClass().getConstructor(JiemamyElement.class, String.class, Object.class); - Command undo = constructor.newInstance(target, propertyName, oldValue); - if (commandStack != null) { - commandStack.push(undo); - } - } catch (SecurityException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalArgumentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InvocationTargetException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (NoSuchMethodException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } catch (InstantiationException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + public Command getNegateCommand() { + if (property == null) { + return new ModifyModelPropertyCommand(target, propertyName, oldValue, newValue); + } else { + return new ModifyModelPropertyCommand<T>(target, property, oldValue, newValue); } } @@ -98,9 +141,19 @@ } /** + * TODO for daisuke + * @return the property + */ + public JiemamyProperty<T> getProperty() { + return property; + } + + /** * 変更する属性のフィールド名称 * @return 変更する属性のフィールド名称 + * @deprecated use {@link #getProperty()} */ + @Deprecated public String getPropertyName() { return propertyName; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -27,7 +27,6 @@ import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.impl.AddEntityToRootCommand; -import org.jiemamy.model.RootModel; import org.jiemamy.model.entity.EntityModel; /** @@ -40,11 +39,13 @@ /** TODO for daisuke */ protected final Jiemamy jiemamy; + /** TODO for daisuke */ protected Stack<Command> undoStack = new Stack<Command>(); + /** TODO for daisuke */ protected Stack<Command> redoStack = new Stack<Command>(); - private final CommandProcessor processor; + private final CommandProcessor commandProcessor; /** @@ -56,7 +57,7 @@ public JiemamyFacadeImpl(Jiemamy jiemamy) { Validate.notNull(jiemamy); this.jiemamy = jiemamy; - processor = new CommandProcessorImpl(jiemamy.getEventBroker()); + commandProcessor = new CommandProcessorImpl(jiemamy.getEventBroker()); } /** @@ -65,8 +66,9 @@ * @param entity */ public void addEntity(EntityModel entity) { - AddEntityToRootCommand command = new AddEntityToRootCommand(getRootModel(), entity); - command.execute(processor, undoStack); + AddEntityToRootCommand command = new AddEntityToRootCommand(jiemamy.getFactory().getRootModel(), entity); + command.execute(commandProcessor); + undoStack.push(command.getNegateCommand()); } /** @@ -78,7 +80,8 @@ return; } Command command = redoStack.pop(); - command.execute(processor, undoStack); + command.execute(commandProcessor); + undoStack.push(command.getNegateCommand()); } /** @@ -90,15 +93,7 @@ return; } Command command = undoStack.pop(); - command.execute(processor, redoStack); + command.execute(commandProcessor); + redoStack.push(command.getNegateCommand()); } - - /** - * TODO for daisuke - * - * @return - */ - protected RootModel getRootModel() { - return jiemamy.getFactory().getRootModel(); - } } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractAdaptable.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractAdaptable.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractAdaptable.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -24,6 +24,7 @@ import org.apache.commons.lang.Validate; import org.jiemamy.utils.Adaptable; +import org.jiemamy.utils.AdapterNotFoundException; import org.jiemamy.utils.AnnotationUtil; import org.jiemamy.utils.CollectionsUtil; @@ -47,7 +48,7 @@ return adapterClass.cast(adapter); } } - return null; + throw new AdapterNotFoundException(adapterClass); } public List<Object> getAdapters() { @@ -72,7 +73,7 @@ Adapter annotation = AnnotationUtil.getTypeAnnotation(adapter, Adapter.class); if (annotation == null) { - throw new IllegalArgumentException(); + throw new IllegalArgumentException(adapter.getClass().getName() + " does not have Adapter annotation."); } adapters.add(adapter); Copied: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java (from rev 2740, artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java) =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,80 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/19 + * + * 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; + +import java.util.UUID; + +import org.apache.commons.lang.builder.ReflectionToStringBuilder; +import org.apache.commons.lang.builder.ToStringStyle; + +import org.jiemamy.Jiemamy; + +/** + * 参照オブジェクトの骨格実装。 + * + * @param <T> 参照対象オブジェクトの型 + * @author daisuke + */ +public abstract class AbstractElementReference<T extends JiemamyElement> implements ElementReference<T> { + + private final Jiemamy jiemamy; + + private final UUID referenceId; + + + /** + * インスタンスを生成する。 + * + * @param jiemamy + * @param referenceId + */ + public AbstractElementReference(Jiemamy jiemamy, UUID referenceId) { + this.jiemamy = jiemamy; + this.referenceId = referenceId; + } + + /** + * インスタンスを生成する。 + * + * @param decl + */ + public AbstractElementReference(T decl) { + jiemamy = decl.getJiemamy(); + referenceId = decl.getId(); + } + + public Jiemamy getJiemamy() { + return jiemamy; + } + + public UUID getReferenceId() { + return referenceId; + } + + @Override + public String toString() { + ReflectionToStringBuilder toStringBuilder = + new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); + toStringBuilder.setExcludeFieldNames(new String[] { + "jiemamy" + }); + + return toStringBuilder.toString(); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/AbstractElementReference.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/ElementReferenceImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -1,80 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/19 - * - * 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; - -import java.util.UUID; - -import org.apache.commons.lang.builder.ReflectionToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import org.jiemamy.Jiemamy; - -/** - * 参照オブジェクトの骨格実装。 - * - * @param <T> 参照対象オブジェクトの型 - * @author daisuke - */ -public class ElementReferenceImpl<T extends JiemamyElement> implements ElementReference<T> { - - private final Jiemamy jiemamy; - - private final UUID referenceId; - - - /** - * インスタンスを生成する。 - * - * @param jiemamy - * @param referenceId - */ - public ElementReferenceImpl(Jiemamy jiemamy, UUID referenceId) { - this.jiemamy = jiemamy; - this.referenceId = referenceId; - } - - /** - * インスタンスを生成する。 - * - * @param decl - */ - public ElementReferenceImpl(T decl) { - jiemamy = decl.getJiemamy(); - referenceId = decl.getId(); - } - - public Jiemamy getJiemamy() { - return jiemamy; - } - - public UUID getReferenceId() { - return referenceId; - } - - @Override - public String toString() { - ReflectionToStringBuilder toStringBuilder = - new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE); - toStringBuilder.setExcludeFieldNames(new String[] { - "jiemamy" - }); - - return toStringBuilder.toString(); - } -} 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/RootModelImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -27,7 +27,6 @@ import org.apache.commons.lang.builder.ToStringStyle; import org.jiemamy.Jiemamy; -import org.jiemamy.dialect.generic.GenericDialect; import org.jiemamy.model.dataset.DataSetModel; import org.jiemamy.model.datatype.DomainModel; import org.jiemamy.model.entity.EntityModel; @@ -41,7 +40,7 @@ public class RootModelImpl extends AbstractJiemamyElement implements RootModel { /** SQL方言ID */ - private String dialectClassName = GenericDialect.class.getName(); + private String dialectClassName; /** 開始スクリプト */ private String beginScript; @@ -146,7 +145,6 @@ } 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnModelImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,7 +20,6 @@ import java.util.UUID; -import org.apache.commons.lang.Validate; import org.apache.commons.lang.builder.ToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; @@ -101,12 +100,6 @@ this.defaultValue = defaultValue; } - @Override - public void setName(String name) { - Validate.notNull(name); - super.setName(name); - } - public void setNotNull(NotNullConstraintModel notNull) { this.notNull = notNull; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/attribute/ColumnRefImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -21,14 +21,14 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.model.ElementReferenceImpl; +import org.jiemamy.model.AbstractElementReference; /** * {@link ColumnModel}に対する参照オブジェクトの実装。Artemisにおける{@link ColumnRef}の実装クラス。 * * @author daisuke */ -public class ColumnRefImpl extends ElementReferenceImpl<ColumnModel> implements ColumnRef { +public class ColumnRefImpl extends AbstractElementReference<ColumnModel> implements ColumnRef { /** * インスタンスを生成する。 @@ -45,7 +45,6 @@ * @param jiemamy * @param referenceId */ - @Deprecated public ColumnRefImpl(Jiemamy jiemamy, UUID referenceId) { super(jiemamy, referenceId); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/BuiltinDataTypeImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,7 +18,6 @@ */ package org.jiemamy.model.datatype; -import org.apache.commons.lang.Validate; import org.apache.commons.lang.builder.ReflectionToStringBuilder; import org.apache.commons.lang.builder.ToStringStyle; @@ -59,7 +58,6 @@ } public void setCategory(DataTypeCategory category) { - Validate.notNull(category); this.category = category; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainModelImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -61,7 +61,6 @@ */ public DomainModelImpl(Jiemamy jiemamy, UUID id) { super(jiemamy, id); - Validate.notNull(id); } @Override Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainRefImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainRefImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/datatype/DomainRefImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -21,14 +21,14 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.model.ElementReferenceImpl; +import org.jiemamy.model.AbstractElementReference; /** * {@link DomainModel}に対する参照オブジェクトの実装。Artemisにおける{@link DomainRef}の実装クラス。 * * @author daisuke */ -public class DomainRefImpl extends ElementReferenceImpl<DomainModel> implements DomainRef { +public class DomainRefImpl extends AbstractElementReference<DomainModel> implements DomainRef { /** * インスタンスを生成する。 @@ -45,7 +45,6 @@ * @param jiemamy * @param uuid */ - @Deprecated public DomainRefImpl(Jiemamy jiemamy, UUID uuid) { super(jiemamy, uuid); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/AbstractEntityModel.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,8 +20,6 @@ import java.util.UUID; -import org.apache.commons.lang.Validate; - import org.jiemamy.Jiemamy; import org.jiemamy.model.AbstractJiemamyElement; @@ -33,7 +31,7 @@ public abstract class AbstractEntityModel extends AbstractJiemamyElement implements EntityModel { /** 名前 */ - private String name = ""; + private String name; /** 論理名 */ private String logicalName; @@ -96,7 +94,6 @@ } public void setName(String name) { - Validate.notNull(name); this.name = name; } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/TableRefImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -21,14 +21,14 @@ import java.util.UUID; import org.jiemamy.Jiemamy; -import org.jiemamy.model.ElementReferenceImpl; +import org.jiemamy.model.AbstractElementReference; /** * {@link TableModel}に対する参照オブジェクトの実装。Artemisにおける{@link TableRef}の実装クラス。 * * @author daisuke */ -public class TableRefImpl extends ElementReferenceImpl<TableModel> implements TableRef { +public class TableRefImpl extends AbstractElementReference<TableModel> implements TableRef { /** * インスタンスを生成する。 @@ -36,7 +36,6 @@ * @param jiemamy * @param uuid */ - @Deprecated public TableRefImpl(Jiemamy jiemamy, UUID uuid) { super(jiemamy, uuid); } 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/entity/ViewModelImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -20,8 +20,6 @@ import java.util.UUID; -import org.apache.commons.lang.Validate; - import org.jiemamy.Jiemamy; /** @@ -51,7 +49,6 @@ } public void setDefinition(String definition) { - Validate.notNull(definition); this.definition = definition; } } 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Identifier.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -47,9 +47,7 @@ * * @param identifier 識別子文字列 */ - @Deprecated - // TODO package privateに - public Identifier(String identifier) { + Identifier(String identifier) { this.identifier = identifier; } 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-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/model/sql/Literal.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -32,53 +32,62 @@ public class Literal implements Token { /** NULL */ - public static final Literal NULL = Literal.of("NULL", LiteralType.NULL); + public static final Literal NULL = new Literal("NULL", LiteralType.NULL); /** TRUE */ - public static final Literal TRUE = Literal.of(true); + public static final Literal TRUE = new Literal(true); /** FALSE */ - public static final Literal FALSE = Literal.of(false); + public static final Literal FALSE = new Literal(false); /** - * TODO for daisuke + * リテラルインスタンスを取得する。 * - * @param bool - * @return + * @param bool リテラルのJava表現 + * @return リテラルインスタンス */ public static Literal of(boolean bool) { - return new Literal(bool); + return bool ? TRUE : FALSE; } /** - * TODO for daisuke + * リテラルインスタンスを取得する。 * - * @param number - * @return + * @param number リテラルのJava表現 + * @return リテラルインスタンス */ public static Literal of(Number number) { + if (number == null) { + return NULL; + } return new Literal(number); } /** - * TODO for daisuke + * リテラルインスタンスを取得する。 * - * @param string - * @return + * @param string リテラルのJava文字列表現 + * @return リテラルインスタンス */ public static Literal of(String string) { + if (string == null) { + return NULL; + } return new Literal(string, LiteralType.CHARACTER); } /** - * TODO for daisuke + * リテラルインスタンスを取得する。 * - * @param string - * @param type - * @return + * @param string リテラルのJava文字列表現 + * @param type リテラルの種類 + * @return リテラルインスタンス */ public static Literal of(String string, LiteralType type) { + if (string == null) { + return NULL; + } return new Literal(string, type); } @@ -92,9 +101,7 @@ * * @param bool 値 */ - @Deprecated - // TODO package privateに - public Literal(boolean bool) { + Literal(boolean bool) { this(Boolean.valueOf(bool).toString(), LiteralType.BOOLEAN); } @@ -103,9 +110,7 @@ * * @param number 値 */ - @Deprecated - // TODO package privateに - public Literal(Number number) { + Literal(Number number) { this(number.toString(), LiteralType.NUMERIC); } @@ -115,9 +120,7 @@ * @param string クオートを含まない、値をあらわす文字列 * @param type リテラルの種類 */ - @Deprecated - // TODO package privateに - public Literal(String string, LiteralType type) { + Literal(String string, LiteralType type) { Validate.notNull(string); this.string = type.convert(string); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ReflectionUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ReflectionUtil.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/ReflectionUtil.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -30,11 +30,14 @@ */ public class ReflectionUtil { - private static final String SET = "set"; + /** setterの接頭句 */ + public static final String SET = "set"; - private static final String GET = "get"; + /** getterの接頭句 */ + public static final String GET = "get"; - private static final String IS = "is"; + /** boolean getterの接頭句 */ + public static final String IS = "is"; /** @@ -57,6 +60,27 @@ } /** + * TODO for daisuke + * + * @param fieldName + * @param prefix + * @return + */ + public static String convertFieldNameToAccessorName(String fieldName, String prefix) { + return prefix + JmStringUtil.toCapital(fieldName); + } + + /** + * TODO for daisuke + * + * @param fieldName + * @return + */ + public static String convertFieldNameToSetterName(String fieldName) { + return convertFieldNameToAccessorName(fieldName, SET); + } + + /** * フィールドからアクセサ名を割り出す。 * * @param field フィールド @@ -64,7 +88,7 @@ * @return アクセサ名 */ public static String convertFieldToAccessorName(Field field, String prefix) { - return prefix + JmStringUtil.toCapital(field.getName()); + return convertFieldNameToAccessorName(field.getName(), prefix); } /** Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/JiemamyPropertyUtil.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/JiemamyPropertyUtil.java (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/JiemamyPropertyUtil.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,75 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils.model; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import org.jiemamy.JiemamyProperty; +import org.jiemamy.exception.UnexpectedConditionError; +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.utils.ReflectionUtil; + +/** + * TODO for daisuke + * + * @author daisuke + */ +public final class JiemamyPropertyUtil { + + /** + * TODO for daisuke + * + * @param element + * @param property + * @return + */ + public static <T extends JiemamyElement>Object getProperty(T element, JiemamyProperty<T> property) { + String getterName = ReflectionUtil.convertFieldNameToAccessorName(property.name(), ReflectionUtil.GET); + Method method = null; + try { + method = element.getClass().getMethod(getterName); + } catch (SecurityException e) { + throw new UnexpectedConditionError("security error", e); + } catch (NoSuchMethodException e) { + getterName = ReflectionUtil.convertFieldNameToAccessorName(property.name(), ReflectionUtil.IS); + try { + method = element.getClass().getMethod(getterName); + } catch (SecurityException e2) { + throw new UnexpectedConditionError("security error", e); + } catch (NoSuchMethodException e2) { + throw new UnexpectedConditionError("アクセサの存在はテストで保証されているはず", e); + } + } + assert method != null; + + try { + return method.invoke(element); + } catch (IllegalArgumentException e) { + throw new UnexpectedConditionError("引数なしのメソッドを拾っているはず", e); + } catch (IllegalAccessException e) { + throw new UnexpectedConditionError("getterはpublicなはず", e); + } catch (InvocationTargetException e) { + throw new UnexpectedConditionError("なんぞ?", e); // TODO 調べろw + } + } + + private JiemamyPropertyUtil() { + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/JiemamyPropertyUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -32,6 +32,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.jiemamy.JiemamyProperty.AttributeProperty; +import org.jiemamy.JiemamyProperty.EntityProperty; import org.jiemamy.editcommand.Command; import org.jiemamy.editcommand.CommandListener; import org.jiemamy.editcommand.CommandProcessorImpl; @@ -44,9 +46,11 @@ import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.ConstraintModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; /** @@ -66,8 +70,6 @@ private CommandProcessorImpl commandProcessor; - private Stack<Command> commandStack; - private RootModel rootModel; @@ -83,7 +85,6 @@ rootModel = factory.newModel(RootModel.class); eventBroker = jiemamy.getEventBroker(); commandProcessor = new CommandProcessorImpl(eventBroker); - commandStack = new Stack<Command>(); } /** @@ -98,95 +99,77 @@ rootModel = null; eventBroker = null; commandProcessor = null; - commandStack = null; } /** - * Tableが保持している{@link ConstraintModel}が参照する{@link ColumnModel}に対する変更も通知される。 + * シンプルなイベント通知の動作確認。 * * @throws Exception 例外が発生した場合 */ @Test - public void testReferenceで保持した要素からのバブリング() throws Exception { - TableModel table = factory.newModel(TableModel.class); - ColumnModel column1 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column1).execute(commandProcessor, commandStack); - ColumnModel column2 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column2).execute(commandProcessor, commandStack); + public void test01_バブリングとか無しでの通知() throws Exception { + Stack<Command> commandStack = new Stack<Command>(); - PrimaryKeyModel primaryKey = factory.newModel(PrimaryKeyModel.class); - new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column2).execute(commandProcessor, - commandStack); - new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1, 0).execute( - commandProcessor, commandStack); - new AddPrimaryKeyCommand(table, primaryKey).execute(commandProcessor, commandStack); + TableModel emp = factory.newModel(TableModel.class); + TableModel dept = factory.newModel(TableModel.class); - // ここまでで以下の構造を構築した事になる。 - // table - // +attributes - // -column1 - // -column2 - // +primaryKey - // -[ref]column1 - // -[ref]column2 + Command command = new ModifyModelPropertyCommand<EntityModel>(emp, EntityProperty.name, "T_EMP"); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); - DefaultCommandListener tableListener = new DefaultCommandListener(table); - eventBroker.addListener(tableListener); - DefaultCommandListener columnListener1 = new DefaultCommandListener(column1); - eventBroker.addListener(columnListener1); - DefaultCommandListener columnListener2 = new DefaultCommandListener(column2); - eventBroker.addListener(columnListener2); - DefaultCommandListener pkeyListener = new DefaultCommandListener(primaryKey); - eventBroker.addListener(pkeyListener); + command = new ModifyModelPropertyCommand<EntityModel>(dept, EntityProperty.name, "T_DEPT"); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); - assertThat(columnListener1.commandList.size(), is(0)); - assertThat(columnListener2.commandList.size(), is(0)); - assertThat(pkeyListener.commandList.size(), is(0)); - assertThat(tableListener.commandList.size(), is(0)); - assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey - assertThat(primaryKey.getKeyColumns().size(), is(2)); // [ref]column1, [ref]column2。 - assertThat(primaryKey.getKeyColumns().get(0).getReferenceId(), is(column1.getId())); - assertThat(primaryKey.getKeyColumns().get(1).getReferenceId(), is(column2.getId())); + command = new AddEntityToRootCommand(rootModel, emp); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); - new ModifyModelPropertyCommand(column1, "name", "column1").execute(commandProcessor, commandStack); + command = new AddEntityToRootCommand(rootModel, dept); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); - assertThat(columnListener1.commandList.size(), is(1)); // 変更があったcolumn自身。 - assertThat(columnListener2.commandList.size(), is(0)); - assertThat(pkeyListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているから通知を受ける。 - assertThat(tableListener.commandList.size(), is(1)); // 変更があったcolumnを保持しているから通知を受ける。 - assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey - assertThat(primaryKey.getKeyColumns().size(), is(2)); // [ref]column1, [ref]column2。 - assertThat(primaryKey.getKeyColumns().get(0).getReferenceId(), is(column1.getId())); - assertThat(primaryKey.getKeyColumns().get(1).getReferenceId(), is(column2.getId())); + // Listenerを作成、追加する。 + DefaultCommandListener empListener = new DefaultCommandListener(emp); + eventBroker.addListener(empListener); + DefaultCommandListener deptListener = new DefaultCommandListener(dept); + eventBroker.addListener(deptListener); - columnListener1.commandList.clear(); - columnListener2.commandList.clear(); - pkeyListener.commandList.clear(); - tableListener.commandList.clear(); - // columnをprimaryKeyから削除する。 - new DeleteColumnFromColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1).execute( - commandProcessor, commandStack); + // EMPに対して変更Commandを適用する。 + command = new ModifyModelPropertyCommand<EntityModel>(emp, EntityProperty.name, "newEmp"); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); - assertThat(columnListener1.commandList.size(), is(0)); // column自身は何も変更されていない。 - assertThat(columnListener2.commandList.size(), is(0)); - assertThat(pkeyListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているから通知を受ける。 - assertThat(tableListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているprumaruKeyを保持しているから通知を受ける。 - assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey - assertThat(primaryKey.getKeyColumns().size(), is(1)); // [ref]column2。 + assertThat(empListener.commandList.size(), is(1)); + assertThat(deptListener.commandList.size(), is(0)); + assertThat(emp.getName(), is("newEmp")); - columnListener1.commandList.clear(); - columnListener2.commandList.clear(); - pkeyListener.commandList.clear(); - tableListener.commandList.clear(); - // columnをtableから削除する。 - new DeleteColumnCommand(table, column1).execute(commandProcessor, commandStack); + // Undoしてみる。 + command = commandStack.pop(); + command.execute(commandProcessor); - assertThat(columnListener1.commandList.size(), is(0)); // column自身は何も変更されていない。 - assertThat(columnListener2.commandList.size(), is(0)); - assertThat(pkeyListener.commandList.size(), is(0)); - assertThat(tableListener.commandList.size(), is(1)); - assertThat(table.getAttributes().size(), is(2)); // column2,pkey - assertThat(primaryKey.getKeyColumns().size(), is(1)); // [ref]column2。 + assertThat(empListener.commandList.size(), is(2)); + assertThat(deptListener.commandList.size(), is(0)); + assertThat(emp.getName(), is("T_EMP")); + + // DEPTに対して変更Commandを適用する。 + empListener.commandList.clear(); + deptListener.commandList.clear(); + command = new ModifyModelPropertyCommand<EntityModel>(dept, EntityProperty.name, "newDept"); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + + assertThat(empListener.commandList.size(), is(0)); + assertThat(deptListener.commandList.size(), is(1)); + assertThat(dept.getName(), is("newDept")); + + // Undoしてみる。 + command = commandStack.pop(); + command.execute(commandProcessor); + + assertThat(empListener.commandList.size(), is(0)); + assertThat(deptListener.commandList.size(), is(2)); + assertThat(dept.getName(), is("T_DEPT")); } /** @@ -195,11 +178,11 @@ * @throws Exception 例外が発生した場合 */ @Test - public void testバブリング() throws Exception { + public void test02_バブリング() throws Exception { TableModel table = factory.newModel(TableModel.class); - new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, table).execute(commandProcessor); ColumnModel column = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column).execute(commandProcessor, commandStack); + new AddColumnCommand(table, column).execute(commandProcessor); // ここまでで以下の構造を構築した事になる。 // table @@ -215,14 +198,14 @@ DefaultCommandListener columnListener = new DefaultCommandListener(column); eventBroker.addListener(columnListener); - new ModifyModelPropertyCommand(table, "name", "T_EMP"). // tableを変更する。 - execute(commandProcessor, commandStack); // tableListener, rootListenerへ通知されるはず。 - new ModifyModelPropertyCommand(column, "name", "ID") // columnを変更する。 - .execute(commandProcessor, commandStack); // columnListener,tableListener,rootListenerへ通知される + new ModifyModelPropertyCommand<EntityModel>(table, EntityProperty.name, "T_EMP"). // tableを変更する。 + execute(commandProcessor); // tableListener, rootListenerへ通知されるはず。 + new ModifyModelPropertyCommand<AttributeModel>(column, AttributeProperty.name, "ID") // columnを変更する。 + .execute(commandProcessor); // columnListener,tableListener,rootListenerへ通知される new AddColumnCommand(table, factory.newModel(ColumnModel.class)) // 新たに作成したcolumnを追加する。 - .execute(commandProcessor, commandStack); // tableListener, rootListenerへ通知されるはず。 + .execute(commandProcessor); // tableListener, rootListenerへ通知されるはず。 new AddEntityToRootCommand(rootModel, factory.newModel(TableModel.class)) // 新たに作成したtableを追加する。 - .execute(commandProcessor, commandStack); // rootListenerへ通知されるはず。 + .execute(commandProcessor); // rootListenerへ通知されるはず。 assertThat(table.getAttributes().size(), is(2)); assertThat(rootModel.getEntities().size(), is(2)); @@ -245,12 +228,13 @@ // RootModelに追加しないColumnModelを作ったり、属性を変更したり。 ColumnModel column2 = factory.newModel(ColumnModel.class); - new ModifyModelPropertyCommand(column2, "name", "NAME").execute(commandProcessor, commandStack); + new ModifyModelPropertyCommand<AttributeModel>(column2, AttributeProperty.name, "NAME") + .execute(commandProcessor); // RootModelに追加しないColumnModelを作ったり、属性を変更したり。 TableModel table2 = factory.newModel(TableModel.class); - new ModifyModelPropertyCommand(table2, "name", "Y_DEPT").execute(commandProcessor, commandStack); + new ModifyModelPropertyCommand<EntityModel>(table2, EntityProperty.name, "Y_DEPT").execute(commandProcessor); // RootModelに追加していないTableModelにColumnModelを追加してみたり。 - new AddColumnCommand(table2, column2).execute(commandProcessor, commandStack); + new AddColumnCommand(table2, column2).execute(commandProcessor); assertThat(columnListener.commandList.size(), is(0)); assertThat(tableListener.commandList.size(), is(0)); @@ -258,50 +242,91 @@ } /** - * シンプルなイベント通知の動作確認。 + * Tableが保持している{@link ConstraintModel}が参照する{@link ColumnModel}に対する変更も通知される。 * * @throws Exception 例外が発生した場合 */ @Test - public void testバブリングとか無しでの通知() throws Exception { - TableModel emp = factory.newModel(TableModel.class); - TableModel dept = factory.newModel(TableModel.class); - new ModifyModelPropertyCommand(emp, "name", "T_EMP").execute(commandProcessor, commandStack); - new ModifyModelPropertyCommand(dept, "name", "T_DEPT").execute(commandProcessor, commandStack); - new AddEntityToRootCommand(rootModel, emp).execute(commandProcessor, commandStack); - new AddEntityToRootCommand(rootModel, dept).execute(commandProcessor, commandStack); + public void test03_Referenceで保持した要素からのバブリング() throws Exception { + TableModel table = factory.newModel(TableModel.class); + ColumnModel column1 = factory.newModel(ColumnModel.class); + new AddColumnCommand(table, column1).execute(commandProcessor); + ColumnModel column2 = factory.newModel(ColumnModel.class); + new AddColumnCommand(table, column2).execute(commandProcessor); - // Listenerを作成、追加する。 - DefaultCommandListener empListener = new DefaultCommandListener(emp); - eventBroker.addListener(empListener); - DefaultCommandListener deptListener = new DefaultCommandListener(dept); - eventBroker.addListener(deptListener); + PrimaryKeyModel primaryKey = factory.newModel(PrimaryKeyModel.class); + new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column2).execute(commandProcessor); + new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1, 0) + .execute(commandProcessor); + new AddPrimaryKeyCommand(table, primaryKey).execute(commandProcessor); - // EMPに対して変更Commandを適用する。 - new ModifyModelPropertyCommand(emp, "name", "newEmp").execute(commandProcessor, commandStack); - assertThat(empListener.commandList.size(), is(1)); - assertThat(deptListener.commandList.size(), is(0)); - assertThat(emp.getName(), is("newEmp")); - // Undoしてみる。 - Command undoCommand1 = commandStack.pop(); - undoCommand1.execute(commandProcessor, commandStack); - assertThat(empListener.commandList.size(), is(2)); - assertThat(deptListener.commandList.size(), is(0)); - assertThat(emp.getName(), is("T_EMP")); + // ここまでで以下の構造を構築した事になる。 + // table + // +attributes + // -column1 + // -column2 + // +primaryKey + // -[ref]column1 + // -[ref]column2 - // DEPTに対して変更Commandを適用する。 - empListener.commandList.clear(); - deptListener.commandList.clear(); - new ModifyModelPropertyCommand(dept, "name", "newDept").execute(commandProcessor, commandStack); - assertThat(empListener.commandList.size(), is(0)); - assertThat(deptListener.commandList.size(), is(1)); - assertThat(dept.getName(), is("newDept")); - // Undoしてみる。 - Command undoCommand2 = commandStack.pop(); - undoCommand2.execute(commandProcessor, commandStack); - assertThat(empListener.commandList.size(), is(0)); - assertThat(deptListener.commandList.size(), is(2)); - assertThat(dept.getName(), is("T_DEPT")); + DefaultCommandListener tableListener = new DefaultCommandListener(table); + eventBroker.addListener(tableListener); + DefaultCommandListener columnListener1 = new DefaultCommandListener(column1); + eventBroker.addListener(columnListener1); + DefaultCommandListener columnListener2 = new DefaultCommandListener(column2); + eventBroker.addListener(columnListener2); + DefaultCommandListener pkeyListener = new DefaultCommandListener(primaryKey); + eventBroker.addListener(pkeyListener); + + assertThat(columnListener1.commandList.size(), is(0)); + assertThat(columnListener2.commandList.size(), is(0)); + assertThat(pkeyListener.commandList.size(), is(0)); + assertThat(tableListener.commandList.size(), is(0)); + assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey + assertThat(primaryKey.getKeyColumns().size(), is(2)); // [ref]column1, [ref]column2。 + assertThat(primaryKey.getKeyColumns().get(0).getReferenceId(), is(column1.getId())); + assertThat(primaryKey.getKeyColumns().get(1).getReferenceId(), is(column2.getId())); + + new ModifyModelPropertyCommand<AttributeModel>(column1, AttributeProperty.name, "column1") + .execute(commandProcessor); + + assertThat(columnListener1.commandList.size(), is(1)); // 変更があったcolumn自身。 + assertThat(columnListener2.commandList.size(), is(0)); + assertThat(pkeyListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているから通知を受ける。 + assertThat(tableListener.commandList.size(), is(1)); // 変更があったcolumnを保持しているから通知を受ける。 + assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey + assertThat(primaryKey.getKeyColumns().size(), is(2)); // [ref]column1, [ref]column2。 + assertThat(primaryKey.getKeyColumns().get(0).getReferenceId(), is(column1.getId())); + assertThat(primaryKey.getKeyColumns().get(1).getReferenceId(), is(column2.getId())); + + columnListener1.commandList.clear(); + columnListener2.commandList.clear(); + pkeyListener.commandList.clear(); + tableListener.commandList.clear(); + // columnをprimaryKeyから削除する。 + new DeleteColumnFromColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1) + .execute(commandProcessor); + + assertThat(columnListener1.commandList.size(), is(0)); // column自身は何も変更されていない。 + assertThat(columnListener2.commandList.size(), is(0)); + assertThat(pkeyListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているから通知を受ける。 + assertThat(tableListener.commandList.size(), is(1)); // 変更があったcolumnのreferenceを保持しているprumaruKeyを保持しているから通知を受ける。 + assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey + assertThat(primaryKey.getKeyColumns().size(), is(1)); // [ref]column2。 + + columnListener1.commandList.clear(); + columnListener2.commandList.clear(); + pkeyListener.commandList.clear(); + tableListener.commandList.clear(); + // columnをtableから削除する。 + new DeleteColumnCommand(table, column1).execute(commandProcessor); + + assertThat(columnListener1.commandList.size(), is(0)); // column自身は何も変更されていない。 + assertThat(columnListener2.commandList.size(), is(0)); + assertThat(pkeyListener.commandList.size(), is(0)); + assertThat(tableListener.commandList.size(), is(1)); + assertThat(table.getAttributes().size(), is(2)); // column2,pkey + assertThat(primaryKey.getKeyColumns().size(), is(1)); // [ref]column2。 } Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -103,19 +103,35 @@ @Test public void test01親子関係の判断() throws Exception { Stack<Command> commandStack = new Stack<Command>(); + TableModel table = factory.newModel(TableModel.class); - new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); + Command command = new AddEntityToRootCommand(rootModel, table); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + ColumnModel column1 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column1).execute(commandProcessor, commandStack); + command = new AddColumnCommand(table, column1); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + ColumnModel column2 = factory.newModel(ColumnModel.class); - new AddColumnCommand(table, column2).execute(commandProcessor, commandStack); + command = new AddColumnCommand(table, column2); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); PrimaryKeyModel primaryKey = factory.newModel(PrimaryKeyModel.class); - new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column2).execute(commandProcessor, - commandStack); - new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1, 0).execute( - commandProcessor, commandStack); - new AddPrimaryKeyCommand(table, primaryKey).execute(commandProcessor, commandStack); + command = new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column2); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + + command = new AddColumnToColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1, 0); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + + command = new AddPrimaryKeyCommand(table, primaryKey); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + commandStackStack.push(commandStack); // 構築操作を行ったCommandStackをpushする。 assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey @@ -143,8 +159,10 @@ commandStack = new Stack<Command>(); // columnをprimaryKeyから削除する。 - new DeleteColumnFromColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1).execute( - commandProcessor, commandStack); + command = new DeleteColumnFromColumnRefListCommand(primaryKey, primaryKey.getKeyColumns(), column1); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(true)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true)); @@ -153,7 +171,10 @@ assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(false)); // columnをtableから削除する。 - new DeleteColumnCommand(table, column1).execute(commandProcessor, commandStack); + command = new DeleteColumnCommand(table, column1); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(false)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(true)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(true)); @@ -161,8 +182,11 @@ assertThat(ReferenceResolverImpl.isDescendFromElement(table, primaryKey.getId()), is(true)); assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), is(false)); - // talbeをRootModelから削除する。 - new DeleteEntityFromRootCommand(rootModel, table).execute(commandProcessor, commandStack); + // tableをRootModelから削除する。 + command = new DeleteEntityFromRootCommand(rootModel, table); + command.execute(commandProcessor); + commandStack.push(command.getNegateCommand()); + assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), is(false)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), is(false)); assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, table.getId()), is(false)); @@ -174,8 +198,8 @@ // 一連の削除操作を全て取り消す。 Stack<Command> deleteCommands = commandStackStack.pop(); while (deleteCommands.isEmpty() == false) { - Command command = deleteCommands.pop(); - command.execute(commandProcessor, null); + command = deleteCommands.pop(); + command.execute(commandProcessor); } assertThat(table.getAttributes().size(), is(3)); // column1,column2,pkey Modified: artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-dialect-mysql/src/main/java/org/jiemamy/dialect/mysql/MySqlEmitter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -86,7 +86,7 @@ List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); tokens.add(Keyword.TABLE); - tokens.add(new Identifier(tableModel.getName())); + tokens.add(Identifier.of(tableModel.getName())); tokens.add(Separator.LEFT_PAREN); for (AttributeModel attributeModel : tableModel.getAttributes()) { AttributeEmitStrategy strategy = AttributeEmitStrategy.fromAttribute(attributeModel); @@ -102,7 +102,7 @@ if (type != null) { tokens.add(Keyword.of("ENGINE")); tokens.add(Separator.EQUAL); - tokens.add(new Identifier(type.toString())); + tokens.add(Identifier.of(type.toString())); } } @@ -121,9 +121,9 @@ List<Token> tokens = CollectionsUtil.newArrayList(); tokens.add(Keyword.CREATE); tokens.add(Keyword.VIEW); - tokens.add(new Identifier(viewModel.getName())); + tokens.add(Identifier.of(viewModel.getName())); tokens.add(Keyword.AS); - tokens.add(new Literal(viewModel.getDefinition(), LiteralType.FRAGMENT)); + tokens.add(Literal.of(viewModel.getDefinition(), LiteralType.FRAGMENT)); tokens.add(Separator.SEMICOLON); return new SqlStatementImpl(tokens); } Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/AddProfileToDiaglamCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,8 +18,6 @@ */ package org.jiemamy.editcommand; -import java.util.Stack; - import org.jiemamy.editcommand.impl.AbstractCommand; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.JiemamyElement; @@ -35,13 +33,13 @@ */ public class AddProfileToDiaglamCommand extends AbstractCommand { - final RootModel root; + private final RootModel root; - final NodeAdapter nodeAdapter; + private final NodeAdapter nodeAdapter; - final NodeProfile nodeProfile; + private final NodeProfile nodeProfile; - final int diagramIndex; + private final int diagramIndex; /** @@ -60,14 +58,6 @@ this.nodeProfile = nodeProfile; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new DeleteProfileFromDiaglamCommand(root, getDiagramIndex(), nodeAdapter); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** * @return the diagramIndex */ @@ -75,6 +65,10 @@ return diagramIndex; } + public Command getNegateCommand() { + return new DeleteProfileFromDiaglamCommand(root, getDiagramIndex(), nodeAdapter); + } + /** * @return ノードを識別するための{@link NodeAdapter} */ Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/editcommand/DeleteProfileFromDiaglamCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,8 +18,6 @@ */ package org.jiemamy.editcommand; -import java.util.Stack; - import org.jiemamy.editcommand.impl.AbstractCommand; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.JiemamyElement; @@ -30,19 +28,19 @@ /** * {@link RootModel}に登録された{@link DiagramPresentations}アダプタから{@link NodeProfile}を削除するコマンド。 * - * @author shin1ogawa * @see AddProfileToDiaglamCommand + * @author shin1ogawa */ public class DeleteProfileFromDiaglamCommand extends AbstractCommand { - final RootModel root; + private final RootModel root; - final NodeAdapter nodeAdapter; + private final NodeAdapter nodeAdapter; + private final int diagramIndex; + private NodeProfile nodeProfile; - final int diagramIndex; - /** * インスタンスを生成する。 @@ -58,14 +56,6 @@ this.nodeAdapter = nodeAdapter; } - public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) { - commandProcessor.process(this); - Command undo = new AddProfileToDiaglamCommand(root, getDiagramIndex(), nodeAdapter, getNodeProfile()); - if (commandStack != null) { - commandStack.push(undo); - } - } - /** * @return the diagramIndex */ @@ -73,6 +63,10 @@ return diagramIndex; } + public Command getNegateCommand() { + return new AddProfileToDiaglamCommand(root, getDiagramIndex(), nodeAdapter, getNodeProfile()); + } + /** * @return ノードを識別するための{@link NodeAdapter} */ @@ -102,7 +96,7 @@ } /** - * @param ノードの見た目の情報を保持する{@link NodeProfile} + * @param nodeProfile ノードの見た目の情報を保持する{@link NodeProfile} */ public void setNodeProfile(NodeProfile nodeProfile) { this.nodeProfile = nodeProfile; Modified: artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java 2009-02-26 03:59:32 UTC (rev 2741) +++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -28,7 +28,6 @@ import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.DeleteProfileFromDiaglamCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; -import org.jiemamy.facade.JiemamyFacadeImpl; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.NodeProfile; @@ -65,8 +64,11 @@ * @param nodeProfile 追加する{@link NodeProfile} */ public void addNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter, final NodeProfile nodeProfile) { - final Command command = new AddProfileToDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter, nodeProfile); - command.execute(commandProcessor, undoStack); + Command command = + new AddProfileToDiaglamCommand(jiemamy.getFactory().getRootModel(), diagramIndex, nodeAdapter, + nodeProfile); + command.execute(commandProcessor); + undoStack.push(command.getNegateCommand()); redoStack.push(command); } @@ -78,7 +80,8 @@ * @param constraint */ public void changeNodeConstraint(int diagramIndex, NodeAdapter nodeAdapter, JmRectangle constraint) { - DiagramPresentations diagramPresentations = getRootModel().getAdapter(DiagramPresentations.class); + DiagramPresentations diagramPresentations = + jiemamy.getFactory().getRootModel().getAdapter(DiagramPresentations.class); DiagramPresentationModel diagramPresentationModel = diagramPresentations.get(diagramIndex); Map<NodeAdapter, NodeProfile> figureProfiles = diagramPresentationModel.getFigureProfiles(); if (figureProfiles.containsKey(nodeAdapter) == false) { @@ -86,8 +89,9 @@ figureProfiles.put(nodeAdapter, profile); } NodeProfile nodeProfile = figureProfiles.get(nodeAdapter); - ModifyModelPropertyCommand redoCommand = new ModifyModelPropertyCommand(nodeProfile, "layout", constraint); - redoCommand.execute(commandProcessor, undoStack); + Command redoCommand = new ModifyModelPropertyCommand(nodeProfile, "layout", constraint); + redoCommand.execute(commandProcessor); + undoStack.push(redoCommand.getNegateCommand()); redoStack.push(redoCommand); } @@ -98,8 +102,10 @@ * @param nodeAdapter ノードに対応する{@link NodeAdapter} */ public void deleteNodeProfile(int diagramIndex, final NodeAdapter nodeAdapter) { - final Command command = new DeleteProfileFromDiaglamCommand(getRootModel(), diagramIndex, nodeAdapter); - command.execute(commandProcessor, undoStack); + final Command command = + new DeleteProfileFromDiaglamCommand(jiemamy.getFactory().getRootModel(), diagramIndex, nodeAdapter); + command.execute(commandProcessor); + undoStack.push(command.getNegateCommand()); redoStack.push(command); } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -27,9 +27,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jiemamy.JiemamyViewFacadeImpl; import org.jiemamy.Migration; import org.jiemamy.eclipse.utils.ConvertUtil; +import org.jiemamy.facade.JiemamyViewFacadeImpl; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; import org.jiemamy.model.RootModel; Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-26 03:59:32 UTC (rev 2741) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -23,9 +23,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.jiemamy.JiemamyViewFacadeImpl; import org.jiemamy.Migration; import org.jiemamy.eclipse.utils.ConvertUtil; +import org.jiemamy.facade.JiemamyViewFacadeImpl; import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.NodeProfile; import org.jiemamy.model.RootModel; Added: vesta/trunk/org.jiemamy.eclipse/src/main/resources/logback.xml =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/resources/logback.xml (rev 0) +++ vesta/trunk/org.jiemamy.eclipse/src/main/resources/logback.xml 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<configuration> + <consolePlugin /> +</configuration> Property changes on: vesta/trunk/org.jiemamy.eclipse/src/main/resources/logback.xml ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyProperty.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyProperty.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/JiemamyProperty.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,6 +18,7 @@ */ package org.jiemamy; +import org.jiemamy.model.JiemamyElement; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.AttributeModel; import org.jiemamy.model.attribute.ColumnModel; @@ -41,17 +42,22 @@ /** * 各モデルの「概念的な」(実装としては強要しない)プロパティを表すインターフェイス。 + * + * @param <T> * @author daisuke */ -public interface JiemamyProperty { +public interface JiemamyProperty<T extends JiemamyElement> { + String name(); + + /** * {@link AttributeModel}のプロパティを表す列挙型。 * * @author daisuke */ @TargetModel(AttributeModel.class) - public enum AttributeProperty implements JiemamyProperty { + public enum AttributeProperty implements JiemamyProperty<AttributeModel> { /** {@link AttributeModel#getName()}で取得できるプロパティ */ name, @@ -81,7 +87,7 @@ * @author daisuke */ @TargetModel(ColumnCheckModel.class) - public enum ColumnCheckModelProperty implements JiemamyProperty { + public enum ColumnCheckModelProperty implements JiemamyProperty<ColumnCheckModel> { } @@ -91,7 +97,7 @@ * @author daisuke */ @TargetModel(ColumnModel.class) - public enum ColumnProperty implements JiemamyProperty { + public enum ColumnProperty implements JiemamyProperty<ColumnModel> { /** {@link ColumnModel#getDataType()}で取得できるプロパティ */ dataType, @@ -118,7 +124,7 @@ * @author daisuke */ @TargetModel(ConstraintModel.class) - public enum ConstraintProperty implements JiemamyProperty { + public enum ConstraintProperty implements JiemamyProperty<ConstraintModel> { /** {@link ConstraintModel#getName()}で取得できるプロパティ */ name @@ -130,7 +136,7 @@ * @author daisuke */ @TargetModel(DataSetModel.class) - public enum DataSetProperty implements JiemamyProperty { + public enum DataSetProperty implements JiemamyProperty<DataSetModel> { /** {@link DataSetModel#getName()}で取得できるプロパティ */ name, @@ -145,7 +151,7 @@ * @author daisuke */ @TargetModel(Deferrability.class) - public enum DeferrabilityProperty implements JiemamyProperty { + public enum DeferrabilityProperty implements JiemamyProperty<Deferrability> { /** {@link Deferrability#isDeferrable()}で取得できるプロパティ */ deferrable, @@ -160,7 +166,7 @@ * @author daisuke */ @TargetModel(EntityModel.class) - public enum EntityProperty implements JiemamyProperty { + public enum EntityProperty implements JiemamyProperty<EntityModel> { /** {@link EntityModel#getName()}で取得できるプロパティ */ name, @@ -183,7 +189,7 @@ * @author daisuke */ @TargetModel(ForeignKeyModel.class) - public enum ForeignKeyProperty implements JiemamyProperty { + public enum ForeignKeyProperty implements JiemamyProperty<ForeignKeyModel> { /** {@link ForeignKeyModel#getReferenceColumns()}で取得できるプロパティ */ referenceColumns, @@ -204,7 +210,7 @@ * @author daisuke */ @TargetModel(IndexColumnModel.class) - public enum IndexColumnProperty implements JiemamyProperty { + public enum IndexColumnProperty implements JiemamyProperty<IndexColumnModel> { /** {@link IndexColumnModel#getColumn()}で取得できるプロパティ */ column, @@ -219,7 +225,7 @@ * @author daisuke */ @TargetModel(IndexModel.class) - public enum IndexProperty implements JiemamyProperty { + public enum IndexProperty implements JiemamyProperty<IndexModel> { /** {@link IndexModel#getName()}で取得できるプロパティ */ name, @@ -237,7 +243,7 @@ * @author daisuke */ @TargetModel(KeyConstraintModel.class) - public enum KeyConstraintModelProperty implements JiemamyProperty { + public enum KeyConstraintModelProperty implements JiemamyProperty<KeyConstraintModel> { /** {@link KeyConstraintModel#getDeferrability()}で取得できるプロパティ */ deferrability, @@ -252,7 +258,7 @@ * @author daisuke */ @TargetModel(NotNullConstraintModel.class) - public enum NotNullConstraintProperty implements JiemamyProperty { + public enum NotNullConstraintProperty implements JiemamyProperty<NotNullConstraintModel> { } @@ -262,7 +268,7 @@ * @author daisuke */ @TargetModel(PrimaryKeyModel.class) - public enum PrimaryKeyProperty implements JiemamyProperty { + public enum PrimaryKeyProperty implements JiemamyProperty<PrimaryKeyModel> { } @@ -272,7 +278,7 @@ * @author daisuke */ @TargetModel(RecordModel.class) - public enum RecordProperty implements JiemamyProperty { + public enum RecordProperty implements JiemamyProperty<RecordModel> { /** {@link RecordModel#getValues()}で取得できるプロパティ */ values @@ -284,7 +290,7 @@ * @author daisuke */ @TargetModel(RootModel.class) - public enum RootProperty implements JiemamyProperty { + public enum RootProperty implements JiemamyProperty<RootModel> { /** {@link RootModel#getDialectClassName()}で取得できるプロパティ */ dialectClassName, @@ -317,7 +323,7 @@ * @author daisuke */ @TargetModel(TableCheckModel.class) - public enum TableCheckModelProperty implements JiemamyProperty { + public enum TableCheckModelProperty implements JiemamyProperty<TableCheckModel> { } @@ -327,7 +333,7 @@ * @author daisuke */ @TargetModel(TableModel.class) - public enum TableProperty implements JiemamyProperty { + public enum TableProperty implements JiemamyProperty<TableModel> { /** {@link TableModel#getAttributes()}で取得できるプロパティ */ attributes, @@ -342,7 +348,7 @@ * @author daisuke */ @TargetModel(UniqueKeyModel.class) - public enum UniqueKeyProperty implements JiemamyProperty { + public enum UniqueKeyProperty implements JiemamyProperty<UniqueKeyModel> { } @@ -352,7 +358,7 @@ * @author daisuke */ @TargetModel(ValueConstraintModel.class) - public enum ValueConstraintProperty implements JiemamyProperty { + public enum ValueConstraintProperty implements JiemamyProperty<ValueConstraintModel> { } @@ -362,7 +368,7 @@ * @author daisuke */ @TargetModel(ViewModel.class) - public enum ViewProperty implements JiemamyProperty { + public enum ViewProperty implements JiemamyProperty<ViewModel> { /** {@link ViewModel#getDefinition()}で取得できるプロパティ */ definition Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ExportException.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ExportException.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ExportException.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -30,12 +30,6 @@ /** * インスタンスを生成する。 - */ - public ExportException() { - } - - /** - * インスタンスを生成する。 * * @param cause 起因例外 */ Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ImportException.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ImportException.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/composer/ImportException.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -30,12 +30,6 @@ /** * インスタンスを生成する。 - */ - public ImportException() { - } - - /** - * インスタンスを生成する。 * * @param message 例外メッセージ */ 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-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/Dialect.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -69,11 +69,12 @@ List<SqlStatement> emitStatements(RootModel rootModel, EmitConfig config); /** - * TODO for daisuke + * 指定したカテゴリ、型名に最も適したモールドを取得する。 * - * @param category - * @param typeName - * @return + * @param category 型カテゴリ + * @param typeName 型名 + * @return モールド + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ BuiltinDataTypeMold findDataTypeMold(DataTypeCategory category, String typeName); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/editcommand/Command.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -18,13 +18,13 @@ */ package org.jiemamy.editcommand; -import java.util.Stack; - import org.jiemamy.model.JiemamyElement; /** * モデルを編集するためのコマンドのインターフェース。 * + * <p>このインターフェイスの実装は、イミュータブルでなければならない。</p> + * * @author daisuke * @author shin1ogawa */ @@ -33,14 +33,21 @@ /** * コマンドを実行する。 * - * <p>逆操作を行うコマンドは、与えられたスタックに追加する。</p> - * * @param commandProcessor コマンドプロセッサ - * @param commandStack undoの為のコマンドスタック */ - void execute(CommandProcessor commandProcessor, Stack<Command> commandStack); + void execute(CommandProcessor commandProcessor); /** + * 取り消しコマンドを取得する。 + * + * <p>このメソッドは、 {@link #execute(CommandProcessor)}を実行前後、どちらでも、 + * 同じ効果をもたらす取り消しコマンドを返さなければならない。</p> + * + * @return 取り消しコマンド + */ + Command getNegateCommand(); + + /** * 操作対象の{@link JiemamyElement}を返す。 * * @return 操作対象の{@link JiemamyElement} 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-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/RootModel.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -124,7 +124,6 @@ * 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/AttributeModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/AttributeModel.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -68,7 +68,6 @@ * 物理名を設定する。 * * @param name 物理名 - * @throws IllegalArgumentException {@code null}を許可しない実装の引数に{@code null}を与えた場合 */ void setName(String name); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/EntityModel.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -94,7 +94,6 @@ * エンティティ名を設定する。 * * @param name エンティティ名 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ void setName(String name); } Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/entity/ViewModel.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -35,7 +35,6 @@ * VIEW定義SELECT文を設定する。 * * @param definition VIEW定義SELECT文 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 */ void setDefinition(String definition); Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/Adaptable.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/Adaptable.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/Adaptable.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -37,13 +37,13 @@ /** * このオブジェクトにまつわる、指定した型を持つアダプタのインスタンスを取得する。 * - * <p>{@link #hasAdapter(Class)}の結果が{@code true}の場合は、この{@code null}を返してはならない(MUST)。 - * また、{@code false}の場合は、必ず{@code null}を返さなければならない(MUST)。</p> + * <p>このメソッドは{@code null}を返してはならない(MUST)。</p> * * @param <T> アダプタを表すクラス * @param adapterClass アダプタを表すクラス - * @return アダプタのインスタンス。該当するアダプタが存在しない場合、{@code null}を返す。 + * @return アダプタのインスタンス * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + * @throws AdapterNotFoundException 登録されていないアダプタを取得しようとした場合 */ <T>T getAdapter(Class<T> adapterClass); @@ -67,12 +67,12 @@ /** * アダプタを登録する。 * - * <p>アダプタは、{@link Adapter}アノテーションをつけなければならない。 + * <p>アダプタは、その実装クラスまたは上流の型のいずれかに{@link Adapter}アノテーションをつけなければならない。 * また、その場合そのアダプタは、同一性判別のため{@link Object#equals(Object)}メソッドをオーバーライド * していなければならない。</p> * * @param adapter 登録するアダプタ - * @throws UnsupportedOperationException + * @throws UnsupportedOperationException アダプタの追加登録をサポートしない場合 * @throws IllegalArgumentException 引数に{@code null}を与えた場合 * @throws IllegalArgumentException 引数のクラスに{@link Adapter}アノテーションがついていない場合 */ Added: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/AdapterNotFoundException.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/AdapterNotFoundException.java (rev 0) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/AdapterNotFoundException.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -0,0 +1,52 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +/** + * {@link Adaptable#getAdapter(Class)}により、登録されていないアダプタを取得しようとした場合。 + * + * @author daisuke + */ + @ SuppressWarnings("serial") +public class AdapterNotFoundException extends RuntimeException { + + /** 見つけられなかったアダプタの型 */ + private final Class<?> adapterClass; + + + /** + * インスタンスを生成する。 + * + * @param adapterClass 見つけられなかったアダプタの型 + */ + public AdapterNotFoundException(Class<?> adapterClass) { + super(adapterClass.getName()); + this.adapterClass = adapterClass; + } + + /** + * 見つけられなかったアダプタの型を取得する。 + * + * @return 見つけられなかったアダプタの型 + */ + public Class<?> getAdapterClass() { + return adapterClass; + } + +} Property changes on: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/utils/AdapterNotFoundException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/connection/ConnectionAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/connection/ConnectionAdapter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/connection/ConnectionAdapter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -53,9 +53,9 @@ boolean isSelfConnection(); /** - * TODO for daisuke + * このオブジェクトでラッピングされた、コアオブジェクトを取得する。 * - * @return + * @return コアとなっている外部キー */ ForeignKeyModel unwrap(); } Modified: zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/node/NodeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/node/NodeAdapter.java 2009-02-26 03:59:32 UTC (rev 2741) +++ zeus/trunk/jiemamy-spec-view/src/main/java/org/jiemamy/model/node/NodeAdapter.java 2009-02-26 09:17:10 UTC (rev 2742) @@ -48,9 +48,9 @@ Collection<ConnectionAdapter> getTargetConnections(); /** - * TODO for daisuke + * このオブジェクトでラッピングされた、コアオブジェクトを取得する。 * - * @return + * @return コアとなっているエンティティ */ EntityModel unwrap(); }