@@ -75,83 +75,6 @@ private List<PipelineStageInternal> getPipelineNodes() {
75
75
.collect (Collectors .toList ());
76
76
}
77
77
78
- public PipelineGraph createGraph () {
79
- List <PipelineStageInternal > stages = getPipelineNodes ();
80
-
81
- // id => stage
82
- Map <String , PipelineStageInternal > stageMap =
83
- stages .stream ()
84
- .collect (
85
- Collectors .toMap (
86
- PipelineStageInternal ::getId , stage -> stage , (u , v ) -> u , LinkedHashMap ::new ));
87
-
88
- Map <String , List <String >> stageToChildrenMap = new HashMap <>();
89
-
90
- List <String > stagesThatAreNested = new ArrayList <>();
91
-
92
- Map <String , String > nextSiblingToOlderSibling = new HashMap <>();
93
-
94
- List <String > stagesThatAreChildrenOrNestedStages = new ArrayList <>();
95
- stages .forEach (
96
- stage -> {
97
- if (stage .getParents ().isEmpty ()) {
98
- stageToChildrenMap .put (stage .getId (), new ArrayList <>());
99
- } else if (stage .getType ().equals ("PARALLEL" )) {
100
- String parentId = stage .getParents ().get (0 ); // assume one parent for now
101
- List <String > childrenOfParent =
102
- stageToChildrenMap .getOrDefault (parentId , new ArrayList <>());
103
- childrenOfParent .add (stage .getId ());
104
- stageToChildrenMap .put (parentId , childrenOfParent );
105
- stagesThatAreChildrenOrNestedStages .add (stage .getId ());
106
- } else if (stageMap .get (stage .getParents ().get (0 )).getType ().equals ("PARALLEL" )) {
107
- String parentId = stage .getParents ().get (0 );
108
- PipelineStageInternal parent = stageMap .get (parentId );
109
- parent .setSeqContainerName (parent .getName ());
110
- parent .setName (stage .getName ());
111
- parent .setSequential (true );
112
- parent .setType (stage .getType ());
113
- parent .setTitle (stage .getTitle ());
114
- parent .setCompletePercent (stage .getCompletePercent ());
115
- stage .setSequential (true );
116
-
117
- nextSiblingToOlderSibling .put (stage .getId (), parentId );
118
- stagesThatAreNested .add (stage .getId ());
119
- stagesThatAreChildrenOrNestedStages .add (stage .getId ());
120
- // nested stage of nested stage
121
- } else if (stagesThatAreNested .contains (
122
- stageMap .get (stage .getParents ().get (0 )).getId ())) {
123
- PipelineStageInternal parent =
124
- stageMap .get (nextSiblingToOlderSibling .get (stage .getParents ().get (0 )));
125
- // shouldn't happen but found it after restarting a matrix build
126
- // this breaks the layout badly but prevents a null pointer
127
- if (parent != null ) {
128
- stage .setSequential (true );
129
- parent .setNextSibling (stage );
130
- stagesThatAreNested .add (stage .getId ());
131
- stagesThatAreChildrenOrNestedStages .add (stage .getId ());
132
- }
133
- }
134
- });
135
-
136
- List <PipelineStage > stageResults =
137
- stageMap .values ().stream ()
138
- .map (
139
- pipelineStageInternal -> {
140
- List <PipelineStage > children =
141
- stageToChildrenMap .getOrDefault (pipelineStageInternal .getId (), emptyList ())
142
- .stream ()
143
- .map (mapper (stageMap , stageToChildrenMap ))
144
- .collect (Collectors .toList ());
145
-
146
- return pipelineStageInternal .toPipelineStage (children );
147
- })
148
- .filter (stage -> !stagesThatAreChildrenOrNestedStages .contains (stage .getId ()))
149
- .collect (Collectors .toList ());
150
-
151
- FlowExecution execution = run .getExecution ();
152
- return new PipelineGraph (stageResults , execution != null && execution .isComplete ());
153
- }
154
-
155
78
private Function <String , PipelineStage > mapper (
156
79
Map <String , PipelineStageInternal > stageMap , Map <String , List <String >> stageToChildrenMap ) {
157
80
0 commit comments