Skip to content

Commit 999b6fb

Browse files
authored
Add support for link type between issues (#964)
* Add support for link type between issues Fixes #847 * Create AbstractIssue
1 parent 6e248bc commit 999b6fb

File tree

7 files changed

+431
-321
lines changed

7 files changed

+431
-321
lines changed

src/main/java/org/gitlab4j/api/IssuesApi.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.gitlab4j.api.models.IssueLink;
1717
import org.gitlab4j.api.models.IssuesStatistics;
1818
import org.gitlab4j.api.models.IssuesStatisticsFilter;
19+
import org.gitlab4j.api.models.LinkType;
1920
import org.gitlab4j.api.models.MergeRequest;
2021
import org.gitlab4j.api.models.Participant;
2122
import org.gitlab4j.api.models.TimeStats;
@@ -889,10 +890,31 @@ public Stream<Issue> getIssueLinksStream(Object projectIdOrPath, Long issueIid)
889890
*/
890891
public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid,
891892
Object targetProjectIdOrPath, Long targetIssueIid) throws GitLabApiException {
893+
return createIssueLink(projectIdOrPath, issueIid, targetProjectIdOrPath, targetIssueIid, null);
894+
}
895+
896+
/**
897+
* Creates a two-way relation between two issues. User must be allowed to update both issues in order to succeed.
898+
*
899+
* <p>NOTE: Only available in GitLab Starter, GitLab Bronze, and higher tiers.</p>
900+
*
901+
* <pre><code>GitLab Endpoint: POST /projects/:id/issues/:issue_iid/links</code></pre>
902+
*
903+
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
904+
* @param issueIid the internal ID of a project's issue
905+
* @param targetProjectIdOrPath the project in the form of an Long(ID), String(path), or Project instance of the target project
906+
* @param targetIssueIid the internal ID of a target project’s issue
907+
* @param linkType the type of the relation (optional), defaults to {@link LinkType#RELATES_TO}.
908+
* @return an instance of IssueLink holding the link relationship
909+
* @throws GitLabApiException if any exception occurs
910+
*/
911+
public IssueLink createIssueLink(Object projectIdOrPath, Long issueIid,
912+
Object targetProjectIdOrPath, Long targetIssueIid, LinkType linkType) throws GitLabApiException {
892913

893914
GitLabApiForm formData = new GitLabApiForm()
894915
.withParam("target_project_id", getProjectIdOrPath(targetProjectIdOrPath), true)
895-
.withParam("target_issue_iid", targetIssueIid, true);
916+
.withParam("target_issue_iid", targetIssueIid, true)
917+
.withParam("link_type", linkType, false);
896918

897919
Response response = post(Response.Status.OK, formData.asMap(),
898920
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "links");
Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
2+
package org.gitlab4j.api.models;
3+
4+
import java.util.Date;
5+
import java.util.List;
6+
7+
import org.gitlab4j.api.Constants.IssueState;
8+
import org.gitlab4j.api.utils.JacksonJson;
9+
10+
import com.fasterxml.jackson.annotation.JsonIgnore;
11+
import com.fasterxml.jackson.annotation.JsonProperty;
12+
import com.fasterxml.jackson.databind.node.IntNode;
13+
import com.fasterxml.jackson.databind.node.LongNode;
14+
import com.fasterxml.jackson.databind.node.TextNode;
15+
import com.fasterxml.jackson.databind.node.ValueNode;
16+
17+
public abstract class AbstractIssue {
18+
19+
public static class TaskCompletionStatus {
20+
21+
private Integer count;
22+
private Integer completedCount;
23+
24+
public Integer getCount() {
25+
return count;
26+
}
27+
28+
public void setCount(Integer count) {
29+
this.count = count;
30+
}
31+
32+
public Integer getCompletedCount() {
33+
return completedCount;
34+
}
35+
36+
public void setCompletedCount(Integer completedCount) {
37+
this.completedCount = completedCount;
38+
}
39+
40+
@Override
41+
public String toString() {
42+
return (JacksonJson.toJsonString(this));
43+
}
44+
}
45+
46+
private Assignee assignee;
47+
private List<Assignee> assignees;
48+
private Author author;
49+
private Boolean confidential;
50+
private Date createdAt;
51+
private Date updatedAt;
52+
private Date closedAt;
53+
private User closedBy;
54+
private String description;
55+
private Date dueDate;
56+
57+
@JsonProperty("id")
58+
private ValueNode actualId;
59+
@JsonIgnore
60+
private String externalId;
61+
@JsonIgnore
62+
private Long id;
63+
64+
private Long iid;
65+
private List<String> labels;
66+
private Milestone milestone;
67+
private Long projectId;
68+
private IssueState state;
69+
private String title;
70+
private Integer userNotesCount;
71+
private String webUrl;
72+
private Integer weight;
73+
private Boolean discussionLocked;
74+
private TimeStats timeStats;
75+
76+
private Integer upvotes;
77+
private Integer downvotes;
78+
private Integer mergeRequestsCount;
79+
private Boolean hasTasks;
80+
private String taskStatus;
81+
private TaskCompletionStatus taskCompletionStatus;
82+
83+
public Assignee getAssignee() {
84+
return assignee;
85+
}
86+
87+
public void setAssignee(Assignee assignee) {
88+
this.assignee = assignee;
89+
}
90+
91+
public List<Assignee> getAssignees() {
92+
return assignees;
93+
}
94+
95+
public void setAssignees(List<Assignee> assignees) {
96+
this.assignees = assignees;
97+
}
98+
99+
public Author getAuthor() {
100+
return author;
101+
}
102+
103+
public void setAuthor(Author author) {
104+
this.author = author;
105+
}
106+
107+
public Boolean getConfidential() {
108+
return confidential;
109+
}
110+
111+
public void setConfidential(Boolean confidential) {
112+
this.confidential = confidential;
113+
}
114+
115+
public Date getCreatedAt() {
116+
return createdAt;
117+
}
118+
119+
public void setCreatedAt(Date createdAt) {
120+
this.createdAt = createdAt;
121+
}
122+
123+
public String getDescription() {
124+
return description;
125+
}
126+
127+
public void setDescription(String description) {
128+
this.description = description;
129+
}
130+
131+
public Date getDueDate() {
132+
return dueDate;
133+
}
134+
135+
public void setDueDate(Date dueDate) {
136+
this.dueDate = dueDate;
137+
}
138+
139+
public ValueNode getActualId() {
140+
return actualId;
141+
}
142+
143+
public void setActualId(ValueNode id) {
144+
actualId = id;
145+
if (actualId instanceof TextNode) {
146+
externalId = actualId.asText();
147+
} else if (actualId instanceof IntNode || actualId instanceof LongNode) {
148+
this.id = actualId.asLong();
149+
}
150+
}
151+
152+
public Long getId() {
153+
return (id);
154+
}
155+
156+
public void setId(Long id) {
157+
this.id = id;
158+
if (id != null) {
159+
actualId = new LongNode(id);
160+
externalId = null;
161+
}
162+
}
163+
164+
public String getExternalId() {
165+
return (externalId);
166+
}
167+
168+
public void setExternalId(String externalId) {
169+
this.externalId = externalId;
170+
if (externalId != null) {
171+
actualId = new TextNode(externalId);
172+
id = null;
173+
}
174+
}
175+
176+
public Long getIid() {
177+
return iid;
178+
}
179+
180+
public void setIid(Long iid) {
181+
this.iid = iid;
182+
}
183+
184+
public List<String> getLabels() {
185+
return labels;
186+
}
187+
188+
public void setLabels(List<String> labels) {
189+
this.labels = labels;
190+
}
191+
192+
public Milestone getMilestone() {
193+
return milestone;
194+
}
195+
196+
public void setMilestone(Milestone milestone) {
197+
this.milestone = milestone;
198+
}
199+
200+
public Long getProjectId() {
201+
return projectId;
202+
}
203+
204+
public void setProjectId(Long projectId) {
205+
this.projectId = projectId;
206+
}
207+
208+
public IssueState getState() {
209+
return state;
210+
}
211+
212+
public void setState(IssueState state) {
213+
this.state = state;
214+
}
215+
216+
public String getTitle() {
217+
return title;
218+
}
219+
220+
public void setTitle(String title) {
221+
this.title = title;
222+
}
223+
224+
public Date getUpdatedAt() {
225+
return updatedAt;
226+
}
227+
228+
public void setUpdatedAt(Date updatedAt) {
229+
this.updatedAt = updatedAt;
230+
}
231+
232+
public Date getClosedAt() {
233+
return closedAt;
234+
}
235+
236+
public void setClosedAt(Date closedAt) {
237+
this.closedAt = closedAt;
238+
}
239+
240+
public User getClosedBy() {
241+
return closedBy;
242+
}
243+
244+
public void setClosedBy(User closedBy) {
245+
this.closedBy = closedBy;
246+
}
247+
248+
public Integer getUserNotesCount() {
249+
return userNotesCount;
250+
}
251+
252+
public void setUserNotesCount(Integer userNotesCount) {
253+
this.userNotesCount = userNotesCount;
254+
}
255+
256+
public String getWebUrl() {
257+
return webUrl;
258+
}
259+
260+
public void setWebUrl(String webUrl) {
261+
this.webUrl = webUrl;
262+
}
263+
264+
public Integer getWeight() {
265+
return weight;
266+
}
267+
268+
public void setWeight(Integer weight) {
269+
this.weight = weight;
270+
}
271+
272+
public Boolean getDiscussionLocked() {
273+
return discussionLocked;
274+
}
275+
276+
public void setDiscussionLocked(Boolean discussionLocked) {
277+
this.discussionLocked = discussionLocked;
278+
}
279+
280+
public TimeStats getTimeStats() {
281+
return timeStats;
282+
}
283+
284+
public void setTimeStats(TimeStats timeStats) {
285+
this.timeStats = timeStats;
286+
}
287+
288+
public Integer getUpvotes() {
289+
return upvotes;
290+
}
291+
292+
public void setUpvotes(Integer upvotes) {
293+
this.upvotes = upvotes;
294+
}
295+
296+
public Integer getDownvotes() {
297+
return downvotes;
298+
}
299+
300+
public void setDownvotes(Integer downvotes) {
301+
this.downvotes = downvotes;
302+
}
303+
304+
public Integer getMergeRequestsCount() {
305+
return mergeRequestsCount;
306+
}
307+
308+
public void setMergeRequestsCount(Integer mergeRequestsCount) {
309+
this.mergeRequestsCount = mergeRequestsCount;
310+
}
311+
312+
public Boolean getHasTasks() {
313+
return hasTasks;
314+
}
315+
316+
public void setHasTasks(Boolean hasTasks) {
317+
this.hasTasks = hasTasks;
318+
}
319+
320+
public String getTaskStatus() {
321+
return taskStatus;
322+
}
323+
324+
public void setTaskStatus(String taskStatus) {
325+
this.taskStatus = taskStatus;
326+
}
327+
328+
public TaskCompletionStatus getTaskCompletionStatus() {
329+
return taskCompletionStatus;
330+
}
331+
332+
public void setTaskCompletionStatus(TaskCompletionStatus taskCompletionStatus) {
333+
this.taskCompletionStatus = taskCompletionStatus;
334+
}
335+
336+
@Override
337+
public String toString() {
338+
return (JacksonJson.toJsonString(this));
339+
}
340+
}

0 commit comments

Comments
 (0)