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
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 = "";
......
......@@ -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();
......
......@@ -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);
}
});
......
......@@ -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;
......
......@@ -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
......@@ -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()));
......
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