File tree Expand file tree Collapse file tree 5 files changed +28
-3
lines changed
core/src/main/java/com/flowci/core/flow Expand file tree Collapse file tree 5 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -43,15 +43,19 @@ public class FlowController {
4343
4444 private final FlowService flowService ;
4545
46+ private final FlowGroupService flowGroupService ;
47+
4648 private final FlowItemService flowItemService ;
4749
4850 public FlowController (List <Template > templates ,
4951 UserService userService ,
5052 FlowService flowService ,
53+ FlowGroupService flowGroupService ,
5154 FlowItemService flowItemService ) {
5255 this .templates = templates ;
5356 this .userService = userService ;
5457 this .flowService = flowService ;
58+ this .flowGroupService = flowGroupService ;
5559 this .flowItemService = flowItemService ;
5660 }
5761
@@ -69,8 +73,12 @@ public List<Template> getTemplates() {
6973
7074 @ GetMapping (value = "/{name}" )
7175 @ Action (FlowAction .GET )
72- public Flow get (@ PathVariable String name ) {
73- return flowService .get (name );
76+ public Flow get (@ PathVariable String name , @ RequestParam boolean group ) {
77+ var flow = flowService .get (name );
78+ if (group && flow .hasParentId ()) {
79+ flow .setParent (flowGroupService .getById (flow .getParentId ()));
80+ }
81+ return flow ;
7482 }
7583
7684 @ GetMapping (value = "/{name}/exist" )
Original file line number Diff line number Diff line change 1717package com .flowci .core .flow .domain ;
1818
1919import com .fasterxml .jackson .annotation .JsonIgnore ;
20+ import com .fasterxml .jackson .annotation .JsonInclude ;
2021import com .flowci .core .common .domain .Variables ;
2122import com .flowci .domain .StringVars ;
2223import com .flowci .domain .VarValue ;
2930import lombok .EqualsAndHashCode ;
3031import lombok .Getter ;
3132import lombok .Setter ;
33+ import org .springframework .data .annotation .Transient ;
3234import org .springframework .data .mongodb .core .mapping .Document ;
3335
3436import java .util .Objects ;
@@ -84,6 +86,10 @@ public static void validateName(String name) {
8486
8587 private WebhookStatus webhookStatus ;
8688
89+ @ JsonInclude ()
90+ @ Transient
91+ private FlowGroup parent ;
92+
8793 public Flow () {
8894 this .type = Type .Flow ;
8995 }
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ public enum Type {
4040 protected String parentId = ROOT_ID ;
4141
4242 public boolean hasParentId () {
43- return StringHelper .hasValue (parentId );
43+ return StringHelper .hasValue (parentId ) && ! parentId . equals ( ROOT_ID ) ;
4444 }
4545
4646 public boolean hasRootParent () {
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ public interface FlowGroupService {
99
1010 FlowGroup get (String name );
1111
12+ FlowGroup getById (String id );
13+
1214 List <Flow > flows (String id );
1315
1416 FlowGroup create (String name );
Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ public FlowGroup get(String name) {
4949 return optional .get ();
5050 }
5151
52+ @ Override
53+ public FlowGroup getById (String id ) {
54+ Optional <FlowGroup > optional = flowGroupDao .findById (id );
55+ if (optional .isEmpty ()) {
56+ throw new NotFoundException ("Group {0} not found" , id );
57+ }
58+ return optional .get ();
59+ }
60+
5261 @ Override
5362 public FlowGroup create (String name ) {
5463 var email = sessionManager .getUserEmail ();
You can’t perform that action at this time.
0 commit comments