svnno****@sourc*****
svnno****@sourc*****
2008年 9月 29日 (月) 00:28:24 JST
Revision: 1969 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=jiemamy&view=rev&rev=1969 Author: daisuke_m Date: 2008-09-29 00:28:23 +0900 (Mon, 29 Sep 2008) Log Message: ----------- modelインターフェイスにユーティリティメソッドを記述&実装。 Modified Paths: -------------- artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ColumnModelImpl.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/connection/ForeignKeyMappingImpl.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModelImpl.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractEntityModelImpl.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModelImpl.java 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/ViewModelImpl.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/SetDefaultColumnsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/UpdateMappingsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetReferenceEntitiesProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetEntityProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetNodesProcessor.java artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/base/ForeignKeyTestBase.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/entity/GetForeignKeyParentsTest.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessorTest.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GetNodesProcessorTest.java artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java artemis/trunk/org.jiemamy.dialect/src/test/resources/test.dicon artemis/trunk/org.jiemamy.event/src/main/resources/jiemamy-event.dicon artemis/trunk/org.jiemamy.event/src/test/java/org/jiemamy/core/event/SetterInterceptorTest.java artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModelImpl.java artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessor.java artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessorTest.java artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetColorProcessorTest.java artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetConstraintProcessorTest.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/FitNodeConstraintAction.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeColorCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateConnectionCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteNodeCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteRelationCommand.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java zeus/trunk/org.jiemamy.spec.core/META-INF/MANIFEST.MF zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/FactoryStrategy.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/RootModelFactory.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/ColumnModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyMapping.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/datatype/DataType.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/AbstractEntityModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/TableModel.java zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/ViewModel.java zeus/trunk/org.jiemamy.spec.view/src/main/java/org/jiemamy/spec/model/presentation/DiagramPresentationModel.java Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ModelIdManager.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/ProvideForeignKeyNameProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetConstrainEntitiesProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetConnectionsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/ProvideEntityNameProcessor.java artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon Removed Paths: ------------- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/InheritanceColumnModel.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/typedef/ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/IsSubColumnOfProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/AttachConnectionProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/DetachConnectionProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/GenerateForeignKeyNameProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSubEntitiesProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSuperEntitiesProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/AddInheritedColumnsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/IsCompositeKeyTableProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RefreshInheritedColumnsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RemoveInheritedColumnsProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessor.java artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/creation/ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/entity/table/ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/core/model/ -------------- next part -------------- Modified: artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java =================================================================== --- artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.composer/src/main/java/org/jiemamy/composer/importer/DatabaseImporter.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -17,9 +17,6 @@ import org.jiemamy.core.model.connection.ForeignKeyMappingImpl; import org.jiemamy.core.utils.DriverUtil; import org.jiemamy.core.utils.JmIOUtil; -import org.jiemamy.core.utils.processor.entity.table.GetColumnProcessor; -import org.jiemamy.core.utils.processor.root.GetTableProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewForeignKeyProcessor; import org.jiemamy.core.utils.visitor.AbstractResultSetVisitor; import org.jiemamy.dialect.generic.GeneralDialect; import org.jiemamy.spec.exception.GenericModelingModeException; @@ -231,19 +228,19 @@ String pkColumnName = keys.getString("PKCOLUMN_NAME"); try { - TableModel source = rootModel.process(new GetTableProcessor(fkTableName)); - TableModel target = rootModel.process(new GetTableProcessor(pkTableName)); + TableModel source = rootModel.getEntity(TableModel.class, fkTableName); + TableModel target = rootModel.getEntity(TableModel.class, pkTableName); if (source != null && target != null) { ForeignKeyModel fkModel = fkModels.get(fkName); if (fkModel == null) { - fkModel = rootModel.process(new CreateNewForeignKeyProcessor(fkName, source, target)); + fkModel = rootModel.createJiemamyModel(ForeignKeyModel.class).init(fkName, source, target); fkModel.setName(fkName); } ForeignKeyMapping mapping = new ForeignKeyMappingImpl(); - mapping.setConstraintColumn(source.process(new GetColumnProcessor(fkColumnName))); - mapping.setReferenceColumn(target.process(new GetColumnProcessor(pkColumnName))); + mapping.setConstraintColumn(source.getColumn(fkColumnName)); + mapping.setReferenceColumn(target.getColumn(pkColumnName)); fkModel.setName(fkName); fkModel.getMappings().add(mapping); Modified: artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java =================================================================== --- artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.composer/src/test/java/org/jiemamy/composer/importer/DatabaseImporterTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -34,7 +34,6 @@ import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.core.extension.composer.ImportContextImpl; -import org.jiemamy.core.utils.processor.root.GetTableProcessor; import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.extension.composer.ImportContext; import org.jiemamy.spec.extension.composer.Importer; @@ -64,6 +63,8 @@ @Before @SuppressWarnings("unchecked") public void setUp() throws Exception { + RootModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon")); + URLClassLoader classLoader = new URLClassLoader(new URL[] { new File("../org.jiemamy.dialect/target/classes").toURL(), new File("../org.jiemamy.dialect.postgresql/target/classes").toURL() @@ -92,8 +93,7 @@ */ @Test public void test01_DBからのインポートテスト() throws Exception { - RootModel rootModel = - RootModelFactory.getInstance(new S2FactoryStrategy("jiemamy-core.dicon")).createInstance(); + RootModel rootModel = RootModelFactory.createInstance(); ImportContext ctx = new ImportContextImpl(); ctx.setValue(DatabaseImporter.DIALECT, dialect); ctx.setValue(DatabaseImporter.DATABASE_NAME, "jpoll"); @@ -112,7 +112,7 @@ assertThat(rootModel.getNodes().size(), is(4)); assertThat(rootModel.getConnections().size(), is(5)); - TableModel pollTable = rootModel.process(new GetTableProcessor("t_poll")); + TableModel pollTable = rootModel.getEntity(TableModel.class, "t_poll"); assertThat(pollTable.getName(), is("t_poll")); assertThat(pollTable.getColumns().size(), is(11)); assertThat(pollTable.getColumns().get(0).getName(), is("poll_id")); Modified: artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF =================================================================== --- artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/META-INF/MANIFEST.MF 2008-09-28 15:28:23 UTC (rev 1969) @@ -271,7 +271,6 @@ org.jiemamy.core.utils.processor.entity, org.jiemamy.core.utils.processor.entity.table, org.jiemamy.core.utils.processor.root, - org.jiemamy.core.utils.processor.root.creation, org.jiemamy.core.utils.processor.root.dataset, org.jiemamy.core.utils.visitor, org.jiemamy.core.utils.visitor.impl, Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/AbstractModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,161 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. Created on 2008/06/09 + * + * This file is part of Jiemamy-core. + * + * 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.model; + +import java.util.List; +import java.util.UUID; + +import org.seasar.framework.container.annotation.tiger.Binding; + +import org.jiemamy.spec.model.JiemamyModel; +import org.jiemamy.spec.util.Processor; + +/** + * Jiemamyが扱う、ユーザが定義するDB設計に関わるデータ(モデル)クラスの抽象クラス。 + * @author daisuke + */ +public abstract class AbstractModel implements JiemamyModel { + + /** + * モデルID + * + * <p>モデルIDは、このモデルのライフサイクル(生成から削除まで)を通して一貫している。</p> + */ + private UUID id; + + /** 適用可能なアダプタのリスト */ + @Binding("list") + private List<Object> adapters; + + + /** + * コンストラクタ。 + * @category instance creation + */ + public AbstractModel() { + ModelIdManager modelManager = ModelIdManager.getInstance(); + modelManager.register(this); + } + + /** + * {@inheritDoc} + */ + public void dispose() { + ModelIdManager modelIdManager = ModelIdManager.getInstance(); + modelIdManager.unregister(this); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AbstractModel other = (AbstractModel) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + return true; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public <T>T getAdapter(Class<T> adapter) { + for (Object myAdapter : adapters) { + if (myAdapter.getClass().isAssignableFrom(adapter)) { + return (T) myAdapter; + } + } + return null; + } + + /** + * 適用可能なアダプタのリストを取得する。 + * @return 適用可能なアダプタのリスト + */ + public List<Object> getAdapters() { + return adapters; + } + + /** + * {@inheritDoc} + */ + public UUID getId() { + return id; + } + + /** + * {@inheritDoc} + */ + public boolean hasAdapter(Class<?> adapter) { + for (Object myAdapter : adapters) { + if (myAdapter.getClass().isAssignableFrom(adapter)) { + return true; + } + } + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public <R, T extends JiemamyModel, E extends Exception>R process(Processor<T, R, E> processor) throws E { + return processor.process((T) this); + } + + /** + * モデルIDを設定する。 + * + * <p>モデルIDは、このモデルのライフサイクル(生成から削除まで)を通して一貫しているべきであり、通常このメソッドは + * 呼び出されるべきではない。deserialize時の現状復帰用として存在するメソッドである。</p> + * + * @param id モデルID + * @category accessing + */ + public void setId(UUID id) { + this.id = id; + } + + protected void addAdapter(Object adapter) { + adapters.add(adapter); + } + +} Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ColumnModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ColumnModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ColumnModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -179,6 +179,15 @@ } /** + * {@inheritDoc} + */ + public ColumnModel init(String columnName, DataType dataType) { + setName(columnName); + setDataType(dataType); + return this; + } + + /** * 代表カラムかどうかを取得する。 * @return 代表カラムかどうか */ @@ -262,14 +271,6 @@ this.representation = representation; } - /** - * 単純インデックスの有無を設定する。 - * @param simpleIndex 単純インデックスの有無 - */ - public void setSimpleIndex(boolean simpleIndex) { - this.simpleIndex = simpleIndex; - } - // /** // * {@inheritDoc} // */ @@ -279,6 +280,14 @@ // } /** + * 単純インデックスの有無を設定する。 + * @param simpleIndex 単純インデックスの有無 + */ + public void setSimpleIndex(boolean simpleIndex) { + this.simpleIndex = simpleIndex; + } + + /** * 制約を設定する。 * @param constraints 制約 */ Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/InheritanceColumnModel.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/InheritanceColumnModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/InheritanceColumnModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,131 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/06/09 - * - * This file is part of Jiemamy-core. - * - * 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.model; - -import org.jiemamy.spec.model.ColumnModel; -import org.jiemamy.spec.model.constraint.Constraint; -import org.jiemamy.spec.model.datatype.DataType; - -/** - * 継承カラムモデル。 - * @author daisuke - */ - @ SuppressWarnings("serial") -public class InheritanceColumnModel extends ColumnModelImpl implements ColumnModel { - - /** 基底カラム */ - private ColumnModel superColumn; - - - /** - * コンストラクタ。 - * @category instance creation - */ - public InheritanceColumnModel() { - } - - /** - * コンストラクタ。 - * @param superColumn 継承基底カラム - * @category instance creation - */ - public InheritanceColumnModel(ColumnModel superColumn) { - this.superColumn = superColumn; - } - - /** - * {@inheritDoc} - */ - @Override - public void addConstraint(Constraint constraint) { - superColumn.getConstraints().add(constraint); - } - - /** - * {@inheritDoc} - */ - @Override - public DataType getDataType() { - return superColumn.getDataType(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getDefaultValue() { - return superColumn.getDefaultValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getDescription() { - return superColumn.getDescription(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getFreeString() { - return superColumn.getFreeString(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getName() { - return superColumn.getName(); - } - - /** - * 基底カラムを取得する。 - * @return 基底カラム - */ - public ColumnModel getSuperColumn() { - return superColumn; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean hasConstraint(Class<? extends Constraint> clazz) { - return superColumn.getConstraints().has(clazz); - } - - /** - * {@inheritDoc} - */ - @Override - public void removeConstraint(Class<? extends Constraint> constraintClass) { - superColumn.getConstraints().remove(constraintClass); - } - - /** - * 基底カラムを設定する。 - * @param superColumn 基底カラム - */ - void setSuperColumn(ColumnModel superColumn) { - this.superColumn = superColumn; - } -} Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ModelIdManager.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ModelIdManager.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/ModelIdManager.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,105 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/06/27 + * + * 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.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.jiemamy.spec.model.JiemamyModel; + +/** + * モデルIDを管理するマネージャクラス。 + * @author j5ik2o + */ +public final class ModelIdManager { + + /** シングルトンインスタンス */ + private static ModelIdManager instance; + + + /** + * シングルトンのインスタンスを取得する。 + * <p>THINK パフォーマンスを改善する余地があるなら,instanceのnullチェック以降にsynchronizedを設けてみる。</p> + * @return ModelManagerのインスタンス + */ + public synchronized static ModelIdManager getInstance() { + if (instance == null) { + instance = (new ModelIdManager()); + } + return instance; + } + + + /** モデル管理マップ */ + private Map<UUID, JiemamyModel> modelMap = new HashMap<UUID, JiemamyModel>(); + + + /** + * コンストラクタ。 + * @category instance creation + */ + protected ModelIdManager() { + } + + /** + * モデルIDからモデルを検索する。 + * + * <p>該当するモデルが見つからなかった時は、<code>null</code>を返す。</p> + * + * @param <T> モデルの型 + * @param id モデルID + * @return AbstractModel モデル + */ + @SuppressWarnings("unchecked") + public <T extends JiemamyModel>T findModel(UUID id) { + T result = (T) modelMap.get(id); + return result; + } + + /** + * モデルIDを生成して返す。 + * @return モデルID + */ + synchronized UUID generateModelId() { + UUID id = UUID.randomUUID(); + return id; + } + + /** + * モデルに新しいモデルIDを設定し,モデル管理マップに登録する。 + * @param model モデル + */ + synchronized void register(JiemamyModel model) { + UUID id = UUID.randomUUID(); + ((AbstractModel) model).setId(id); + modelMap.put(id, model); + } + + /** + * モデルIDを消去する。 + * <p>モデルIDに関連づくオブジェクトも破棄されます</p> + * @param model モデル + */ + synchronized void unregister(JiemamyModel model) { + modelMap.remove(model.getId()); + ((AbstractModel) model).setId(null); + } + +} 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-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/RootModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -19,13 +19,24 @@ package org.jiemamy.core.model; import java.util.List; -import java.util.Set; +import org.seasar.framework.container.annotation.tiger.Binding; + +import org.jiemamy.core.utils.processor.connection.foreignkey.ProvideForeignKeyNameProcessor; +import org.jiemamy.core.utils.processor.root.GetConnectionsProcessor; +import org.jiemamy.core.utils.processor.root.GetEntityProcessor; +import org.jiemamy.core.utils.processor.root.GetNodesProcessor; +import org.jiemamy.core.utils.processor.root.ProvideEntityNameProcessor; +import org.jiemamy.spec.exception.JiemamyRuntimeException; +import org.jiemamy.spec.exception.TooManyElementsException; +import org.jiemamy.spec.extension.dialect.IdentifierValidator; import org.jiemamy.spec.model.DomainModel; import org.jiemamy.spec.model.JiemamyModel; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractConnectionModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.dataset.InsertDataSetModel; +import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.model.node.AbstractNodeModel; /** @@ -54,25 +65,16 @@ private List<DomainModel> domains; /** ノードのリスト */ - private Set<AbstractNodeModel> nodes; + private List<AbstractNodeModel> nodes; /** - * コネクションのリスト - * - * THINK bacchusでは、connectionsを保持していなかった。nodesを辿れば全てのconnectionsが取れるから。 - * しかし、モデル的に考えると「ノード」と「コネクション」の間には従属関係がなく、等レベルの要素な気がする。 - * (対する、テーブルとカラムの間には親子の従属関係がある) - * その為、connectionはnodeにぶら下がる形でなく、RootModelの中でリストを持ってみた。 - */ - private Set<AbstractConnectionModel> connections; - - /** * INSERTデータセット * * bacchusでは、1つのDBモデルに対して、INSERTするデータセットが1つしか定義できなかったが、 * データセットモデルを分離してCollectionで持つことにより、複数のデータセットを保持できる。 * (テストA用のデータセット、テストB用のデータセット... 等) */ + @Binding("list") private List<InsertDataSetModel> insertDataSets; @@ -88,8 +90,15 @@ * {@inheritDoc} */ public void appendModel(JiemamyModel jiemamyModel) { - // TODO Auto-generated method stub - + if (jiemamyModel instanceof AbstractNodeModel) { + nodes.add((AbstractNodeModel) jiemamyModel); + } else if (jiemamyModel instanceof AbstractConnectionModel) { + AbstractConnectionModel connection = (AbstractConnectionModel) jiemamyModel; + connection.getSource().getSourceConnections().add(connection); + connection.getTarget().getTargetConnections().add(connection); + } else { + throw new JiemamyRuntimeException(); + } } /** @@ -110,9 +119,6 @@ for (AbstractNodeModel node : nodes) { node.dispose(); } - for (AbstractConnectionModel connection : connections) { - connection.dispose(); - } for (InsertDataSetModel insertDataSet : insertDataSets) { insertDataSet.dispose(); } @@ -131,8 +137,8 @@ * コネクションのリストを取得する。 * @return コネクションのリスト */ - public Set<AbstractConnectionModel> getConnections() { - return connections; + public List<AbstractConnectionModel> getConnections() { + return process(new GetConnectionsProcessor<AbstractConnectionModel>()); } /** @@ -168,6 +174,15 @@ } /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public <T extends AbstractEntityModel>T getEntity(Class<T> clazz, String entityName) + throws TooManyElementsException { + return (T) process(new GetEntityProcessor<T>(clazz, entityName)); + } + + /** * INSERTデータセットを取得する。 * @return INSERTデータセット */ @@ -179,11 +194,18 @@ * ノードのリストを取得する。 * @return ノードのリスト */ - public Set<AbstractNodeModel> getNodes() { + public List<AbstractNodeModel> getNodes() { return nodes; } /** + * {@inheritDoc} + */ + public <T extends AbstractNodeModel>List<T> getNodes(Class<T> clazz) { + return process(new GetNodesProcessor<T>(clazz)); + } + + /** * スキーマ名を取得する。 * @return スキーマ名 */ @@ -192,6 +214,43 @@ } /** + * {@inheritDoc} + */ + public void provideValidName(AbstractEntityModel entityModel, IdentifierValidator validator) { + process(new ProvideEntityNameProcessor(entityModel, validator)); + } + +// /** +// * {@inheritDoc} +// */ +// @Override +// public String toString() { +// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); +// } + + /** + * {@inheritDoc} + */ + public void provideValidName(ForeignKeyModel relationModel, IdentifierValidator validator) { + process(new ProvideForeignKeyNameProcessor(relationModel, validator)); + } + + /** + * {@inheritDoc} + */ + public void removeModel(JiemamyModel jiemamyModel) { + if (jiemamyModel instanceof AbstractNodeModel) { + nodes.remove(jiemamyModel); + } else if (jiemamyModel instanceof AbstractConnectionModel) { + AbstractConnectionModel connection = (AbstractConnectionModel) jiemamyModel; + connection.getSource().getSourceConnections().remove(connection); + connection.getTarget().getTargetConnections().remove(connection); + } else { + throw new JiemamyRuntimeException(); + } + } + + /** * 開始スクリプトを設定する。 * @param beginScript 開始スクリプト */ @@ -215,14 +274,6 @@ this.dialectClassName = dialectClassName; } -// /** -// * {@inheritDoc} -// */ -// @Override -// public String toString() { -// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); -// } - /** * 終了スクリプトを設定する。 * @param endScript 終了スクリプト @@ -240,14 +291,6 @@ } /** - * コネクションのリストを設定する。 - * @param connections コネクションのリスト - */ - void setConnections(Set<AbstractConnectionModel> connections) { - this.connections = connections; - } - - /** * ドメインのリストを設定する。 * @param domains ドメインのリスト */ @@ -267,7 +310,7 @@ * ノードのリストを設定する。 * @param nodes ノードのリスト */ - void setNodes(Set<AbstractNodeModel> nodes) { + void setNodes(List<AbstractNodeModel> nodes) { this.nodes = nodes; } Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyMappingImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyMappingImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyMappingImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -19,8 +19,11 @@ package org.jiemamy.core.model.connection; import org.jiemamy.core.model.AbstractModel; +import org.jiemamy.core.utils.processor.SetDefaultColumnsProcessor; import org.jiemamy.spec.model.ColumnModel; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.ForeignKeyMapping; +import org.jiemamy.spec.model.node.TableModel; /** * 外部キーマッピングのモデル。 @@ -67,6 +70,14 @@ } /** + * {@inheritDoc} + */ + public void setDefaultColumns(RootModel rootModel, TableModel sourceTable, ColumnModel referencePkColumn, + boolean createColumnWithFk) { + process(new SetDefaultColumnsProcessor(rootModel, sourceTable, getReferenceColumn(), createColumnWithFk)); + } + + /** * 参照先カラムを設定する。 * @param referenceColumn 参照先カラム */ Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/connection/ForeignKeyModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,9 +20,11 @@ import java.util.List; -import org.jiemamy.core.utils.processor.SetDefaultColumnsProcessor; -import org.jiemamy.core.utils.processor.entity.table.GetPrimaryKeyColumnsProcessor; +import org.jiemamy.core.utils.processor.connection.foreignkey.GetMappingProcessor; +import org.jiemamy.core.utils.processor.connection.foreignkey.ProvideForeignKeyNameProcessor; +import org.jiemamy.core.utils.processor.connection.foreignkey.UpdateMappingsProcessor; import org.jiemamy.spec.model.ColumnModel; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.ForeignKeyMapping; import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.node.AbstractEntityModel; @@ -93,26 +95,27 @@ * 既存のカラムにマッピングする場合は<tt>false</tt>を渡す。 * @category instance creation */ - public ForeignKeyModelImpl(AbstractEntityModel source, AbstractEntityModel target, boolean createColumn) { + public ForeignKeyModelImpl(RootModel rootModel, AbstractEntityModel source, AbstractEntityModel target, + boolean createColumn) { super(source, target); - createMappings(createColumn); + createMappings(rootModel, createColumn); } /** * targetを元に、マッピングを生成する。 - * + * @param rootModel * @param createColumn 参照先カラムと同名のカラムを生成して、そのカラムにマッピングする場合は<tt>true</tt> * 既存のカラムにマッピングする場合は<tt>false</tt>を渡す。 * TODO extract to processor */ - public void createMappings(boolean createColumn) { + public void createMappings(RootModel rootModel, boolean createColumn) { mappings.clear(); TableModel tableModel = (TableModel) getTarget(); - List<ColumnModel> referencePkColumns = tableModel.process(GetPrimaryKeyColumnsProcessor.getInstance()); + List<ColumnModel> referencePkColumns = tableModel.getPrimaryKeyColumns(); for (ColumnModel referencePkColumn : referencePkColumns) { ForeignKeyMapping mapping = new ForeignKeyMappingImpl(); - mapping.process(new SetDefaultColumnsProcessor((TableModel) getSource(), referencePkColumn, createColumn)); + mapping.setDefaultColumns(rootModel, (TableModel) getSource(), referencePkColumn, createColumn); mappings.add(mapping); } } @@ -153,6 +156,13 @@ } /** + * {@inheritDoc} + */ + public ForeignKeyMapping getMapping(ColumnModel referencePkColumn) { + return process(new GetMappingProcessor(referencePkColumn)); + } + + /** * マッピングのリストを取得する。 * @return マッピングのリスト */ @@ -195,8 +205,20 @@ /** * {@inheritDoc} */ + public ForeignKeyModel init(String fkName, TableModel source, TableModel target) { + setName(fkName); + setSource(source); + setTarget(target); + return this; + } + + /** + * {@inheritDoc} + */ public ForeignKeyModel init(TableModel source, TableModel target) { - return null; + init(null, source, target); + process(new ProvideForeignKeyNameProcessor(this, null)); + return this; } /** @@ -272,6 +294,13 @@ } /** + * {@inheritDoc} + */ + public void updateMappings(RootModel rootModel, boolean createColumnWithFk) { + process(new UpdateMappingsProcessor(rootModel, createColumnWithFk)); + } + + /** * マッピングのリストを設定する。 * @param mappings マッピングのリスト */ Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractEntityModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractEntityModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractEntityModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,6 +18,10 @@ */ package org.jiemamy.core.model.node; +import java.util.List; + +import org.jiemamy.core.utils.processor.entity.GetConstrainEntitiesProcessor; +import org.jiemamy.core.utils.processor.entity.GetReferenceEntitiesProcessor; import org.jiemamy.spec.model.node.AbstractEntityModel; /** @@ -67,6 +71,10 @@ return beginScript; } + public List<AbstractEntityModel> getConstrainEntities(boolean recursive) { + return process(new GetConstrainEntitiesProcessor(recursive)); + } + /** * 説明文を取得する。 * @return 説明文 @@ -100,6 +108,13 @@ } /** + * {@inheritDoc} + */ + public List<AbstractEntityModel> getReferenceEntities(boolean recursive) { + return process(new GetReferenceEntitiesProcessor(recursive)); + } + + /** * 開始スクリプトを設定する。 * @param beginScript 開始スクリプト */ Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/AbstractNodeModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,6 +20,8 @@ import java.util.List; +import org.seasar.framework.container.annotation.tiger.Binding; + import org.jiemamy.core.model.AbstractModel; import org.jiemamy.spec.model.connection.AbstractConnectionModel; import org.jiemamy.spec.model.node.AbstractNodeModel; @@ -33,9 +35,11 @@ public class AbstractNodeModelImpl extends AbstractModel implements AbstractNodeModel { /** このモデルを接続元とするコネクションのリスト */ + @Binding("list") private List<AbstractConnectionModel> sourceConnections; /** このモデルを接続先とするコネクションのリスト */ + @Binding("list") private List<AbstractConnectionModel> targetConnections; 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-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/TableModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,6 +20,12 @@ import java.util.List; +import org.seasar.framework.container.annotation.tiger.Binding; + +import org.jiemamy.core.utils.processor.entity.table.GetColumnProcessor; +import org.jiemamy.core.utils.processor.entity.table.GetPrimaryKeyColumnsProcessor; +import org.jiemamy.core.utils.processor.root.ProvideEntityNameProcessor; +import org.jiemamy.spec.exception.TooManyElementsException; import org.jiemamy.spec.model.ColumnModel; import org.jiemamy.spec.model.constraint.CheckConstraintModel; import org.jiemamy.spec.model.index.IndexModel; @@ -34,33 +40,19 @@ public class TableModelImpl extends AbstractEntityModelImpl implements TableModel { // implements DialectOptionSupport { /** カラムのリスト */ + @Binding("list") private List<ColumnModel> columns; /** インデックスのリスト */ + @Binding("list") private List<IndexModel> indexes; /** テーブルCHECK制約のリスト */ + @Binding("list") private List<CheckConstraintModel> checks; /** - * コンストラクタ。 - * @category instance creation - */ - public TableModelImpl() { - this(null); - } - - /** - * コンストラクタ。 - * @param name テーブル名 - * @category instance creation - */ - public TableModelImpl(String name) { - super(name); - } - - /** * {@inheritDoc} */ @Override @@ -86,6 +78,13 @@ } /** + * {@inheritDoc} + */ + public ColumnModel getColumn(String columnName) throws TooManyElementsException { + return process(new GetColumnProcessor(columnName)); + } + + /** * カラムのリストを取得する。 * @return カラムのリスト */ @@ -93,6 +92,14 @@ return columns; } +// /** +// * {@inheritDoc} +// */ +// @Override +// public String toString() { +// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); +// } + /** * インデックスのリストを取得する。 * @return インデックスのリスト @@ -101,17 +108,24 @@ return indexes; } -// /** -// * {@inheritDoc} -// */ -// @Override -// public String toString() { -// return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE); -// } + /** + * {@inheritDoc} + */ + public List<ColumnModel> getPrimaryKeyColumns() { + return process(GetPrimaryKeyColumnsProcessor.getInstance()); + } /** * {@inheritDoc} */ + public TableModel init() { + process(new ProvideEntityNameProcessor(this, null)); + return this; + } + + /** + * {@inheritDoc} + */ public TableModel init(String tableName) { setName(tableName); return this; Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/ViewModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/ViewModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/model/node/ViewModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,6 +18,7 @@ */ package org.jiemamy.core.model.node; +import org.jiemamy.core.utils.processor.root.ProvideEntityNameProcessor; import org.jiemamy.spec.model.node.ViewModel; /** @@ -61,6 +62,23 @@ } /** + * {@inheritDoc} + */ + public ViewModel init() { + process(new ProvideEntityNameProcessor(this, null)); + return this; + } + + /** + * {@inheritDoc} + */ + public ViewModel init(String viewName, String definition) { + setName(viewName); + setDefinition(definition); + return this; + } + + /** * VIEW定義SELECT文を設定する。 * @param definition VIEW定義SELECT文 */ Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/IsSubColumnOfProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/IsSubColumnOfProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/IsSubColumnOfProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,55 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor; - -import org.jiemamy.core.model.InheritanceColumnModel; -import org.jiemamy.spec.model.ColumnModel; -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * カラムが、指定したテーブルから継承されたものであるかどうかを取得する。 - * @author daisuke - */ -public class IsSubColumnOfProcessor implements Processor<ColumnModel, Boolean, RuntimeException> { - - private TableModel parentTable; - - - /** - * コンストラクタ。 - * @param parentTable - * @category instance creation - */ - public IsSubColumnOfProcessor(TableModel parentTable) { - this.parentTable = parentTable; - } - - /** - * {@inheritDoc} - */ - public Boolean process(ColumnModel columnModel) { - if (columnModel instanceof InheritanceColumnModel) { - ColumnModel superColumn = ((InheritanceColumnModel) columnModel).getSuperColumn(); - return parentTable.getColumns().contains(superColumn); - } - return false; - } - -} Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/SetDefaultColumnsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/SetDefaultColumnsProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/SetDefaultColumnsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,11 +18,10 @@ */ package org.jiemamy.core.utils.processor; -import org.jiemamy.core.utils.processor.entity.table.CreateNewColumnProcessor; -import org.jiemamy.core.utils.processor.entity.table.GetColumnProcessor; import org.jiemamy.spec.exception.TooManyElementsException; import org.jiemamy.spec.model.ColumnModel; import org.jiemamy.spec.model.JiemamyModel; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.ForeignKeyMapping; import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.util.Processor; @@ -33,6 +32,8 @@ */ public class SetDefaultColumnsProcessor implements Processor<ForeignKeyMapping, Void, RuntimeException> { + private RootModel rootModel; + private TableModel sourceTable; private ColumnModel referencePkColumn; @@ -42,12 +43,15 @@ /** * コンストラクタ。 + * @param rootModel * @param sourceTable 参照元テーブル * @param referencePkColumn 参照先(targetのPKカラム) * @param createColumn 同名かラムが存在しなかった場合、新規作成するかどうか。 * @category instance creation */ - public SetDefaultColumnsProcessor(TableModel sourceTable, ColumnModel referencePkColumn, boolean createColumn) { + public SetDefaultColumnsProcessor(RootModel rootModel, TableModel sourceTable, ColumnModel referencePkColumn, + boolean createColumn) { + this.rootModel = rootModel; this.sourceTable = sourceTable; this.referencePkColumn = referencePkColumn; this.createColumn = createColumn; @@ -62,7 +66,7 @@ // targetのPKと同じ名前のカラムが、同じ型であればマッピング try { - ColumnModel sameNameColumn = sourceTable.process(new GetColumnProcessor(referencePkColumn.getName())); + ColumnModel sameNameColumn = sourceTable.getColumn(referencePkColumn.getName()); if (referencePkColumn.getDataType().equals(sameNameColumn.getDataType())) { mapping.setConstraintColumn(sameNameColumn); } @@ -80,26 +84,22 @@ if (createColumn) { // sourceに新しいカラムを作成 ColumnModel additionalColumn = - sourceTable.process(new CreateNewColumnProcessor(referencePkColumn.getName(), referencePkColumn - .getDataType())); + rootModel.createJiemamyModel(ColumnModel.class).init(referencePkColumn.getName(), + referencePkColumn.getDataType()); + sourceTable.getColumns().add(additionalColumn); additionalColumn.setLogicalName(referencePkColumn.getLogicalName()); - - // 追加したカラムにマッピング mapping.setConstraintColumn(additionalColumn); } else { for (ColumnModel column : sourceTable.getColumns()) { if (referencePkColumn.getDataType().equals(column.getDataType())) { - // 型が一致するカラムにマッピング mapping.setConstraintColumn(column); } } } } if (mapping.getConstraintColumn() == null && sourceTable.getColumns().size() != 0) { - // 最終手段。1番目のカラムにマッピング mapping.setConstraintColumn(sourceTable.getColumns().get(0)); } return null; } - } Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/AttachConnectionProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/AttachConnectionProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/AttachConnectionProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,75 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.connection; - -import org.jiemamy.spec.model.connection.AbstractConnectionModel; -import org.jiemamy.spec.model.connection.ForeignKeyModel; -import org.jiemamy.spec.util.Processor; - -/** - * コネクションをアタッチする。 - * - * {@link ForeignKeyModel}を作っただけではノードのステートが変化しない為、この処理をコールする必要がある。 - * @author daisuke - */ -public class AttachConnectionProcessor implements Processor<AbstractConnectionModel, Void, RuntimeException> { - - /** プロセッサのsingletonインスタンス */ - private volatile static AttachConnectionProcessor singleton; - - - /** - * プロセッサのsingletonインスタンスを取得する。 - * @return プロセッサのsingletonインスタンス - */ - public static AttachConnectionProcessor getInstance() { - if (singleton == null) { - singleton = (new AttachConnectionProcessor()); - } - return singleton; - } - - private AttachConnectionProcessor() { - } - - /** - * {@inheritDoc} - */ - public Void process(AbstractConnectionModel connection) { - attachSource(connection); - attachTarget(connection); - return null; - } - - private void attachSource(AbstractConnectionModel connectionModel) { - assert connectionModel != null; - assert connectionModel.getSource() != null; - assert connectionModel.getSource().getSourceConnections() != null; - if (connectionModel.getSource().getSourceConnections().contains(connectionModel) == false) { - connectionModel.getSource().getSourceConnections().add(connectionModel); - } - } - - private void attachTarget(AbstractConnectionModel connectionModel) { - if (connectionModel.getTarget().getTargetConnections().contains(connectionModel) == false) { - connectionModel.getTarget().getTargetConnections().add(connectionModel); - } - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/DetachConnectionProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/DetachConnectionProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/DetachConnectionProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,59 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.connection; - -import org.jiemamy.spec.model.connection.AbstractConnectionModel; -import org.jiemamy.spec.util.Processor; - -/** - * コネクションをデタッチする。 - * @author daisuke - */ -public class DetachConnectionProcessor implements Processor<AbstractConnectionModel, Void, RuntimeException> { - - /** プロセッサのsingletonインスタンス */ - private volatile static DetachConnectionProcessor singleton; - - - /** - * プロセッサのsingletonインスタンスを取得する。 - * @return プロセッサのsingletonインスタンス - */ - public static DetachConnectionProcessor getInstance() { - if (singleton == null) { - singleton = (new DetachConnectionProcessor()); - } - return singleton; - } - - private DetachConnectionProcessor() { - } - - /** - * {@inheritDoc} - */ - public Void process(AbstractConnectionModel connectionModel) { - boolean s = connectionModel.getSource().getSourceConnections().remove(connectionModel); - boolean t = connectionModel.getTarget().getTargetConnections().remove(connectionModel); - - assert s; - assert t; - return null; - } -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/GenerateForeignKeyNameProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/GenerateForeignKeyNameProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/GenerateForeignKeyNameProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,64 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.connection.foreignkey; - -import java.util.Date; - -import org.jiemamy.spec.model.connection.ForeignKeyModel; -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * 適切な初期エンティティ名称を生成する。 - * @author daisuke - */ -public class GenerateForeignKeyNameProcessor implements Processor<ForeignKeyModel, String, RuntimeException> { - - /** プロセッサのsingletonインスタンス */ - private volatile static GenerateForeignKeyNameProcessor singleton; - - - /** - * プロセッサのsingletonインスタンスを取得する。 - * @return プロセッサのsingletonインスタンス - */ - public static GenerateForeignKeyNameProcessor getInstance() { - if (singleton == null) { - singleton = (new GenerateForeignKeyNameProcessor()); - } - return singleton; - } - - private GenerateForeignKeyNameProcessor() { - } - - /** - * {@inheritDoc} - */ - public String process(ForeignKeyModel foreignKeyModel) { - StringBuilder sb = new StringBuilder(); - TableModel sourceTable = (TableModel) foreignKeyModel.getSource(); - TableModel targetTable = (TableModel) foreignKeyModel.getTarget(); - sb.append("fkey_").append(sourceTable.getName()).append("_").append(targetTable.getName()).append("_").append( - (new Date()).getTime()); - foreignKeyModel.setName(sb.toString()); - return sb.toString(); - } - -} Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/ProvideForeignKeyNameProcessor.java (from rev 1968, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/GenerateForeignKeyNameProcessor.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/ProvideForeignKeyNameProcessor.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/ProvideForeignKeyNameProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,64 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/08/01 + * + * 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.utils.processor.connection.foreignkey; + +import java.util.Date; + +import org.jiemamy.spec.extension.dialect.IdentifierValidator; +import org.jiemamy.spec.model.RootModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel; +import org.jiemamy.spec.model.node.TableModel; +import org.jiemamy.spec.util.Processor; + +/** + * 適切な初期エンティティ名称を生成する。 + * @author daisuke + */ +public class ProvideForeignKeyNameProcessor implements Processor<RootModel, String, RuntimeException> { + + private ForeignKeyModel foreignKeyModel; + + private IdentifierValidator validator; + + + /** + * コンストラクタ。 + * @param foreignKeyModel + * @param validator + * @category instance creation + */ + public ProvideForeignKeyNameProcessor(ForeignKeyModel foreignKeyModel, IdentifierValidator validator) { + this.foreignKeyModel = foreignKeyModel; + this.validator = validator; + } + + /** + * {@inheritDoc} + */ + public String process(RootModel rootModel) { + StringBuilder sb = new StringBuilder(); + TableModel sourceTable = (TableModel) foreignKeyModel.getSource(); + TableModel targetTable = (TableModel) foreignKeyModel.getTarget(); + sb.append("fkey_").append(sourceTable.getName()).append("_").append(targetTable.getName()).append("_").append( + (new Date()).getTime()); + foreignKeyModel.setName(sb.toString()); + return sb.toString(); + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/ProvideForeignKeyNameProcessor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/UpdateMappingsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/UpdateMappingsProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/connection/foreignkey/UpdateMappingsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -23,10 +23,9 @@ import java.util.List; import org.jiemamy.core.model.connection.ForeignKeyMappingImpl; -import org.jiemamy.core.utils.processor.SetDefaultColumnsProcessor; -import org.jiemamy.core.utils.processor.entity.table.GetPrimaryKeyColumnsProcessor; import org.jiemamy.spec.exception.ElementNotFoundException; import org.jiemamy.spec.model.ColumnModel; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.ForeignKeyMapping; import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.node.TableModel; @@ -38,15 +37,19 @@ */ public class UpdateMappingsProcessor implements Processor<ForeignKeyModel, Void, RuntimeException> { + private RootModel rootModel; + private boolean createColumnWithFk; /** * コンストラクタ。 + * @param rootModel * @param createColumnWithFk * @category instance creation */ - public UpdateMappingsProcessor(boolean createColumnWithFk) { + public UpdateMappingsProcessor(RootModel rootModel, boolean createColumnWithFk) { + this.rootModel = rootModel; this.createColumnWithFk = createColumnWithFk; } @@ -56,31 +59,31 @@ public Void process(ForeignKeyModel fkModel) { TableModel targetTable = (TableModel) fkModel.getTarget(); TableModel sourceTable = (TableModel) fkModel.getSource(); - List<ColumnModel> targetPkColumns = targetTable.process(GetPrimaryKeyColumnsProcessor.getInstance()); + List<ColumnModel> targetPkColumns = targetTable.getPrimaryKeyColumns(); // 編集によって参照先テーブル(targetTable)のPKが削除されていた場合、 // そのmappingを削除する。 - List<ForeignKeyMapping> mappingsToRemove = new ArrayList<ForeignKeyMapping>(fkModel.getMappings().size()); + List<ForeignKeyMapping> removalMappings = new ArrayList<ForeignKeyMapping>(fkModel.getMappings().size()); for (ForeignKeyMapping mapping : fkModel.getMappings()) { if (!targetPkColumns.contains(mapping.getReferenceColumn())) { - mappingsToRemove.add(mapping); + removalMappings.add(mapping); } } - fkModel.getMappings().removeAll(mappingsToRemove); + fkModel.getMappings().removeAll(removalMappings); // 編集によって参照先テーブル(targetTable)のPKが追加されていた場合、 // そのmappingを新規作成する。 - List<ForeignKeyMapping> mappingsToAdd = new ArrayList<ForeignKeyMapping>(targetPkColumns.size()); + List<ForeignKeyMapping> additionalMappings = new ArrayList<ForeignKeyMapping>(targetPkColumns.size()); for (ColumnModel referencePkColumn : targetPkColumns) { try { - fkModel.process(new GetMappingProcessor(referencePkColumn)); + fkModel.getMapping(referencePkColumn); } catch (ElementNotFoundException e) { ForeignKeyMapping mapping = new ForeignKeyMappingImpl(); - mapping.process(new SetDefaultColumnsProcessor(sourceTable, referencePkColumn, createColumnWithFk)); - mappingsToAdd.add(mapping); + mapping.setDefaultColumns(rootModel, sourceTable, referencePkColumn, createColumnWithFk); + additionalMappings.add(mapping); } } - fkModel.getMappings().addAll(mappingsToAdd); + fkModel.getMappings().addAll(additionalMappings); // この時点で、targetのPK数とmapping数は同一であるはず。 assert targetPkColumns.size() == fkModel.getMappings().size(); @@ -88,7 +91,7 @@ // mappinngの順序を、参照先テーブル(targetTable)のPKに合わせる。 for (int pkColumnIndex = 0; pkColumnIndex < targetPkColumns.size(); pkColumnIndex++) { ColumnModel referencePkColumn = targetPkColumns.get(pkColumnIndex); - ForeignKeyMapping baseMapping = fkModel.process(new GetMappingProcessor(referencePkColumn)); + ForeignKeyMapping baseMapping = fkModel.getMapping(referencePkColumn); if (fkModel.getMappings().indexOf(baseMapping) != pkColumnIndex) { Collections.swap(fkModel.getMappings(), pkColumnIndex, pkColumnIndex + 1); } @@ -104,8 +107,7 @@ } continue; } - mapping.process(new SetDefaultColumnsProcessor(sourceTable, mapping.getReferenceColumn(), - createColumnWithFk)); + mapping.setDefaultColumns(rootModel, sourceTable, mapping.getReferenceColumn(), createColumnWithFk); } return null; } Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetConstrainEntitiesProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetConstrainEntitiesProcessor.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetConstrainEntitiesProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,93 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/08/01 + * + * 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.utils.processor.entity; + +import java.util.List; + +import org.seasar.framework.util.tiger.CollectionsUtil; + +import org.jiemamy.spec.model.connection.AbstractConnectionModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel; +import org.jiemamy.spec.model.node.AbstractEntityModel; +import org.jiemamy.spec.util.Processor; + +/** + * 指定したエンティティの参照元子にあたるモデルのリストを取得する。 + * @author daisuke + */ +public class GetConstrainEntitiesProcessor implements + Processor<AbstractEntityModel, List<AbstractEntityModel>, RuntimeException> { + + private boolean recursive; + + + /** + * コンストラクタ。 + * @param recursive 再帰的に辿るかどうか + * @category instance creation + */ + public GetConstrainEntitiesProcessor(boolean recursive) { + this.recursive = recursive; + } + + /** + * {@inheritDoc} + */ + public List<AbstractEntityModel> process(AbstractEntityModel entity) { + return recursive ? processRecursive(entity) : processNonRecursive(entity); + } + + /** + * 参照先親モデルを返す。 + * @param entity 対象エンティティ + * @return 親モデルのSet + */ + private List<AbstractEntityModel> processNonRecursive(AbstractEntityModel entity) { + List<AbstractEntityModel> parents = CollectionsUtil.newArrayList(); + + for (AbstractConnectionModel connection : entity.getTargetConnections()) { + if (connection instanceof ForeignKeyModel) { + ForeignKeyModel fkModel = (ForeignKeyModel) connection; + parents.add((AbstractEntityModel) fkModel.getSource()); + } + } + + return parents; + } + + /** + * 全ての参照先 祖先モデルを返す。 + * @param entity 対象エンティティ + * @return 祖先モデルのSet + */ + private List<AbstractEntityModel> processRecursive(AbstractEntityModel entity) { + List<AbstractEntityModel> parentEntities = entity.getReferenceEntities(false); + List<AbstractEntityModel> entities = CollectionsUtil.newArrayList(); + + entities.addAll(parentEntities); + for (AbstractEntityModel parentEntity : parentEntities) { + if (entity.equals(parentEntity) == false) { + entities.addAll(parentEntity.getReferenceEntities(true)); + } + } + + return entities; + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetConstrainEntitiesProcessor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetReferenceEntitiesProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetReferenceEntitiesProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetReferenceEntitiesProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,9 +18,10 @@ */ package org.jiemamy.core.utils.processor.entity; -import java.util.HashSet; -import java.util.Set; +import java.util.List; +import org.seasar.framework.util.tiger.CollectionsUtil; + import org.jiemamy.spec.model.connection.AbstractConnectionModel; import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.node.AbstractEntityModel; @@ -30,7 +31,8 @@ * 指定したエンティティの参照先親にあたるモデルのリストを取得する。 * @author daisuke */ -public class GetReferenceEntitiesProcessor implements Processor<AbstractEntityModel, Set<AbstractEntityModel>, RuntimeException> { +public class GetReferenceEntitiesProcessor implements + Processor<AbstractEntityModel, List<AbstractEntityModel>, RuntimeException> { private boolean recursive; @@ -47,7 +49,7 @@ /** * {@inheritDoc} */ - public Set<AbstractEntityModel> process(AbstractEntityModel entity) { + public List<AbstractEntityModel> process(AbstractEntityModel entity) { return recursive ? processRecursive(entity) : processNonRecursive(entity); } @@ -56,8 +58,8 @@ * @param entity 対象エンティティ * @return 親モデルのSet */ - private Set<AbstractEntityModel> processNonRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> parents = new HashSet<AbstractEntityModel>(); + private List<AbstractEntityModel> processNonRecursive(AbstractEntityModel entity) { + List<AbstractEntityModel> parents = CollectionsUtil.newArrayList(); for (AbstractConnectionModel connection : entity.getSourceConnections()) { if (connection instanceof ForeignKeyModel) { @@ -74,14 +76,14 @@ * @param entity 対象エンティティ * @return 祖先モデルのSet */ - private Set<AbstractEntityModel> processRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> parentEntities = entity.process(new GetReferenceEntitiesProcessor(false)); - Set<AbstractEntityModel> entities = new HashSet<AbstractEntityModel>(); + private List<AbstractEntityModel> processRecursive(AbstractEntityModel entity) { + List<AbstractEntityModel> parentEntities = entity.getReferenceEntities(false); + List<AbstractEntityModel> entities = CollectionsUtil.newArrayList(); entities.addAll(parentEntities); for (AbstractEntityModel parentEntity : parentEntities) { if (entity.equals(parentEntity) == false) { - entities.addAll(parentEntity.process(new GetReferenceEntitiesProcessor(true))); + entities.addAll(parentEntity.getReferenceEntities(true)); } } Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSubEntitiesProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSubEntitiesProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSubEntitiesProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,90 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.entity; - -import java.util.HashSet; -import java.util.Set; - -import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.spec.model.connection.AbstractConnectionModel; -import org.jiemamy.spec.model.node.AbstractEntityModel; -import org.jiemamy.spec.util.Processor; - -/** - * 指定したエンティティの継承先子にあたるモデルのリストを取得する。 - * @author daisuke - */ -public class GetSubEntitiesProcessor implements - Processor<AbstractEntityModel, Set<AbstractEntityModel>, RuntimeException> { - - private boolean recursive; - - - /** - * コンストラクタ。 - * @param recursive 再帰的に辿るかどうか - * @category instance creation - */ - public GetSubEntitiesProcessor(boolean recursive) { - this.recursive = recursive; - } - - /** - * {@inheritDoc} - */ - public Set<AbstractEntityModel> process(AbstractEntityModel entity) { - return recursive ? processRecursive(entity) : processNonRecursive(entity); - } - - /** - * 継承先子モデルを返す。 - * @param entity 対象エンティティ - * @return 継承先子モデルのSet - */ - private Set<AbstractEntityModel> processNonRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> children = new HashSet<AbstractEntityModel>(); - - for (AbstractConnectionModel relation : entity.getTargetConnections()) { - if (relation instanceof InheritanceModel) { - InheritanceModel inheritanceModel = (InheritanceModel) relation; - children.add((AbstractEntityModel) inheritanceModel.getSource()); - } - } - - return children; - } - - /** - * 全ての継承先 子孫モデルを返す。 - * @param entity 対象エンティティ - * @return 継承先子モデルのSet - */ - private Set<AbstractEntityModel> processRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> childrenEntities = entity.process(new GetSubEntitiesProcessor(false)); - Set<AbstractEntityModel> entities = new HashSet<AbstractEntityModel>(); - - entities.addAll(childrenEntities); - for (AbstractEntityModel childEntity : childrenEntities) { - entities.addAll(childEntity.process(new GetSubEntitiesProcessor(false))); - } - - return entities; - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSuperEntitiesProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSuperEntitiesProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/GetSuperEntitiesProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,92 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.entity; - -import java.util.HashSet; -import java.util.Set; - -import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.spec.model.connection.AbstractConnectionModel; -import org.jiemamy.spec.model.node.AbstractEntityModel; -import org.jiemamy.spec.util.Processor; - -/** - * 指定したエンティティの継承親にあたるモデルのリストを取得する。 - * @author daisuke - */ -public class GetSuperEntitiesProcessor implements - Processor<AbstractEntityModel, Set<AbstractEntityModel>, RuntimeException> { - - private boolean recursive; - - - /** - * コンストラクタ。 - * @param recursive 再帰的に辿るかどうか - * @category instance creation - */ - public GetSuperEntitiesProcessor(boolean recursive) { - this.recursive = recursive; - } - - /** - * {@inheritDoc} - */ - public Set<AbstractEntityModel> process(AbstractEntityModel entity) { - return recursive ? processRecursive(entity) : processNonRecursive(entity); - } - - /** - * 継承先親モデルを返す。 - * @param entity 対象エンティティ - * @return 継承先親モデルのSet - */ - private Set<AbstractEntityModel> processNonRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> parents = new HashSet<AbstractEntityModel>(); - - for (AbstractConnectionModel relation : entity.getSourceConnections()) { - if (relation instanceof InheritanceModel) { - InheritanceModel inheritanceModel = (InheritanceModel) relation; - parents.add((AbstractEntityModel) inheritanceModel.getTarget()); - } - } - - return parents; - } - - /** - * 全ての継承先 祖先モデルを返す。 - * @param entity 対象エンティティ - * @return 継承先親モデルのSet - */ - private Set<AbstractEntityModel> processRecursive(AbstractEntityModel entity) { - Set<AbstractEntityModel> parentEntities = entity.process(new GetSuperEntitiesProcessor(false)); - Set<AbstractEntityModel> entities = new HashSet<AbstractEntityModel>(); - - entities.addAll(parentEntities); - for (AbstractEntityModel parentEntity : parentEntities) { - if (entity.equals(parentEntity) == false) { - entities.addAll(parentEntity.process(new GetSuperEntitiesProcessor(true))); - } - } - - return entities; - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/AddInheritedColumnsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/AddInheritedColumnsProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/AddInheritedColumnsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,57 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/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.utils.processor.entity.table; - -import org.jiemamy.core.model.InheritanceColumnModel; -import org.jiemamy.spec.model.ColumnModel; -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * 指定した親モデルから継承されるカラムを追加する。 - * @author daisuke - */ -public class AddInheritedColumnsProcessor implements Processor<TableModel, Void, RuntimeException> { - - private TableModel parentTable; - - - /** - * コンストラクタ。 - * @param parentTable 追加対象の親モデル - * @category instance creation - */ - public AddInheritedColumnsProcessor(TableModel parentTable) { - this.parentTable = parentTable; - } - - /** - * {@inheritDoc} - */ - public Void process(TableModel tableModel) { - // 継承カラムを追加 - for (ColumnModel parentColumn : parentTable.getColumns()) { - ColumnModel inhColumnModel = new InheritanceColumnModel(parentColumn); - inhColumnModel.setDataType(parentColumn.getDataType()); - tableModel.getColumns().add(inhColumnModel); - } - return null; - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/IsCompositeKeyTableProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/IsCompositeKeyTableProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/IsCompositeKeyTableProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,55 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.entity.table; - -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * 複合キーテーブルかどうかを取得する。 - * @author daisuke - */ -public class IsCompositeKeyTableProcessor implements Processor<TableModel, Boolean, RuntimeException> { - - /** プロセッサのsingletonインスタンス */ - private volatile static IsCompositeKeyTableProcessor singleton; - - - /** - * プロセッサのsingletonインスタンスを取得する。 - * @return プロセッサのsingletonインスタンス - */ - public static IsCompositeKeyTableProcessor getInstance() { - if (singleton == null) { - singleton = new IsCompositeKeyTableProcessor(); - } - return singleton; - } - - private IsCompositeKeyTableProcessor() { - } - - /** - * {@inheritDoc} - */ - public Boolean process(TableModel tableModel) { - return tableModel.process(GetPrimaryKeyColumnsProcessor.getInstance()).size() > 1; - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RefreshInheritedColumnsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RefreshInheritedColumnsProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RefreshInheritedColumnsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,51 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/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.utils.processor.entity.table; - -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * 継承カラムをリフレッシュするプロセッサ。 - * @author daisuke - */ -public class RefreshInheritedColumnsProcessor implements Processor<TableModel, Void, RuntimeException> { - - private TableModel parentTable; - - - /** - * コンストラクタ。 - * @param parentTable - * @category instance creation - */ - public RefreshInheritedColumnsProcessor(TableModel parentTable) { - this.parentTable = parentTable; - } - - /** - * {@inheritDoc} - */ - public Void process(TableModel target) { - target.process(new RemoveInheritedColumnsProcessor(parentTable)); - target.process(new AddInheritedColumnsProcessor(parentTable)); - return null; - } - -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RemoveInheritedColumnsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RemoveInheritedColumnsProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/entity/table/RemoveInheritedColumnsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,64 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/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.utils.processor.entity.table; - -import java.util.ArrayList; -import java.util.List; - -import org.jiemamy.core.model.InheritanceColumnModel; -import org.jiemamy.core.utils.processor.IsSubColumnOfProcessor; -import org.jiemamy.spec.model.ColumnModel; -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.util.Processor; - -/** - * 指定した親モデルから継承されたカラムを削除する。 - * @author daisuke - */ -public class RemoveInheritedColumnsProcessor implements Processor<TableModel, Void, RuntimeException> { - - private TableModel parentTable; - - - /** - * コンストラクタ。 - * @param parentTable 削除対象の親モデル - * @category instance creation - */ - public RemoveInheritedColumnsProcessor(TableModel parentTable) { - this.parentTable = parentTable; - } - - /** - * {@inheritDoc} - */ - public Void process(TableModel tableModel) { - List<InheritanceColumnModel> colsToRemove = new ArrayList<InheritanceColumnModel>(); - // 継承カラム情報を収集 - for (ColumnModel column : tableModel.getColumns()) { - if (column.process(new IsSubColumnOfProcessor(parentTable))) { - colsToRemove.add((InheritanceColumnModel) column); - } - } - - tableModel.getColumns().removeAll(colsToRemove); - - return null; - } -} Deleted: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,62 +0,0 @@ -/* - * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. - * Created on 2008/08/01 - * - * 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.utils.processor.root; - -import org.jiemamy.spec.model.RootModel; -import org.jiemamy.spec.model.node.AbstractEntityModel; -import org.jiemamy.spec.model.node.TableModel; -import org.jiemamy.spec.model.node.ViewModel; -import org.jiemamy.spec.util.Processor; - -/** - * 適切な初期エンティティ名称を生成する。 - * @author daisuke - */ -public class GenerateEntityNameProcessor implements Processor<RootModel, String, RuntimeException> { - - private AbstractEntityModel entityModel; - - - /** - * コンストラクタ。 - * @param entityModel - * @category instance creation - */ - public GenerateEntityNameProcessor(AbstractEntityModel entityModel) { - this.entityModel = entityModel; - } - - /** - * {@inheritDoc} - */ - public String process(RootModel rootModel) { - String entityHead; - if (entityModel instanceof TableModel) { - entityHead = "TABLE_"; - } else if (entityModel instanceof ViewModel) { - entityHead = "VIEW_"; - } else { - entityHead = "UNKNOWN_"; - } - - int entityNumber = rootModel.getNodes().size(); - entityModel.setName(entityHead + entityNumber); - return entityHead + entityNumber; - } -} Added: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetConnectionsProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetConnectionsProcessor.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetConnectionsProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,66 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. Created on 2008/08/01 + * + * 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.utils.processor.root; + +import java.util.List; + +import org.seasar.framework.util.tiger.CollectionsUtil; + +import org.jiemamy.spec.model.RootModel; +import org.jiemamy.spec.model.connection.AbstractConnectionModel; +import org.jiemamy.spec.model.node.AbstractNodeModel; +import org.jiemamy.spec.util.Processor; + +/** + * 特定の種類のノードを取得する。 + * @param <T> ノードの種類を表すクラス + * @author daisuke + */ +public class GetConnectionsProcessor<T extends AbstractConnectionModel> implements + Processor<RootModel, List<T>, RuntimeException> { + + private Class<T> clazz; + + + public GetConnectionsProcessor() { + this(null); + } + + /** + * コンストラクタ。 + * @param clazz + * @category instance creation + */ + public GetConnectionsProcessor(Class<T> clazz) { + this.clazz = clazz; + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public List<T> process(RootModel rootModel) { + List<T> connections = CollectionsUtil.newArrayList(); + for (AbstractNodeModel node : rootModel.getNodes()) { + for (AbstractConnectionModel connection : node.getSourceConnections()) { + if (clazz == null || clazz.isAssignableFrom(connection.getClass())) { + connections.add((T) connection); + } + } + } + return connections; + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetConnectionsProcessor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetEntityProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetEntityProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetEntityProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -33,13 +33,28 @@ * エンティティを取得する。 * @author daisuke */ -public class GetEntityProcessor implements Processor<RootModel, AbstractEntityModel, TooManyElementsException> { +public class GetEntityProcessor<T extends AbstractEntityModel> implements + Processor<RootModel, AbstractEntityModel, TooManyElementsException> { + private Class<?> clazz; + private String entityName; /** * コンストラクタ。 + * @param <T> + * @param clazz + * @param entityName + * @category instance creation + */ + public <T> GetEntityProcessor(Class<T> clazz, String entityName) { + this.clazz = clazz; + this.entityName = entityName; + } + + /** + * コンストラクタ。 * @param entityName * @category instance creation */ @@ -56,7 +71,7 @@ for (AbstractNodeModel node : rootModel.getNodes()) { if (node instanceof AbstractEntityModel) { AbstractEntityModel entiy = (AbstractEntityModel) node; - if (entityName.equals(entiy.getName())) { + if (entityName.equals(entiy.getName()) && (clazz == null || clazz.isAssignableFrom(entiy.getClass()))) { entities.add(entiy); } } Modified: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetNodesProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetNodesProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GetNodesProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -52,7 +52,7 @@ if (nodeClass.getName().contains("$$") && node.getClass().getSuperclass().isAssignableFrom(clazz)) { // s2containerから取得したComponentの場合は、superClassで評価する。 nodes.add((T) node); - } else if (node.getClass().isAssignableFrom(clazz)) { + } else if (clazz.isAssignableFrom(node.getClass())) { nodes.add((T) node); } } Copied: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/ProvideEntityNameProcessor.java (from rev 1968, artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessor.java) =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/ProvideEntityNameProcessor.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/ProvideEntityNameProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,67 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/08/01 + * + * 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.utils.processor.root; + +import org.jiemamy.spec.extension.dialect.IdentifierValidator; +import org.jiemamy.spec.model.RootModel; +import org.jiemamy.spec.model.node.AbstractEntityModel; +import org.jiemamy.spec.model.node.TableModel; +import org.jiemamy.spec.model.node.ViewModel; +import org.jiemamy.spec.util.Processor; + +/** + * 適切な初期エンティティ名称を生成する。 + * @author daisuke + */ +public class ProvideEntityNameProcessor implements Processor<RootModel, String, RuntimeException> { + + private AbstractEntityModel entityModel; + + private IdentifierValidator validator; + + + /** + * コンストラクタ。 + * @param entityModel + * @param validator + * @category instance creation + */ + public ProvideEntityNameProcessor(AbstractEntityModel entityModel, IdentifierValidator validator) { + this.entityModel = entityModel; + this.validator = validator; + } + + /** + * {@inheritDoc} + */ + public String process(RootModel rootModel) { + String entityHead; + if (entityModel instanceof TableModel) { + entityHead = "TABLE_"; + } else if (entityModel instanceof ViewModel) { + entityHead = "VIEW_"; + } else { + entityHead = "UNKNOWN_"; + } + + int entityNumber = rootModel.getNodes().size(); + entityModel.setName(entityHead + entityNumber); + return entityHead + entityNumber; + } +} Property changes on: artemis/trunk/org.jiemamy.core/src/main/java/org/jiemamy/core/utils/processor/root/ProvideEntityNameProcessor.java ___________________________________________________________________ Name: svn:mime-type + text/plain Modified: artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon =================================================================== --- artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/main/resources/jiemamy-core.dicon 2008-09-28 15:28:23 UTC (rev 1969) @@ -1,7 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN" "http://www.seasar.org/dtd/components24.dtd"> -<components> +<components namespace="org.jiemamy"> + <component name="list" class="java.util.ArrayList" instance="prototype"/> + <component name="set" class="java.util.HashSet" instance="prototype"/> + <!-- Jiemamy Model --> <component class="org.jiemamy.core.model.RootModelImpl" instance="prototype"/> <component class="org.jiemamy.core.model.node.ViewModelImpl" instance="prototype"/> Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/base/ForeignKeyTestBase.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/base/ForeignKeyTestBase.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/base/ForeignKeyTestBase.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,9 +21,8 @@ import org.junit.After; import org.junit.Before; -import org.jiemamy.core.model.RootModelImpl; -import org.jiemamy.core.utils.processor.root.creation.CreateNewForeignKeyProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewTableProcessor; +import org.jiemamy.core.S2FactoryStrategy; +import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.node.TableModel; @@ -51,13 +50,16 @@ */ @Before public void setUp() throws Exception { - rootModel = new RootModelImpl(); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon")); + rootModel = RootModelFactory.createInstance(); - empTableModel = rootModel.process(new CreateNewTableProcessor("T_EMP")); - deptTableModel = rootModel.process(new CreateNewTableProcessor("T_DEPT")); + empTableModel = rootModel.createJiemamyModel(TableModel.class).init("T_EMP"); + rootModel.getNodes().add(empTableModel); + deptTableModel = rootModel.createJiemamyModel(TableModel.class).init("T_DEPT"); + rootModel.getNodes().add(deptTableModel); - foreignKeyModel = rootModel.process(new CreateNewForeignKeyProcessor(empTableModel, deptTableModel, true)); - selfRefFkModel = rootModel.process(new CreateNewForeignKeyProcessor(empTableModel, empTableModel, false)); + foreignKeyModel = rootModel.createJiemamyModel(ForeignKeyModel.class).init(empTableModel, deptTableModel); + selfRefFkModel = rootModel.createJiemamyModel(ForeignKeyModel.class).init(empTableModel, empTableModel); } /** Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/entity/GetForeignKeyParentsTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/entity/GetForeignKeyParentsTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/entity/GetForeignKeyParentsTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -40,9 +40,9 @@ */ @Test public void test01_name() throws Exception { - assertThat(deptTableModel.process(new GetReferenceEntitiesProcessor(true)).size(), is(0)); - assertThat(deptTableModel.process(new GetReferenceEntitiesProcessor(false)).size(), is(0)); - assertThat(empTableModel.process(new GetReferenceEntitiesProcessor(true)).size(), is(2)); - assertThat(empTableModel.process(new GetReferenceEntitiesProcessor(false)).size(), is(2)); + assertThat(deptTableModel.getReferenceEntities(true).size(), is(0)); + assertThat(deptTableModel.getReferenceEntities(false).size(), is(0)); + assertThat(empTableModel.getReferenceEntities(true).size(), is(2)); + assertThat(empTableModel.getReferenceEntities(false).size(), is(2)); } } Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GenerateEntityNameProcessorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -27,15 +27,14 @@ import org.junit.runner.RunWith; import org.seasar.framework.unit.Seasar2; -import org.jiemamy.core.model.RootModelImpl; -import org.jiemamy.core.utils.processor.root.creation.CreateNewTableProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewViewProcessor; +import org.jiemamy.core.S2FactoryStrategy; +import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.model.node.ViewModel; /** - * {@link GenerateEntityNameProcessor}のテストクラス。 + * {@link ProvideEntityNameProcessor}のテストクラス。 * @author daisuke */ @RunWith(Seasar2.class) @@ -50,7 +49,8 @@ */ @Before public void setUp() throws Exception { - rootModel = (new RootModelImpl()); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon")); + rootModel = RootModelFactory.createInstance(); } /** @@ -68,24 +68,20 @@ */ @Test public void test01_() throws Exception { - TableModel tableModel1 = rootModel.process(new CreateNewTableProcessor()); - String result1 = rootModel.process(new GenerateEntityNameProcessor(tableModel1)); - assertThat(result1, is("TABLE_1")); + TableModel tableModel1 = rootModel.createJiemamyModel(TableModel.class).init(); + rootModel.appendModel(tableModel1); assertThat(tableModel1.getName(), is("TABLE_1")); - TableModel tableModel2 = rootModel.process(new CreateNewTableProcessor()); - String result2 = rootModel.process(new GenerateEntityNameProcessor(tableModel2)); - assertThat(result2, is("TABLE_2")); + TableModel tableModel2 = rootModel.createJiemamyModel(TableModel.class).init(); + rootModel.appendModel(tableModel2); assertThat(tableModel2.getName(), is("TABLE_2")); - ViewModel viewModel1 = rootModel.process(new CreateNewViewProcessor()); - String result3 = rootModel.process(new GenerateEntityNameProcessor(viewModel1)); - assertThat(result3, is("VIEW_3")); + ViewModel viewModel1 = rootModel.createJiemamyModel(ViewModel.class).init(); + rootModel.appendModel(viewModel1); assertThat(viewModel1.getName(), is("VIEW_3")); - ViewModel viewModel2 = rootModel.process(new CreateNewViewProcessor()); - String result4 = rootModel.process(new GenerateEntityNameProcessor(viewModel2)); - assertThat(result4, is("VIEW_4")); + ViewModel viewModel2 = rootModel.createJiemamyModel(ViewModel.class).init(); + rootModel.appendModel(viewModel2); assertThat(viewModel2.getName(), is("VIEW_4")); } } Modified: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GetNodesProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GetNodesProcessorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/utils/processor/root/GetNodesProcessorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -27,9 +27,8 @@ import org.junit.runner.RunWith; import org.seasar.framework.unit.Seasar2; -import org.jiemamy.core.model.RootModelImpl; -import org.jiemamy.core.utils.processor.root.creation.CreateNewTableProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewViewProcessor; +import org.jiemamy.core.S2FactoryStrategy; +import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.model.node.ViewModel; @@ -50,7 +49,8 @@ */ @Before public void setUp() throws Exception { - rootModel = new RootModelImpl(); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon")); + rootModel = RootModelFactory.createInstance(); } /** @@ -68,14 +68,14 @@ */ @Test public void test01_rootModelから特定のエンティティを抽出するテスト() throws Exception { - rootModel.process(new CreateNewTableProcessor("table1")); - rootModel.process(new CreateNewTableProcessor("table2")); - rootModel.process(new CreateNewTableProcessor("table3")); - rootModel.process(new CreateNewViewProcessor("view1", "select * from table1")); - rootModel.process(new CreateNewViewProcessor("view2", "select * from table2")); + rootModel.getNodes().add(rootModel.createJiemamyModel(TableModel.class).init("table1")); + rootModel.getNodes().add(rootModel.createJiemamyModel(TableModel.class).init("table2")); + rootModel.getNodes().add(rootModel.createJiemamyModel(TableModel.class).init("table3")); + rootModel.getNodes().add(rootModel.createJiemamyModel(ViewModel.class).init("view1", "select * from table1")); + rootModel.getNodes().add(rootModel.createJiemamyModel(ViewModel.class).init("view2", "select * from table2")); // FIXME ↓ GetNodesProcessorのgenericsと引数が冗長。 - assertThat(rootModel.process(new GetNodesProcessor<TableModel>(TableModel.class)).size(), is(3)); - assertThat(rootModel.process(new GetNodesProcessor<ViewModel>(ViewModel.class)).size(), is(2)); + assertThat(rootModel.getNodes(TableModel.class).size(), is(3)); + assertThat(rootModel.getNodes(ViewModel.class).size(), is(2)); } } Modified: artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java =================================================================== --- artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.dialect/src/main/java/org/jiemamy/dialect/AbstractDialect.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -36,9 +36,6 @@ import org.jiemamy.core.model.datatype.adapter.SizedDataTypeAdapter; import org.jiemamy.core.utils.ForEachUtil; import org.jiemamy.core.utils.JmIOUtil; -import org.jiemamy.core.utils.processor.entity.table.CreateNewColumnProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewTableProcessor; -import org.jiemamy.core.utils.processor.root.creation.CreateNewViewProcessor; import org.jiemamy.core.utils.visitor.AbstractResultSetVisitor; import org.jiemamy.spec.exception.DataTypeNotFoundException; import org.jiemamy.spec.exception.IllegalDataTypeMappingException; @@ -188,8 +185,9 @@ * @return 読み込んだ結果生成された{@link TableModel} * @throws SQLException */ - private TableModel createTable(RootModel rootModel, String tableName, Connection connection) throws SQLException { - final TableModel tableModel = rootModel.process(new CreateNewTableProcessor()); + private TableModel createTable(final RootModel rootModel, String tableName, Connection connection) + throws SQLException { + final TableModel tableModel = rootModel.createJiemamyModel(TableModel.class); final List<ColumnModel> columns = new ArrayList<ColumnModel>(); tableModel.setName(tableName); @@ -212,7 +210,8 @@ String name = element.getString("COLUMN_NAME"); - ColumnModel column = tableModel.process(new CreateNewColumnProcessor(name, dataType)); + ColumnModel column = rootModel.createJiemamyModel(ColumnModel.class).init(name, dataType); + tableModel.getColumns().add(column); if (dataType.hasAdapter(SizedDataTypeAdapter.class)) { SizedDataTypeAdapter sized = dataType.getAdapter(SizedDataTypeAdapter.class); @@ -287,11 +286,12 @@ */ @SuppressWarnings("unused") private ViewModel createView(RootModel rootModel, String viewName, Connection connection) throws SQLException { - ViewModel view = rootModel.process(new CreateNewViewProcessor(viewName)); - // UNDONE ビューの定義SQLを取得する一般的な手段が分からない。 // bacchusでは実は実装できなかった所。 + String definition = null; + ViewModel view = rootModel.createJiemamyModel(ViewModel.class).init(viewName, definition); + return view; } } Modified: artemis/trunk/org.jiemamy.dialect/src/test/resources/test.dicon =================================================================== --- artemis/trunk/org.jiemamy.dialect/src/test/resources/test.dicon 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.dialect/src/test/resources/test.dicon 2008-09-28 15:28:23 UTC (rev 1969) @@ -4,5 +4,4 @@ <components> <include path="aop.dicon"/> <include path="jiemamy-dialect.dicon"/> - <component class="org.jiemamy.core.model.ApplicationModelCreator"/> </components> Modified: artemis/trunk/org.jiemamy.event/src/main/resources/jiemamy-event.dicon =================================================================== --- artemis/trunk/org.jiemamy.event/src/main/resources/jiemamy-event.dicon 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.event/src/main/resources/jiemamy-event.dicon 2008-09-28 15:28:23 UTC (rev 1969) @@ -3,6 +3,10 @@ "http://www.seasar.org/dtd/components24.dtd"> <components> <include path="jiemamy-core.dicon"/> + + <component name="list" class="org.jiemamy.spec.event.collectionimpl.ObservableList" instance="prototype"/> + <component name="set" class="org.jiemamy.spec.event.collectionimpl.ObservableSet" instance="prototype"/> + <!-- ChangeEventを自動的に発火させるためのsetterInterceptor --> <component name="setterInterceptor" class="org.jiemamy.core.event.SetterInterceptor"/> <component class="org.jiemamy.core.model.node.TableModelImpl" instance="prototype"> Modified: artemis/trunk/org.jiemamy.event/src/test/java/org/jiemamy/core/event/SetterInterceptorTest.java =================================================================== --- artemis/trunk/org.jiemamy.event/src/test/java/org/jiemamy/core/event/SetterInterceptorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.event/src/test/java/org/jiemamy/core/event/SetterInterceptorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -30,7 +30,7 @@ import org.seasar.framework.container.factory.S2ContainerFactory; import org.seasar.framework.util.tiger.CollectionsUtil; -import org.jiemamy.spec.DefaultFactoryStrategy; +import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.TableModel; @@ -70,6 +70,8 @@ */ @Before public void setUp() { + RootModelFactory.init(new S2FactoryStrategy("jiemamy-core.dicon")); + tableModel = (TableModel) s2container.getComponent(TableModel.class); listener = (new ModelChangeListenerImpl()); tableModel.getAdapter(Observable.class).addModelChangeListener(listener); @@ -100,7 +102,7 @@ */ @Test public void test_S2管理下ではないインスタンスには反応しない() { - RootModel rootModel = RootModelFactory.getInstance(new DefaultFactoryStrategy()).createInstance(); + RootModel rootModel = RootModelFactory.createInstance(); TableModel tableModel2 = rootModel.createJiemamyModel(TableModel.class).init("T_USER"); tableModel2.getAdapter(Observable.class).addModelChangeListener(listener); tableModel2.setBeginScript("abc"); Modified: artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModelImpl.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModelImpl.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/model/presentation/DiagramPresentationModelImpl.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -23,6 +23,7 @@ import java.util.Set; import org.jiemamy.core.model.AbstractModel; +import org.jiemamy.core.utils.processor.root.presentation.ResetBendpointProcessor; import org.jiemamy.spec.geometory.JmColor; import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.geometory.JmRectangle; @@ -107,6 +108,37 @@ } /** + * {@inheritDoc} + */ + public void resetBendpoints(AbstractConnectionModel connection) { + process(new ResetBendpointProcessor(connection)); + } + + /** + * {@inheritDoc} + */ + public void setBendpoints(AbstractConnectionModel connection, List<JmPoint> bendpoints) { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setColor(AbstractNodeModel node, JmColor color) { + // TODO Auto-generated method stub + + } + + /** + * {@inheritDoc} + */ + public void setConstraint(AbstractNodeModel node, JmRectangle constraint) { + // TODO Auto-generated method stub + + } + + /** * 表示モードを設定する。 * @param displayTargetSet 表示モード */ Modified: artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessor.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessor.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.view/src/main/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessor.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -22,10 +22,9 @@ import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.geometory.JmRectangle; -import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractConnectionModel; +import org.jiemamy.spec.model.presentation.DiagramPresentationModel; import org.jiemamy.spec.util.Processor; -import org.jiemamy.spec.view.DiagramPresentations; /** * ベンドポイントを初期化する。 @@ -33,32 +32,27 @@ * ベンドポイントは全て削除され、自己コネクションの時は、見やすさの為のベンドポイントを自動的に2つ設定する。 * @author daisuke */ -public class ResetBendpointProcessor implements Processor<RootModel, Void, RuntimeException> { +public class ResetBendpointProcessor implements Processor<DiagramPresentationModel, Void, RuntimeException> { private static final int AUTO_BENDPOINT_OFFSET = 50; - private int index; - private AbstractConnectionModel connection; /** * コンストラクタ。 - * @param index * @param connection * @category instance creation */ - public ResetBendpointProcessor(int index, AbstractConnectionModel connection) { - this.index = index; + public ResetBendpointProcessor(AbstractConnectionModel connection) { this.connection = connection; } /** * {@inheritDoc} */ - public Void process(RootModel rootModel) { - List<JmPoint> bendpoints = - rootModel.getAdapter(DiagramPresentations.class).get(index).getConnectionLayouts().get(connection); + public Void process(DiagramPresentationModel diagramPresentation) { + List<JmPoint> bendpoints = diagramPresentation.getConnectionLayouts().get(connection); if (bendpoints == null) { throw new IllegalStateException("表示されていないレイアウトをリセットしようとしました。"); } @@ -66,17 +60,15 @@ if (connection.isSelfConnection()) { // 自己コネクション時の、bendpoint自動作成 - JmRectangle rect = - rootModel.getAdapter(DiagramPresentations.class).get(index).getNodeLayouts().get( - connection.getSource()); + JmRectangle rect = diagramPresentation.getNodeLayouts().get(connection.getSource()); if (rect == null) { throw new IllegalStateException("表示されていないノードのコネクションを操作しようとしました。"); } - rootModel.getAdapter(DiagramPresentations.class).get(index).getConnectionLayouts().get(connection).add(0, + diagramPresentation.getConnectionLayouts().get(connection).add(0, new JmPoint(Math.max(rect.x - AUTO_BENDPOINT_OFFSET, 0), rect.y)); - rootModel.getAdapter(DiagramPresentations.class).get(index).getConnectionLayouts().get(connection).add(1, + diagramPresentation.getConnectionLayouts().get(connection).add(1, new JmPoint(rect.x, Math.max(rect.y - AUTO_BENDPOINT_OFFSET, 0))); } return null; Added: artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon =================================================================== --- artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon (rev 0) +++ artemis/trunk/org.jiemamy.view/src/main/resources/jiemamy-view.dicon 2008-09-28 15:28:23 UTC (rev 1969) @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE components PUBLIC "-//SEASAR//DTD S2Container 2.4//EN" + "http://www.seasar.org/dtd/components24.dtd"> +<components> + <include path="jiemamy-core.dicon"/> +</components> Modified: artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/ResetBendpointProcessorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,7 +28,8 @@ import org.junit.Ignore; import org.junit.Test; -import org.jiemamy.spec.FactoryStrategy; +import org.jiemamy.core.MustBeMulti; +import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.model.RootModel; @@ -59,13 +60,8 @@ */ @Before public void setUp() throws Exception { - rootModel = RootModelFactory.getInstance(new FactoryStrategy() { - - public RootModel createInstance() { - return null; - } - - }).createInstance(); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-view.dicon")); + rootModel = RootModelFactory.createInstance(); empTableModel = rootModel.createJiemamyModel(TableModel.class); empTableModel.setName("T_EMP"); @@ -100,14 +96,13 @@ @Ignore public void test01_ベンドポイントをリセットすると_通常ベンドポイントは0になり_自己参照時には2になる() throws Exception { List<JmPoint> bendpoints; - rootModel.process(new ResetBendpointProcessor(0, foreignKeyModel)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).resetBendpoints(foreignKeyModel); bendpoints = rootModel.getAdapter(DiagramPresentations.class).get(0).getConnectionLayouts().get(foreignKeyModel); assertThat(bendpoints.size(), is(0)); - rootModel.process(new ResetBendpointProcessor(0, selfRefFkModel)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).resetBendpoints(selfRefFkModel); bendpoints = rootModel.getAdapter(DiagramPresentations.class).get(0).getConnectionLayouts().get(selfRefFkModel); assertThat(bendpoints.size(), is(2)); } - } Modified: artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetColorProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetColorProcessorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetColorProcessorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,6 +28,7 @@ import org.junit.runner.RunWith; import org.seasar.framework.unit.Seasar2; +import org.jiemamy.core.MustBeMulti; import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.geometory.JmColor; @@ -54,7 +55,8 @@ */ @Before public void setUp() throws Exception { - rootModel = RootModelFactory.getInstance(new S2FactoryStrategy("jiemamy-view.dicon")).createInstance(); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-view.dicon")); + rootModel = RootModelFactory.createInstance(); DiagramPresentationModel presentation = rootModel.createJiemamyModel(DiagramPresentationModel.class); presentation.setName("テスト"); rootModel.appendModel(presentation); @@ -85,7 +87,8 @@ result = rootModel.getAdapter(DiagramPresentations.class).get(0).getNodeColors().get(tableModel); assertThat(result, nullValue()); - rootModel.process(new SetColorProcessor(0, tableModel, new JmColor(10, 20, 30))); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).setColor(tableModel, + new JmColor(10, 20, 30)); result = rootModel.getAdapter(DiagramPresentations.class).get(0).getNodeColors().get(tableModel); assertThat(result.red, is(10)); Modified: artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetConstraintProcessorTest.java =================================================================== --- artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetConstraintProcessorTest.java 2008-09-28 10:24:28 UTC (rev 1968) +++ artemis/trunk/org.jiemamy.view/src/test/java/org/jiemamy/core/utils/processor/root/presentation/SetConstraintProcessorTest.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,6 +28,7 @@ import org.junit.runner.RunWith; import org.seasar.framework.unit.Seasar2; +import org.jiemamy.core.MustBeMulti; import org.jiemamy.core.S2FactoryStrategy; import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.geometory.JmRectangle; @@ -54,7 +55,8 @@ */ @Before public void setUp() throws Exception { - rootModel = RootModelFactory.getInstance(new S2FactoryStrategy("jiemamy-view.dicon")).createInstance(); + RootModelFactory.init(new S2FactoryStrategy("jiemamy-view.dicon")); + rootModel = RootModelFactory.createInstance(); DiagramPresentationModel presentation = rootModel.createJiemamyModel(DiagramPresentationModel.class); presentation.setName("テスト"); rootModel.appendModel(presentation); @@ -85,7 +87,8 @@ result = rootModel.getAdapter(DiagramPresentations.class).get(0).getNodeLayouts().get(tableModel); assertThat(result, nullValue()); - rootModel.process(new SetConstraintProcessor(0, tableModel, new JmRectangle(100, 200))); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).setConstraint(tableModel, + new JmRectangle(100, 200)); result = rootModel.getAdapter(DiagramPresentations.class).get(0).getNodeLayouts().get(tableModel); assertThat(result.x, is(100)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -36,12 +36,6 @@ import org.eclipse.gef.commands.CompoundCommand; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.connection.IsCyclicProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetBendpointsProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; -import org.jiemamy.core.utils.processor.root.presentation.ResetBendpointProcessor; -import org.jiemamy.core.utils.processor.root.presentation.SetBendpointsProcessor; -import org.jiemamy.core.utils.processor.root.presentation.SetConstraintProcessor; import org.jiemamy.eclipse.editor.editpart.diagram.AbstractNodeEditPart; import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.geometory.JmRectangle; @@ -103,7 +97,7 @@ EntityNode node = (EntityNode) obj; List<AbstractConnectionModel> conns = node.model.getSourceConnections(); CONN_LOOP: for (AbstractConnectionModel conn : conns) { - if (conn.process(IsCyclicProcessor.getInstance())) { + if (conn.isSelfConnection()) { continue; } @@ -125,7 +119,7 @@ graph.setDefaultPadding(new Insets(40)); graph.nodes = graphNodes; graph.edges = graphEdges; - new DirectedGraphLayout().visit(graph); + (new DirectedGraphLayout()).visit(graph); for (Object obj : graph.nodes) { EntityNode node = (EntityNode) obj; commands.add(new LayoutCommand(rootModel, node.model, node.x, node.y)); @@ -194,7 +188,8 @@ this.y = y; oldX = rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().get(target).x; - oldY = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, target)).y; + oldY = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().get(target).y; } /** @@ -202,12 +197,15 @@ */ @Override public void execute() { - rootModel.process(new SetConstraintProcessor(MustBeMulti.ZERO, target, new JmRectangle(x, y, -1, -1))); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(target, + new JmRectangle(x, y, -1, -1)); oldBendpoints.clear(); for (AbstractConnectionModel conn : target.getSourceConnections()) { - List<JmPoint> points = rootModel.process(new GetBendpointsProcessor(MustBeMulti.ZERO, conn)); + List<JmPoint> points = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts() + .get(conn); oldBendpoints.put(conn.getId(), points); - conn.process(new ResetBendpointProcessor(MustBeMulti.ZERO, conn)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).resetBendpoints(conn); } } @@ -217,10 +215,11 @@ @Override public void undo() { for (AbstractConnectionModel conn : target.getSourceConnections()) { - rootModel.process(new SetBendpointsProcessor(MustBeMulti.ZERO, conn, oldBendpoints.get(conn.getId()))); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts().put(conn, + oldBendpoints.get(conn.getId())); } - rootModel - .process(new SetConstraintProcessor(MustBeMulti.ZERO, target, new JmRectangle(oldX, oldY, -1, -1))); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(target, + new JmRectangle(oldX, oldY, -1, -1)); } } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/FitNodeConstraintAction.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/FitNodeConstraintAction.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/action/FitNodeConstraintAction.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -23,12 +23,12 @@ import org.eclipse.gef.commands.CommandStack; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; import org.jiemamy.eclipse.editor.command.ChangeNodeConstraintCommand; import org.jiemamy.spec.geometory.JmRectangle; import org.jiemamy.spec.model.JiemamyModel; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.AbstractNodeModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * ノードのサイズをフィット(デフォルトサイズに変更)させるアクション。 @@ -55,7 +55,9 @@ if (model instanceof AbstractNodeModel) { AbstractNodeModel nodeModel = (AbstractNodeModel) model; CommandStack stack = getViewer().getEditDomain().getCommandStack(); - JmRectangle constraint = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, nodeModel)); + JmRectangle constraint = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().get( + nodeModel); JmRectangle newConstraint = new JmRectangle(constraint.x, constraint.y, -1, -1); @@ -64,5 +66,4 @@ stack.execute(command); } } - } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeColorCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeColorCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeColorCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,11 +21,10 @@ import org.eclipse.gef.commands.Command; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetColorProcessor; -import org.jiemamy.core.utils.processor.root.presentation.SetColorProcessor; import org.jiemamy.spec.geometory.JmColor; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.AbstractNodeModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * ノードの背景色変更コマンド。 @@ -52,7 +51,8 @@ public ChangeNodeColorCommand(RootModel rootModel, AbstractNodeModel nodeModel, JmColor newColor) { this.rootModel = rootModel; this.nodeModel = nodeModel; - oldColor = rootModel.process(new GetColorProcessor(MustBeMulti.ZERO, nodeModel)); + oldColor = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().get(nodeModel); this.newColor = newColor; } @@ -61,7 +61,7 @@ */ @Override public void execute() { - rootModel.process(new SetColorProcessor(MustBeMulti.ZERO, nodeModel, newColor)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().put(nodeModel, newColor); } /** @@ -69,6 +69,6 @@ */ @Override public void undo() { - rootModel.process(new SetColorProcessor(MustBeMulti.ZERO, nodeModel, oldColor)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().put(nodeModel, oldColor); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/ChangeNodeConstraintCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,9 +28,6 @@ import org.jiemamy.core.MustBeMulti; import org.jiemamy.core.model.AbstractModel; import org.jiemamy.core.utils.JmPointUtil; -import org.jiemamy.core.utils.processor.root.presentation.GetBendpointsProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; -import org.jiemamy.core.utils.processor.root.presentation.SetConstraintProcessor; import org.jiemamy.eclipse.utils.ConvertUtil; import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.geometory.JmRectangle; @@ -38,6 +35,7 @@ import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractConnectionModel; import org.jiemamy.spec.model.node.AbstractNodeModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * ノードの位置・サイズ変更コマンド @@ -77,7 +75,8 @@ this.rootModel = rootModel; this.nodeModel = nodeModel; - oldConstraint = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, nodeModel)); + oldConstraint = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().get(nodeModel); constraint = rectangle; this.viewer = viewer; @@ -106,7 +105,8 @@ @Override public void execute() { // 本体の移動 - rootModel.process(new SetConstraintProcessor(MustBeMulti.ZERO, nodeModel, constraint)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(nodeModel, + constraint); // ベンドポイントの移動 shiftBendpoints(false); @@ -120,7 +120,8 @@ */ @Override public void undo() { - rootModel.process(new SetConstraintProcessor(MustBeMulti.ZERO, nodeModel, constraint)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(nodeModel, + constraint); shiftBendpoints(true); shiftPosition(true); } @@ -140,7 +141,9 @@ for (AbstractConnectionModel connection : nodeModel.getSourceConnections()) { if (selectedModels.contains(connection.getSource()) && selectedModels.contains(connection.getTarget())) { - List<JmPoint> bendpoints = rootModel.process(new GetBendpointsProcessor(MustBeMulti.ZERO, connection)); + List<JmPoint> bendpoints = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts() + .get(connection); for (JmPoint bendpoint : bendpoints) { if (positive) { JmPointUtil.shiftPositive(bendpoint, delta); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateBendpointCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,11 +21,11 @@ import org.eclipse.draw2d.geometry.Point; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetBendpointsProcessor; import org.jiemamy.eclipse.utils.ConvertUtil; import org.jiemamy.spec.geometory.JmPoint; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractRelationModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * ベンドポイント追加コマンド。 @@ -67,8 +67,8 @@ */ @Override public void execute() { - rootModel.process(new GetBendpointsProcessor(MustBeMulti.ZERO, relation)).add(index, - ConvertUtil.convert(location)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts().get(relation) + .add(index, ConvertUtil.convert(location)); shiftPosition(false); } @@ -77,7 +77,8 @@ */ @Override public void undo() { - rootModel.process(new GetBendpointsProcessor(MustBeMulti.ZERO, relation)).remove(index); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts().get(relation) + .remove(index); shiftPosition(true); } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateConnectionCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateConnectionCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateConnectionCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,23 +18,11 @@ */ package org.jiemamy.eclipse.editor.command; -import java.util.List; - import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.gef.commands.Command; import org.seasar.eclipse.common.util.LogUtil; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.core.utils.processor.connection.DetachConnectionProcessor; -import org.jiemamy.core.utils.processor.connection.IsCyclicProcessor; -import org.jiemamy.core.utils.processor.connection.foreignkey.GenerateForeignKeyNameProcessor; -import org.jiemamy.core.utils.processor.entity.GetReferenceEntitiesProcessor; -import org.jiemamy.core.utils.processor.entity.GetSubEntitiesProcessor; -import org.jiemamy.core.utils.processor.entity.GetSuperEntitiesProcessor; -import org.jiemamy.core.utils.processor.entity.table.AddInheritedColumnsProcessor; -import org.jiemamy.core.utils.processor.entity.table.RemoveInheritedColumnsProcessor; -import org.jiemamy.core.utils.processor.root.presentation.ResetBendpointProcessor; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.preference.JiemamyPreference; import org.jiemamy.spec.model.RootModel; @@ -43,8 +31,8 @@ import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.model.node.AbstractNodeModel; import org.jiemamy.spec.model.node.StickyModel; -import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.model.node.ViewModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * コネクション作成コマンド。 @@ -95,37 +83,10 @@ if (connection instanceof ForeignKeyModel) { // 循環参照の禁止(ターゲットの親に自分がいたら、参照不可) - if (((AbstractEntityModel) target).process(new GetReferenceEntitiesProcessor(true)).contains(source)) { + if (((AbstractEntityModel) target).getReferenceEntities(true).contains(source)) { LogUtil.log(JiemamyPlugin.getDefault(), "attempt to create cyclic connection"); // RESOURCE return false; } - } else if (connection instanceof InheritanceModel) { - // 継承の二重コネクション禁止 - List<AbstractConnectionModel> connections = source.getSourceConnections(); - for (AbstractConnectionModel connection : connections) { - if (connection instanceof InheritanceModel && connection.process(IsCyclicProcessor.getInstance())) { - LogUtil.log(JiemamyPlugin.getDefault(), "attempt to connect double inheritance"); // RESOURCE - return false; - } - } - - // 継承の自己コネクション禁止 - if (source.equals(target)) { - LogUtil.log(JiemamyPlugin.getDefault(), "attempt to create self connect"); // RESOURCE - return false; - } - - // 循環継承の禁止(ターゲットの親に自分がいたら、継承不可) - if (((AbstractEntityModel) target).process(new GetSuperEntitiesProcessor(true)).contains(source)) { - LogUtil.log(JiemamyPlugin.getDefault(), "attempt to create cyclic inheritance"); // RESOURCE - return false; - } - - // 同エンティティの間接多重継承の禁止(ターゲットの子に自分がいたら、継承不可) - if (((AbstractEntityModel) target).process(new GetSubEntitiesProcessor(true)).contains(source)) { - LogUtil.log(JiemamyPlugin.getDefault(), "attempt xxx"); // TODO - return false; - } } return true; @@ -138,13 +99,11 @@ public void execute() { if (connection instanceof ForeignKeyModel) { createMappings(); - ((ForeignKeyModel) connection).process(GenerateForeignKeyNameProcessor.getInstance()); - } else if (connection instanceof InheritanceModel) { - ((TableModel) source).process(new AddInheritedColumnsProcessor((TableModel) target)); + rootModel.provideValidName((ForeignKeyModel) connection, null); } - rootModel.process(new ResetBendpointProcessor(MustBeMulti.ZERO, connection)); -// connection.firePropertyChange(create!); + rootModel.appendModel(connection); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).resetBendpoints(connection); } /** @@ -152,10 +111,7 @@ */ @Override public void redo() { - if (connection instanceof InheritanceModel) { - ((TableModel) source).process(new AddInheritedColumnsProcessor((TableModel) target)); - } -// connection.firePropertyChange(revert!); + rootModel.appendModel(connection); } /** @@ -189,16 +145,11 @@ */ @Override public void undo() { -// connection.firePropertyChange(delete!); - connection.process(DetachConnectionProcessor.getInstance()); - - if (connection instanceof InheritanceModel) { - ((TableModel) source).process(new RemoveInheritedColumnsProcessor((TableModel) target)); - } + rootModel.removeModel(connection); } private void createMappings() { JiemamyPreference pref = JiemamyPlugin.getPreference(); - ((ForeignKeyModel) connection).createMappings(pref.isCreateColumnWithFk()); + ((ForeignKeyModel) connection).createMappings(rootModel, pref.isCreateColumnWithFk()); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/CreateNodeCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -22,11 +22,10 @@ import org.eclipse.gef.commands.Command; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.RemoveFromDiagramProcessor; -import org.jiemamy.core.utils.processor.root.presentation.SetConstraintProcessor; import org.jiemamy.eclipse.utils.ConvertUtil; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.AbstractNodeModel; +import org.jiemamy.spec.view.DiagramPresentations; /** * ノード作成コマンド。 @@ -58,8 +57,8 @@ @Override public void execute() { rootModel.getNodes().add(nodeModel); - rootModel.process(new SetConstraintProcessor(MustBeMulti.ZERO, nodeModel, ConvertUtil.convert(rectangle))); -// nodeModel.firePropertyChange(create!); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(nodeModel, + ConvertUtil.convert(rectangle)); } /** @@ -68,8 +67,8 @@ @Override public void redo() { rootModel.getNodes().add(nodeModel); - rootModel.process(new SetConstraintProcessor(MustBeMulti.ZERO, nodeModel, ConvertUtil.convert(rectangle))); -// nodeModel.firePropertyChange(revert!); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().put(nodeModel, + ConvertUtil.convert(rectangle)); } /** @@ -77,8 +76,7 @@ */ @Override public void undo() { -// nodeModel.firePropertyChange(delete!); - rootModel.process(new RemoveFromDiagramProcessor(MustBeMulti.ZERO, nodeModel)); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts().remove(nodeModel); rootModel.getNodes().remove(nodeModel); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteNodeCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteNodeCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteNodeCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,22 +18,14 @@ */ package org.jiemamy.eclipse.editor.command; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.eclipse.gef.commands.Command; import org.seasar.framework.util.tiger.CollectionsUtil; -import org.jiemamy.core.model.InheritanceColumnModel; -import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.core.utils.processor.connection.DetachConnectionProcessor; -import org.jiemamy.core.utils.processor.entity.table.AddInheritedColumnsProcessor; -import org.jiemamy.core.utils.processor.entity.table.RemoveInheritedColumnsProcessor; import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractConnectionModel; import org.jiemamy.spec.model.node.AbstractNodeModel; -import org.jiemamy.spec.model.node.TableModel; /** * ノード削除コマンド @@ -52,10 +44,6 @@ /** 削除対象のモデルをターゲットとするコネクションのリスト */ private List<AbstractConnectionModel> targetConnections = CollectionsUtil.newArrayList(); - /** エンティティ削除と共に削除された継承カラムの情報(undo用) THINK */ - private Map<AbstractNodeModel, List<InheritanceColumnModel>> deletedInheritedColumns = - new HashMap<AbstractNodeModel, List<InheritanceColumnModel>>(); - /** * コンストラクタ。 @@ -77,21 +65,12 @@ targetConnections.addAll(targetNode.getTargetConnections()); for (AbstractConnectionModel connection : sourceConnections) { -// connection.firePropertyChange(delete!); - connection.process(DetachConnectionProcessor.getInstance()); + rootModel.removeModel(connection); } for (AbstractConnectionModel connection : targetConnections) { -// connection.firePropertyChange(delete!); - connection.process(DetachConnectionProcessor.getInstance()); - if (connection instanceof InheritanceModel) { - TableModel source = (TableModel) connection.getSource(); - TableModel target = (TableModel) connection.getTarget(); - (source).process(new RemoveInheritedColumnsProcessor(target)); - } + rootModel.removeModel(connection); } - -// targetNode.firePropertyChange(delete!); rootModel.getNodes().remove(targetNode); } @@ -102,23 +81,7 @@ public void undo() { rootModel.getNodes().add(targetNode); -// for (AbstractConnectionModel connection : sourceConnections) { -// connection.firePropertyChange(revert!); -// } - - for (AbstractConnectionModel connection : targetConnections) { - if (connection instanceof InheritanceModel) { - TableModel source = (TableModel) connection.getSource(); - TableModel target = (TableModel) connection.getTarget(); - source.process(new AddInheritedColumnsProcessor(target)); - } -// connection.firePropertyChange(revert!); - } - - deletedInheritedColumns.clear(); sourceConnections.clear(); targetConnections.clear(); - -// targetNode.firePropertyChange(revert!); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteRelationCommand.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteRelationCommand.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/command/DeleteRelationCommand.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,33 +20,28 @@ import org.eclipse.gef.commands.Command; -import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.core.utils.processor.connection.DetachConnectionProcessor; -import org.jiemamy.core.utils.processor.entity.table.AddInheritedColumnsProcessor; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractRelationModel; -import org.jiemamy.spec.model.node.AbstractNodeModel; -import org.jiemamy.spec.model.node.TableModel; /** * コネクション削除コマンド。 */ public class DeleteRelationCommand extends Command { - private AbstractNodeModel source, target; + private RootModel rootModel; private AbstractRelationModel relation; /** - * コンストラクタ - * - * @param model 削除対象のコネクション + * コンストラクタ。 + * @param rootModel + * @param relation 削除対象のコネクション */ - public DeleteRelationCommand(AbstractRelationModel model) { + public DeleteRelationCommand(RootModel rootModel, AbstractRelationModel relation) { super(); - relation = model; - source = relation.getSource(); - target = relation.getTarget(); + this.rootModel = rootModel; + this.relation = relation; } /** @@ -54,8 +49,7 @@ */ @Override public void execute() { -// relation.firePropertyChange(delete!); - relation.process(DetachConnectionProcessor.getInstance()); + rootModel.removeModel(relation); } /** @@ -63,11 +57,6 @@ */ @Override public void undo() { - if (relation instanceof InheritanceModel) { - ((TableModel) source).process(new AddInheritedColumnsProcessor((TableModel) target)); - } - - relation.process(DetachConnectionProcessor.getInstance()); -// relation.firePropertyChange(revert!); + rootModel.removeModel(relation); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractEntityEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,10 +20,8 @@ import org.eclipse.gef.tools.DirectEditManager; -import org.jiemamy.core.utils.processor.entity.GetSuperEntitiesProcessor; import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.util.ModelChangeEvent; -import org.jiemamy.spec.util.Observable; /** * {@link AbstractEntityModel}に対するDiagram用EditPart(コントローラ)の抽象クラス。 @@ -38,11 +36,6 @@ public void activate() { super.activate(); AbstractEntityModel entityModel = (AbstractEntityModel) getModel(); - - // 継承親モデルを監視開始 - for (AbstractEntityModel parent : entityModel.process(new GetSuperEntitiesProcessor(false))) { - parent.getAdapter(Observable.class).addModelChangeListener(this); - } } /** @@ -51,12 +44,6 @@ @Override public void deactivate() { AbstractEntityModel entityModel = (AbstractEntityModel) getModel(); - - // 継承親モデルを監視終了 - for (AbstractEntityModel parent : entityModel.process(new GetSuperEntitiesProcessor(false))) { - parent.getAdapter(Observable.class).removeModelChangeListener(this); - } - super.deactivate(); } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/AbstractRelationEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,7 +28,6 @@ import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetBendpointsProcessor; import org.jiemamy.eclipse.editor.editpolicy.JmBendpointEditPolicy; import org.jiemamy.eclipse.editor.editpolicy.JmRelationEditPolicy; import org.jiemamy.spec.geometory.JmPoint; @@ -37,6 +36,7 @@ import org.jiemamy.spec.util.ModelChangeEvent; import org.jiemamy.spec.util.ModelChangeListener; import org.jiemamy.spec.util.Observable; +import org.jiemamy.spec.view.DiagramPresentations; /** * Relationに対するDiagram用EditPart(コントローラ)。の抽象クラス。 @@ -113,7 +113,8 @@ private void refreshBendpoints() { RootModel rootModel = (RootModel) getRoot().getContents().getModel(); List<JmPoint> bendpoints = - rootModel.process(new GetBendpointsProcessor(MustBeMulti.ZERO, (AbstractRelationModel) getModel())); + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getConnectionLayouts().get( + getModel()); List<AbsoluteBendpoint> constraint = new ArrayList<AbsoluteBendpoint>(bendpoints.size()); for (JmPoint bendpoint : bendpoints) { Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ForeignKeyEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -29,7 +29,6 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; -import org.jiemamy.core.utils.processor.connection.foreignkey.UpdateMappingsProcessor; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.editpart.DoubleClickSupport; import org.jiemamy.eclipse.editor.editpart.EditDialogSupport; @@ -144,10 +143,11 @@ } private void updateMapping() { + RootModel rootModel = (RootModel) getRoot().getContents().getModel(); JiemamyPreference pref = JiemamyPlugin.getPreference(); ForeignKeyModel fkModel = (ForeignKeyModel) getModel(); - fkModel.process(new UpdateMappingsProcessor(pref.isCreateColumnWithFk())); + fkModel.updateMappings(rootModel, pref.isCreateColumnWithFk()); } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/StickyEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,8 +28,6 @@ import org.seasar.framework.container.S2Container; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetColorProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.figure.StickyFigure; import org.jiemamy.eclipse.utils.ConvertUtil; @@ -38,6 +36,7 @@ import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.StickyModel; import org.jiemamy.spec.util.ModelChangeEvent; +import org.jiemamy.spec.view.DiagramPresentations; /** * ビューモデルに対するDiagram用EditPart(コントローラ)。 @@ -138,7 +137,9 @@ StickyModel stickyModel = (StickyModel) getModel(); GraphicalEditPart editPart = (GraphicalEditPart) getParent(); - JmRectangle constraint = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, stickyModel)); + JmRectangle constraint = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts() + .get(stickyModel); editPart.setLayoutConstraint(this, getFigure(), ConvertUtil.convert(constraint)); updateFigure(getFigure()); @@ -154,7 +155,8 @@ StickyModel stickyModel = (StickyModel) getModel(); StickyFigure stickyFigure = (StickyFigure) figure; - JmColor color = rootModel.process(new GetColorProcessor(MustBeMulti.ZERO, stickyModel)); + JmColor color = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().get(stickyModel); stickyFigure.setContents(stickyModel.getContents()); stickyFigure.setBgColor(ConvertUtil.convert(color)); } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/TableEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -25,17 +25,9 @@ import org.eclipse.draw2d.StackLayout; import org.eclipse.gef.GraphicalEditPart; import org.eclipse.gef.NodeEditPart; -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; import org.seasar.framework.container.S2Container; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.model.InheritanceColumnModel; -import org.jiemamy.core.utils.processor.entity.GetSuperEntitiesProcessor; -import org.jiemamy.core.utils.processor.entity.table.RefreshInheritedColumnsProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetColorProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.DisplayPlace; import org.jiemamy.eclipse.editor.DisplayTarget; @@ -53,6 +45,7 @@ import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.model.presentation.DiagramPresentationModel.DisplayItem; import org.jiemamy.spec.util.ModelChangeEvent; +import org.jiemamy.spec.view.DiagramPresentations; /** * テーブルモデルに対するDiagram用EditPart(コントローラ)。 @@ -94,10 +87,6 @@ refreshTargetConnections(); updateFigure(getFigure()); // } - } else if (((TableModel) getModel()).process(new GetSuperEntitiesProcessor(false)).contains(evt.getSource())) { // 継承親の発火 -// if (evt.getField().equals(TableModel.P_ENTITY_TABLE_COLUMNS)) { // 継承親モデルのカラムが編集された時 - refreshInheritColumns((TableModel) evt.getSource()); -// } // } else if (((TableModel) getModel()).getSourceConnections().contains(evt.getSource())) { // source関連の発火 // if (evt.getField().equals(ForeignKeyModel.P_RELATION_FK_MAPPING)) { // マッピングが編集された時 // updateFigure(getFigure()); @@ -170,7 +159,9 @@ AbstractEntityModel entityModel = (AbstractEntityModel) getModel(); GraphicalEditPart editPart = (GraphicalEditPart) getParent(); - JmRectangle constraint = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, entityModel)); + JmRectangle constraint = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts() + .get(entityModel); editPart.setLayoutConstraint(this, getFigure(), ConvertUtil.convert(constraint)); updateFigure(getFigure()); @@ -187,7 +178,8 @@ String labelString = rootModel.process(new LabelStringProcessor(tableModel, DisplayTarget.NAME, DisplayPlace.FIGURE)); - JmColor color = rootModel.process(new GetColorProcessor(MustBeMulti.ZERO, tableModel)); + JmColor color = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().get(tableModel); tableFigure.setTableName(labelString); tableFigure.setBgColor(ConvertUtil.convert(color)); @@ -221,20 +213,9 @@ typeLabel.setUnderline(true); } - if (column instanceof InheritanceColumnModel) { - Font labelFont = new Font(null, new FontData("", 9, SWT.ITALIC)); - nameLabel.setFont(labelFont); - typeLabel.setFont(labelFont); - } - return new ColumnFigure[] { nameLabel, typeLabel }; } - - private void refreshInheritColumns(TableModel parent) { - TableModel tableModel = (TableModel) getModel(); - tableModel.process(new RefreshInheritedColumnsProcessor(parent)); - } } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/diagram/ViewEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -28,8 +28,6 @@ import org.seasar.framework.container.S2Container; import org.jiemamy.core.MustBeMulti; -import org.jiemamy.core.utils.processor.root.presentation.GetColorProcessor; -import org.jiemamy.core.utils.processor.root.presentation.GetConstraintProcessor; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.editor.DisplayPlace; import org.jiemamy.eclipse.editor.DisplayTarget; @@ -42,6 +40,7 @@ import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.model.node.ViewModel; import org.jiemamy.spec.util.ModelChangeEvent; +import org.jiemamy.spec.view.DiagramPresentations; /** * {@link ViewModel}に対するDiagram用EditPart(コントローラ)。 @@ -133,7 +132,9 @@ AbstractEntityModel entityModel = (AbstractEntityModel) getModel(); GraphicalEditPart editPart = (GraphicalEditPart) getParent(); - JmRectangle constraint = rootModel.process(new GetConstraintProcessor(MustBeMulti.ZERO, entityModel)); + JmRectangle constraint = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeLayouts() + .get(entityModel); editPart.setLayoutConstraint(this, getFigure(), ConvertUtil.convert(constraint)); updateFigure(getFigure()); @@ -150,7 +151,8 @@ String labelString = rootModel.process(new LabelStringProcessor(viewModel, DisplayTarget.NAME, DisplayPlace.FIGURE)); - JmColor color = rootModel.process(new GetColorProcessor(MustBeMulti.ZERO, viewModel)); + JmColor color = + rootModel.getAdapter(DiagramPresentations.class).get(MustBeMulti.ZERO).getNodeColors().get(viewModel); viewFigure.setEntityName(labelString); viewFigure.setBgColor(ConvertUtil.convert(color)); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/AbstractEntityTreeEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,7 +18,6 @@ */ package org.jiemamy.eclipse.editor.editpart.outlinetree; -import org.jiemamy.core.utils.processor.entity.GetSuperEntitiesProcessor; import org.jiemamy.spec.model.connection.AbstractConnectionModel; import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.util.ModelChangeEvent; @@ -50,11 +49,6 @@ for (AbstractConnectionModel connection : entity.getTargetConnections()) { connection.getAdapter(Observable.class).addModelChangeListener(this); } - - // 継承親モデルの監視 - for (AbstractEntityModel parent : entity.process(new GetSuperEntitiesProcessor(false))) { - parent.getAdapter(Observable.class).addModelChangeListener(this); - } } /** @@ -63,9 +57,6 @@ @Override public void deactivate() { AbstractEntityModel entity = (AbstractEntityModel) getModel(); - for (AbstractEntityModel parent : entity.process(new GetSuperEntitiesProcessor(false))) { - parent.getAdapter(Observable.class).removeModelChangeListener(this); - } for (AbstractConnectionModel connection : entity.getTargetConnections()) { connection.getAdapter(Observable.class).removeModelChangeListener(this); } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpart/outlinetree/RelationTreeEditPart.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,13 +21,12 @@ import org.eclipse.jface.resource.ImageRegistry; import org.jiemamy.core.model.connection.InheritanceModel; -import org.jiemamy.core.utils.processor.connection.IsCyclicProcessor; -import org.jiemamy.core.utils.processor.entity.table.IsCompositeKeyTableProcessor; import org.jiemamy.eclipse.Images; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.spec.model.connection.AbstractRelationModel; import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.node.AbstractEntityModel; +import org.jiemamy.spec.model.node.TableModel; import org.jiemamy.spec.util.ModelChangeEvent; /** @@ -63,12 +62,12 @@ if (model instanceof ForeignKeyModel) { ForeignKeyModel fkModel = (ForeignKeyModel) model; - if (fkModel.getTarget().process(IsCompositeKeyTableProcessor.getInstance()) + if (((TableModel) fkModel.getTarget()).getPrimaryKeyColumns().size() > 1 || fkModel.getMappings().size() == 0) { // 複合キー時 or マッピング未定義時 sb.append(fkModel.getName()).append(" (").append(((AbstractEntityModel) fkModel.getSource()).getName()) .append(" => ").append(((AbstractEntityModel) fkModel.getTarget()).getName()).append(")"); - } else if (fkModel.process(IsCyclicProcessor.getInstance())) { + } else if (fkModel.isSelfConnection()) { sb.append(fkModel.getName()).append(" (").append( fkModel.getMappings().get(0).getConstraintColumn().getName()).append(" => ").append( fkModel.getMappings().get(0).getReferenceColumn().getName()).append(")"); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmRelationEditPolicy.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -23,6 +23,7 @@ import org.eclipse.gef.requests.GroupRequest; import org.jiemamy.eclipse.editor.command.DeleteRelationCommand; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.connection.AbstractRelationModel; /** @@ -36,7 +37,9 @@ */ @Override protected Command getDeleteCommand(GroupRequest request) { - DeleteRelationCommand command = new DeleteRelationCommand((AbstractRelationModel) getHost().getModel()); + RootModel rootModel = (RootModel) getHost().getRoot().getContents().getModel(); + DeleteRelationCommand command = + new DeleteRelationCommand(rootModel, (AbstractRelationModel) getHost().getModel()); return command; } Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/editor/editpolicy/JmXYLayoutEditPolicy.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -25,7 +25,6 @@ import org.eclipse.gef.editpolicies.XYLayoutEditPolicy; import org.eclipse.gef.requests.CreateRequest; -import org.jiemamy.core.utils.processor.root.GenerateEntityNameProcessor; import org.jiemamy.eclipse.editor.command.ChangeNodeConstraintCommand; import org.jiemamy.eclipse.editor.command.CreateNodeCommand; import org.jiemamy.spec.model.RootModel; @@ -69,7 +68,7 @@ if (nodeModel instanceof AbstractEntityModel) { AbstractEntityModel abstractEntityModel = (AbstractEntityModel) nodeModel; - rootModel.process(new GenerateEntityNameProcessor(abstractEntityModel)); + rootModel.provideValidName(abstractEntityModel, null); } else if (nodeModel instanceof StickyModel) { StickyModel stickyModel = (StickyModel) nodeModel; stickyModel.setContents("default contents"); Modified: vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java =================================================================== --- vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2008-09-28 10:24:28 UTC (rev 1968) +++ vesta/trunk/org.jiemamy.eclipse/src/main/java/org/jiemamy/eclipse/wizard/NewDiagramWizard.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -31,10 +31,10 @@ import org.eclipse.ui.ide.IDE; import org.seasar.framework.container.S2Container; -import org.jiemamy.core.model.RootModelImpl; import org.jiemamy.eclipse.JiemamyPlugin; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.serializer.JiemamySerializer; +import org.jiemamy.spec.RootModelFactory; import org.jiemamy.spec.model.RootModel; /** @@ -142,7 +142,7 @@ */ @Override protected InputStream getInitialContents() { - RootModel rootModel = new RootModelImpl(); + RootModel rootModel = RootModelFactory.createInstance(); try { return serializer.serialize(rootModel); Modified: zeus/trunk/org.jiemamy.spec.core/META-INF/MANIFEST.MF =================================================================== --- zeus/trunk/org.jiemamy.spec.core/META-INF/MANIFEST.MF 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/META-INF/MANIFEST.MF 2008-09-28 15:28:23 UTC (rev 1969) @@ -7,8 +7,7 @@ Bundle-Vendor: Jiemamy Project Eclipse-BuddyPolicy: registered Eclipse-LazyStart: false -Export-Package: org.jiemamy.core.model, - org.jiemamy.spec, +Export-Package: org.jiemamy.spec, org.jiemamy.spec.adapter, org.jiemamy.spec.exception, org.jiemamy.spec.extension, Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/FactoryStrategy.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/FactoryStrategy.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/FactoryStrategy.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,14 +21,14 @@ import org.jiemamy.spec.model.RootModel; /** - * TODO for daisuke + * インスタンス生成戦略インターフェイス。 * @author daisuke */ public interface FactoryStrategy { /** - * TODO for daisuke - * @return + * {@link RootModel}のインスタンスを生成する。 + * @return {@link RootModel}のインスタンス */ RootModel createInstance(); Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/RootModelFactory.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/RootModelFactory.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/RootModelFactory.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,6 +18,7 @@ */ package org.jiemamy.spec; +import org.jiemamy.spec.exception.JiemamyRuntimeException; import org.jiemamy.spec.model.RootModel; /** @@ -26,41 +27,43 @@ */ public class RootModelFactory { - private static RootModelFactory singleton; + private static RootModelFactory instance; - public static RootModelFactory getInstance() { - return singleton; + /** + * 新しい {@link RootModel} のインスタンスを取得する。 + * @return {@link RootModel}のインスタンス。 + */ + public static RootModel createInstance() { + if (instance == null) { + throw new JiemamyRuntimeException("createInstance()呼び出し前に、init()が必要です。"); + } + return instance.strategy.createInstance(); } - public static RootModelFactory getInstance(FactoryStrategy strategy) { - if (singleton == null) { - singleton = (new RootModelFactory(strategy)); + /** + * ファクトリを初期化する。 + * @param strategy インスタンス生成戦略 + */ + public static void init(FactoryStrategy strategy) { + if (instance != null) { + return; +// throw new JiemamyRuntimeException("ファクトリは既に初期化済みです。"); } - return getInstance(); + instance = (new RootModelFactory(strategy)); } + /** インスタンス生成戦略 */ private FactoryStrategy strategy; - private RootModelFactory() { - strategy = (new DefaultFactoryStrategy()); - } - /** * privateコンストラクタ。 + * @param strategy インスタンス生成戦略 * @category instance creation */ private RootModelFactory(FactoryStrategy strategy) { this.strategy = strategy; } - - /** - * 新しい {@link RootModel} のインスタンスを取得する。 - * @return {@link RootModel}のインスタンス。 - */ - public RootModel createInstance() { - return strategy.createInstance(); - } } Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/ColumnModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/ColumnModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/ColumnModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -84,6 +84,14 @@ boolean hasConstraint(Class<? extends Constraint> clazz); /** + * TODO for daisuke + * @param columnName + * @param dataType + * @return + */ + ColumnModel init(String columnName, DataType dataType); + + /** * 代表カラムかどうかを取得する。 * @return 代表カラムかどうか */ @@ -95,13 +103,6 @@ */ boolean isSimpleIndex(); -// /** -// * カラムが、指定したテーブルから継承されたものであるかどうかを取得する。 -// * @param parentTable 親テーブル -// * @return 指定したテーブルから継承されたものであれば <code>true</code> -// */ -// boolean isSubColumnOf(TableModel parentTable); - /** * 制約を削除する。 * @param constraintClass 制約クラス Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/RootModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -21,8 +21,13 @@ import java.util.List; import java.util.Set; +import org.jiemamy.spec.exception.ElementNotFoundException; +import org.jiemamy.spec.exception.TooManyElementsException; +import org.jiemamy.spec.extension.dialect.IdentifierValidator; import org.jiemamy.spec.model.connection.AbstractConnectionModel; +import org.jiemamy.spec.model.connection.ForeignKeyModel; import org.jiemamy.spec.model.dataset.InsertDataSetModel; +import org.jiemamy.spec.model.node.AbstractEntityModel; import org.jiemamy.spec.model.node.AbstractNodeModel; /** @@ -37,23 +42,6 @@ */ void appendModel(JiemamyModel jiemamyModel); -// -// /** -// * 既存エンティティと衝突しない適切な初期エンティティ名で初期化を行う。 -// * @param entityModel 初期化対象のエンティティ -// * @param validator 識別子名の適切性を判断するバリデータ -// * additional logic -// */ -// void generateValidName(AbstractEntityModel entityModel, IdentifierValidator validator); -// -// /** -// * 既存リレーションと衝突しない適切な初期リレーション名で初期化を行う。 -// * @param relationModel 初期化対象のリレーション -// * @param validator 識別子名の適切性を判断するバリデータ -// * additional logic -// */ -// void generateValidName(ForeignKeyModel relationModel, IdentifierValidator validator); - /** * 新規にモデルインスタンスを生成する。 * @param <T> 生成するモデルの種類を表す型 @@ -69,20 +57,11 @@ */ String getBeginScript(); -// /** -// * 特定の種類のコネクション{@link Set}を取得する。 -// * @param <T> 取得したいコネクションのクラス -// * @param clazz 取得したいコネクションのクラス -// * @return コネクションの{@link List} -// * additional logic -// */ -// <T extends AbstractConnectionModel>Set<T> getConnections(Class<T> clazz); - /** * コネクションのリストを取得する。 * @return コネクションのリスト */ - Set<AbstractConnectionModel> getConnections(); + List<AbstractConnectionModel> getConnections(); /** * 説明文を取得する。 @@ -96,24 +75,21 @@ */ String getDialectClassName(); +// /** +// * 特定の種類のコネクション{@link Set}を取得する。 +// * @param <T> 取得したいコネクションのクラス +// * @param clazz 取得したいコネクションのクラス +// * @return コネクションの{@link List} +// * additional logic +// */ +// <T extends AbstractConnectionModel>Set<T> getConnections(Class<T> clazz); + /** * ドメインのリストを取得する。 * @return ドメインのリスト */ List<DomainModel> getDomains(); -// /** -// * 指定した名前を持つエンティティを取得する。 -// * @param <T> エンティティの種類 -// * @param clazz エンティティの種類 -// * @param entityName エンティティ名 -// * @return 見つかったエンティティ -// * @throws TooManyElementsException 同名のエンティティが複数見つかった場合 -// * @throws ElementNotFoundException エンティティが見つからなかった場合 -// * additional logic -// */ -// <T extends AbstractEntityModel>T getEntity(Class<T> clazz, String entityName) throws TooManyElementsException; - /** * 終了スクリプトを取得する。 * @return 終了スクリプト @@ -121,37 +97,36 @@ String getEndScript(); /** + * 指定した名前を持つエンティティを取得する。 + * @param <T> エンティティの種類 + * @param clazz エンティティの種類 + * @param entityName エンティティ名 + * @return 見つかったエンティティ + * @throws TooManyElementsException 同名のエンティティが複数見つかった場合 + * @throws ElementNotFoundException エンティティが見つからなかった場合 + * additional logic + */ + <T extends AbstractEntityModel>T getEntity(Class<T> clazz, String entityName) throws TooManyElementsException; + + /** * INSERTデータセットを取得する。 * @return INSERTデータセット */ List<InsertDataSetModel> getInsertDataSets(); -// /** -// * 特定の種類のノード{@link Set}を取得する。 -// * @param <T> 取得したいノードのクラス -// * @param clazz 取得したいノードのクラス -// * @return ノードの{@link List} -// */ -// <T extends AbstractNodeModel>Set<T> getNodes(Class<T> clazz); - /** * ノードのリストを取得する。 * @return ノードのリスト */ - Set<AbstractNodeModel> getNodes(); + List<AbstractNodeModel> getNodes(); -// /** -// * ベンドポイントを初期化する。 -// * -// * <p>異なるノード間のコネクションである場合、ベンドポイントは無くなるべきである(SHOULD)。 -// * また、同一ノード間のコネクション(自己参照)である場合、コネクションが見やすい位置に複数のベンドポイントを -// * 配置してもよい(MAY)。</p> -// * -// * @param index ダイアグラム番号 -// * @param connection 設定対象コネクション -// * additional logic -// */ -// void resetBendpoints(int index, AbstractConnectionModel connection); + /** + * 特定の種類のノード{@link Set}を取得する。 + * @param <T> 取得したいノードのクラス + * @param clazz 取得したいノードのクラス + * @return ノードの{@link List} + */ + <T extends AbstractNodeModel>List<T> getNodes(Class<T> clazz); /** * スキーマ名を取得する。 @@ -159,37 +134,29 @@ */ String getSchemaName(); -// /** -// * コネクションのベンドポイント情報を設定する。 -// * -// * <p>ベンドポイント情報のリストは、source側を起点とした順番で格納されたリストである。</p> -// * -// * @param index ダイアグラム番号 -// * @param connection 設定対象コネクション -// * @param bendpoints ベンドポイント情報のリスト -// * additional logic -// */ -// void setBendpoints(int index, AbstractConnectionModel connection, List<JmPoint> bendpoints); -// -// /** -// * ノードの背景色情報を設定する。 -// * @param index ダイアグラム番号 -// * @param node 設定対象ノード -// * @param color 背景色情報 -// * additional logic -// */ -// void setColor(int index, AbstractNodeModel node, JmColor color); -// -// /** -// * ノードの位置サイズ情報を設定する。 -// * @param index ダイアグラム番号 -// * @param node 設定対象ノード -// * @param constraint 位置サイズ情報 -// * additional logic -// */ -// void setConstraint(int index, AbstractNodeModel node, JmRectangle constraint); + /** + * 既存エンティティと衝突しない適切な初期エンティティ名で初期化を行う。 + * @param entityModel 初期化対象のエンティティ + * @param validator 識別子名の適切性を判断するバリデータ + * additional logic + */ + void provideValidName(AbstractEntityModel entityModel, IdentifierValidator validator); /** + * 既存リレーションと衝突しない適切な初期リレーション名で初期化を行う。 + * @param relationModel 初期化対象のリレーション + * @param validator 識別子名の適切性を判断するバリデータ + * additional logic + */ + void provideValidName(ForeignKeyModel relationModel, IdentifierValidator validator); + + /** + * TODO for daisuke + * @param jiemamyModel + */ + void removeModel(JiemamyModel jiemamyModel); + + /** * 開始スクリプトを設定する。 * @param beginScript 開始スクリプト */ Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyMapping.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyMapping.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyMapping.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,6 +20,8 @@ import org.jiemamy.spec.model.ColumnModel; import org.jiemamy.spec.model.JiemamyModel; +import org.jiemamy.spec.model.RootModel; +import org.jiemamy.spec.model.node.TableModel; /** * TODO for daisuke @@ -39,14 +41,6 @@ */ ColumnModel getReferenceColumn(); -// /** -// * デフォルトの「制約を受けるカラム」と「参照先カラム」を設定する。 -// * @param sourceTable -// * @param referencePkColumn -// * @param createColumn -// */ -// void initWithDefaultColumns(TableModel sourceTable, ColumnModel referencePkColumn, boolean createColumn); - /** * 制約を受けるカラムを設定する。 * @param constraintColumn 制約を受けるカラム @@ -54,6 +48,16 @@ void setConstraintColumn(ColumnModel constraintColumn); /** + * デフォルトの「制約を受けるカラム」と「参照先カラム」を設定する。 + * @param rootModel + * @param sourceTable + * @param referencePkColumn + * @param createColumnWithFk + */ + void setDefaultColumns(RootModel rootModel, TableModel sourceTable, ColumnModel referencePkColumn, + boolean createColumnWithFk); + + /** * 参照先カラムを設定する。 * @param referenceColumn 参照先カラム */ Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/connection/ForeignKeyModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -20,6 +20,8 @@ import java.util.List; +import org.jiemamy.spec.model.ColumnModel; +import org.jiemamy.spec.model.RootModel; import org.jiemamy.spec.model.node.TableModel; /** @@ -35,12 +37,12 @@ /** * targetを元に、マッピングを生成する。 - * + * @param rootModel * @param createColumn 参照先カラムと同名のカラムを生成して、そのカラムにマッピングする場合は<tt>true</tt> * 既存のカラムにマッピングする場合は<tt>false</tt>を渡す。 * TODO extract to processor */ - public void createMappings(boolean createColumn); + public void createMappings(RootModel rootModel, boolean createColumn); /** * 説明文を取得する。 @@ -61,6 +63,13 @@ public String getLogicalName(); /** + * TODO for daisuke + * @param referencePkColumn + * @return + */ + public ForeignKeyMapping getMapping(ColumnModel referencePkColumn); + + /** * マッピングのリストを取得する。 * @return マッピングのリスト */ @@ -92,6 +101,15 @@ /** * TODO for daisuke + * @param fkName + * @param source + * @param target + * @return + */ + public ForeignKeyModel init(String fkName, TableModel source, TableModel target); + + /** + * TODO for daisuke * @param source * @param target * @return @@ -152,6 +170,13 @@ */ public void setOnUpdate(ReferentialAction onUpdate); + /** + * TODO for daisuke + * @param rootModel + * @param createColumnWithFk + */ + public void updateMappings(RootModel rootModel, boolean createColumnWithFk); + /** * 制約検査を行うデフォルトの時期。 Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/datatype/DataType.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/datatype/DataType.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/datatype/DataType.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -30,6 +30,9 @@ */ public interface DataType extends JiemamyModel { + /** + * {@inheritDoc} + */ List<Object> getAdapters(); /** Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/AbstractEntityModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/AbstractEntityModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/AbstractEntityModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -18,6 +18,8 @@ */ package org.jiemamy.spec.model.node; +import java.util.List; +import java.util.Set; /** * TODO for daisuke @@ -31,12 +33,12 @@ */ String getBeginScript(); -// /** -// * 指定したエンティティが外部キー制約によって参照しているエンティティの {@link Set} を取得する。 -// * @param recursive 再帰的に検索する場合は <code>true</code> -// * @return 外部キー制約によって参照しているエンティティの {@link Set} -// */ -// Set<AbstractEntityModel> getConstrainEntities(boolean recursive); + /** + * 指定したエンティティが外部キー制約によって参照しているエンティティの {@link Set} を取得する。 + * @param recursive 再帰的に検索する場合は <code>true</code> + * @return 外部キー制約によって参照しているエンティティの {@link Set} + */ + List<AbstractEntityModel> getConstrainEntities(boolean recursive); /** * 説明文を取得する。 @@ -62,26 +64,12 @@ */ String getName(); -// /** -// * 指定したエンティティが外部キー制約によって参照しているエンティティの {@link Set} を取得する。 -// * @param recursive 再帰的に検索する場合は <code>true</code> -// * @return 外部キー制約によって参照しているエンティティの {@link Set} -// */ -// Set<AbstractEntityModel> getReferenceEntities(boolean recursive); -// -// /** -// * 指定したエンティティの継承派生エンティティの {@link Set} を取得する。 -// * @param recursive 再帰的に検索する場合は <code>true</code> -// * @return 継承派生エンティティの {@link Set} -// */ -// Set<AbstractEntityModel> getSubEntities(boolean recursive); -// -// /** -// * 指定したエンティティの継承基底エンティティの {@link Set} を取得する。 -// * @param recursive 再帰的に検索する場合は <code>true</code> -// * @return 継承基底エンティティの {@link Set} -// */ -// Set<AbstractEntityModel> getSuperEntities(boolean recursive); + /** + * 指定したエンティティが外部キー制約によって参照しているエンティティの {@link Set} を取得する。 + * @param recursive 再帰的に検索する場合は <code>true</code> + * @return 外部キー制約によって参照しているエンティティの {@link Set} + */ + List<AbstractEntityModel> getReferenceEntities(boolean recursive); /** * 開始スクリプトを設定する。 Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/TableModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/TableModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/TableModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -19,7 +19,10 @@ package org.jiemamy.spec.model.node; import java.util.List; +import java.util.Set; +import org.jiemamy.spec.exception.ElementNotFoundException; +import org.jiemamy.spec.exception.TooManyElementsException; import org.jiemamy.spec.model.ColumnModel; import org.jiemamy.spec.model.constraint.CheckConstraintModel; import org.jiemamy.spec.model.index.IndexModel; @@ -36,14 +39,14 @@ */ List<CheckConstraintModel> getChecks(); -// /** -// * 指定した名前を持つカラムを取得する。 -// * @param columnName カラム名 -// * @return 見つかったカラム -// * @throws TooManyElementsException 同名のカラムが複数見つかった場合 -// * @throws ElementNotFoundException カラムが見つからなかった場合 -// */ -// ColumnModel getColumn(String columnName) throws TooManyElementsException; + /** + * 指定した名前を持つカラムを取得する。 + * @param columnName カラム名 + * @return 見つかったカラム + * @throws TooManyElementsException 同名のカラムが複数見つかった場合 + * @throws ElementNotFoundException カラムが見つからなかった場合 + */ + ColumnModel getColumn(String columnName) throws TooManyElementsException; /** * カラムのリストを取得する。 @@ -58,22 +61,22 @@ List<IndexModel> getIndexes(); /** + * 主キーカラムの {@link Set} を取得する。 + * @return 主キーカラムの {@link Set} + */ + List<ColumnModel> getPrimaryKeyColumns(); + + /** * TODO for daisuke + * @return + */ + TableModel init(); + + /** + * TODO for daisuke * @param tableName * @return */ TableModel init(String tableName); -// /** -// * 主キーカラムの {@link Set} を取得する。 -// * @return 主キーカラムの {@link Set} -// */ -// Set<ColumnModel> getPrimaryKeyColumns(); - -// /** -// * 複合キーテーブルかどうかを取得する。 -// * @return 複合キーテーブルであれば <code>true</code> -// */ -// boolean isCompositeKeyTable(); - } Modified: zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/ViewModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/ViewModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.core/src/main/java/org/jiemamy/spec/model/node/ViewModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -31,6 +31,20 @@ String getDefinition(); /** + * TODO for daisuke + * @return + */ + ViewModel init(); + + /** + * TODO for daisuke + * @param viewName + * @param definition + * @return + */ + ViewModel init(String viewName, String definition); + + /** * VIEW定義SELECT文を設定する。 * @param definition VIEW定義SELECT文 */ Modified: zeus/trunk/org.jiemamy.spec.view/src/main/java/org/jiemamy/spec/model/presentation/DiagramPresentationModel.java =================================================================== --- zeus/trunk/org.jiemamy.spec.view/src/main/java/org/jiemamy/spec/model/presentation/DiagramPresentationModel.java 2008-09-28 10:24:28 UTC (rev 1968) +++ zeus/trunk/org.jiemamy.spec.view/src/main/java/org/jiemamy/spec/model/presentation/DiagramPresentationModel.java 2008-09-28 15:28:23 UTC (rev 1969) @@ -66,6 +66,45 @@ Map<AbstractNodeModel, JmRectangle> getNodeLayouts(); /** + * ベンドポイントを初期化する。 + * + * <p>異なるノード間のコネクションである場合、ベンドポイントは無くなるべきである(SHOULD)。 + * また、同一ノード間のコネクション(自己参照)である場合、コネクションが見やすい位置に複数のベンドポイントを + * 配置してもよい(MAY)。</p> + * + * @param connection 設定対象コネクション + * additional logic + */ + void resetBendpoints(AbstractConnectionModel connection); + + /** + * コネクションのベンドポイント情報を設定する。 + * + * <p>ベンドポイント情報のリストは、source側を起点とした順番で格納されたリストである。</p> + * + * @param connection 設定対象コネクション + * @param bendpoints ベンドポイント情報のリスト + * additional logic + */ + void setBendpoints(AbstractConnectionModel connection, List<JmPoint> bendpoints); + + /** + * ノードの背景色情報を設定する。 + * @param node 設定対象ノード + * @param color 背景色情報 + * additional logic + */ + void setColor(AbstractNodeModel node, JmColor color); + + /** + * ノードの位置サイズ情報を設定する。 + * @param node 設定対象ノード + * @param constraint 位置サイズ情報 + * additional logic + */ + void setConstraint(AbstractNodeModel node, JmRectangle constraint); + + /** * 表示モードを設定する。 * @param displayTargetSet 表示モード */