Commit 1efb57bc by Vishal Kadam

HDPDGI-69:Dileep:Use details api to get LoadProcess name

parent d54a5981
...@@ -18,8 +18,9 @@ ...@@ -18,8 +18,9 @@
'use strict'; 'use strict';
angular.module('dgc.lineage').controller('LineageController', ['$element', '$scope', '$state', '$stateParams', 'lodash', 'LineageResource', 'd3', angular.module('dgc.lineage').controller('LineageController', ['$element', '$scope', '$state', '$stateParams', 'lodash', 'LineageResource', 'd3', 'DetailsResource', '$q',
function($element, $scope, $state, $stateParams, _, LineageResource, d3) { function($element, $scope, $state, $stateParams, _, LineageResource, d3, DetailsResource, $q) {
var guidsList = [];
function getLineageData(tableData, callRender) { function getLineageData(tableData, callRender) {
LineageResource.get({ LineageResource.get({
...@@ -27,15 +28,38 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco ...@@ -27,15 +28,38 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco
type: tableData.type type: tableData.type
}, function lineageSuccess(response) { }, function lineageSuccess(response) {
if (!_.isEmpty(response.results.values.vertices)) { if (!_.isEmpty(response.results.values.vertices)) {
var allGuids = loadProcess(response.results.values.edges, response.results.values.vertices);
allGuids.then(function(res) {
guidsList = JSON.parse(res);
$scope.lineageData = transformData(response.results); $scope.lineageData = transformData(response.results);
if (callRender) { if (callRender) {
render(); render();
} }
});
} }
$scope.requested = false; $scope.requested = false;
}); });
} }
function loadProcess(edges, vertices) {
var urlCalls = [];
var deferred = $q.defer();
for (var guid in edges) {
if (!vertices.hasOwnProperty(guid)) {
urlCalls.push(DetailsResource.get({
id: guid
}).$promise);
}
}
$q.all(urlCalls)
.then(function(results) {
deferred.resolve(JSON.stringify(results));
});
return deferred.promise;
}
$scope.type = $element.parent().attr('data-table-type'); $scope.type = $element.parent().attr('data-table-type');
$scope.requested = false; $scope.requested = false;
...@@ -67,10 +91,24 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco ...@@ -67,10 +91,24 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco
nodes = {}; nodes = {};
function getNode(guid) { function getNode(guid) {
var name, type;
if (vertices.hasOwnProperty(guid)) {
name = vertices[guid].values.name;
type = vertices[guid].values.vertexId.values.typeName;
} else {
var loadProcess = getLoadProcessTypes(guid);
if (typeof loadProcess !== "undefined") {
name = loadProcess.name;
type = loadProcess.typeName;
} else {
name = 'Load Process';
type = 'Load Process';
}
}
var vertex = { var vertex = {
guid: guid, guid: guid,
name: vertices.hasOwnProperty(guid) ? vertices[guid].values.name : 'Load Process', name: name,
type: vertices.hasOwnProperty(guid) ? vertices[guid].values.vertexId.values.typeName : 'LoadProcess' type: type
}; };
if (!nodes.hasOwnProperty(guid)) { if (!nodes.hasOwnProperty(guid)) {
nodes[guid] = vertex; nodes[guid] = vertex;
...@@ -78,6 +116,17 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco ...@@ -78,6 +116,17 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco
return nodes[guid]; return nodes[guid];
} }
function getLoadProcessTypes(guid) {
var procesRes = [];
angular.forEach(guidsList, function(value) {
if (value.id.id === guid) {
procesRes.name = value.values.name;
procesRes.typeName = value.typeName;
}
});
return procesRes;
}
function attachParent(edge, node) { function attachParent(edge, node) {
edge.forEach(function eachPoint(childGuid) { edge.forEach(function eachPoint(childGuid) {
var childNode = getNode(childGuid); var childNode = getNode(childGuid);
...@@ -172,7 +221,6 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco ...@@ -172,7 +221,6 @@ angular.module('dgc.lineage').controller('LineageController', ['$element', '$sco
.attr("y", "-18px") .attr("y", "-18px")
.attr("width", "34px") .attr("width", "34px")
.attr("height", "34px"); .attr("height", "34px");
nodeEnter.append('text') nodeEnter.append('text')
.attr('x', function(d) { .attr('x', function(d) {
return d.children || d._children ? return d.children || d._children ?
......
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