Repository: atlas
Updated Branches:
  refs/heads/master 88ac0fa62 -> f3f4fbfa4


ATLAS-2762: In Relationship UI Tab , when a relationshipdef between entities is 
DELETED , the entity is also set to DELETED

Signed-off-by: Madhan Neethiraj <[email protected]>


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

Branch: refs/heads/master
Commit: f3f4fbfa4e869424560193a26709c8c6beafbedf
Parents: 88ac0fa
Author: Abhishek Kadam <[email protected]>
Authored: Wed Jun 20 14:48:18 2018 +0530
Committer: kevalbhatt <[email protected]>
Committed: Thu Jun 21 18:50:12 2018 +0530

----------------------------------------------------------------------
 .../public/js/utils/CommonViewFunction.js       | 31 +++------
 .../views/audit/CreateAuditTableLayoutView.js   |  2 +-
 .../views/entity/EntityDetailTableLayoutView.js |  2 +-
 .../js/views/graph/RelationshipLayoutView.js    | 71 +++++++++++++-------
 .../model/instance/AtlasRelatedObjectId.java    | 21 ++++--
 .../store/graph/v2/EntityGraphRetriever.java    |  9 +--
 6 files changed, 80 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/dashboardv2/public/js/utils/CommonViewFunction.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/utils/CommonViewFunction.js 
b/dashboardv2/public/js/utils/CommonViewFunction.js
index 241b812..51b141a 100644
--- a/dashboardv2/public/js/utils/CommonViewFunction.js
+++ b/dashboardv2/public/js/utils/CommonViewFunction.js
@@ -75,7 +75,6 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
         var scope = options.scope,
             valueObject = options.valueObject,
             extractJSON = options.extractJSON,
-            relationshipAttributes = options.relationshipAttributes,
             isTable = _.isUndefined(options.isTable) ? true : options.isTable,
             attributeDefs = options.attributeDefs;
 
@@ -105,8 +104,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
                             scope.$('td div[data-id="' + id + 
'"]').append(deleteButton);
                         }
                     },
-                    cust_error: function() {
-                        scope.$('td div[data-id="' + id + 
'"]').html('<div><span class="text-danger"><i class="fa 
fa-exclamation-triangle" aria-hidden="true"></i> Not Authorized</span></div>');
+                    cust_error: function(error, xhr) {
+                        if (xhr.status == 403) {
+                            scope.$('td div[data-id="' + id + 
'"]').html('<div><span class="text-danger"><i class="fa 
fa-exclamation-triangle" aria-hidden="true"></i> Not Authorized</span></div>');
+                        } else {
+                            scope.$('td div[data-id="' + id + 
'"]').html('<div><span class="text-danger"><i class="fa 
fa-exclamation-triangle" aria-hidden="true"></i> ' + 
Messages.defaultErrorMessage + '</span></div>');
+                        }
                     },
                     complete: function() {}
                 });
@@ -169,22 +172,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
                     if (id && inputOutputField) {
                         var name = Utils.getName(inputOutputField);
                         if ((name === "-" || name === id) && 
!inputOutputField.attributes) {
-                            var rAttrValue = relationshipAttributes && 
relationshipAttributes[key];
-                            if (!rAttrValue) {
-                                var fetch = true;
-                                var fetchId = (_.isObject(id) ? id.id : id);
-                                fetchInputOutputValue(fetchId);
-                                tempLink += '<div data-id="' + fetchId + 
'"><div class="value-loader"></div></div>';
-                            } else {
-                                if (_.isArray(rAttrValue) && 
rAttrValue.length) {
-                                    var attrVal = _.find(rAttrValue, 
inputOutputField);
-                                    if (attrVal) {
-                                        tempLink += '<div data-id="' + 
attrVal.guid + '"><a href="#!/detailPage/' + attrVal.guid + '">' + 
Utils.getName(attrVal) + '</a></div>';
-                                    }
-                                } else {
-                                    tempLink += '<div data-id="' + 
rAttrValue.guid + '"><a href="#!/detailPage/' + rAttrValue.guid + '">' + 
Utils.getName(rAttrValue) + '</a></div>';
-                                }
-                            }
+                            var fetch = true;
+                            var fetchId = (_.isObject(id) ? id.id : id);
+                            fetchInputOutputValue(fetchId);
+                            tempLink += '<div data-id="' + fetchId + '"><div 
class="value-loader"></div></div>';
                         } else {
                             tempLink += '<a href="#!/detailPage/' + id + '">' 
+ name + '</a>'
                         }
@@ -227,7 +218,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 
'utils/Messages', 'utils/Enum
                 }
             } else {
                 if (_.isObject(keyValue)) {
-                    keyValue = extractObject({ "keyValue": keyValue, "key": 
key })
+                    keyValue = extractObject({ "keyValue": keyValue, "key": 
key });
                 }
             }
             var val = "";

http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js 
b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
index 0d66235..aa6f5f4 100644
--- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -87,7 +87,7 @@ define(['require',
                     this.ui.name.text(name);
                     if (parseDetailsObject) {
                         this.ui.auditHeaderValue.html('<th>Key</th><th>New 
Value</th>');
-                        table = CommonViewFunction.propertyTable({ scope: 
this, valueObject: parseDetailsObject, relationshipAttributes: 
parseDetailsObject.relationshipAttributes, attributeDefs: this.attributeDefs });
+                        table = CommonViewFunction.propertyTable({ scope: 
this, valueObject: parseDetailsObject, attributeDefs: this.attributeDefs });
                         if (table.length) {
                             this.ui.noData.hide();
                             this.ui.tableAudit.show();

http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js 
b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
index 138e2cc..28eb749 100644
--- a/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
+++ b/dashboardv2/public/js/views/entity/EntityDetailTableLayoutView.js
@@ -56,7 +56,7 @@ define(['require',
                 this.entityTableGenerate();
             },
             entityTableGenerate: function() {
-                var table = CommonViewFunction.propertyTable({ scope: this, 
valueObject: this.entity.attributes, relationshipAttributes: 
this.entity.relationshipAttributes, attributeDefs: this.attributeDefs });
+                var table = CommonViewFunction.propertyTable({ scope: this, 
valueObject: this.entity.attributes, attributeDefs: this.attributeDefs });
                 this.ui.detailValue.append(table);
             }
         });

http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/dashboardv2/public/js/views/graph/RelationshipLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/graph/RelationshipLayoutView.js 
b/dashboardv2/public/js/views/graph/RelationshipLayoutView.js
index edb7672..c3d46da 100644
--- a/dashboardv2/public/js/views/graph/RelationshipLayoutView.js
+++ b/dashboardv2/public/js/views/graph/RelationshipLayoutView.js
@@ -118,8 +118,8 @@ define(['require',
                 this.$("[data-id='typeName']").text(typeName);
                 var getElement = function(options) {
                     var name = options.entityName ? options.entityName : 
Utils.getName(options, "displayText");
-                    return "<li class=" + 
(Enums.entityStateReadOnly[options.relationshipStatus] ? "deleted-relation" : 
'') + "><a href=#!/detailPage/" + options.guid + "?tabActive=relationship>" + 
_.escape(name) + " (" + options.typeName + ")</a>" +
-                        '<button type="button" title="Deleted" class="btn 
btn-sm deleteBtn deletedTableBtn ' + 
(Enums.entityStateReadOnly[options.relationshipStatus] ? "" : 'hide') + '"><i 
class="fa fa-trash"></i></button>' +
+                    return "<li class=" + 
(Enums.entityStateReadOnly[options.entityStatus || options.status] ? 
"deleted-relation" : '') + "><a href=#!/detailPage/" + options.guid + 
"?tabActive=relationship>" + _.escape(name) + " (" + options.typeName + ")</a>" 
+
+                        '<button type="button" title="Deleted" class="btn 
btn-sm deleteBtn deletedTableBtn ' + 
(Enums.entityStateReadOnly[options.entityStatus || options.status] ? "" : 
'hide') + '"><i class="fa fa-trash"></i></button>' +
                         "</li>";
                 }
                 if (_.isArray(data)) {
@@ -150,7 +150,9 @@ define(['require',
                     height = this.$('svg').height();
 
                 var scale = 1.0,
-                    activeEntityColor = "#00b98b";
+                    activeEntityColor = "#00b98b",
+                    deletedEntityColor = "#BB5838",
+                    defaultEntityColor = "#e0e0e0";
 
                 var force = d3.layout.force()
                     .nodes(d3.values(data.nodes))
@@ -240,7 +242,7 @@ define(['require',
 
                 // build the arrow.
                 container.append("svg:defs").selectAll("marker")
-                    .data(["output"]) // Different link/path types can be 
defined here
+                    .data(["deletedLink", "activeLink"]) // Different 
link/path types can be defined here
                     .enter().append("svg:marker") // This section adds in the 
arrows
                     .attr("id", String)
                     .attr("viewBox", "0 -5 10 10")
@@ -251,7 +253,30 @@ define(['require',
                     .attr("orient", "auto")
                     .append("svg:path")
                     .attr("d", "M0,-5L10,0L0,5")
-                    .attr("fill", activeEntityColor);
+                    .attr("fill", function(d) {
+                        return d == "deletedLink" ? deletedEntityColor : 
activeEntityColor;
+                    });
+
+                function getPathColor(options) {
+                    return isAllEntityRelationDeleted(options) ? 
deletedEntityColor : activeEntityColor
+                }
+
+                function isAllEntityRelationDeleted(options) {
+                    var data = options.data,
+                        type = options.type;
+                    var d = $.extend(true, {}, data);
+                    if (d && !_.isArray(d.value)) {
+                        d.value = [d.value];
+                    }
+
+                    return (_.findIndex(d.value, function(val) {
+                        if (type == "node") {
+                            return (val.entityStatus || val.status) == "ACTIVE"
+                        } else {
+                            return val.relationshipStatus == "ACTIVE"
+                        }
+                    }) == -1);
+                }
 
                 // add the links and the arrows
                 var path = container.append("svg:g").selectAll("path")
@@ -259,8 +284,10 @@ define(['require',
                     .enter().append("svg:path")
                     //    .attr("class", function(d) { return "link " + 
d.type; })
                     .attr("class", "relatioship-link")
-                    .attr("stroke", activeEntityColor)
-                    .attr("marker-end", "url(#output)");
+                    .attr("stroke", function(d) { return getPathColor({ data: 
d, type: 'path' }) })
+                    .attr("marker-end", function(d) {
+                        return "url(#" + (isAllEntityRelationDeleted({ data: d 
}) ? "deletedLink" : "activeLink") + ")";
+                    });
 
                 // define the nodes
                 var node = container.selectAll(".node")
@@ -307,19 +334,7 @@ define(['require',
                     }
                 })
 
-                function isSingleRelationDeleted(data) {
-                    var d = $.extend(true, {}, data);
-                    if (!_.isArray(d.value)) {
-                        d.value = [d.value];
-                    }
-                    if (d && _.isArray(d.value)) {
-                        if (d.value.length == 1 && 
Enums.entityStateReadOnly[_.first(d.value).relationshipStatus]) {
-                            return true;
-                        } else {
-                            return false;
-                        }
-                    }
-                }
+
                 circleContainer.append("circle")
                     .attr("cx", 0)
                     .attr("cy", 0)
@@ -329,11 +344,15 @@ define(['require',
                     })
                     .attr("fill", function(d) {
                         if (d && d.value && d.value.guid == that.guid) {
-                            return activeEntityColor;
-                        } else if (isSingleRelationDeleted(d)) {
-                            return "#BB5838";
+                            if (isAllEntityRelationDeleted({ data: d, type: 
'node' })) {
+                                return deletedEntityColor;
+                            } else {
+                                return activeEntityColor;
+                            }
+                        } else if (isAllEntityRelationDeleted({ data: d, type: 
'node' })) {
+                            return deletedEntityColor;
                         } else {
-                            return "#e0e0e0";
+                            return defaultEntityColor;
                         }
                     })
                     .attr("typename", function(d) {
@@ -361,7 +380,7 @@ define(['require',
                     .attr("fill", function(d) {
                         if (d && d.value && d.value.guid == that.guid) {
                             return "#fff";
-                        } else if (isSingleRelationDeleted(d)) {
+                        } else if (isAllEntityRelationDeleted({ data: d, type: 
'node' })) {
                             return "#fff";
                         } else {
                             return "#000";
@@ -381,7 +400,7 @@ define(['require',
                     .attr('dx', 18)
                     .attr('dy', -16)
                     .attr("text-anchor", "middle")
-                    .attr("fill", "#e0e0e0")
+                    .attr("fill", defaultEntityColor)
                     .text(function(d) {
                         if (_.isArray(d.value) && d.value.length > 1) {
                             return d.value.length;

http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
----------------------------------------------------------------------
diff --git 
a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java 
b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
index 543de61..fde2629 100644
--- 
a/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
+++ 
b/intg/src/main/java/org/apache/atlas/model/instance/AtlasRelatedObjectId.java
@@ -46,6 +46,7 @@ public class AtlasRelatedObjectId extends AtlasObjectId 
implements Serializable
     public static final String KEY_RELATIONSHIP_GUID       = 
"relationshipGuid";
     public static final String KEY_RELATIONSHIP_ATTRIBUTES = 
"relationshipAttributes";
 
+    private AtlasEntity.Status       entityStatus       = null;
     private String                   displayText        = null;
     private String                   relationshipGuid   = null;
     private AtlasRelationship.Status relationshipStatus = null;
@@ -53,20 +54,22 @@ public class AtlasRelatedObjectId extends AtlasObjectId 
implements Serializable
 
     public AtlasRelatedObjectId() { }
 
-    public AtlasRelatedObjectId(String guid, String typeName, String 
relationshipGuid,
+    public AtlasRelatedObjectId(String guid, String typeName, 
AtlasEntity.Status entityStatus, String relationshipGuid,
                                 AtlasRelationship.Status relationshipStatus, 
AtlasStruct relationshipAttributes) {
         super(guid, typeName);
 
+        setEntityStatus(entityStatus);
         setRelationshipGuid(relationshipGuid);
         setRelationshipStatus(relationshipStatus);
         setRelationshipAttributes(relationshipAttributes);
     }
 
-    public AtlasRelatedObjectId(String guid, String typeName, Map<String, 
Object> uniqueAttributes, String displayText,
+    public AtlasRelatedObjectId(String guid, String typeName, 
AtlasEntity.Status entityStatus, Map<String, Object> uniqueAttributes, String 
displayText,
                                 String relationshipGuid, 
AtlasRelationship.Status relationshipStatus,
                                 AtlasStruct relationshipAttributes) {
         super(guid, typeName, uniqueAttributes);
 
+        setEntityStatus(entityStatus);
         setRelationshipGuid(relationshipGuid);
         setRelationshipStatus(relationshipStatus);
         setDisplayText(displayText);
@@ -91,7 +94,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId 
implements Serializable
         if (o == null || getClass() != o.getClass()) { return false; }
         if (!super.equals(o)) { return false; }
         AtlasRelatedObjectId that = (AtlasRelatedObjectId) o;
-        return Objects.equals(displayText, that.displayText) &&
+        return Objects.equals(entityStatus, that.entityStatus) &&
+               Objects.equals(displayText, that.displayText) &&
                Objects.equals(relationshipGuid, that.relationshipGuid) &&
                Objects.equals(relationshipStatus, that.relationshipStatus) &&
                Objects.equals(relationshipAttributes, 
that.relationshipAttributes);
@@ -115,7 +119,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId 
implements Serializable
 
         sb.append("AtlasRelatedObjectId{");
         super.toString(sb);
-        sb.append("displayText='").append(displayText).append('\'');
+        sb.append("entityStatus='").append(entityStatus).append('\'');
+        sb.append(", displayText='").append(displayText).append('\'');
         sb.append(", 
relationshipGuid='").append(relationshipGuid).append('\'');
         sb.append(", 
relationshipStatus='").append(relationshipStatus).append('\'');
         sb.append(", relationshipAttributes=").append(relationshipAttributes);
@@ -131,4 +136,12 @@ public class AtlasRelatedObjectId extends AtlasObjectId 
implements Serializable
     public void setRelationshipStatus(final AtlasRelationship.Status 
relationshipStatus) {
         this.relationshipStatus = relationshipStatus;
     }
+
+    public AtlasEntity.Status getEntityStatus() {
+        return entityStatus;
+    }
+
+    public void setEntityStatus(AtlasEntity.Status entityStatus) {
+        this.entityStatus = entityStatus;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/atlas/blob/f3f4fbfa/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
----------------------------------------------------------------------
diff --git 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
index cea63f0..448d03b 100644
--- 
a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
+++ 
b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
@@ -937,11 +937,12 @@ public final class EntityGraphRetriever {
             }
 
             if (referenceVertex != null) {
-                String            entityTypeName = 
getTypeName(referenceVertex);
-                String            entityGuid     = getGuid(referenceVertex);
-                AtlasRelationship relationship   = 
mapEdgeToAtlasRelationship(edge);
+                String             entityTypeName = 
getTypeName(referenceVertex);
+                String             entityGuid     = getGuid(referenceVertex);
+                AtlasEntity.Status entityStatus   = 
GraphHelper.getStatus(referenceVertex);
+                AtlasRelationship  relationship   = 
mapEdgeToAtlasRelationship(edge);
 
-                ret = new AtlasRelatedObjectId(entityGuid, entityTypeName,
+                ret = new AtlasRelatedObjectId(entityGuid, entityTypeName, 
entityStatus,
                                                relationship.getGuid(), 
relationship.getStatus(),
                                                new 
AtlasStruct(relationship.getTypeName(), relationship.getAttributes()));
 

Reply via email to