You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by ab...@apache.org on 2019/04/05 12:44:15 UTC

[cayenne] branch STABLE-4.0 updated: CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in dbRelationship

This is an automated email from the ASF dual-hosted git repository.

abulatski pushed a commit to branch STABLE-4.0
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/STABLE-4.0 by this push:
     new 7f035af  CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in dbRelationship
7f035af is described below

commit 7f035af0a3526ee2e3da19f7e8257020e4a236c8
Author: Arseni Bulatski <an...@gmail.com>
AuthorDate: Fri Apr 5 15:43:26 2019 +0300

    CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in dbRelationship
---
 RELEASE-NOTES.txt                                  |  1 +
 .../apache/cayenne/modeler/util/ProjectUtil.java   | 35 +++++++++++-----------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 02a2cd0..bec8ead 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -15,6 +15,7 @@ Date:
 Bug Fixes:
 
 CAY-2550 Modeler: ObjAttribute inspector modifies wrong columns in attribute table
+CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in dbRelationship
 
 ----------------------------------
 Release: 4.0.1
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 cb2c8b1..b548d34 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
@@ -19,6 +19,12 @@
 
 package org.apache.cayenne.modeler.util;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.Attribute;
@@ -37,18 +43,11 @@ import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.map.ObjRelationship;
 import org.apache.cayenne.map.Procedure;
 import org.apache.cayenne.map.ProcedureParameter;
-import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.map.QueryDescriptor;
+import org.apache.cayenne.map.Relationship;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.util.Util;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Pattern;
-
 /**
  * Provides utility methods to perform various manipulations with project objects.
  */
@@ -380,7 +379,7 @@ public class ProjectUtil {
         Entity parent = attribute.getEntity();
 
         if (parent == null) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
 
         Collection<DbRelationship> parentRelationships = (Collection<DbRelationship>) parent
@@ -406,12 +405,12 @@ public class ProjectUtil {
         Entity parent = attribute.getEntity();
 
         if (parent == null) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
 
         DataMap map = parent.getDataMap();
         if (map == null) {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
 
         Collection<DbRelationship> relationships = new ArrayList<DbRelationship>();
@@ -470,12 +469,14 @@ public class ProjectUtil {
             for (DataMap map : domain.getDataMaps()) {
                 for (ObjEntity entity : map.getObjEntities()) {
                     for (ObjAttribute objAttribute : entity.getAttributes()) {
-                        if(objAttribute.getDbAttributePath() != null) {
-                            dbAttrPathByDot = objAttribute.getDbAttributePath()
-                                    .split(Pattern.quote("."));
-                            for (String partOfPath : dbAttrPathByDot) {
-                                if (partOfPath.equals(relationship.getName())) {
-                                    attributes.add(objAttribute);
+                        if(objAttribute.isFlattened()) {
+                            Iterator<?> it = objAttribute.getDbPathIterator();
+                            while(it.hasNext()) {
+                                Object entry = it.next();
+                                if(entry instanceof DbRelationship) {
+                                    if(entry.equals(relationship)) {
+                                        attributes.add(objAttribute);
+                                    }
                                 }
                             }
                         }