cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abulat...@apache.org
Subject [cayenne] branch STABLE-4.1 updated: CAY-2559 Modeler: Warning dialog shows wrong information after changing target entity in dbRelationship
Date Fri, 05 Apr 2019 12:37:48 GMT
This is an automated email from the ASF dual-hosted git repository.

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


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

commit 16a668508564133a67114834b36d254036a7b511
Author: Arseni Bulatski <ancarseni@gmail.com>
AuthorDate: Fri Apr 5 15:36:31 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, 17 insertions(+), 19 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index 94df294..96ea851 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -13,6 +13,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.1.B1
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 a201a75..8dbce2c 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,11 @@
 
 package org.apache.cayenne.modeler.util;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
 import org.apache.cayenne.configuration.DataChannelDescriptor;
 import org.apache.cayenne.configuration.DataNodeDescriptor;
 import org.apache.cayenne.map.Attribute;
@@ -37,18 +42,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 +378,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 +404,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>();
@@ -465,19 +463,18 @@ public class ProjectUtil {
                                                                                DbRelationship
relationship) {
         DataChannelDescriptor domain = (DataChannelDescriptor) mediator.getProject().getRootNode();
         List<ObjAttribute> attributes = new ArrayList<>();
-        String[] dbAttrPathByDot;
         if (domain != null) {
             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()) {
+                            objAttribute.getDbPathIterator().forEachRemaining(entry ->
{
+                                if(entry instanceof DbRelationship) {
+                                    if(entry.equals(relationship)) {
+                                        attributes.add(objAttribute);
+                                    }
                                 }
-                            }
+                            });
                         }
                     }
                 }


Mime
View raw message