Skip to content

Commit 82cbb9d

Browse files
committed
Update graphql-client and ADD_CHILDREN Action
1 parent 2b05716 commit 82cbb9d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

gitlab4j-test/WorkItemScript.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
///usr/bin/env jbang "$0" "$@" ; exit $?
22

33
//DEPS info.picocli:picocli:4.6.3
4-
//DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/b93a9f97e53e2647a0531c33b2dc67be940fd80c
4+
//DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/96673d87850c148ef174fbf4c5d163db745ae3ea
55
//DEPS io.smallrye:smallrye-graphql-client-implementation-vertx:2.11.0
66
//DEPS org.jboss.logmanager:jboss-logmanager:3.1.1.Final
77
//JAVA 17
@@ -25,7 +25,8 @@
2525
import graphql.gitlab.model.WorkItemID;
2626
import graphql.gitlab.model.WorkItemUpdateInput;
2727
import graphql.gitlab.model.WorkItemUpdatePayload;
28-
import graphql.gitlab.model.WorkItemWidgetHierarchyUpdateInput;
28+
import graphql.gitlab.model.WorkItemWidgetHierarchyUpdateInputWithChildren;
29+
import graphql.gitlab.model.WorkItemWidgetHierarchyUpdateInputWithParent;
2930
import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;
3031
import picocli.CommandLine;
3132
import picocli.CommandLine.Command;
@@ -52,7 +53,10 @@ public class WorkItemScript implements Callable<Integer> {
5253
@Option(names = { "-p", "--parentId" }, description = "workitem parentId")
5354
private String parentId;
5455

55-
@Option(names = { "-r", "--ref", "--reference" }, description = "references in the namespace")
56+
@Option(names = { "-s", "--childId" }, description = "workitem childrenIds")
57+
private List<String> childrenIds;
58+
59+
@Option(names = { "-r", "--h", "--reference" }, description = "references in the namespace")
5660
private List<String> refs;
5761

5862
@Option(names = { "-c", "--config" }, description = "configuration file location")
@@ -62,7 +66,7 @@ public class WorkItemScript implements Callable<Integer> {
6266
Boolean logHttp;
6367

6468
private static enum Action {
65-
GET_WORKITEM, DELETE_WORKITEM, ADD_PARENT, REMOVE_PARENT
69+
GET_WORKITEM, DELETE_WORKITEM, ADD_PARENT, REMOVE_PARENT, ADD_CHILDREN
6670
}
6771

6872
@Override
@@ -93,6 +97,9 @@ public Integer call() throws Exception {
9397
case REMOVE_PARENT:
9498
deleteParent(api);
9599
break;
100+
case ADD_CHILDREN:
101+
addChildren(api);
102+
break;
96103
default:
97104
throw new IllegalArgumentException("Unexpected value: " + action);
98105
}
@@ -120,7 +127,7 @@ private void addParent(WorkitemClientApi api) {
120127
ensureExists(parentId, "parentId");
121128
WorkItemUpdatePayload response = api.workItemUpdate(new WorkItemUpdateInput()
122129
.setId(new WorkItemID(id))
123-
.setHierarchyWidget(new WorkItemWidgetHierarchyUpdateInput() //
130+
.setHierarchyWidget(new WorkItemWidgetHierarchyUpdateInputWithParent() //
124131
.setParentId(new WorkItemID(parentId)) //
125132
) //
126133
);
@@ -131,7 +138,21 @@ private void deleteParent(WorkitemClientApi api) {
131138
ensureExists(id, "id");
132139
WorkItemUpdatePayload response = api.workItemUpdate(new WorkItemUpdateInput()
133140
.setId(new WorkItemID(id))
134-
.setHierarchyWidget(new WorkItemWidgetHierarchyUpdateInput().setParentId(null)));
141+
.setHierarchyWidget(new WorkItemWidgetHierarchyUpdateInputWithParent().setParentId(null)));
142+
System.out.println(response);
143+
}
144+
145+
private void addChildren(WorkitemClientApi api) {
146+
ensureExists(id, "id");
147+
ensureExists(childrenIds, "childId");
148+
WorkItemUpdatePayload response = api.workItemUpdate(new WorkItemUpdateInput()
149+
.setId(new WorkItemID(id))
150+
.setHierarchyWidget(new WorkItemWidgetHierarchyUpdateInputWithChildren() //
151+
.setChildrenIds(childrenIds.stream()
152+
.map(WorkItemID::new)
153+
.toList()) //
154+
) //
155+
);
135156
System.out.println(response);
136157
}
137158

0 commit comments

Comments
 (0)