svnno****@sourc*****
svnno****@sourc*****
2009年 3月 4日 (水) 01:50:12 JST
Revision: 2797 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2797 Author: shin1 Date: 2009-03-04 01:50:12 +0900 (Wed, 04 Mar 2009) Log Message: ----------- Columnを追加するファサードメソッドを追加した。 Modified Paths: -------------- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/facade/JiemamyFacadeImplTest.java -------------- next part -------------- Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-03 16:38:28 UTC (rev 2796) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/facade/JiemamyFacadeImpl.java 2009-03-03 16:50:12 UTC (rev 2797) @@ -27,12 +27,14 @@ import org.jiemamy.editcommand.Command; import org.jiemamy.editcommand.CommandProcessor; import org.jiemamy.editcommand.CommandProcessorImpl; +import org.jiemamy.editcommand.impl.AddColumnCommand; import org.jiemamy.editcommand.impl.AddEntityToRootCommand; import org.jiemamy.editcommand.impl.AddForeignKeyCommand; import org.jiemamy.editcommand.impl.DeleteEntityFromRootCommand; import org.jiemamy.editcommand.impl.DeleteForeignKeyCommand; import org.jiemamy.editcommand.impl.ModifyModelPropertyCommand; import org.jiemamy.model.JiemamyElement; +import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.attribute.constraint.ForeignKeyModel; import org.jiemamy.model.entity.EntityModel; import org.jiemamy.model.entity.TableModel; @@ -69,6 +71,19 @@ } /** + * {@link TableModel}に{@link ColumnModel}を追加する。 + * + * @param table + * @param column + */ + public void addColumn(TableModel table, ColumnModel column) { + AddColumnCommand command = new AddColumnCommand(table, column); + command.execute(getCommandProcessor()); + undoStack.push(command.getNegateCommand()); + redoStack.clear(); + } + + /** * TODO for daisuke * * @param entity Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/facade/JiemamyFacadeImplTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/facade/JiemamyFacadeImplTest.java 2009-03-03 16:38:28 UTC (rev 2796) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/facade/JiemamyFacadeImplTest.java 2009-03-03 16:50:12 UTC (rev 2797) @@ -30,7 +30,9 @@ import org.jiemamy.JiemamyFactory; import org.jiemamy.JiemamyProperty.EntityProperty; import org.jiemamy.model.RootModel; +import org.jiemamy.model.attribute.ColumnModel; import org.jiemamy.model.entity.TableModel; +import org.jiemamy.utils.model.TableUtil; /** * {@link JiemamyFacadeImpl}のテストクラス。 @@ -67,6 +69,44 @@ } /** + * {@link JiemamyFacadeImpl#addColumn(TableModel, ColumnModel)}のテスト。 + */ + @Test + public void test_addColumn() { + TableModel table = jiemamy.getFactory().newModel(TableModel.class); + coreFacade.addEntity(table); + ColumnModel column1 = jiemamy.getFactory().newModel(ColumnModel.class); + ColumnModel column2 = jiemamy.getFactory().newModel(ColumnModel.class); + ColumnModel column3 = jiemamy.getFactory().newModel(ColumnModel.class); + assertThat(TableUtil.getColumns(table).size(), is(0)); + + coreFacade.addColumn(table, column1); + assertThat(TableUtil.getColumns(table).size(), is(1)); + assertThat(TableUtil.getColumns(table).get(0), is(column1)); + + coreFacade.addColumn(table, column2); + assertThat(TableUtil.getColumns(table).size(), is(2)); + assertThat(TableUtil.getColumns(table).get(0), is(column1)); + assertThat(TableUtil.getColumns(table).get(1), is(column2)); + + coreFacade.undo(); + assertThat(TableUtil.getColumns(table).size(), is(1)); + assertThat(TableUtil.getColumns(table).get(0), is(column1)); + + coreFacade.addColumn(table, column2); + coreFacade.addColumn(table, column3); + assertThat(TableUtil.getColumns(table).size(), is(3)); + assertThat(TableUtil.getColumns(table).get(0), is(column1)); + assertThat(TableUtil.getColumns(table).get(1), is(column2)); + assertThat(TableUtil.getColumns(table).get(2), is(column3)); + + coreFacade.undo(); + coreFacade.undo(); + coreFacade.undo(); + assertThat(TableUtil.getColumns(table).size(), is(0)); + } + + /** * {@link JiemamyFacadeImpl#addEntity(org.jiemamy.model.entity.EntityModel)}のテスト。 */ @Test