cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/3] cayenne git commit: CAY-2281 ObjEntity attribute overrides are never deleted
Date Wed, 19 Apr 2017 15:22:51 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 0ac7dd455 -> 4e268e756


CAY-2281 ObjEntity attribute overrides are never deleted


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/3d55765c
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/3d55765c
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/3d55765c

Branch: refs/heads/master
Commit: 3d55765cae68f90d65cf0b3ed205240b765bcd5e
Parents: 0ac7dd4
Author: Anton Dreka <drekoas@gmail.com>
Authored: Wed Apr 19 16:20:47 2017 +0300
Committer: Anton Dreka <drekoas@gmail.com>
Committed: Wed Apr 19 16:20:47 2017 +0300

----------------------------------------------------------------------
 .../src/main/java/org/apache/cayenne/map/ObjEntity.java   |  7 +++++++
 docs/doc/src/main/resources/RELEASE-NOTES.txt             |  2 +-
 .../cayenne/modeler/action/RemoveAttributeAction.java     |  7 +++++++
 .../cayenne/modeler/editor/ObjEntityAttributePanel.java   |  1 +
 .../java/org/apache/cayenne/modeler/util/ProjectUtil.java | 10 ++++++++++
 5 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/3d55765c/cayenne-server/src/main/java/org/apache/cayenne/map/ObjEntity.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/main/java/org/apache/cayenne/map/ObjEntity.java b/cayenne-server/src/main/java/org/apache/cayenne/map/ObjEntity.java
index 055d753..fee79a3 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/map/ObjEntity.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/map/ObjEntity.java
@@ -787,6 +787,13 @@ public class ObjEntity extends Entity implements ObjEntityListener, Configuratio
     }
 
     /**
+     * @since 4.0
+     */
+    public void removeAttributeOverride(String attributeName) {
+        attributeOverrides.remove(attributeName);
+    }
+
+    /**
      * @since 3.0
      */
     public Map<String, String> getDeclaredAttributeOverrides() {

http://git-wip-us.apache.org/repos/asf/cayenne/blob/3d55765c/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index eb1166c..957c17d 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -53,7 +53,7 @@ CAY-2273 Modeler: default suggested cgen location is rooted in subpackage
 CAY-2275 Documentation: tutorial is out of sync with 4.0.M5 version
 CAY-2276 PrePersist listener registered as PostPersist in LifecycleCallbackRegistry.addListener(Class<?>,
LifecycleListener)
 CAY-2279 cdbimport: skip PK comparison for VIEWs
-
+CAY-2281 ObjEntity attribute overrides are never deleted
 ----------------------------------
 Release: 4.0.M5
 Date: March 6, 2017

http://git-wip-us.apache.org/repos/asf/cayenne/blob/3d55765c/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
index af1f4b9..769b2a0 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/RemoveAttributeAction.java
@@ -21,6 +21,8 @@ package org.apache.cayenne.modeler.action;
 
 import java.awt.event.ActionEvent;
 
+import java.util.Collection;
+
 import org.apache.cayenne.configuration.ConfigurationNode;
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.map.Attribute;
@@ -171,6 +173,11 @@ public class RemoveAttributeAction extends RemoveAction implements MultipleObjec
                     entity,
                     MapEvent.REMOVE);
             mediator.fireObjAttributeEvent(e);
+
+            Collection<ObjEntity> objEntities = ProjectUtil.getCollectionOfChildren((ObjEntity)
e.getEntity());
+            for (ObjEntity objEntity: objEntities) {
+                objEntity.removeAttributeOverride(e.getAttribute().getName());
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/3d55765c/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
index 7601a2c..13c7361 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/ObjEntityAttributePanel.java
@@ -322,6 +322,7 @@ public class ObjEntityAttributePanel extends JPanel implements ObjEntityDisplayL
                 shouldDelete = selectedValue != null && selectedValue.equals(JOptionPane.YES_OPTION);
                 if (shouldDelete) {
                     objEntity.removeAttribute(e.getAttribute().getName());
+                    objEntity.removeAttributeOverride(e.getAttribute().getName());
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/cayenne/blob/3d55765c/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
index 28ea313..0f61ce3 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/util/ProjectUtil.java
@@ -429,4 +429,14 @@ public class ProjectUtil {
         }
         return relationships;
     }
+
+    public static Collection<ObjEntity> getCollectionOfChildren(ObjEntity objEntity)
{
+        Collection<ObjEntity> objEntities = new ArrayList<>();
+        for (ObjEntity child: objEntity.getDataMap().getObjEntities()) {
+            if (child.isSubentityOf(objEntity)) {
+                objEntities.add(child);
+            }
+        }
+        return objEntities;
+    }
 }
\ No newline at end of file


Mime
View raw message