[Jiemamy-notify] commit [2127] Appender経由で追加削除されるコレクションをetterで取得する時、Unmodifiableでデコレートするようにした。 /

Zurück zum Archiv-Index

svnno****@sourc***** svnno****@sourc*****
2008年 11月 10日 (月) 22:38:03 JST


Revision: 2127
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=2127
Author:   daisuke_m
Date:     2008-11-10 22:38:03 +0900 (Mon, 10 Nov 2008)

Log Message:
-----------
Appender経由で追加削除されるコレクションをetterで取得する時、Unmodifiableでデコレートするようにした。 /
InsertDataSetもappender経由の操作とした。

Modified Paths:
--------------
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/ColumnAppender.java
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/DomainAppender.java
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/NodeAppender.java
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModelImpl.java
    artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon
    artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/core/model/ApplicationModelCreator.java
    zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/RootModelAccessor.java
    zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/node/TableModelAccessor.java

Added Paths:
-----------
    artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/InsertDataSetsAppender.java


-------------- next part --------------
Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/ColumnAppender.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/ColumnAppender.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/ColumnAppender.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -21,6 +21,7 @@
 import org.apache.commons.lang.ClassUtils;
 
 import org.jiemamy.core.model.JiemamyModelAppender;
+import org.jiemamy.spec.accessor.node.TableModelAccessor;
 import org.jiemamy.spec.model.ColumnModel;
 import org.jiemamy.spec.model.node.TableModel;
 
@@ -34,14 +35,14 @@
 	 * {@inheritDoc}
 	 */
 	public void append(TableModel tableModel, ColumnModel columnModel) {
-		tableModel.getColumns().add(columnModel);
+		((TableModelAccessor) tableModel).getModifiableColumns().add(columnModel);
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	public void remove(TableModel rootModel, ColumnModel columnModel) {
-		rootModel.getColumns().remove(columnModel);
+		((TableModelAccessor) rootModel).getModifiableColumns().remove(columnModel);
 	}
 	
 	/**

Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/DomainAppender.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/DomainAppender.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/DomainAppender.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -21,6 +21,7 @@
 import org.apache.commons.lang.ClassUtils;
 
 import org.jiemamy.core.model.JiemamyModelAppender;
+import org.jiemamy.spec.accessor.RootModelAccessor;
 import org.jiemamy.spec.model.DomainModel;
 import org.jiemamy.spec.model.RootModel;
 
@@ -34,14 +35,14 @@
 	 * {@inheritDoc}
 	 */
 	public void append(RootModel rootModel, DomainModel domainModel) {
-		rootModel.getDomains().add(domainModel);
+		((RootModelAccessor) rootModel).getModifiableDomains().add(domainModel);
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	public void remove(RootModel rootModel, DomainModel domainModel) {
-		rootModel.removeModel(domainModel);
+		((RootModelAccessor) rootModel).getModifiableDomains().remove(domainModel);
 	}
 	
 	/**

Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/InsertDataSetsAppender.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/InsertDataSetsAppender.java	                        (rev 0)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/InsertDataSetsAppender.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others.
+ * Created on 2008/10/02
+ *
+ * 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.core.appender;
+
+import org.apache.commons.lang.ClassUtils;
+
+import org.jiemamy.core.model.JiemamyModelAppender;
+import org.jiemamy.spec.accessor.RootModelAccessor;
+import org.jiemamy.spec.model.DomainModel;
+import org.jiemamy.spec.model.RootModel;
+import org.jiemamy.spec.model.dataset.InsertDataSetModel;
+
+/**
+ * {@link RootModel} に対して {@link DomainModel}を追加/削除するアペンダ。
+ * @author daisuke
+ */
+public class InsertDataSetsAppender implements JiemamyModelAppender<RootModel, InsertDataSetModel> {
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public void append(RootModel rootModel, InsertDataSetModel dataSet) {
+		((RootModelAccessor) rootModel).getModifiableInsertDataSets().add(dataSet);
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public void remove(RootModel rootModel, InsertDataSetModel dataSet) {
+		((RootModelAccessor) rootModel).getModifiableInsertDataSets().remove(dataSet);
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public String toString() {
+		return ClassUtils.getShortClassName(this, "null");
+	}
+}


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

Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/NodeAppender.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/NodeAppender.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/appender/NodeAppender.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -21,6 +21,7 @@
 import org.apache.commons.lang.ClassUtils;
 
 import org.jiemamy.core.model.JiemamyModelAppender;
+import org.jiemamy.spec.accessor.RootModelAccessor;
 import org.jiemamy.spec.model.RootModel;
 import org.jiemamy.spec.model.node.AbstractNodeModel;
 
@@ -34,14 +35,14 @@
 	 * {@inheritDoc}
 	 */
 	public void append(RootModel rootModel, AbstractNodeModel nodeModel) {
-		rootModel.getNodes().add(nodeModel);
+		((RootModelAccessor) rootModel).getModifiableNodes().add(nodeModel);
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
 	public void remove(RootModel rootModel, AbstractNodeModel nodeModel) {
-		rootModel.getNodes().remove(nodeModel);
+		((RootModelAccessor) rootModel).getModifiableNodes().remove(nodeModel);
 	}
 	
 	/**

Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -20,6 +20,7 @@
 
 import java.util.List;
 
+import org.apache.commons.collections15.list.UnmodifiableList;
 import org.seasar.framework.container.annotation.tiger.Binding;
 
 import org.jiemamy.core.utils.ValueCheckUtil;
@@ -158,7 +159,7 @@
 	 * {@inheritDoc}
 	 */
 	public List<DomainModel> getDomains() {
-		return domains;
+		return UnmodifiableList.decorate(domains);
 	}
 	
 	/**
@@ -181,19 +182,40 @@
 	 * {@inheritDoc}
 	 */
 	public List<InsertDataSetModel> getInsertDataSets() {
+		return UnmodifiableList.decorate(insertDataSets);
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<DomainModel> getModifiableDomains() {
+		return domains;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<InsertDataSetModel> getModifiableInsertDataSets() {
 		return insertDataSets;
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
-	public List<AbstractNodeModel> getNodes() {
+	public List<AbstractNodeModel> getModifiableNodes() {
 		return nodes;
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
+	public List<AbstractNodeModel> getNodes() {
+		return UnmodifiableList.decorate(nodes);
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
 	public <T extends AbstractNodeModel>List<T> getNodes(Class<T> clazz) {
 		return process(new GetNodesProcessor<T>(clazz));
 	}
@@ -205,6 +227,14 @@
 		return schemaName;
 	}
 	
+//	/**
+//	 * {@inheritDoc}
+//	 */
+//	@Override
+//	public String toString() {
+//		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+//	}
+	
 	/**
 	 * {@inheritDoc}
 	 */
@@ -227,14 +257,6 @@
 		process(new ProvideForeignKeyNameProcessor(relationModel, validator));
 	}
 	
-//	/**
-//	 * {@inheritDoc}
-//	 */
-//	@Override
-//	public String toString() {
-//		return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
-//	}
-	
 	/**
 	 * {@inheritDoc}
 	 */

Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModelImpl.java
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModelImpl.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModelImpl.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -20,6 +20,7 @@
 
 import java.util.List;
 
+import org.apache.commons.collections15.list.UnmodifiableList;
 import org.seasar.framework.container.annotation.tiger.Binding;
 
 import org.jiemamy.core.model.JiemamyModelAppender;
@@ -95,6 +96,7 @@
 	 * {@inheritDoc}
 	 */
 	public List<CheckConstraintModel> getChecks() {
+		// TODO Unmodifiable.decorate();
 		return checks;
 	}
 	
@@ -109,7 +111,7 @@
 	 * {@inheritDoc}
 	 */
 	public List<ColumnModel> getColumns() {
-		return columns;
+		return UnmodifiableList.decorate(columns);
 	}
 	
 	/**
@@ -117,12 +119,34 @@
 	 * @return インデックスのリスト
 	 */
 	public List<IndexModel> getIndexes() {
+		// TODO Unmodifiable.decorate();
 		return indexes;
 	}
 	
 	/**
 	 * {@inheritDoc}
 	 */
+	public List<CheckConstraintModel> getModifiableChecks() {
+		return checks;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<ColumnModel> getModifiableColumns() {
+		return columns;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
+	public List<IndexModel> getModifiableIndexes() {
+		return indexes;
+	}
+	
+	/**
+	 * {@inheritDoc}
+	 */
 	public List<ColumnModel> getPrimaryKeyColumns() {
 		return process(GetPrimaryKeyColumnsProcessor.getInstance());
 	}

Modified: artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon
===================================================================
--- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon	2008-11-10 13:38:03 UTC (rev 2127)
@@ -17,6 +17,9 @@
 		<initMethod name="registerAppender">
 			<arg><component class="org.jiemamy.core.appender.DomainAppender" /></arg>
 		</initMethod>
+		<initMethod name="registerAppender">
+			<arg><component class="org.jiemamy.core.appender.InsertDataSetsAppender" /></arg>
+		</initMethod>
 	</component>
 	<component class="org.jiemamy.core.model.node.ViewModelImpl" instance="prototype"/>
 	<component class="org.jiemamy.core.model.node.StickyModelImpl" instance="prototype"/>

Modified: artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/core/model/ApplicationModelCreator.java
===================================================================
--- artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/core/model/ApplicationModelCreator.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ artemis/trunk/org.jiemamy.serializer/src/main/java/org/jiemamy/core/model/ApplicationModelCreator.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -149,13 +149,13 @@
 		InsertDataSetModel dataSetEn = rootModel.createJiemamyModel(InsertDataSetModel.class).init("データ群en");
 		dataSetEn.getRecords().put(deptTable, createDeptDataSetEn(deptTable));
 		dataSetEn.getRecords().put(empTable, createEmpDataSetEn(empTable));
-		rootModel.getInsertDataSets().add(dataSetEn);
+		rootModel.appendModel(dataSetEn);
 		
 		// データセットの生成・追加(2)
 		InsertDataSetModel dataSetJa = rootModel.createJiemamyModel(InsertDataSetModel.class).init("データ群ja");
 		dataSetJa.getRecords().put(deptTable, createDeptDataSetJa(deptTable));
 		dataSetJa.getRecords().put(empTable, createEmpDataSetJa(empTable));
-		rootModel.getInsertDataSets().add(dataSetJa);
+		rootModel.appendModel(dataSetJa);
 		
 		return rootModel;
 	}

Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/RootModelAccessor.java
===================================================================
--- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/RootModelAccessor.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/RootModelAccessor.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -31,12 +31,6 @@
  */
 public interface RootModelAccessor extends JiemamyModelAccessor {
 	
-//	/**
-//	 * 当モデルに対して、子モデルを追加するアペンダのリストを取得する。
-//	 * @return 当モデルに対して、子モデルを追加するアペンダのリスト
-//	 */
-//	List<JiemamyModelAppender> getAppenders();
-	
 	/**
 	 * 開始スクリプトを取得する。
 	 * @return 開始スクリプト
@@ -56,28 +50,28 @@
 	Dialect getDialect();
 	
 	/**
-	 * ドメインのリストを取得する。
-	 * @return ドメインのリスト
-	 */
-	List<DomainModel> getDomains();
-	
-	/**
 	 * 終了スクリプトを取得する。
 	 * @return 終了スクリプト
 	 */
 	String getEndScript();
 	
 	/**
+	 * ドメインのリストを取得する。
+	 * @return ドメインのリスト
+	 */
+	List<DomainModel> getModifiableDomains();
+	
+	/**
 	 * INSERTデータセットを取得する。
 	 * @return INSERTデータセット
 	 */
-	List<InsertDataSetModel> getInsertDataSets();
+	List<InsertDataSetModel> getModifiableInsertDataSets();
 	
 	/**
 	 * ノードのリストを取得する。
 	 * @return ノードのリスト
 	 */
-	List<AbstractNodeModel> getNodes();
+	List<AbstractNodeModel> getModifiableNodes();
 	
 	/**
 	 * スキーマ名を取得する。
@@ -85,12 +79,6 @@
 	 */
 	String getSchemaName();
 	
-//	/**
-//	 * 当モデルに対して、子モデルを追加するアペンダのリストを設定する。
-//	 * @param appenders 当モデルに対して、子モデルを追加するアペンダのリスト
-//	 */
-//	void setAppenders(List<JiemamyModelAppender> appenders);
-	
 	/**
 	 * 開始スクリプトを設定する。
 	 * @param beginScript 開始スクリプト

Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/node/TableModelAccessor.java
===================================================================
--- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/node/TableModelAccessor.java	2008-11-10 13:11:59 UTC (rev 2126)
+++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/accessor/node/TableModelAccessor.java	2008-11-10 13:38:03 UTC (rev 2127)
@@ -34,19 +34,19 @@
 	 * テーブルCHECK制約のリストを取得する。
 	 * @return テーブルCHECK制約のリスト
 	 */
-	List<CheckConstraintModel> getChecks();
+	List<CheckConstraintModel> getModifiableChecks();
 	
 	/**
 	 * カラムのリストを取得する。
 	 * @return カラムのリスト
 	 */
-	List<ColumnModel> getColumns();
+	List<ColumnModel> getModifiableColumns();
 	
 	/**
 	 * インデックスのリストを取得する。
 	 * @return インデックスのリスト
 	 */
-	List<IndexModel> getIndexes();
+	List<IndexModel> getModifiableIndexes();
 	
 	/**
 	 * テーブルCHECK制約のリストを設定する。


Jiemamy-notify メーリングリストの案内
Zurück zum Archiv-Index