in dashboardv2/public/js/external_lib/atlas-lineage/src/Utils/DataUtils.js [180:338]
generateData: function({ data = {}, filterObj, entityDefCollection, g, guid, setGraphEdge, setGraphNode }) {
return new Promise((resolve, reject) => {
try {
var relations = data.relations || {},
guidEntityMap = data.guidEntityMap || {},
isHideFilterOn = filterObj.isProcessHideCheck || filterObj.isDeletedEntityHideCheck,
newHashMap = {},
styleObj = {
fill: "none",
stroke: "#ffb203",
width: 3
},
makeNodeData = (relationObj) => {
if (relationObj) {
if (relationObj.updatedValues) {
return relationObj;
}
var nodeLabel = relationObj.displayText ? relationObj.displayText : " ",
obj = Object.assign(relationObj, {
shape: "img",
updatedValues: true,
label: nodeLabel.trunc(18),
toolTipLabel: nodeLabel,
id: relationObj.guid,
isLineage: true,
isIncomplete: relationObj.isIncomplete,
entityDef: this.getEntityDef({ typeName: relationObj.typeName, entityDefCollection })
});
obj["serviceType"] = this.getServiceType(obj);
obj["superTypes"] = this.getNestedSuperTypes({
...obj,
entityDefCollection: entityDefCollection
});
obj["isProcess"] = this.isProcess(obj);
obj["isDeleted"] = this.isDeleted(obj);
return obj;
}
},
crateLineageRelationshipHashMap = function({ relations } = {}) {
var newHashMap = {};
relations.forEach(function(obj) {
if (newHashMap[obj.fromEntityId]) {
newHashMap[obj.fromEntityId].push(obj.toEntityId);
} else {
newHashMap[obj.fromEntityId] = [obj.toEntityId];
}
});
return newHashMap;
},
getStyleObjStr = function(styleObj) {
return "fill:" + styleObj.fill + ";stroke:" + styleObj.stroke + ";stroke-width:" + styleObj.width;
},
getNewToNodeRelationship = (toNodeGuid, filterObj) => {
if (toNodeGuid && relationshipMap[toNodeGuid]) {
var newRelationship = [];
relationshipMap[toNodeGuid].forEach((guid) => {
var nodeToBeUpdated = this.isNodeToBeUpdated(makeNodeData(guidEntityMap[guid]), filterObj);
if (nodeToBeUpdated.update) {
var newRelation = getNewToNodeRelationship(guid, filterObj);
if (newRelation) {
newRelationship = newRelationship.concat(newRelation);
}
} else {
newRelationship.push(guid);
}
});
return newRelationship;
} else {
return null;
}
},
getToNodeRelation = (toNodes, fromNodeToBeUpdated, filterObj) => {
var toNodeRelationship = [];
toNodes.forEach((toNodeGuid) => {
var toNodeToBeUpdated = this.isNodeToBeUpdated(makeNodeData(guidEntityMap[toNodeGuid]), filterObj);
if (toNodeToBeUpdated.update) {
// To node need to updated
if (pendingFromRelationship[toNodeGuid]) {
toNodeRelationship = toNodeRelationship.concat(pendingFromRelationship[toNodeGuid]);
} else {
var newToNodeRelationship = getNewToNodeRelationship(toNodeGuid, filterObj);
if (newToNodeRelationship) {
toNodeRelationship = toNodeRelationship.concat(newToNodeRelationship);
}
}
} else {
//when bothe node not to be updated.
toNodeRelationship.push(toNodeGuid);
}
});
return toNodeRelationship;
},
setNode = (guid) => {
if (!g._nodes[guid]) {
var nodeData = makeNodeData(guidEntityMap[guid]);
setGraphNode(guid, nodeData);
return nodeData;
} else {
return g._nodes[guid];
}
},
setEdge = function(fromNodeGuid, toNodeGuid, opt = {}) {
setGraphEdge(fromNodeGuid, toNodeGuid, {
arrowhead: "arrowPoint",
curve: curveBasis,
style: getStyleObjStr(styleObj),
styleObj: styleObj,
...opt
});
},
setGraphData = function(fromEntityId, toEntityId) {
setNode(fromEntityId);
setNode(toEntityId);
setEdge(fromEntityId, toEntityId);
},
pendingFromRelationship = {};
if (isHideFilterOn) {
var relationshipMap = crateLineageRelationshipHashMap(data);
Object.keys(relationshipMap).forEach((fromNodeGuid) => {
var toNodes = relationshipMap[fromNodeGuid],
fromNodeToBeUpdated = this.isNodeToBeUpdated(makeNodeData(guidEntityMap[fromNodeGuid]), filterObj),
toNodeList = getToNodeRelation(toNodes, fromNodeToBeUpdated, filterObj);
if (fromNodeToBeUpdated.update) {
if (pendingFromRelationship[fromNodeGuid]) {
pendingFromRelationship[fromNodeGuid] = pendingFromRelationship[fromNodeGuid].concat(toNodeList);
} else {
pendingFromRelationship[fromNodeGuid] = toNodeList;
}
} else {
toNodeList.forEach(function(toNodeGuid) {
setGraphData(fromNodeGuid, toNodeGuid);
});
}
});
} else {
relations.forEach(function(obj) {
setGraphData(obj.fromEntityId, obj.toEntityId);
});
}
if (g._nodes[guid]) {
if (g._nodes[guid]) {
g._nodes[guid]["isLineage"] = false;
}
this.findImpactNodeAndUpdateData({
guid,
g,
setEdge,
getStyleObjStr
});
}
if (!g._nodes[guid]) {
setNode(guid);
}
resolve(g);
} catch (e) {
reject(e);
}
});
},