[Jiemamy-notify:1396] commit [2635] 編集コマンドとイベントブローカに関するソースをマージした。specへのインターフェースをpullupする作業とテストケースのマージはできていない。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 8日 (日) 23:38:33 JST


Revision: 2635
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2635
Author:   shin1
Date:     2009-02-08 23:38:33 +0900 (Sun, 08 Feb 2009)

Log Message:
-----------
編集コマンドとイベントブローカに関するソースをマージした。specへのインターフェースをpullupする作業とテストケースのマージはできていない。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java

Added Paths:
-----------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/EventBrokerImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/Command.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandListener.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.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/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/AddTableCommand.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/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/DeleteTableCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java	2009-02-08 14:14:33 UTC (rev 2634)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/Artemis.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -53,6 +53,9 @@
 	/** 参照オブジェクトから実体モデルを解決するリゾルバ */
 	private final ReferenceResolver resolver = new ReferenceResolverImpl();
 	
+	/** イベント通知を適切に行うブローカー */
+	private final EventBrokerImpl eventBroker = new EventBrokerImpl();
+	
 	/** 実装に施された拡張の配列 */
 	private final ArtemisExtender[] extensions;
 	
@@ -100,6 +103,14 @@
 	/**
 	 * {@inheritDoc}
 	 */
+	public EventBrokerImpl getEventBroker() {
+		assert eventBroker != null;
+		return eventBroker;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
 	public JiemamyFactory getFactory(Jiemamy jiemamy) {
 		Validate.notNull(jiemamy);
 		JiemamyFactory factory = factoryCache.get(jiemamy);

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/EventBrokerImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/EventBrokerImpl.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/EventBrokerImpl.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,71 @@
+package org.jiemamy;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.editcommand.CommandListener;
+import org.jiemamy.editcommand.CommandProcessor;
+import org.jiemamy.model.JiemamyElement;
+
+/**
+ * コマンドの実行を監視し、登録されている{@link CommandListener}にイベントを通知する。
+ * <p>{@link Command}が実行されたタイミングで、{@link #listeners}として保持している{@link CommandListener}の中で,
+ * {@link Command#getTarget()}を監視する必要があるものにイベントを通知する。</p>
+ * <p>{@link CommandProcessor}は{@link Command}を実行した時に、どこからかコイツを取得して
+ * {@link #fireCommandProcess(Command)}を実行する事。</p>
+ * 
+ * FIXME 当然こいつもインターフェースを用意してspecに置きたいが、
+ * CommandProcessorのインターフェースが用意されていない問題の影響を受けてしまっている。
+ * 
+ * @author shin1ogawa
+ */
+public class EventBrokerImpl {
+	
+	private List<CommandListener> listeners = new ArrayList<CommandListener>();
+	
+
+	/**
+	 * リスナを登録する。
+	 * 
+	 * @param listener
+	 */
+	public void addListener(CommandListener listener) {
+		listeners.add(listener);
+	}
+	
+	/**
+	 * 実行されたコマンドをイベントとして通知する。
+	 * 
+	 * @param command
+	 */
+	public void fireCommandProcess(Command command) {
+		JiemamyElement target = command.getTarget();
+		for (CommandListener l : listeners) {
+			if (requireNotification(l, target)) {
+				l.commandProcess(command);
+			}
+		}
+	}
+	
+	/**
+	 * リスなを削除する。
+	 * 
+	 * @param listener
+	 */
+	public void removeListener(CommandListener listener) {
+		listeners.remove(listener);
+	}
+	
+	/**
+	 * 通知が必要なリスナかどうか。
+	 * <p>targetの親を監視したい{@link CommandListener}へも通知する必要がある。</p>
+	 * 
+	 * @param l リスナ
+	 * @param target Commandが操作する対象の{@link JiemamyElement}
+	 * @return 通知が必要なら{@code true}、不要なら{@code false}
+	 */
+	private boolean requireNotification(CommandListener l, JiemamyElement target) {
+		return l.getTarget() == target || ReferenceResolverImpl.isChild(l.getTarget(), target);
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/EventBrokerImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

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-08 14:14:33 UTC (rev 2634)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/ReferenceResolverImpl.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -46,7 +46,7 @@
 	/**
 	 * 指定したModelが、指定したModelの配下にあるのかどうかを返す。
 	 * <p>Modelの構造の外で解決した方が良い気がするので、ここに置いてみた。</p>
-	 * <p>こんな適当な実装だとメソッドの中がエライ事になりそうだし、この実装はない。</p>
+	 * <p>FIXME こんな適当な実装だとメソッドの中がエライ事になりそうだし、この実装はない。なんかうまい実装は無いものか。</p>
 	 * 
 	 * @param parent
 	 * @param child

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/Command.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/Command.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/Command.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/01/15
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.editcommand;
+
+import java.util.Stack;
+
+import org.jiemamy.model.JiemamyElement;
+
+/**
+ * モデルを編集するためのコマンドのインターフェース
+ * 
+ * FIXME specに移動した方が良いと思うが、CommandProcessorのインターフェース化ができていない。
+ * 
+ * @author daisuke
+ * @author shin1ogawa
+ */
+public interface Command {
+	
+	/**
+	 * コマンドを実行する。
+	 * 
+	 * @param processor コマンドプロセッサ
+	 * @return 逆操作を行うコマンド
+	 * @throws Exception 
+	 */
+	Command execute(CommandProcessor processor) throws Exception;
+	
+	/**
+	 * コマンドを実行する。
+	 * 
+	 * <p>逆操作を行うコマンドは、与えられたスタックに追加する。</p>
+	 * 
+	 * @param commandProcessor コマンドプロセッサ
+	 * @param commandStack undoの為のコマンドスタック
+	 * @throws Exception 
+	 */
+	void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) throws Exception;
+	
+	/**
+	 * 操作対象の{@link JiemamyElement}を返す。
+	 * 
+	 * @return 操作対象の{@link JiemamyElement}
+	 */
+	JiemamyElement getTarget();
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/Command.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandListener.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandListener.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandListener.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,28 @@
+package org.jiemamy.editcommand;
+
+import org.jiemamy.EventBrokerImpl;
+import org.jiemamy.model.JiemamyElement;
+
+/**
+ * コマンドが実行されたイベントの通知を受け取るリスナ。
+ * 
+ * FIXME specに移動した方が良いと思うが、Command(->CommandProcessor)のインターフェース化ができていない。
+ * 
+ * @author shin1ogawa
+ */
+public interface CommandListener {
+	
+	/**
+	 * 監視対象に変更があった場合に{@link EventBrokerImpl}がCallbackしてくれる。
+	 * 
+	 * @param command
+	 */
+	void commandProcess(Command command);
+	
+	/**
+	 * 監視対象を返す。
+	 * 
+	 * @return 監視対象の{@link JiemamyElement}
+	 */
+	JiemamyElement getTarget();
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandListener.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/01/15
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific language
+ * governing permissions and limitations under the License.
+ */
+package org.jiemamy.editcommand;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+import org.jiemamy.EventBrokerImpl;
+import org.jiemamy.editcommand.impl.AddColumnCommand;
+import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand;
+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.DeleteForeignKeyCommand;
+import org.jiemamy.editcommand.impl.DeletePrimaryKeyCommand;
+import org.jiemamy.editcommand.impl.DeleteTableCommand;
+import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand;
+import org.jiemamy.model.JiemamyElement;
+import org.jiemamy.model.RootModel;
+import org.jiemamy.model.RootModelImpl;
+import org.jiemamy.model.attribute.ColumnModel;
+import org.jiemamy.model.attribute.ColumnRef;
+import org.jiemamy.model.attribute.ColumnRefImpl;
+import org.jiemamy.model.attribute.constraint.ForeignKeyModel;
+import org.jiemamy.model.attribute.constraint.PrimaryKeyModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * コマンドを実行するクラス。
+ * <p>全部のprocessメソッドにて{@link EventBrokerImpl#fireCommandProcess(Command)}を実行する。
+ * ここでイベントブローカーへの発火を行うのが本当に正しいかはワカラナイ!</p>
+ * 
+ * FIXME インターフェース化してspecへ移動した方が良いと思うが、specとしてprcoess()メソッドは公開できない。
+ * 
+ * @author daisuke
+ * @author shin1ogawa
+ */
+public class CommandProcessor {
+	
+	final EventBrokerImpl eventBroker;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * @param eventBroker 
+	 */
+	public CommandProcessor(EventBrokerImpl eventBroker) {
+		this.eventBroker = eventBroker;
+	}
+	
+	/**
+	 * {@link ColumnModel}を{@link TableModel}に追加するコマンドを実行する。
+	 * 
+	 * @param newColumnCommand
+	 */
+	public void process(AddColumnCommand newColumnCommand) {
+		ColumnModel column = newColumnCommand.getColumn();
+		TableModel table = newColumnCommand.getTable();
+		table.getAttributes().add(column);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(newColumnCommand);
+	}
+	
+	/**
+	 * {@link ColumnRef}のリストに{@link ColumnModel}を追加するコマンドを実行する。
+	 * 
+	 * @param command
+	 */
+	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()));
+		}
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(command);
+	}
+	
+	/**
+	 * {@link TableModel}に{@link ForeignKeyModel}を追加するコマンドを実行する。
+	 * 
+	 * @param newForeignKeyCommand
+	 */
+	public void process(AddForeignKeyCommand newForeignKeyCommand) {
+		ForeignKeyModel fk = newForeignKeyCommand.getFk();
+		TableModel table = newForeignKeyCommand.getTable();
+		table.getAttributes().add(fk);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(newForeignKeyCommand);
+	}
+	
+	/**
+	 * {@link TableModel}に{@link PrimaryKeyModel}を追加するコマンドを実行する。
+	 * 
+	 * @param newPrimaryKeyCommand
+	 */
+	public void process(AddPrimaryKeyCommand newPrimaryKeyCommand) {
+		PrimaryKeyModel pk = newPrimaryKeyCommand.getPrimaryKey();
+		TableModel table = newPrimaryKeyCommand.getTable();
+		table.getAttributes().add(pk);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(newPrimaryKeyCommand);
+	}
+	
+	/**
+	 * {@link RootModel}に{@link TableModel}を追加するコマンドを実行する。
+	 * 
+	 * @param newTableCommand
+	 */
+	public void process(AddTableCommand newTableCommand) {
+		TableModel table = newTableCommand.getTable();
+		RootModelImpl.class.cast(newTableCommand.getTarget()).getEntities().add(table);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(newTableCommand);
+	}
+	
+	/**
+	 * {@link TableModel}から{@link ColumnModel}を削除するコマンドを実行する。
+	 * 
+	 * @param deleteColumnCommand
+	 */
+	public void process(DeleteColumnCommand deleteColumnCommand) {
+		ColumnModel column = deleteColumnCommand.getColumn();
+		TableModel table = deleteColumnCommand.getTable();
+		table.getAttributes().remove(column);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(deleteColumnCommand);
+	}
+	
+	/**
+	 * {@link ColumnRef}のリストから{@link ColumnModel}を削除するコマンドを実行する。
+	 * 
+	 * @param command
+	 */
+	public void process(DeleteColumnFromColumnRefListCommand command) {
+		int index = command.getIndex();
+		command.getColumnRefList().remove(index);
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(command);
+	}
+	
+	/**
+	 * {@link TableModel}から{@link ForeignKeyModel}を削除するコマンドを実行する。
+	 * 
+	 * @param deleteForeignKeyCommand
+	 */
+	public void process(DeleteForeignKeyCommand deleteForeignKeyCommand) {
+		ForeignKeyModel fk = deleteForeignKeyCommand.getFk();
+		TableModel table = deleteForeignKeyCommand.getTable();
+		table.getAttributes().remove(fk);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(deleteForeignKeyCommand);
+	}
+	
+	/**
+	 * {@link TableModel}から{@link PrimaryKeyModel}を削除するコマンドを実行する。
+	 * 
+	 * @param deletePrimaryKeyCommand
+	 */
+	public void process(DeletePrimaryKeyCommand deletePrimaryKeyCommand) {
+		PrimaryKeyModel pk = deletePrimaryKeyCommand.getPrimaryKey();
+		TableModel table = deletePrimaryKeyCommand.getTable();
+		table.getAttributes().remove(pk);
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(deletePrimaryKeyCommand);
+	}
+	
+	/**
+	 * {@link RootModel}から{@link TableModel}を削除するコマンドを実行する。
+	 * 
+	 * @param deleteTableCommand
+	 */
+	public void process(DeleteTableCommand deleteTableCommand) {
+		deleteTableCommand.getRoot().getEntities().remove(deleteTableCommand.getTable());
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(deleteTableCommand);
+	}
+	
+	/**
+	 * モデルの属性を変更するコマンドを実行します。
+	 * 
+	 * @param command
+	 */
+	public void process(ModifyModelPropertyCommand command) {
+		JiemamyElement target = command.getTarget();
+		try {
+			BeanUtils.setProperty(target, command.getPropertyName(), command.getNewValue());
+		} catch (IllegalAccessException e) {
+			throw new RuntimeException(e);
+		} catch (InvocationTargetException e) {
+			throw new RuntimeException(e);
+		}
+		
+		// 面倒だけど、全部のprocessメソッドに入れる(Interceptorで手を抜きたい)。
+		eventBroker.fireCommandProcess(command);
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/CommandProcessor.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,38 @@
+/*
+ * 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.editcommand.impl;
+
+import java.util.Stack;
+
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.editcommand.CommandProcessor;
+
+/**
+ * {@link Command}を実装するための抽象クラス。
+ * 
+ * @author daisuke
+ */
+public abstract class AbstractCommand implements Command {
+	
+	public void execute(CommandProcessor commandProcessor, Stack<Command> commandStack) throws Exception {
+		Command undo = execute(commandProcessor);
+		commandStack.push(undo);
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AbstractCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,81 @@
+/*
+ * 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.attribute.ColumnModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link ColumnModel}を{@link TableModel}に追加するコマンド。
+ * 
+ * @author daisuke
+ */
+public class AddColumnCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final ColumnModel column;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param table 
+	 * @param column 
+	 */
+	public AddColumnCommand(TableModel table, ColumnModel column) {
+		this.table = table;
+		this.column = column;
+		
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new DeleteColumnCommand(table, column);
+	}
+	
+	/**
+	 * column
+	 * @return column
+	 */
+	public ColumnModel getColumn() {
+		return column;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/01/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.List;
+
+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;
+
+/**
+ * {@link ColumnRef}のリストに{@link ColumnModel}を追加するコマンド。
+ * 
+ * @author shin1ogawa
+ */
+public class AddColumnToColumnRefListCommand extends AbstractCommand implements Command {
+	
+	private final JiemamyElement target;
+	
+	private final List<ColumnRef> columnRefList;
+	
+	private final ColumnModel column;
+	
+	private int index = -1;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param target
+	 * @param columnRefList
+	 * @param column
+	 */
+	public AddColumnToColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList, ColumnModel column) {
+		super();
+		this.target = target;
+		this.columnRefList = columnRefList;
+		this.column = column;
+	}
+	
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param target
+	 * @param columnRefList
+	 * @param column
+	 * @param index
+	 */
+	public AddColumnToColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList, ColumnModel column,
+			int index) {
+		super();
+		this.target = target;
+		this.columnRefList = columnRefList;
+		this.column = column;
+		this.index = index;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new DeleteColumnFromColumnRefListCommand(target, columnRefList, column, index);
+	}
+	
+	/**
+	 * column
+	 * @return column
+	 */
+	public ColumnModel getColumn() {
+		return column;
+	}
+	
+	/**
+	 * columnRefList
+	 * @return columnRefList
+	 */
+	public List<ColumnRef> getColumnRefList() {
+		return columnRefList;
+	}
+	
+	/**
+	 * index
+	 * @return index
+	 */
+	public int getIndex() {
+		return index;
+	}
+	
+	/**
+	 * target
+	 * @return target
+	 */
+	public JiemamyElement getTarget() {
+		return target;
+	}
+	
+	/**
+	 * index
+	 * @param index index
+	 */
+	public void setIndex(int index) {
+		this.index = index;
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddColumnToColumnRefListCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,79 @@
+/*
+ * 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.attribute.constraint.ForeignKeyModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link TableModel}に{@link ForeignKeyModel}を追加するコマンド。
+ * 
+ * @author daisuke
+ */
+public class AddForeignKeyCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final ForeignKeyModel fk;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * @param table
+	 * @param fk 
+	 */
+	public AddForeignKeyCommand(TableModel table, ForeignKeyModel fk) {
+		this.table = table;
+		this.fk = fk;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new DeleteForeignKeyCommand(table, fk);
+	}
+	
+	/**
+	 * fk
+	 * @return fk
+	 */
+	public ForeignKeyModel getFk() {
+		return fk;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddForeignKeyCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,80 @@
+/*
+ * 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.attribute.constraint.PrimaryKeyModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link TableModel}に{@link PrimaryKeyModel}を追加するコマンド。
+ * 
+ * @author daisuke
+ */
+public class AddPrimaryKeyCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final PrimaryKeyModel primaryKey;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param table
+	 * @param primaryKey
+	 */
+	public AddPrimaryKeyCommand(TableModel table, PrimaryKeyModel primaryKey) {
+		this.table = table;
+		this.primaryKey = primaryKey;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new DeletePrimaryKeyCommand(table, primaryKey);
+	}
+	
+	/**
+	 * primaryKey
+	 * @return primaryKey
+	 */
+	public PrimaryKeyModel getPrimaryKey() {
+		return primaryKey;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddPrimaryKeyCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,81 @@
+/*
+ * 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();
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/AddTableCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,81 @@
+/*
+ * 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.attribute.ColumnModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link TableModel}から{@link ColumnModel}を削除するコマンド。
+ * 
+ * @author daisuke
+ */
+public class DeleteColumnCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final ColumnModel column;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param table 
+	 * @param column 
+	 */
+	public DeleteColumnCommand(TableModel table, ColumnModel column) {
+		this.table = table;
+		this.column = column;
+		
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new AddColumnCommand(table, column);
+	}
+	
+	/**
+	 * column
+	 * @return column
+	 */
+	public ColumnModel getColumn() {
+		return column;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/01/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.List;
+
+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;
+
+/**
+ * {@link ColumnRef}のリストから{@link ColumnModel}を削除するコマンド。
+ * 
+ * @author shin1ogawa
+ */
+public class DeleteColumnFromColumnRefListCommand extends AbstractCommand implements Command {
+	
+	private final JiemamyElement target;
+	
+	private final List<ColumnRef> columnRefList;
+	
+	private final ColumnModel column;
+	
+	private final int index;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param target
+	 * @param columnRefList
+	 * @param column
+	 */
+	public DeleteColumnFromColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList, ColumnModel column) {
+		super();
+		// List内での削除対象columnのindexを探す。
+		int i = 0;
+		for (ColumnRef ref : columnRefList) {
+			if (ref.getReferenceId().equals(column.getId())) {
+				break;
+			}
+			i++;
+		}
+		if (i >= columnRefList.size()) {
+			// List内に削除対象columnが見つからない。
+			throw new IllegalArgumentException();
+		}
+		index = i;
+		this.target = target;
+		this.columnRefList = columnRefList;
+		this.column = column;
+	}
+	
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param target
+	 * @param columnRefList
+	 * @param column
+	 * @param index
+	 */
+	public DeleteColumnFromColumnRefListCommand(JiemamyElement target, List<ColumnRef> columnRefList,
+			ColumnModel column, int index) {
+		super();
+		this.target = target;
+		this.columnRefList = columnRefList;
+		this.column = column;
+		this.index = index;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new AddColumnToColumnRefListCommand(target, columnRefList, column, index);
+	}
+	
+	/**
+	 * column
+	 * @return column
+	 */
+	public ColumnModel getColumn() {
+		return column;
+	}
+	
+	/**
+	 * columnRefList
+	 * @return columnRefList
+	 */
+	public List<ColumnRef> getColumnRefList() {
+		return columnRefList;
+	}
+	
+	/**
+	 * index
+	 * @return index
+	 */
+	public int getIndex() {
+		return index;
+	}
+	
+	/**
+	 * target
+	 * @return target
+	 */
+	public JiemamyElement getTarget() {
+		return target;
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteColumnFromColumnRefListCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,80 @@
+/*
+ * 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.attribute.constraint.ForeignKeyModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link TableModel}から{@link ForeignKeyModel}を削除するコマンド。
+ * 
+ * @author daisuke
+ */
+public class DeleteForeignKeyCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final ForeignKeyModel fk;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * @param table 
+	 * @param fk 
+	 */
+	public DeleteForeignKeyCommand(TableModel table, ForeignKeyModel fk) {
+		this.table = table;
+		this.fk = fk;
+		
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new AddForeignKeyCommand(table, fk);
+	}
+	
+	/**
+	 * fk
+	 * @return fk
+	 */
+	public ForeignKeyModel getFk() {
+		return fk;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteForeignKeyCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,80 @@
+/*
+ * 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.attribute.constraint.PrimaryKeyModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * {@link TableModel}から{@link PrimaryKeyModel}を削除するコマンド。
+ * 
+ * @author daisuke
+ */
+public class DeletePrimaryKeyCommand extends AbstractCommand implements Command {
+	
+	private final TableModel table;
+	
+	private final PrimaryKeyModel primaryKey;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param table
+	 * @param primaryKey
+	 */
+	public DeletePrimaryKeyCommand(TableModel table, PrimaryKeyModel primaryKey) {
+		this.table = table;
+		this.primaryKey = primaryKey;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		processor.process(this);
+		return new AddPrimaryKeyCommand(table, primaryKey);
+	}
+	
+	/**
+	 * primaryKey
+	 * @return primaryKey
+	 */
+	public PrimaryKeyModel getPrimaryKey() {
+		return primaryKey;
+	}
+	
+	/**
+	 * @return {@link TableModel}
+	 */
+	public TableModel getTable() {
+		return table;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public JiemamyElement getTarget() {
+		return getTable();
+	}
+	
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeletePrimaryKeyCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,81 @@
+/*
+ * 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();
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/DeleteTableCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Added: 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	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java	2009-02-08 14:38:33 UTC (rev 2635)
@@ -0,0 +1,93 @@
+/*
+ * 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.editcommand.impl;
+
+import java.lang.reflect.Constructor;
+
+import org.apache.commons.beanutils.BeanUtils;
+
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.editcommand.CommandProcessor;
+import org.jiemamy.model.JiemamyElement;
+
+/**
+ * モデルの属性を変更するコマンド。
+ * 
+ * @author shin1ogawa
+ */
+public class ModifyModelPropertyCommand extends AbstractCommand implements Command {
+	
+	/** 属性を変更する対象のモデル */
+	private final JiemamyElement target;
+	
+	/** 変更する属性のフィールド名称 */
+	private final String propertyName;
+	
+	/** 変更後の値 */
+	private Object newValue;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param target
+	 * @param propertyName
+	 * @param newValue
+	 */
+	public ModifyModelPropertyCommand(JiemamyElement target, String propertyName, Object newValue) {
+		this.target = target;
+		this.propertyName = propertyName;
+		this.newValue = newValue;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public Command execute(CommandProcessor processor) throws Exception {
+		Object oldValue = BeanUtils.getProperty(target, propertyName);
+		processor.process(this);
+		Constructor<? extends ModifyModelPropertyCommand> constructor =
+				getClass().getConstructor(JiemamyElement.class, String.class, Object.class);
+		return constructor.newInstance(target, propertyName, oldValue);
+	}
+	
+	/**
+	 * 変更後の値
+	 * @return 変更後の値
+	 */
+	public Object getNewValue() {
+		return newValue;
+	}
+	
+	/**
+	 * 変更する属性のフィールド名称
+	 * @return 変更する属性のフィールド名称
+	 */
+	public String getPropertyName() {
+		return propertyName;
+	}
+	
+	/**
+	 * 属性を変更する対象のモデル
+	 * @return 属性を変更する対象のモデル
+	 */
+	public JiemamyElement getTarget() {
+		return target;
+	}
+}


Property changes on: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/editcommand/impl/ModifyModelPropertyCommand.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain



Jiemamy-notify メーリングリストの案内
Back to archive index