cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torehal...@apache.org
Subject svn commit: r783019 - in /cayenne/main/trunk/framework: cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/ cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/
Date Tue, 09 Jun 2009 14:47:18 GMT
Author: torehalset
Date: Tue Jun  9 14:47:18 2009
New Revision: 783019

URL: http://svn.apache.org/viewvc?rev=783019&view=rev
Log:
CAY-1169 - Weird behavior when adding entity via merging
use events to update the modeler for merge-changes to the model

Added:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DefaultModelMergeDelegate.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ModelMergeDelegate.java
Modified:
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropTableToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ExecutingMergerContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergeDirection.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergerContext.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToModel.java
    cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToModel.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
    cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AbstractToModelToken.java
Tue Jun  9 14:47:18 2009
@@ -41,7 +41,7 @@
         return MergeDirection.TO_MODEL;
     }
 
-    protected void synchronizeWithObjEntity(DbEntity entity) {
+    protected void synchronizeWithObjEntity(MergerContext mergerContext, DbEntity entity)
{
         for (ObjEntity objEntity : objEntitiesMappedToDbEntity(entity)) {
             new EntityMergeSupport(objEntity.getDataMap())
                     .synchronizeWithDbEntity(objEntity);
@@ -62,30 +62,32 @@
         return objEntities;
     }
     
-    protected void remove(DbRelationship rel, boolean reverse) {
+    protected void remove(MergerContext mergerContext, DbRelationship rel, boolean reverse)
{
         if (rel == null) {
             return;
         }
         if (reverse) {
-            remove(rel.getReverseRelationship(), false);
+            remove(mergerContext, rel.getReverseRelationship(), false);
         }
 
         DbEntity dbEntity = (DbEntity) rel.getSourceEntity();
         for (ObjEntity objEntity : objEntitiesMappedToDbEntity(dbEntity)) {
-            remove(objEntity.getRelationshipForDbRelationship(rel), true);
+            remove(mergerContext, objEntity.getRelationshipForDbRelationship(rel), true);
         }
         
         rel.getSourceEntity().removeRelationship(rel.getName());
+        mergerContext.getModelMergeDelegate().dbRelationshipRemoved(rel);
     }
 
-    protected void remove(ObjRelationship rel, boolean reverse) {
+    protected void remove(MergerContext mergerContext, ObjRelationship rel, boolean reverse)
{
         if (rel == null) {
             return;
         }
         if (reverse) {
-            remove(rel.getReverseRelationship(), false);
+            remove(mergerContext, rel.getReverseRelationship(), false);
         }
         rel.getSourceEntity().removeRelationship(rel.getName());
+        mergerContext.getModelMergeDelegate().objRelationshipRemoved(rel);
     }
 
     @Override

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddColumnToModel.java
Tue Jun  9 14:47:18 2009
@@ -40,7 +40,8 @@
 
     public void execute(MergerContext mergerContext) {
         getEntity().addAttribute(getColumn());
-        synchronizeWithObjEntity(getEntity());
+        synchronizeWithObjEntity(mergerContext, getEntity());
+        mergerContext.getModelMergeDelegate().dbAttributeAdded(getColumn());
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/AddRelationshipToModel.java
Tue Jun  9 14:47:18 2009
@@ -37,7 +37,8 @@
     public void execute(MergerContext mergerContext) {
         getEntity().addRelationship(rel);
         // TODO: add reverse relationship as well if it does not exist
-        synchronizeWithObjEntity(getEntity());
+        synchronizeWithObjEntity(mergerContext, getEntity());
+        mergerContext.getModelMergeDelegate().dbRelationshipAdded(rel);
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/CreateTableToModel.java
Tue Jun  9 14:47:18 2009
@@ -101,7 +101,10 @@
         
         map.addObjEntity(objEntity);
 
-        synchronizeWithObjEntity(getEntity());
+        synchronizeWithObjEntity(mergerContext, getEntity());
+        
+        mergerContext.getModelMergeDelegate().dbEntityAdded(getEntity());
+        mergerContext.getModelMergeDelegate().objEntityAdded(objEntity);
     }
 
     public String getTokenName() {

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DefaultModelMergeDelegate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DefaultModelMergeDelegate.java?rev=783019&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DefaultModelMergeDelegate.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DefaultModelMergeDelegate.java
Tue Jun  9 14:47:18 2009
@@ -0,0 +1,76 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.apache.cayenne.merge;
+
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+
+/**
+ * A default implementation of {@link ModelMergeDelegate} that does nothing by
+ * itself.
+ */
+class DefaultModelMergeDelegate implements ModelMergeDelegate {
+
+    public void dbAttributeAdded(DbAttribute att) {
+    }
+
+    public void dbAttributeModified(DbAttribute att) {
+    }
+
+    public void dbAttributeRemoved(DbAttribute att) {
+    }
+
+    public void dbEntityAdded(DbEntity ent) {
+    }
+
+    public void dbEntityRemoved(DbEntity ent) {
+    }
+
+    public void dbRelationshipAdded(DbRelationship rel) {
+    }
+
+    public void dbRelationshipRemoved(DbRelationship rel) {
+    }
+
+    public void objAttributeAdded(ObjAttribute att) {
+    }
+
+    public void objAttributeModified(ObjAttribute att) {
+    }
+
+    public void objAttributeRemoved(ObjAttribute att) {
+    }
+
+    public void objEntityAdded(ObjEntity ent) {
+    }
+
+    public void objEntityRemoved(ObjEntity ent) {
+    }
+
+    public void objRelationshipAdded(ObjRelationship rel) {
+    }
+
+    public void objRelationshipRemoved(ObjRelationship rel) {
+    }
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropColumnToModel.java
Tue Jun  9 14:47:18 2009
@@ -51,7 +51,7 @@
         for (DbRelationship dbRelationship : dbRelationships) {
             for (DbJoin join : dbRelationship.getJoins()) {
                 if (join.getSource() == getColumn() || join.getTarget() == getColumn()) {
-                    remove(dbRelationship, true);
+                    remove(mergerContext, dbRelationship, true);
                 }
             }
         }
@@ -61,12 +61,15 @@
             ObjAttribute objAttribute = objEntity.getAttributeForDbAttribute(getColumn());
             if (objAttribute != null) {
                 objEntity.removeAttribute(objAttribute.getName());
+                mergerContext.getModelMergeDelegate().objAttributeRemoved(objAttribute);
             }
 
         }
 
         // remove DbAttribute
         getEntity().removeAttribute(getColumn().getName());
+
+        mergerContext.getModelMergeDelegate().dbAttributeRemoved(getColumn());
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropRelationshipToModel.java
Tue Jun  9 14:47:18 2009
@@ -35,7 +35,7 @@
     }
 
     public void execute(MergerContext mergerContext) {
-        remove(rel, true);
+        remove(mergerContext, rel, true);
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropTableToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropTableToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropTableToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/DropTableToModel.java
Tue Jun  9 14:47:18 2009
@@ -40,8 +40,10 @@
     public void execute(MergerContext mergerContext) {
         for (ObjEntity objEntity : objEntitiesMappedToDbEntity(getEntity())) {
             objEntity.getDataMap().removeObjEntity(objEntity.getName(), true);
+            mergerContext.getModelMergeDelegate().objEntityRemoved(objEntity);
         }
         getEntity().getDataMap().removeDbEntity(getEntity().getName(), true);
+        mergerContext.getModelMergeDelegate().dbEntityRemoved(getEntity());
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ExecutingMergerContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ExecutingMergerContext.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ExecutingMergerContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ExecutingMergerContext.java
Tue Jun  9 14:47:18 2009
@@ -37,17 +37,20 @@
     private DbAdapter adapter;
     private DataSource dataSource;
     private ValidationResult result = new ValidationResult();
+    private ModelMergeDelegate delegate;
 
     public ExecutingMergerContext(DataMap map, DataNode node) {
         this.map = map;
         this.dataSource = node.getDataSource();
         this.adapter = node.getAdapter();
+        this.delegate = new DefaultModelMergeDelegate();
     }
 
-    public ExecutingMergerContext(DataMap map, DataSource dataSource, DbAdapter adapter)
{
+    public ExecutingMergerContext(DataMap map, DataSource dataSource, DbAdapter adapter,
ModelMergeDelegate delegate) {
         this.map = map;
         this.dataSource = dataSource;
         this.adapter = adapter;
+        this.delegate = delegate;
     }
 
     public void executeSql(String sql) {
@@ -93,4 +96,8 @@
         return result;
     }
 
+    public ModelMergeDelegate getModelMergeDelegate() {
+        return delegate;
+    }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergeDirection.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergeDirection.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergeDirection.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergeDirection.java
Tue Jun  9 14:47:18 2009
@@ -21,61 +21,44 @@
 /**
  * Represent a merge direction that can be one of two. Either from the model to the db or
  * from the db to the model.
- * 
  */
-public class MergeDirection {
+public enum MergeDirection {
 
-    private static final int TO_DB_ID = 1;
-    private static final int TO_MODEL_ID = 2;
+    TO_DB("To DB"), TO_MODEL("To Model");
 
-    public static final MergeDirection TO_DB = new MergeDirection(TO_DB_ID, "To DB");
-    public static final MergeDirection TO_MODEL = new MergeDirection(
-            TO_MODEL_ID,
-            "To Model");
-
-    private int id;
     private String name;
 
-    private MergeDirection(int id, String name) {
-        this.id = id;
+    private MergeDirection(String name) {
         this.name = name;
     }
 
     public String getName() {
         return name;
     }
-    
+
     public boolean isToDb() {
-        return (id == TO_DB_ID);
+        return (this == TO_DB);
     }
 
     public boolean isToModel() {
-        return (id == TO_MODEL_ID);
-    }
-    
-    @Override
-    public boolean equals(Object obj) {
-        return (obj == this);
-    }
-
-    @Override
-    public int hashCode() {
-        return id * 17;
+        return (this == TO_MODEL);
     }
 
     @Override
     public String toString() {
+        super.toString();
         return getName();
     }
-
+    
     public MergeDirection reverseDirection() {
-        switch (id) {
-            case TO_DB_ID:
+        switch (this) {
+            case TO_DB:
                 return TO_MODEL;
-            case TO_MODEL_ID:
+            case TO_MODEL:
                 return TO_DB;
             default:
-                throw new IllegalStateException("Invalid direction id: " + id);
+                throw new IllegalStateException("Invalid direction: " + this);
         }
     }
+
 }

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergerContext.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergerContext.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergerContext.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/MergerContext.java
Tue Jun  9 14:47:18 2009
@@ -31,6 +31,8 @@
 
     public void executeSql(String sql);
     
+    public ModelMergeDelegate getModelMergeDelegate();
+    
     public DbAdapter getAdapter();
 
     public DataMap getDataMap();

Added: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ModelMergeDelegate.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ModelMergeDelegate.java?rev=783019&view=auto
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ModelMergeDelegate.java
(added)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/ModelMergeDelegate.java
Tue Jun  9 14:47:18 2009
@@ -0,0 +1,65 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.apache.cayenne.merge;
+
+import org.apache.cayenne.access.DbLoaderDelegate;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+
+/**
+ * A interface used to tell about modifications performed on the model by
+ * {@link MergerToken} with {@link MergeDirection#TO_MODEL}
+ * 
+ * @see DbLoaderDelegate
+ */
+public interface ModelMergeDelegate {
+
+    public void dbEntityAdded(DbEntity ent);
+
+    public void dbEntityRemoved(DbEntity ent);
+
+    public void objEntityAdded(ObjEntity ent);
+
+    public void objEntityRemoved(ObjEntity ent);
+
+    public void dbAttributeAdded(DbAttribute att);
+
+    public void dbAttributeRemoved(DbAttribute att);
+
+    public void dbAttributeModified(DbAttribute att);
+
+    public void objAttributeAdded(ObjAttribute att);
+
+    public void objAttributeRemoved(ObjAttribute att);
+
+    public void objAttributeModified(ObjAttribute att);
+
+    public void dbRelationshipAdded(DbRelationship rel);
+
+    public void dbRelationshipRemoved(DbRelationship rel);
+
+    public void objRelationshipAdded(ObjRelationship rel);
+
+    public void objRelationshipRemoved(ObjRelationship rel);
+
+}

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetAllowNullToModel.java
Tue Jun  9 14:47:18 2009
@@ -37,6 +37,7 @@
 
     public void execute(MergerContext mergerContext) {
         getColumn().setMandatory(false);
+        mergerContext.getModelMergeDelegate().dbAttributeModified(getColumn());
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetColumnTypeToModel.java
Tue Jun  9 14:47:18 2009
@@ -49,6 +49,7 @@
         columnOriginal.setMaxLength(columnNew.getMaxLength());
         columnOriginal.setAttributePrecision(columnNew.getAttributePrecision());
         columnOriginal.setScale(columnNew.getScale());
+        mergerContext.getModelMergeDelegate().dbAttributeModified(columnOriginal);
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToModel.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToModel.java
(original)
+++ cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/merge/SetNotNullToModel.java
Tue Jun  9 14:47:18 2009
@@ -37,6 +37,7 @@
 
     public void execute(MergerContext mergerContext) {
         getColumn().setMandatory(true);
+        mergerContext.getModelMergeDelegate().dbAttributeModified(getColumn());
     }
 
     public String getTokenName() {

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/db/MergerOptions.java
Tue Jun  9 14:47:18 2009
@@ -34,16 +34,30 @@
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 
+import org.apache.cayenne.access.DataDomain;
+import org.apache.cayenne.access.DataNode;
 import org.apache.cayenne.dba.DbAdapter;
 import org.apache.cayenne.map.DataMap;
+import org.apache.cayenne.map.DbAttribute;
+import org.apache.cayenne.map.DbEntity;
+import org.apache.cayenne.map.DbRelationship;
+import org.apache.cayenne.map.ObjAttribute;
+import org.apache.cayenne.map.ObjEntity;
+import org.apache.cayenne.map.ObjRelationship;
+import org.apache.cayenne.map.event.EntityEvent;
+import org.apache.cayenne.map.event.MapEvent;
 import org.apache.cayenne.merge.DbMerger;
 import org.apache.cayenne.merge.ExecutingMergerContext;
 import org.apache.cayenne.merge.MergeDirection;
 import org.apache.cayenne.merge.MergerContext;
 import org.apache.cayenne.merge.MergerToken;
+import org.apache.cayenne.merge.ModelMergeDelegate;
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.dialog.ValidationResultBrowser;
+import org.apache.cayenne.modeler.event.AttributeDisplayEvent;
+import org.apache.cayenne.modeler.event.EntityDisplayEvent;
+import org.apache.cayenne.modeler.event.RelationshipDisplayEvent;
 import org.apache.cayenne.modeler.pref.DBConnectionInfo;
 import org.apache.cayenne.modeler.util.CayenneController;
 import org.apache.cayenne.project.Project;
@@ -172,7 +186,7 @@
         final String lineEnd = (batchTerminator != null) ? "\n"
                 + batchTerminator
                 + "\n\n" : "\n\n";
-
+        
         MergerContext context = new MergerContext() {
 
             public void executeSql(String sql) {
@@ -192,6 +206,10 @@
                 return new ValidationResult();
             }
 
+            public ModelMergeDelegate getModelMergeDelegate() {
+                return null;
+            }
+
         };
 
         while (it.hasNext()) {
@@ -259,6 +277,77 @@
             JOptionPane.showMessageDialog(getView(), "Nothing to migrate.");
             return;
         }
+        
+        final ProjectController c = getProjectController();
+        
+        final Object src = this;
+        final DataDomain domain = getProjectController().getCurrentDataDomain();
+        final DataNode node = getProjectController().getCurrentDataNode();
+
+        final ModelMergeDelegate delegate = new ModelMergeDelegate (){
+
+            public void dbAttributeAdded(DbAttribute att) {
+                c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void dbAttributeModified(DbAttribute att) {
+                c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void dbAttributeRemoved(DbAttribute att) {
+                c.fireDbAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void dbEntityAdded(DbEntity ent) {
+                c.fireDbEntityEvent(new EntityEvent(src, ent, MapEvent.ADD));
+                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node,
domain));
+            }
+
+            public void dbEntityRemoved(DbEntity ent) {
+                c.fireDbEntityEvent(new EntityEvent(src, ent, MapEvent.REMOVE));
+                c.fireDbEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node,
domain));
+            }
+
+            public void dbRelationshipAdded(DbRelationship rel) {
+                c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(),
dataMap, domain));
+            }
+
+            public void dbRelationshipRemoved(DbRelationship rel) {
+                c.fireDbRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel, rel.getSourceEntity(),
dataMap, domain));
+            }
+
+            public void objAttributeAdded(ObjAttribute att) {
+                c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void objAttributeModified(ObjAttribute att) {
+                c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void objAttributeRemoved(ObjAttribute att) {
+                c.fireObjAttributeDisplayEvent(new AttributeDisplayEvent(src, att, att.getEntity(),
dataMap, domain));
+            }
+
+            public void objEntityAdded(ObjEntity ent) {
+                c.fireObjEntityEvent(new EntityEvent(src, ent, MapEvent.ADD));
+                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node,
domain));
+            }
+
+            public void objEntityRemoved(ObjEntity ent) {
+                c.fireObjEntityEvent(new EntityEvent(src, ent, MapEvent.REMOVE));
+                c.fireObjEntityDisplayEvent(new EntityDisplayEvent(src, ent, dataMap, node,
domain));
+            }
+
+            public void objRelationshipAdded(ObjRelationship rel) {
+                c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel,
rel.getSourceEntity(), dataMap, domain));
+            }
+
+            public void objRelationshipRemoved(ObjRelationship rel) {
+                c.fireObjRelationshipDisplayEvent(new RelationshipDisplayEvent(src, rel,
rel.getSourceEntity(), dataMap, domain));
+            }
+            
+        };
+
 
         try {
             DataSource dataSource = connectionInfo.makeDataSource(getApplication()
@@ -268,7 +357,7 @@
             MergerContext mergerContext = new ExecutingMergerContext(
                     dataMap,
                     dataSource,
-                    adapter);
+                    adapter, delegate);
             boolean modelChanged = false;
             for (MergerToken tok : tokensToMigrate) {
                 int numOfFailuresBefore = mergerContext
@@ -348,6 +437,10 @@
             }
         }
     }
+    
+    private ProjectController getProjectController() {
+        return getApplication().getFrameController().getProjectController();
+    }
 
     public void closeAction() {
         view.dispose();

Modified: cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java?rev=783019&r1=783018&r2=783019&view=diff
==============================================================================
--- cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
(original)
+++ cayenne/main/trunk/framework/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/CayenneController.java
Tue Jun  9 14:47:18 2009
@@ -111,6 +111,7 @@
     protected void reportError(String title, Throwable th) {
         th = Util.unwindException(th);
         logObj.info("Error in " + getClass().getName(), th);
+        th.printStackTrace();
 
         JOptionPane.showMessageDialog(getView(),
                 th.getMessage(),



Mime
View raw message