Commit f3f4fbfa by Abhishek Kadam Committed by kevalbhatt

ATLAS-2762: In Relationship UI Tab , when a relationshipdef between entities is…

ATLAS-2762: In Relationship UI Tab , when a relationshipdef between entities is DELETED , the entity is also set to DELETED Signed-off-by: 's avatarMadhan Neethiraj <madhan@apache.org>
parent 88ac0fa6
...@@ -75,7 +75,6 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -75,7 +75,6 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
var scope = options.scope, var scope = options.scope,
valueObject = options.valueObject, valueObject = options.valueObject,
extractJSON = options.extractJSON, extractJSON = options.extractJSON,
relationshipAttributes = options.relationshipAttributes,
isTable = _.isUndefined(options.isTable) ? true : options.isTable, isTable = _.isUndefined(options.isTable) ? true : options.isTable,
attributeDefs = options.attributeDefs; attributeDefs = options.attributeDefs;
...@@ -105,8 +104,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -105,8 +104,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
scope.$('td div[data-id="' + id + '"]').append(deleteButton); scope.$('td div[data-id="' + id + '"]').append(deleteButton);
} }
}, },
cust_error: function() { cust_error: function(error, xhr) {
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>'); 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() {} complete: function() {}
}); });
...@@ -169,22 +172,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -169,22 +172,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (id && inputOutputField) { if (id && inputOutputField) {
var name = Utils.getName(inputOutputField); var name = Utils.getName(inputOutputField);
if ((name === "-" || name === id) && !inputOutputField.attributes) { if ((name === "-" || name === id) && !inputOutputField.attributes) {
var rAttrValue = relationshipAttributes && relationshipAttributes[key]; var fetch = true;
if (!rAttrValue) { var fetchId = (_.isObject(id) ? id.id : id);
var fetch = true; fetchInputOutputValue(fetchId);
var fetchId = (_.isObject(id) ? id.id : id); tempLink += '<div data-id="' + fetchId + '"><div class="value-loader"></div></div>';
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>';
}
}
} else { } else {
tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>' tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>'
} }
...@@ -227,7 +218,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -227,7 +218,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
} }
} else { } else {
if (_.isObject(keyValue)) { if (_.isObject(keyValue)) {
keyValue = extractObject({ "keyValue": keyValue, "key": key }) keyValue = extractObject({ "keyValue": keyValue, "key": key });
} }
} }
var val = ""; var val = "";
......
...@@ -87,7 +87,7 @@ define(['require', ...@@ -87,7 +87,7 @@ define(['require',
this.ui.name.text(name); this.ui.name.text(name);
if (parseDetailsObject) { if (parseDetailsObject) {
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>'); 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) { if (table.length) {
this.ui.noData.hide(); this.ui.noData.hide();
this.ui.tableAudit.show(); this.ui.tableAudit.show();
......
...@@ -56,7 +56,7 @@ define(['require', ...@@ -56,7 +56,7 @@ define(['require',
this.entityTableGenerate(); this.entityTableGenerate();
}, },
entityTableGenerate: function() { 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); this.ui.detailValue.append(table);
} }
}); });
......
...@@ -118,8 +118,8 @@ define(['require', ...@@ -118,8 +118,8 @@ define(['require',
this.$("[data-id='typeName']").text(typeName); this.$("[data-id='typeName']").text(typeName);
var getElement = function(options) { var getElement = function(options) {
var name = options.entityName ? options.entityName : Utils.getName(options, "displayText"); 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>" + 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.relationshipStatus] ? "" : 'hide') + '"><i class="fa fa-trash"></i></button>' + '<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>"; "</li>";
} }
if (_.isArray(data)) { if (_.isArray(data)) {
...@@ -150,7 +150,9 @@ define(['require', ...@@ -150,7 +150,9 @@ define(['require',
height = this.$('svg').height(); height = this.$('svg').height();
var scale = 1.0, var scale = 1.0,
activeEntityColor = "#00b98b"; activeEntityColor = "#00b98b",
deletedEntityColor = "#BB5838",
defaultEntityColor = "#e0e0e0";
var force = d3.layout.force() var force = d3.layout.force()
.nodes(d3.values(data.nodes)) .nodes(d3.values(data.nodes))
...@@ -240,7 +242,7 @@ define(['require', ...@@ -240,7 +242,7 @@ define(['require',
// build the arrow. // build the arrow.
container.append("svg:defs").selectAll("marker") 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 .enter().append("svg:marker") // This section adds in the arrows
.attr("id", String) .attr("id", String)
.attr("viewBox", "0 -5 10 10") .attr("viewBox", "0 -5 10 10")
...@@ -251,7 +253,30 @@ define(['require', ...@@ -251,7 +253,30 @@ define(['require',
.attr("orient", "auto") .attr("orient", "auto")
.append("svg:path") .append("svg:path")
.attr("d", "M0,-5L10,0L0,5") .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 // add the links and the arrows
var path = container.append("svg:g").selectAll("path") var path = container.append("svg:g").selectAll("path")
...@@ -259,8 +284,10 @@ define(['require', ...@@ -259,8 +284,10 @@ define(['require',
.enter().append("svg:path") .enter().append("svg:path")
// .attr("class", function(d) { return "link " + d.type; }) // .attr("class", function(d) { return "link " + d.type; })
.attr("class", "relatioship-link") .attr("class", "relatioship-link")
.attr("stroke", activeEntityColor) .attr("stroke", function(d) { return getPathColor({ data: d, type: 'path' }) })
.attr("marker-end", "url(#output)"); .attr("marker-end", function(d) {
return "url(#" + (isAllEntityRelationDeleted({ data: d }) ? "deletedLink" : "activeLink") + ")";
});
// define the nodes // define the nodes
var node = container.selectAll(".node") var node = container.selectAll(".node")
...@@ -307,19 +334,7 @@ define(['require', ...@@ -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") circleContainer.append("circle")
.attr("cx", 0) .attr("cx", 0)
.attr("cy", 0) .attr("cy", 0)
...@@ -329,11 +344,15 @@ define(['require', ...@@ -329,11 +344,15 @@ define(['require',
}) })
.attr("fill", function(d) { .attr("fill", function(d) {
if (d && d.value && d.value.guid == that.guid) { if (d && d.value && d.value.guid == that.guid) {
return activeEntityColor; if (isAllEntityRelationDeleted({ data: d, type: 'node' })) {
} else if (isSingleRelationDeleted(d)) { return deletedEntityColor;
return "#BB5838"; } else {
return activeEntityColor;
}
} else if (isAllEntityRelationDeleted({ data: d, type: 'node' })) {
return deletedEntityColor;
} else { } else {
return "#e0e0e0"; return defaultEntityColor;
} }
}) })
.attr("typename", function(d) { .attr("typename", function(d) {
...@@ -361,7 +380,7 @@ define(['require', ...@@ -361,7 +380,7 @@ define(['require',
.attr("fill", function(d) { .attr("fill", function(d) {
if (d && d.value && d.value.guid == that.guid) { if (d && d.value && d.value.guid == that.guid) {
return "#fff"; return "#fff";
} else if (isSingleRelationDeleted(d)) { } else if (isAllEntityRelationDeleted({ data: d, type: 'node' })) {
return "#fff"; return "#fff";
} else { } else {
return "#000"; return "#000";
...@@ -381,7 +400,7 @@ define(['require', ...@@ -381,7 +400,7 @@ define(['require',
.attr('dx', 18) .attr('dx', 18)
.attr('dy', -16) .attr('dy', -16)
.attr("text-anchor", "middle") .attr("text-anchor", "middle")
.attr("fill", "#e0e0e0") .attr("fill", defaultEntityColor)
.text(function(d) { .text(function(d) {
if (_.isArray(d.value) && d.value.length > 1) { if (_.isArray(d.value) && d.value.length > 1) {
return d.value.length; return d.value.length;
......
...@@ -46,6 +46,7 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable ...@@ -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_GUID = "relationshipGuid";
public static final String KEY_RELATIONSHIP_ATTRIBUTES = "relationshipAttributes"; public static final String KEY_RELATIONSHIP_ATTRIBUTES = "relationshipAttributes";
private AtlasEntity.Status entityStatus = null;
private String displayText = null; private String displayText = null;
private String relationshipGuid = null; private String relationshipGuid = null;
private AtlasRelationship.Status relationshipStatus = null; private AtlasRelationship.Status relationshipStatus = null;
...@@ -53,20 +54,22 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable ...@@ -53,20 +54,22 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
public AtlasRelatedObjectId() { } 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) { AtlasRelationship.Status relationshipStatus, AtlasStruct relationshipAttributes) {
super(guid, typeName); super(guid, typeName);
setEntityStatus(entityStatus);
setRelationshipGuid(relationshipGuid); setRelationshipGuid(relationshipGuid);
setRelationshipStatus(relationshipStatus); setRelationshipStatus(relationshipStatus);
setRelationshipAttributes(relationshipAttributes); 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, String relationshipGuid, AtlasRelationship.Status relationshipStatus,
AtlasStruct relationshipAttributes) { AtlasStruct relationshipAttributes) {
super(guid, typeName, uniqueAttributes); super(guid, typeName, uniqueAttributes);
setEntityStatus(entityStatus);
setRelationshipGuid(relationshipGuid); setRelationshipGuid(relationshipGuid);
setRelationshipStatus(relationshipStatus); setRelationshipStatus(relationshipStatus);
setDisplayText(displayText); setDisplayText(displayText);
...@@ -91,7 +94,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable ...@@ -91,7 +94,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
if (o == null || getClass() != o.getClass()) { return false; } if (o == null || getClass() != o.getClass()) { return false; }
if (!super.equals(o)) { return false; } if (!super.equals(o)) { return false; }
AtlasRelatedObjectId that = (AtlasRelatedObjectId) o; 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(relationshipGuid, that.relationshipGuid) &&
Objects.equals(relationshipStatus, that.relationshipStatus) && Objects.equals(relationshipStatus, that.relationshipStatus) &&
Objects.equals(relationshipAttributes, that.relationshipAttributes); Objects.equals(relationshipAttributes, that.relationshipAttributes);
...@@ -115,7 +119,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable ...@@ -115,7 +119,8 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
sb.append("AtlasRelatedObjectId{"); sb.append("AtlasRelatedObjectId{");
super.toString(sb); 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(", relationshipGuid='").append(relationshipGuid).append('\'');
sb.append(", relationshipStatus='").append(relationshipStatus).append('\''); sb.append(", relationshipStatus='").append(relationshipStatus).append('\'');
sb.append(", relationshipAttributes=").append(relationshipAttributes); sb.append(", relationshipAttributes=").append(relationshipAttributes);
...@@ -131,4 +136,12 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable ...@@ -131,4 +136,12 @@ public class AtlasRelatedObjectId extends AtlasObjectId implements Serializable
public void setRelationshipStatus(final AtlasRelationship.Status relationshipStatus) { public void setRelationshipStatus(final AtlasRelationship.Status relationshipStatus) {
this.relationshipStatus = 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
...@@ -937,11 +937,12 @@ public final class EntityGraphRetriever { ...@@ -937,11 +937,12 @@ public final class EntityGraphRetriever {
} }
if (referenceVertex != null) { if (referenceVertex != null) {
String entityTypeName = getTypeName(referenceVertex); String entityTypeName = getTypeName(referenceVertex);
String entityGuid = getGuid(referenceVertex); String entityGuid = getGuid(referenceVertex);
AtlasRelationship relationship = mapEdgeToAtlasRelationship(edge); 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(), relationship.getGuid(), relationship.getStatus(),
new AtlasStruct(relationship.getTypeName(), relationship.getAttributes())); new AtlasStruct(relationship.getTypeName(), relationship.getAttributes()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment