Skip to content

Commit 2940d6d

Browse files
authored
Merge pull request #731 from AbsaOSS/bugfix/spline-718-graph-layout-improvement
Bugfix/spline 718 graph layout improvement
2 parents 05272df + 5d48751 commit 2940d6d

File tree

10 files changed

+45
-27
lines changed

10 files changed

+45
-27
lines changed

client-ui/src/app/components/lineage-overview/lineage-overview-details/lineage-overview-details.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ <h3 class="text-center pb-3 mt-3"> Execution Event </h3>
3030
</p>
3131
<ul>
3232
<p>
33-
<strong>URI:</strong> {{ lineageInfo.targetNodeName }}
33+
<strong>URI:</strong> {{ lineageInfo.targetURI }}
3434
</p>
3535
</ul>
3636

client-ui/src/app/components/lineage-overview/lineage-overview-details/lineage-overview-details.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class LineageOverviewDetailsComponent {
3939
readonly executedLogicalPlan$: Observable<ExecutedLogicalPlanVM>
4040

4141
readonly lineageInfo$: Observable<{
42-
targetNodeName: string
42+
targetURI: string
4343
executionEventId: string
4444
[key: string]: any
4545
}>

client-ui/src/app/effects/lineage-overview.effects.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,33 +83,40 @@ export class LineageOverviewEffects {
8383
}
8484

8585
private toLineageOverviewVM = (lineageOverview: LineageOverview, executionEventId: string): LineageOverviewVM => {
86-
const cytoscapeGraphVM = {} as CytoscapeGraphVM
87-
cytoscapeGraphVM.nodes = []
88-
cytoscapeGraphVM.edges = []
86+
const cytoscapeGraphVM: CytoscapeGraphVM = {
87+
nodes: [],
88+
edges: []
89+
}
8990

9091
const graph = lineageOverview.graph
91-
const nonTerminalNodeIds = new Set(graph.edges.map(e => e.source))
92-
const targetNodeId = graph.nodes
93-
.map((n: LineageOverviewNodeVM) => n._id)
94-
.find(id => !nonTerminalNodeIds.has(id))
92+
let targetURI = ''
9593

96-
let targetNodeName = ''
9794
_.each(graph.nodes, (node: LineageOverviewNodeVM) => {
9895
const cytoscapeOperation = {} as CytoscapeOperationVM
99-
if (node._id == targetNodeId) {
100-
targetNodeName = node.name
101-
cytoscapeOperation.properties = { 'targetNode': true }
96+
const isTargetNode = node._id == lineageOverview.info.targetDataSourceId
97+
98+
if (isTargetNode) {
99+
targetURI = node.name
102100
}
101+
103102
cytoscapeOperation._type = node._type
104103
cytoscapeOperation.id = node._id
105104
cytoscapeOperation._id = node.name
105+
106106
const nodeName = node._type == LineageOverviewNodeType.DataSource ? node.name.substring(node.name.lastIndexOf('/') + 1) : node.name
107107
const splitedNames = node.name.split('/')
108108
cytoscapeOperation.name = nodeName == '*' ? `${splitedNames[splitedNames.length - 2]}/${nodeName}` : nodeName
109-
cytoscapeOperation.color = lineageOverviewColorCodes.get(node._type)
110109
cytoscapeOperation.icon = lineageOverviewIconCodes.get(node._type)
111-
cytoscapeGraphVM.nodes.push({ data: cytoscapeOperation })
110+
cytoscapeOperation.color = isTargetNode
111+
? lineageOverviewColorCodes.get("Root")
112+
: lineageOverviewColorCodes.get(node._type)
113+
114+
cytoscapeGraphVM.nodes.push({
115+
data: cytoscapeOperation,
116+
classes: isTargetNode ? ["root"] : undefined
117+
})
112118
})
119+
113120
_.each(graph.edges, (edge: Transition) => {
114121
cytoscapeGraphVM.edges.push({ data: edge })
115122
})
@@ -118,12 +125,11 @@ export class LineageOverviewEffects {
118125
lineageOverviewVM.lineage = cytoscapeGraphVM
119126
lineageOverviewVM.lineageInfo = {
120127
...lineageOverview.info,
121-
targetNodeName: targetNodeName,
128+
targetURI: targetURI,
122129
executionEventId: executionEventId
123130
}
124-
125-
lineageOverviewVM.depthComputed = lineageOverview.graph.depthComputed ? lineageOverview.graph.depthComputed : 0
126-
lineageOverviewVM.depthRequested = lineageOverview.graph.depthRequested ? lineageOverview.graph.depthRequested : 0
131+
lineageOverviewVM.depthComputed = graph.depthComputed ? graph.depthComputed : 0
132+
lineageOverviewVM.depthRequested = graph.depthRequested ? graph.depthRequested : 0
127133
lineageOverviewVM.hasMoreNodes = lineageOverviewVM.depthComputed && lineageOverviewVM.depthComputed >= lineageOverviewVM.depthRequested
128134

129135
return lineageOverviewVM

client-ui/src/app/model/lineage-graph/lineage-graph.models.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Stylesheet } from 'cytoscape'
2020
export const LINE_WIDTH_PLANE = 10
2121
export const LINE_WIDTH_HIGHLIGHTED = 10
2222
export const LINE_WIDTH_SELECTED = 16
23-
export const LINE_COLOR_PLANE = '#eaeaea'
23+
export const LINE_COLOR_PLANE = '#e0e0e0'
2424
export const LINE_COLOR_SELECTED = 'orange'
2525
export const LINE_COLOR_HLT_PRIMARY = 'black'
2626
export const LINE_COLOR_HLT_LINEAGE = 'magenta'
@@ -59,6 +59,12 @@ export const cyStyles: Partial<Stylesheet>[] = [
5959
...selectedNodeStyles
6060
},
6161
} as Stylesheet,
62+
{
63+
selector: 'node.root',
64+
style: {
65+
'background-color': '#333333',
66+
},
67+
} as Stylesheet,
6268
{
6369
selector: 'node.hlt_prim',
6470
style: {
@@ -119,6 +125,7 @@ export const cyStyles: Partial<Stylesheet>[] = [
119125
'width': LINE_WIDTH_PLANE,
120126
'curve-style': 'bezier',
121127
'target-arrow-shape': 'triangle',
128+
'arrow-scale': 1.5,
122129
},
123130
css: {
124131
'label': (el) => el.data('label') || '',

client-ui/src/app/model/types/lineageOverviewNodeType.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717

1818
export const enum LineageOverviewNodeType {
1919
Execution = 'ExecutionNode',
20-
DataSource = 'DataSourceNode'
20+
DataSource = 'DataSourceNode',
21+
Root = 'Root'
2122
}

client-ui/src/app/model/viewModels/cytoscape/graphNodeVM.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
import {CytoscapeOperationVM} from './cytoscapeOperationVM';
1717

1818
export type GraphNode = {
19-
data: CytoscapeOperationVM
19+
data: CytoscapeOperationVM,
20+
classes?: string[]
2021
}

client-ui/src/app/model/viewModels/lineageOverview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { CytoscapeGraphVM } from './cytoscape/cytoscapeGraphVM'
1818

1919
export type LineageOverviewVM = {
2020
lineageInfo: {
21-
targetNodeName: string;
21+
targetURI: string;
2222
executionEventId: string
2323
[key: string]: any
2424
}

client-ui/src/app/store/reducers/layout.reducer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ function getConfiguration(): any {
5353
/* UNDEFINED, RIGHT, LEFT, DOWN, UP */
5454
edgeRouting: 'SPLINES', // Defines how edges are routed (POLYLINE, ORTHOGONAL, SPLINES)
5555
edgeSpacingFactor: 0.5, // Factor by which the object spacing is multiplied to arrive at the minimal spacing between edges.
56-
feedbackEdges: false, // Whether feedback edges should be highlighted by routing around the nodes.
57-
fixedAlignment: 'LEFTUP', // Tells the BK node placer to use a certain alignment instead of taking the optimal result. This option should usually be left alone.
56+
feedbackEdges: true, // Whether feedback edges should be highlighted by routing around the nodes.
57+
fixedAlignment: 'NONE', // Tells the BK node placer to use a certain alignment instead of taking the optimal result. This option should usually be left alone.
5858
/* NONE Chooses the sTmallest layout from the four possible candidates.
5959
LEFTUP Chooses the left-up candidate from the four possible candidates.
6060
RIGHTUP Chooses the right-up candidate from the four possible candidates.
@@ -83,4 +83,4 @@ function getConfiguration(): any {
8383
},
8484
priority: function (edge) { return null }, // Edges with a non-nil value are skipped when geedy edge cycle breaking is enabled
8585
}
86-
}
86+
}

client-ui/src/app/store/reducers/lineage-overview.reducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const lineageOverviewIconCodes: Map<string, number> = new Map([
3535

3636

3737
export const lineageOverviewColorCodes: Map<string, string> = new Map([
38+
[LineageOverviewNodeType.Root, "#ffffff"],
3839
[LineageOverviewNodeType.Execution, "#e39255"],
3940
[LineageOverviewNodeType.DataSource, "#337AB7"]
4041
])

consumer-services/src/main/scala/za/co/absa/spline/consumer/service/repo/LineageRepositoryImpl.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ class LineageRepositoryImpl @Autowired()(db: ArangoDatabaseAsync) extends Lineag
3131
.queryOne[LineageOverview](
3232
"""
3333
|LET executionEvent = FIRST(FOR p IN progress FILTER p._key == @eventId RETURN p)
34+
|LET targetDataSource = FIRST(FOR ds IN 2 OUTBOUND executionEvent progressOf, affects RETURN ds)
3435
|LET lineageGraph = SPLINE::EVENT_LINEAGE_OVERVIEW(executionEvent, @maxDepth)
3536
|
3637
|RETURN lineageGraph && {
3738
| "info": {
3839
| "timestamp" : executionEvent.timestamp,
39-
| "applicationId" : executionEvent.extra.appId
40+
| "applicationId" : executionEvent.extra.appId,
41+
| "targetDataSourceId": targetDataSource._key
4042
| },
4143
| "graph": {
4244
| "depthRequested": @maxDepth,

0 commit comments

Comments
 (0)