Skip to content

Commit d10a410

Browse files
committed
WorkItemScript: Add UPDATE_DUE_DATE actio
1 parent 88b0b3d commit d10a410

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

gitlab4j-test/WorkItemScript.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
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/96673d87850c148ef174fbf4c5d163db745ae3ea
5-
//DEPS io.smallrye:smallrye-graphql-client-implementation-vertx:2.11.0
4+
//DEPS https://github.com/unblu/gitlab-workitem-graphql-client/commit/c9329cfc1c6fb35da6862869f3135045f7f08574
5+
//DEPS patched.unblu.io.smallrye:smallrye-graphql-client-implementation-vertx:2.12.2-unblu-2
66
//DEPS org.jboss.logmanager:jboss-logmanager:3.1.1.Final
77
//JAVA 17
88
//RUNTIME_OPTIONS -Djava.util.logging.manager=org.jboss.logmanager.LogManager
@@ -19,6 +19,7 @@
1919
import java.util.concurrent.Callable;
2020

2121
import graphql.gitlab.api.WorkitemClientApi;
22+
import graphql.gitlab.model.Date;
2223
import graphql.gitlab.model.WorkItem;
2324
import graphql.gitlab.model.WorkItemConnection;
2425
import graphql.gitlab.model.WorkItemDeleteInput;
@@ -28,6 +29,7 @@
2829
import graphql.gitlab.model.WorkItemUpdatePayload;
2930
import graphql.gitlab.model.WorkItemWidgetHierarchyUpdateInputWithChildren;
3031
import graphql.gitlab.model.WorkItemWidgetHierarchyUpdateInputWithParent;
32+
import graphql.gitlab.model.WorkItemWidgetStartAndDueDateUpdateInput;
3133
import io.smallrye.graphql.client.typesafe.api.TypesafeGraphQLClientBuilder;
3234
import picocli.CommandLine;
3335
import picocli.CommandLine.Command;
@@ -57,6 +59,9 @@ public class WorkItemScript implements Callable<Integer> {
5759
@Option(names = { "-s", "--childId" }, description = "workitem childrenIds")
5860
private List<String> childrenIds;
5961

62+
@Option(names = { "-d", "--dueDate" }, description = "workitem dueDate")
63+
private String dueDate;
64+
6065
@Option(names = { "-r", "--ref", "--reference" }, description = "references in the namespace")
6166
private List<String> refs;
6267

@@ -67,7 +72,7 @@ public class WorkItemScript implements Callable<Integer> {
6772
Boolean logHttp;
6873

6974
private static enum Action {
70-
GET_WORKITEM, DELETE_WORKITEM, ADD_PARENT, REMOVE_PARENT, ADD_CHILDREN
75+
GET_WORKITEM, DELETE_WORKITEM, ADD_PARENT, REMOVE_PARENT, ADD_CHILDREN, UPDATE_DUE_DATE
7176
}
7277

7378
@Override
@@ -109,6 +114,9 @@ public Integer call() throws Exception {
109114
case ADD_CHILDREN:
110115
addChildren(api);
111116
break;
117+
case UPDATE_DUE_DATE:
118+
updateDueDate(api);
119+
break;
112120
default:
113121
throw new IllegalArgumentException("Unexpected value: " + action);
114122
}
@@ -157,6 +165,20 @@ private void deleteParent(WorkitemClientApi api) {
157165
System.out.println(response);
158166
}
159167

168+
private void updateDueDate(WorkitemClientApi api) {
169+
ensureExists(id, "id");
170+
WorkItemWidgetStartAndDueDateUpdateInput input = new WorkItemWidgetStartAndDueDateUpdateInput()
171+
.setIsFixed(true);
172+
if (dueDate != null) {
173+
input.setDueDate(new Date(dueDate));
174+
}
175+
WorkItemUpdateInput request = new WorkItemUpdateInput()
176+
.setId(new WorkItemID(id))
177+
.setStartAndDueDateWidget(input);
178+
WorkItemUpdatePayload updateResponse = api.workItemUpdate(request);
179+
System.out.println(updateResponse);
180+
}
181+
160182
private void addChildren(WorkitemClientApi api) {
161183
ensureExists(id, "id");
162184
ensureExists(childrenIds, "childId");

0 commit comments

Comments
 (0)