[Jiemamy-notify:2204] commit [3262] レコードテーブル追加の処理をコマンド経由で実装。 /

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 4月 14日 (火) 00:46:11 JST


Revision: 3262
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3262
Author:   daisuke_m
Date:     2009-04-14 00:46:11 +0900 (Tue, 14 Apr 2009)

Log Message:
-----------
レコードテーブル追加の処理をコマンド経由で実装。/
Domainの追加時にエラーを起こしていたので対策。/
DatabaseTestが落ちていた(スキーマ絡み)ので対策。/
javadoc / refactor

Modified Paths:
--------------
    artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java
    hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java
    hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
    leto/jiemamy-test-helper/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java

Added Paths:
-----------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/AddRecordsToDataSetCommand.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/RemoveRecordsFromDataSetCommand.java

Removed Paths:
-------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/test/


-------------- next part --------------
Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java
===================================================================
--- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -281,7 +281,7 @@
 			DefaultDatabaseImportConfig importConfig = new DefaultDatabaseImportConfig();
 			BeanUtils.copyProperties(importConfig, connectionConfig);
 			importConfig.setDialect(jiemamy.getDialect(jiemamy.getFactory().getRootModel()));
-			importConfig.setSchema(jiemamy.getFactory().getRootModel().getSchemaName());
+//			importConfig.setSchema(jiemamy.getFactory().getRootModel().getSchemaName());
 			
 			databaseCleaner.clean(importConfig);
 			

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/JiemamyFacadeImpl.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -19,7 +19,6 @@
 package org.jiemamy.internal;
 
 import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 
@@ -47,6 +46,7 @@
 import org.jiemamy.internal.editcommand.AddEntityToRootCommand;
 import org.jiemamy.internal.editcommand.AddIndexColumnCommand;
 import org.jiemamy.internal.editcommand.AddIndexCommand;
+import org.jiemamy.internal.editcommand.AddRecordsToDataSetCommand;
 import org.jiemamy.internal.editcommand.ModifyModelPropertyCommand;
 import org.jiemamy.internal.editcommand.RemoveAttributeCommand;
 import org.jiemamy.internal.editcommand.RemoveColumnFromColumnRefListCommand;
@@ -55,6 +55,7 @@
 import org.jiemamy.internal.editcommand.RemoveEntityFromRootCommand;
 import org.jiemamy.internal.editcommand.RemoveIndexColumnCommand;
 import org.jiemamy.internal.editcommand.RemoveIndexCommand;
+import org.jiemamy.internal.editcommand.RemoveRecordsFromDataSetCommand;
 import org.jiemamy.internal.editcommand.SetRecordValueCommand;
 import org.jiemamy.internal.editcommand.SwapListElementCommand;
 import org.jiemamy.internal.editcommand.UpdateForeignKeyMappingCommand;
@@ -206,10 +207,9 @@
 	}
 	
 	public void addRecords(DataSetModel dataSetModel, TableModel tableModel) {
-		// TODO コマンド化せよ
-		JiemamyFactory factory = jiemamy.getFactory();
-		dataSetModel.getRecords().put(factory.newReference(tableModel), new ArrayList<RecordModel>());
-		
+		Command command = new AddRecordsToDataSetCommand(eventBroker, dataSetModel, tableModel);
+		command.execute();
+		undoStack.push(command.getNegateCommand());
 	}
 	
 	public <T extends JiemamyElement>void changeModelProperty(T element, JiemamyProperty<T> property, Object newValue) {
@@ -275,7 +275,7 @@
 			List<ColumnModel> columns = TableUtil.getColumns(tableModel);
 			for (ColumnModel columnModel : columns) {
 				if (columnModel.getDataType().equals(domainRef)) {
-					BuiltinDataType domainDataType = domainModel.getDataType();
+					BuiltinDataType domainDataType = (BuiltinDataType) domainModel.getDataType();
 					BuiltinDataTypeMold mold = dialect.findDataTypeMold(domainDataType);
 					BuiltinDataType newDataType = factory.newDataType(mold);
 					
@@ -384,10 +384,9 @@
 	}
 	
 	public void removeRecords(DataSetModel dataSetModel, TableModel tableModel) {
-		// TODO コマンド化せよ
-		JiemamyFactory factory = jiemamy.getFactory();
-		dataSetModel.getRecords().remove(factory.newReference(tableModel));
-		
+		Command command = new RemoveRecordsFromDataSetCommand(eventBroker, dataSetModel, tableModel);
+		command.execute();
+		undoStack.push(command.getNegateCommand());
 	}
 	
 	public void rollback(SavePoint savePoint) {

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/AddRecordsToDataSetCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/AddRecordsToDataSetCommand.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/AddRecordsToDataSetCommand.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/13
+ *
+ * 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.internal.editcommand;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jiemamy.EventBroker;
+import org.jiemamy.JiemamyFactory;
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.model.JiemamyElement;
+import org.jiemamy.model.dataset.DataSetModel;
+import org.jiemamy.model.dataset.RecordModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class AddRecordsToDataSetCommand extends AbstractCommand {
+	
+	private final DataSetModel dataSetModel;
+	
+	private final TableModel tableModel;
+	
+	private final List<RecordModel> records;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param eventBroker イベント通知用{@link EventBroker}
+	 * @param dataSetModel レコード削除元の{@link DataSetModel}
+	 * @param tableModel レコード削除対象の{@link TableModel}
+	 */
+	public AddRecordsToDataSetCommand(EventBroker eventBroker, DataSetModel dataSetModel, TableModel tableModel) {
+		this(eventBroker, dataSetModel, tableModel, new ArrayList<RecordModel>());
+	}
+	
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param eventBroker イベント通知用{@link EventBroker}
+	 * @param dataSetModel レコード削除元の{@link DataSetModel}
+	 * @param tableModel レコード削除対象の{@link TableModel}
+	 * @param records
+	 */
+	public AddRecordsToDataSetCommand(EventBroker eventBroker, DataSetModel dataSetModel, TableModel tableModel,
+			List<RecordModel> records) {
+		super(eventBroker);
+		this.dataSetModel = dataSetModel;
+		this.tableModel = tableModel;
+		this.records = records;
+	}
+	
+	public Command getNegateCommand() {
+		return new RemoveRecordsFromDataSetCommand(getEventBroker(), dataSetModel, tableModel);
+	}
+	
+	public JiemamyElement getTarget() {
+		return dataSetModel;
+	}
+	
+	@Override
+	protected void execute0() {
+		if (records == null) {
+			return;
+		}
+		JiemamyFactory factory = dataSetModel.getJiemamy().getFactory();
+		dataSetModel.getRecords().put(factory.newReference(tableModel), records);
+	}
+	
+}


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

Added: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/RemoveRecordsFromDataSetCommand.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/RemoveRecordsFromDataSetCommand.java	                        (rev 0)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/editcommand/RemoveRecordsFromDataSetCommand.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/13
+ *
+ * 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.internal.editcommand;
+
+import java.util.List;
+
+import org.jiemamy.EventBroker;
+import org.jiemamy.JiemamyFactory;
+import org.jiemamy.editcommand.Command;
+import org.jiemamy.model.JiemamyElement;
+import org.jiemamy.model.dataset.DataSetModel;
+import org.jiemamy.model.dataset.RecordModel;
+import org.jiemamy.model.entity.TableModel;
+
+/**
+ * TODO for daisuke
+ * 
+ * @author daisuke
+ */
+public class RemoveRecordsFromDataSetCommand extends AbstractCommand {
+	
+	private final DataSetModel dataSetModel;
+	
+	private final TableModel tableModel;
+	
+	private final List<RecordModel> records;
+	
+
+	/**
+	 * インスタンスを生成する。
+	 * 
+	 * @param eventBroker イベント通知用{@link EventBroker}
+	 * @param dataSetModel レコード追加対象の{@link DataSetModel}
+	 * @param tableModel レコード追加対象の{@link TableModel}
+	 */
+	public RemoveRecordsFromDataSetCommand(EventBroker eventBroker, DataSetModel dataSetModel, TableModel tableModel) {
+		super(eventBroker);
+		this.dataSetModel = dataSetModel;
+		this.tableModel = tableModel;
+		
+		JiemamyFactory factory = dataSetModel.getJiemamy().getFactory();
+		records = dataSetModel.getRecords().get(factory.newReference(tableModel));
+	}
+	
+	public Command getNegateCommand() {
+		return new AddRecordsToDataSetCommand(getEventBroker(), dataSetModel, tableModel, records);
+	}
+	
+	public JiemamyElement getTarget() {
+		return dataSetModel;
+	}
+	
+	@Override
+	protected void execute0() {
+		JiemamyFactory factory = dataSetModel.getJiemamy().getFactory();
+		dataSetModel.getRecords().remove(factory.newReference(tableModel));
+	}
+	
+}


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

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -84,7 +84,7 @@
 		return checkConstraint;
 	}
 	
-	public BuiltinDataType getDataType() {
+	public DataType getDataType() {
 		return dataType;
 	}
 	

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/DatabaseCleaner.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -27,6 +27,8 @@
 import java.util.Properties;
 
 import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import org.jiemamy.Jiemamy;
 import org.jiemamy.JiemamyFactory;
@@ -45,6 +47,9 @@
  */
 public class DatabaseCleaner {
 	
+	private static Logger logger = LoggerFactory.getLogger(DatabaseCleaner.class);
+	
+
 	/**
 	 * データベースのエンティティなどを全て削除する。
 	 * 
@@ -52,6 +57,7 @@
 	 * @throws ImportException DB情報の読み込みに失敗した場合
 	 */
 	public void clean(DatabaseImportConfig config) throws ImportException {
+		logger.info("clean: " + config.getUri());
 		Jiemamy jiemamy = Jiemamy.newInstance();
 		JiemamyFactory factory = jiemamy.getFactory();
 		RootModel rootModel = factory.getRootModel();

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/utils/model/DataTypeUtil.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -62,7 +62,7 @@
 		if (dataType instanceof DomainRef) {
 			DomainRef domainRef = (DomainRef) dataType;
 			DomainModel domainModel = resolver.resolve(domainRef);
-			builtin = domainModel.getDataType();
+			builtin = (BuiltinDataType) domainModel.getDataType();
 		} else if (dataType instanceof BuiltinDataType) {
 			builtin = (BuiltinDataType) dataType;
 		} else {

Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/root/RootEditDialogDomainTab.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -346,11 +346,11 @@
 			txtDescription.addKeyListener(editListener);
 		}
 		
+		// THINK ↓要る?
 //		@Override
 //		protected void configureTable(final Table table) {
 //			super.configureTable(table);
 //			
-//			// THINK ↓要る?
 //			final Menu menu = new Menu(table);
 //			table.setMenu(menu);
 //			menu.addMenuListener(new MenuAdapter() {
@@ -537,7 +537,7 @@
 			txtCheckName.setEnabled(true);
 			txtCheckExpression.setEnabled(true);
 			
-			BuiltinDataType dataType = domainModel.getDataType();
+			BuiltinDataType dataType = (BuiltinDataType) domainModel.getDataType();
 			List<Object> adapters = dataType.getAdapters();
 			List<Class<?>> adapterClasses = CollectionsUtil.newArrayList();
 			for (Object adapter : adapters) {

Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java
===================================================================
--- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/dialog/table/TableEditDialogColumnTab.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -132,7 +132,7 @@
 	 * 
 	 * @param parentTabFolder 親となるタブフォルダ
 	 * @param style SWTスタイル値
-	 * @param tableModel 編集対象テーブル
+	 * @param tableModel 編集対象{@link TableModel}
 	 * @param jiemamyFacade モデル操作を行うファサード
 	 */
 	public TableEditDialogColumnTab(TabFolder parentTabFolder, int style, TableModel tableModel,

Modified: leto/jiemamy-test-helper/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java
===================================================================
--- leto/jiemamy-test-helper/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ leto/jiemamy-test-helper/trunk/src/main/java/org/jiemamy/internal/test/CoreTestModelBuilder.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -320,7 +320,7 @@
 		check.setName("hoge");
 		check.setExpression("VALUE > 0");
 		domainId.setCheckConstraint(check);
-		domainId.getDataType().getAdapter(SerialDataTypeAdapter.class).setSerial(true);
+		((BuiltinDataType) domainId.getDataType()).getAdapter(SerialDataTypeAdapter.class).setSerial(true);
 		rootModel.getDomains().add(domainId);
 		
 		domainName = factory.newModel(DomainModel.class, uuid.get("62f1e6ec-e6aa-4d52-a6c3-27dac086f2d7"));

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java	2009-04-13 13:15:56 UTC (rev 3261)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java	2009-04-13 15:46:11 UTC (rev 3262)
@@ -58,7 +58,7 @@
 	 * @return ドメインとして定義された型記述子. 未設定の場合は{@code null}
 	 * @since 0.2
 	 */
-	BuiltinDataType getDataType();
+	DataType getDataType();
 	
 	/**
 	 * 説明文を取得する。



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