[Jiemamy-notify:1620] commit [2824] CreateConnectionでコマンドを使っていない操作をコマンド経由に修正。

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 3月 6日 (金) 00:58:22 JST


Revision: 2824
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2824
Author:   shin1
Date:     2009-03-06 00:58:22 +0900 (Fri, 06 Mar 2009)

Log Message:
-----------
CreateConnectionでコマンドを使っていない操作をコマンド経由に修正。

Modified Paths:
--------------
    artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java
    artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java


-------------- next part --------------
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-03-05 15:05:43 UTC (rev 2823)
+++ artemis/trunk/jiemamy-view/src/main/java/org/jiemamy/facade/JiemamyViewFacadeImpl.java	2009-03-05 15:58:22 UTC (rev 2824)
@@ -38,6 +38,7 @@
 import org.jiemamy.editcommand.RemoveBendpointCommand;
 import org.jiemamy.editcommand.RemoveConnectionViewCommand;
 import org.jiemamy.editcommand.RemoveNodeViewCommand;
+import org.jiemamy.editcommand.impl.AddColumnToColumnRefListCommand;
 import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand;
 import org.jiemamy.model.ConnectionProfile;
 import org.jiemamy.model.DiagramPresentationModel;
@@ -55,7 +56,6 @@
 import org.jiemamy.model.geometory.JmRectangle;
 import org.jiemamy.model.node.NodeAdapter;
 import org.jiemamy.utils.CollectionsUtil;
-import org.jiemamy.utils.model.ForeignKeyUtil;
 import org.jiemamy.utils.model.TableUtil;
 
 /**
@@ -158,7 +158,12 @@
 			ColumnModel keyColumn = sourceColumns.get(0);
 			ColumnModel refColumn = referenceResolver.resolve(columnRef);
 			
-			ForeignKeyUtil.addMapping(foreignKey, keyColumn, refColumn); // FIXME コマンドを使え
+			Command command = new AddColumnToColumnRefListCommand(foreignKey, foreignKey.getKeyColumns(), keyColumn);
+			command.execute(commandProcessor);
+			undoStack.push(command.getNegateCommand());
+			command = new AddColumnToColumnRefListCommand(foreignKey, foreignKey.getReferenceColumns(), refColumn);
+			command.execute(commandProcessor);
+			undoStack.push(command.getNegateCommand());
 		}
 		
 		super.addForeignKey(sourceTable, foreignKey);
@@ -166,14 +171,6 @@
 		redoStack.clear();
 	}
 	
-	public void removeNodeProfile(int diagramIndex, NodeAdapter nodeAdapter) {
-		RootModel rootModel = jiemamy.getFactory().getRootModel();
-		Command command = new RemoveNodeViewCommand(rootModel, diagramIndex, nodeAdapter);
-		command.execute(commandProcessor);
-		undoStack.push(command.getNegateCommand());
-		redoStack.clear();
-	}
-	
 	public void moveBendpoint(int diagramIndex, ConnectionAdapter connectionAdapter, int bendpointIndex,
 			JmPoint position) {
 		RootModel rootModel = jiemamy.getFactory().getRootModel();
@@ -235,6 +232,14 @@
 		return undoCount;
 	}
 	
+	public void removeNodeProfile(int diagramIndex, NodeAdapter nodeAdapter) {
+		RootModel rootModel = jiemamy.getFactory().getRootModel();
+		Command command = new RemoveNodeViewCommand(rootModel, diagramIndex, nodeAdapter);
+		command.execute(commandProcessor);
+		undoStack.push(command.getNegateCommand());
+		redoStack.clear();
+	}
+	
 	public void resetBendpoint(int diagramIndex, ConnectionAdapter connectionAdapter) {
 		RootModel rootModel = jiemamy.getFactory().getRootModel();
 		DiagramPresentations diagramPresentations = rootModel.getAdapter(DiagramPresentations.class);

Modified: artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java
===================================================================
--- artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java	2009-03-05 15:05:43 UTC (rev 2823)
+++ artemis/trunk/jiemamy-view/src/test/java/org/jiemamy/facade/JiemamyViewFacadeImplTest.java	2009-03-05 15:58:22 UTC (rev 2824)
@@ -104,22 +104,34 @@
 	}
 	
 	/**
-	 * {@link JiemamyViewFacadeImpl#removeNode(int, NodeAdapter)}のテスト。
+	 * {@link JiemamyViewFacadeImpl#createConnection(int, ConnectionAdapter, TableModel, TableModel)}のテスト。
 	 */
 	@Test
 	public void test_createConnection() {
 		TableModel[] tables = setUpForConnectionTest();
 		ForeignKeyModel foreignKey = jiemamyWithView.getFactory().newModel(ForeignKeyModel.class);
 		ConnectionAdapter connectionAdapter = new ConnectionAdapterImpl(foreignKey);
+		List<ForeignKeyModel> foreignKeys = TableUtil.getForeignKeys(tables[1]);
+		assertThat(foreignKeys.size(), is(0));
+		
+		SavePoint save = viewFacade.save();
 		viewFacade.createConnection(Migration.DIAGRAM_INDEX, connectionAdapter, tables[1], tables[0]);
 		logger.info(connectionAdapter.getSource().unwrap().toString());
 		assertThat(connectionAdapter.getSource().unwrap(), is((EntityModel) tables[1]));
 		assertThat(connectionAdapter.getTarget().unwrap(), is((EntityModel) tables[0]));
-		List<ForeignKeyModel> foreignKeys = TableUtil.getForeignKeys(tables[1]);
+		foreignKeys = TableUtil.getForeignKeys(tables[1]);
 		assertThat(foreignKeys.size(), is(1));
-		assertThat(foreignKeys.get(0).getKeyColumns().size(), is(1));
-		assertThat(referenceResolver.resolve(foreignKeys.get(0).getKeyColumns().get(0)), is(TableUtil.getColumns(
-				tables[1]).get(0)));
+		assertThat(foreignKeys.get(0), is(foreignKey));
+		assertThat(foreignKey.getKeyColumns().size(), is(1));
+		assertThat(foreignKey.getReferenceColumns().size(), is(1));
+		assertThat(referenceResolver.resolve(foreignKey.getKeyColumns().get(0)), is(TableUtil.getColumns(tables[1])
+			.get(0)));
+		
+		viewFacade.rollback(save);
+		foreignKeys = TableUtil.getForeignKeys(tables[1]);
+		assertThat(foreignKeys.size(), is(0));
+		assertThat(foreignKey.getKeyColumns().size(), is(0));
+		assertThat(foreignKey.getReferenceColumns().size(), is(0));
 	}
 	
 	/**



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