svnno****@sourc*****
svnno****@sourc*****
2009年 2月 22日 (日) 01:15:06 JST
Revision: 2702 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2702 Author: shin1 Date: 2009-02-22 01:15:06 +0900 (Sun, 22 Feb 2009) Log Message: ----------- RootModelへModelを追加するためのコマンドを追加した。 Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java Added Paths: ----------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.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/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/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 Removed Paths: ------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.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-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -35,7 +35,7 @@ import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.impl.AddColumnCommand; -import org.jiemamy.editcommand.impl.AddTableCommand; +import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; import org.jiemamy.model.DiagramPresentationModel; import org.jiemamy.model.DiagramPresentations; @@ -84,7 +84,7 @@ Stack<Command> commandStack = new Stack<Command>(); TableModel table = factory.newModel(TableModel.class); - new AddTableCommand(rootModel, table).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); ColumnModel column1 = factory.newModel(ColumnModel.class); new AddColumnCommand(table, column1).execute(commandProcessor, commandStack); ColumnModel column2 = factory.newModel(ColumnModel.class); 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-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessorImpl.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -25,16 +25,22 @@ import org.jiemamy.EventBroker; import org.jiemamy.EventBrokerImpl; +import org.jiemamy.editcommand.impl.AbstractAddToRootCommand; +import org.jiemamy.editcommand.impl.AbstractDeleteFromRootCommand; import org.jiemamy.editcommand.impl.AddColumnCommand; import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand; +import org.jiemamy.editcommand.impl.AddDataSetToRootCommand; +import org.jiemamy.editcommand.impl.AddDomainToRootCommand; +import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.editcommand.impl.AddForeignKeyCommand; import org.jiemamy.editcommand.impl.AddPrimaryKeyCommand; -import org.jiemamy.editcommand.impl.AddTableCommand; import org.jiemamy.editcommand.impl.DeleteColumnCommand; import org.jiemamy.editcommand.impl.DeleteColumnFromColumnRefListCommand; +import org.jiemamy.editcommand.impl.DeleteDataSetFromRootCommand; +import org.jiemamy.editcommand.impl.DeleteDomainFromRootCommand; +import org.jiemamy.editcommand.impl.DeleteEntityFromRootCommand; import org.jiemamy.editcommand.impl.DeleteForeignKeyCommand; import org.jiemamy.editcommand.impl.DeletePrimaryKeyCommand; -import org.jiemamy.editcommand.impl.DeleteTableCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; import org.jiemamy.exception.JiemamyRuntimeException; import org.jiemamy.model.JiemamyElement; @@ -44,6 +50,9 @@ import org.jiemamy.model.attribute.ColumnRefImpl; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; +import org.jiemamy.model.dataset.DataSetModel; +import org.jiemamy.model.datatype.DomainModel; +import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; /** @@ -99,6 +108,33 @@ } /** + * {@link RootModel}に{@link DataSetModel}を追加するコマンドを実行する。 + * + * @param command + */ + public void process(AddDataSetToRootCommand command) { + processAddToRoot(command); + } + + /** + * {@link RootModel}に{@link DomainModel}を追加するコマンドを実行する。 + * + * @param command + */ + public void process(AddDomainToRootCommand command) { + processAddToRoot(command); + } + + /** + * {@link RootModel}に{@link EntityModel}を追加するコマンドを実行する。 + * + * @param command + */ + public void process(AddEntityToRootCommand command) { + processAddToRoot(command); + } + + /** * {@link TableModel}に{@link ForeignKeyModel}を追加するコマンドを実行する。 * * @param newForeignKeyCommand @@ -127,19 +163,6 @@ } /** - * {@link RootModel}に{@link TableModel}を追加するコマンドを実行する。 - * - * @param newTableCommand - */ - public void process(AddTableCommand newTableCommand) { - TableModel table = newTableCommand.getTable(); - RootModel.class.cast(newTableCommand.getTarget()).getEntities().add(table); - - // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 - eventBroker.fireCommandProcess(newTableCommand); - } - - /** * {@inheritDoc} */ public void process(Command command) { @@ -188,6 +211,33 @@ } /** + * {@link RootModel}から{@link DataSetModel}を削除するコマンドを実行する。 + * + * @param command + */ + public void process(DeleteDataSetFromRootCommand command) { + processDeleteFromRoot(command); + } + + /** + * {@link RootModel}から{@link DomainModel}を削除するコマンドを実行する。 + * + * @param command + */ + public void process(DeleteDomainFromRootCommand command) { + processDeleteFromRoot(command); + } + + /** + * {@link RootModel}から{@link EntityModel}を削除するコマンドを実行する。 + * + * @param command + */ + public void process(DeleteEntityFromRootCommand command) { + processDeleteFromRoot(command); + } + + /** * {@link TableModel}から{@link ForeignKeyModel}を削除するコマンドを実行する。 * * @param deleteForeignKeyCommand @@ -216,18 +266,6 @@ } /** - * {@link RootModel}から{@link TableModel}を削除するコマンドを実行する。 - * - * @param deleteTableCommand - */ - public void process(DeleteTableCommand deleteTableCommand) { - deleteTableCommand.getRoot().getEntities().remove(deleteTableCommand.getTable()); - - // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 - eventBroker.fireCommandProcess(deleteTableCommand); - } - - /** * モデルの属性を変更するコマンドを実行します。 * * @param command @@ -245,4 +283,48 @@ // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 eventBroker.fireCommandProcess(command); } + + /** + * {@link RootModel}に{@link JiemamyElement}を追加するコマンドを実行する。 + * + * @param <T> + * @param command + */ + private <T extends JiemamyElement>void processAddToRoot(AbstractAddToRootCommand<T> command) { + T element = command.getElement(); + command.getTargetList().add(element); + + // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 + eventBroker.fireCommandProcess(command); + } + + /** + * {@link RootModel}から{@link JiemamyElement}を削除するコマンドを実行する。 + * + * @param <T> + * @param command + */ + private <T extends JiemamyElement>void processDeleteFromRoot(AbstractDeleteFromRootCommand<T> command) { + command.getTargetList().remove(command.getElement()); + + // 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。 + eventBroker.fireCommandProcess(command); + } + +// private void processAmbiguous(Command command) throws IllegalArgumentException, IllegalAccessException, +// InvocationTargetException, NoSuchMethodException { +// // 実行時に曖昧にディスパッチする。 +// Method[] methods = CommandProcessorImpl.class.getMethods(); +// for (Method method : methods) { +// if (method.getName().equals("process")) { +// Class<?>[] parameterTypes = method.getParameterTypes(); +// if (ArrayUtils.isEmpty(parameterTypes) == false +// && command.getClass().isAssignableFrom(parameterTypes[0])) { +// method.invoke(this, command); +// return; +// } +// } +// } +// throw new NoSuchMethodException("process(" + command + ")"); +// } } Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,86 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/21 + * + * 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.editcommand.impl; + +import java.util.Collection; + +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 + * @see AbstractDeleteFromRootCommand + */ +public abstract class AbstractAddToRootCommand<T extends JiemamyElement> extends AbstractCommand implements Command { + + private final T element; + + /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ + private final RootModel root; + + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public AbstractAddToRootCommand(RootModel root, T element) { + super(); + this.root = root; + this.element = element; + } + + public Command execute(CommandProcessor processor) throws Exception { + processor.process(this); + return createDeleteFromRootCommand(root, element); + } + + /** + * return the element. + * @return the element + */ + public T getElement() { + return element; + } + + /** + * retuen the root. + * @return the root + */ + public RootModel getRoot() { + return root; + } + + public JiemamyElement getTarget() { + return getRoot(); + } + + /** + * @return {@link RootModel}が保持する、{@link JiemamyElement}のリスト + */ + public abstract Collection<? super T> getTargetList(); + + abstract AbstractDeleteFromRootCommand<T> createDeleteFromRootCommand(RootModel root, T element); +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractAddToRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,86 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/21 + * + * 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.editcommand.impl; + +import java.util.Collection; + +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 + * @see AbstractAddToRootCommand + */ +public abstract class AbstractDeleteFromRootCommand<T extends JiemamyElement> extends AbstractCommand implements + Command { + + private final T element; + + /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ + private final RootModel root; + + + /** + * インスタンスを生成する。 + * @param root + * @param element + */ + public AbstractDeleteFromRootCommand(RootModel root, T element) { + super(); + this.root = root; + this.element = element; + } + + public Command execute(CommandProcessor processor) throws Exception { + processor.process(this); + return createAddToRootCommand(root, element); + } + + /** + * return the element. + * @return the element + */ + public T getElement() { + return element; + } + + /** + * retuen the root. + * @return the root + */ + public RootModel getRoot() { + return root; + } + + public JiemamyElement getTarget() { + return getRoot(); + } + + /** + * @return {@link RootModel}が保持する、{@link JiemamyElement}のリスト + */ + public abstract Collection<? super T> getTargetList(); + + abstract AbstractAddToRootCommand<T> createAddToRootCommand(RootModel root, T element); +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractDeleteFromRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,59 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.RootModel; +import org.jiemamy.model.dataset.DataSetModel; + +/** + * {@link RootModel}に{@link DataSetModel}を追加するコマンド。 + * + * @see DeleteDataSetFromRootCommand + * @author shin1ogawa + */ +public class AddDataSetToRootCommand extends AbstractAddToRootCommand<DataSetModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public AddDataSetToRootCommand(RootModel root, DataSetModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super DataSetModel> getTargetList() { + return getRoot().getDataSets(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractDeleteFromRootCommand<DataSetModel> createDeleteFromRootCommand(RootModel root, DataSetModel element) { + return new DeleteDataSetFromRootCommand(root, element); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDataSetToRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,59 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.RootModel; +import org.jiemamy.model.datatype.DomainModel; + +/** + * {@link RootModel}に{@link DomainModel}を追加するコマンド。 + * + * @see DeleteDomainFromRootCommand + * @author shin1ogawa + */ +public class AddDomainToRootCommand extends AbstractAddToRootCommand<DomainModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public AddDomainToRootCommand(RootModel root, DomainModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super DomainModel> getTargetList() { + return getRoot().getDomains(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractDeleteFromRootCommand<DomainModel> createDeleteFromRootCommand(RootModel root, DomainModel element) { + return new DeleteDomainFromRootCommand(root, element); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddDomainToRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,61 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.AbstractEntityModel; +import org.jiemamy.model.entity.EntityModel; + +/** + * {@link RootModel}に{@link AbstractEntityModel}を追加するコマンド。 + * + * @see DeleteEntityFromRootCommand + * @author shin1ogawa + */ +public class AddEntityToRootCommand extends AbstractAddToRootCommand<EntityModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public AddEntityToRootCommand(RootModel root, EntityModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super EntityModel> getTargetList() { + return getRoot().getEntities(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractDeleteFromRootCommand<EntityModel> createDeleteFromRootCommand(RootModel root, EntityModel element) { + return new DeleteEntityFromRootCommand(root, element); + } + +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddEntityToRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java 2009-02-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -1,81 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/18 - * - * 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.editcommand.impl; - -import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; -import org.jiemamy.model.JiemamyElement; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.entity.TableModel; - -/** - * {@link RootModel}に{@link TableModel}を追加するコマンド。 - * - * @author daisuke - */ -public class AddTableCommand extends AbstractCommand implements Command { - - private final TableModel table; - - /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ - private final RootModel root; - - - /** - * インスタンスを生成する。 - * - * @param root - * @param table - */ - public AddTableCommand(RootModel root, TableModel table) { - this.root = root; - this.table = table; - } - - /** - * {@inheritDoc} - */ - public Command execute(CommandProcessor processor) throws Exception { - processor.process(this); - return new DeleteTableCommand(root, table); - } - - /** - * イベントのバブリングのために{@link #getTarget()}で返す対象として必要。1 - * @return イベントのバブリングのために{@link #getTarget()}で返す対象として必要。1 - */ - public RootModel getRoot() { - return root; - } - - /** - * table - * @return table - */ - public TableModel getTable() { - return table; - } - - /** - * {@inheritDoc} - */ - public JiemamyElement getTarget() { - return getRoot(); - } -} Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,59 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.RootModel; +import org.jiemamy.model.dataset.DataSetModel; + +/** + * {@link RootModel}から{@link DataSetModel}を削除するコマンド。 + * + * @see AddDataSetToRootCommand + * @author shin1ogawa + */ +public class DeleteDataSetFromRootCommand extends AbstractDeleteFromRootCommand<DataSetModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public DeleteDataSetFromRootCommand(RootModel root, DataSetModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super DataSetModel> getTargetList() { + return getRoot().getDataSets(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractAddToRootCommand<DataSetModel> createAddToRootCommand(RootModel root, DataSetModel element) { + return new AddDataSetToRootCommand(root, element); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDataSetFromRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,59 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.RootModel; +import org.jiemamy.model.datatype.DomainModel; + +/** + * {@link RootModel}から{@link DomainModel}を削除するコマンド。 + * + * @see AddDomainToRootCommand + * @author shin1ogawa + */ +public class DeleteDomainFromRootCommand extends AbstractDeleteFromRootCommand<DomainModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public DeleteDomainFromRootCommand(RootModel root, DomainModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super DomainModel> getTargetList() { + return getRoot().getDomains(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractAddToRootCommand<DomainModel> createAddToRootCommand(RootModel root, DomainModel element) { + return new AddDomainToRootCommand(root, element); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteDomainFromRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: 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 (rev 0) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -0,0 +1,60 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/18 + * + * 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.editcommand.impl; + +import java.util.Collection; + +import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.RootModel; +import org.jiemamy.model.entity.EntityModel; + +/** + * {@link RootModel}から{@link JiemamyElement}を削除するコマンド。 + * + * @see AddEntityToRootCommand + * @author shin1ogawa + */ +public class DeleteEntityFromRootCommand extends AbstractDeleteFromRootCommand<EntityModel> { + + /** + * インスタンスを生成する。 + * + * @param root + * @param element + */ + public DeleteEntityFromRootCommand(RootModel root, EntityModel element) { + super(root, element); + } + + /** + * {@inheritDoc} + */ + @Override + public Collection<? super EntityModel> getTargetList() { + return getRoot().getEntities(); + } + + /** + * {@inheritDoc} + */ + @Override + AbstractAddToRootCommand<EntityModel> createAddToRootCommand(RootModel root, EntityModel element) { + return new AddEntityToRootCommand(root, element); + } +} Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteEntityFromRootCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.java 2009-02-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -1,81 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/18 - * - * 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.editcommand.impl; - -import org.jiemamy.editcommand.Command; -import org.jiemamy.editcommand.CommandProcessor; -import org.jiemamy.model.JiemamyElement; -import org.jiemamy.model.RootModel; -import org.jiemamy.model.entity.TableModel; - -/** - * {@link RootModel}から{@link TableModel}を削除するコマンド。 - * - * @author daisuke - */ -public class DeleteTableCommand extends AbstractCommand implements Command { - - private final TableModel table; - - /** イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 */ - private final RootModel root; - - - /** - * インスタンスを生成する。 - * - * @param root - * @param table - */ - public DeleteTableCommand(RootModel root, TableModel table) { - this.root = root; - this.table = table; - } - - /** - * {@inheritDoc} - */ - public Command execute(CommandProcessor processor) throws Exception { - processor.process(this); - return new AddTableCommand(root, table); - } - - /** - * イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 - * @return イベントのバブリングのために{@link #getTarget()}で返す対象として必要。 - */ - public RootModel getRoot() { - return root; - } - - /** - * table - * @return table - */ - public TableModel getTable() { - return table; - } - - /** - * {@inheritDoc} - */ - public JiemamyElement getTarget() { - return getRoot(); - } -} 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-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/EventBrokerImplTest.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -36,8 +36,8 @@ import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.impl.AddColumnCommand; import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand; +import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.editcommand.impl.AddPrimaryKeyCommand; -import org.jiemamy.editcommand.impl.AddTableCommand; import org.jiemamy.editcommand.impl.DeleteColumnCommand; import org.jiemamy.editcommand.impl.DeleteColumnFromColumnRefListCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; @@ -178,7 +178,7 @@ @Test public void testバブリング() throws Exception { TableModel table = factory.newModel(TableModel.class); - new AddTableCommand(rootModel, table).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); ColumnModel column = factory.newModel(ColumnModel.class); new AddColumnCommand(table, column).execute(commandProcessor, commandStack); @@ -202,7 +202,7 @@ .execute(commandProcessor, commandStack); // columnListener,tableListener,rootListenerへ通知される new AddColumnCommand(table, factory.newModel(ColumnModel.class)) // 新たに作成したcolumnを追加する。 .execute(commandProcessor, commandStack); // tableListener, rootListenerへ通知されるはず。 - new AddTableCommand(rootModel, factory.newModel(TableModel.class)) // 新たに作成したtableを追加する。 + new AddEntityToRootCommand(rootModel, factory.newModel(TableModel.class)) // 新たに作成したtableを追加する。 .execute(commandProcessor, commandStack); // rootListenerへ通知されるはず。 assertThat(table.getAttributes().size(), is(2)); @@ -218,7 +218,7 @@ assertThat(rootListener.commandList.get(0), instanceOf(ModifyModelPropertyCommand.class)); assertThat(rootListener.commandList.get(1), instanceOf(ModifyModelPropertyCommand.class)); assertThat(rootListener.commandList.get(2), instanceOf(AddColumnCommand.class)); - assertThat(rootListener.commandList.get(3), instanceOf(AddTableCommand.class)); + assertThat(rootListener.commandList.get(3), instanceOf(AddEntityToRootCommand.class)); columnListener.commandList.clear(); tableListener.commandList.clear(); @@ -249,8 +249,8 @@ 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 AddTableCommand(rootModel, emp).execute(commandProcessor, commandStack); - new AddTableCommand(rootModel, dept).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, emp).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, dept).execute(commandProcessor, commandStack); // Listenerを作成、追加する。 DefaultCommandListener empListener = new DefaultCommandListener(emp); 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-21 13:43:00 UTC (rev 2701) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/ReferenceResolverImplTest.java 2009-02-21 16:15:06 UTC (rev 2702) @@ -34,11 +34,11 @@ import org.jiemamy.editcommand.CommandProcessorImpl; import org.jiemamy.editcommand.impl.AddColumnCommand; import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand; +import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.editcommand.impl.AddPrimaryKeyCommand; -import org.jiemamy.editcommand.impl.AddTableCommand; import org.jiemamy.editcommand.impl.DeleteColumnCommand; import org.jiemamy.editcommand.impl.DeleteColumnFromColumnRefListCommand; -import org.jiemamy.editcommand.impl.DeleteTableCommand; +import org.jiemamy.editcommand.impl.DeleteEntityFromRootCommand; import org.jiemamy.model.RootModel; import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.PrimaryKeyModel; @@ -88,7 +88,7 @@ public void test01親子関係の判断() throws Exception { Stack<Command> commandStack = new Stack<Command>(); TableModel table = factory.newModel(TableModel.class); - new AddTableCommand(rootModel, table).execute(commandProcessor, commandStack); + new AddEntityToRootCommand(rootModel, table).execute(commandProcessor, commandStack); ColumnModel column1 = factory.newModel(ColumnModel.class); new AddColumnCommand(table, column1).execute(commandProcessor, commandStack); ColumnModel column2 = factory.newModel(ColumnModel.class); @@ -146,7 +146,7 @@ Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(primaryKey, column1.getId()), Matchers.is(false)); // talbeをRootModelから削除する。 - new DeleteTableCommand(rootModel, table).execute(commandProcessor, commandStack); + new DeleteEntityFromRootCommand(rootModel, table).execute(commandProcessor, commandStack); Assert.assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, column1.getId()), Matchers.is(false)); Assert .assertThat(ReferenceResolverImpl.isDescendFromElement(rootModel, primaryKey.getId()), Matchers.is(false));