Skip to content

Commit 55d3f92

Browse files
KoCoderjmini
andauthored
Add Field Iteration to Issue (#1027)
--------- Co-authored-by: Konstantin Hintermayer <[email protected]> Co-authored-by: Jeremie Bresson <[email protected]>
1 parent 69c7096 commit 55d3f92

File tree

9 files changed

+415
-9
lines changed

9 files changed

+415
-9
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import javax.ws.rs.core.Form;
1212
import javax.ws.rs.core.GenericType;
13+
import javax.ws.rs.core.MultivaluedMap;
1314
import javax.ws.rs.core.Response;
1415

1516
import org.gitlab4j.api.GitLabApi.ApiVersion;
@@ -22,6 +23,8 @@
2223
import org.gitlab4j.api.models.GroupFilter;
2324
import org.gitlab4j.api.models.GroupParams;
2425
import org.gitlab4j.api.models.GroupProjectsFilter;
26+
import org.gitlab4j.api.models.Iteration;
27+
import org.gitlab4j.api.models.IterationFilter;
2528
import org.gitlab4j.api.models.LdapGroupLink;
2629
import org.gitlab4j.api.models.Member;
2730
import org.gitlab4j.api.models.Project;
@@ -1958,4 +1961,20 @@ public void deleteCustomAttribute(final Object groupIdOrPath, final String key)
19581961

19591962
delete(Response.Status.OK, null, "groups", getGroupIdOrPath(groupIdOrPath), "custom_attributes", key);
19601963
}
1964+
1965+
/**
1966+
* Lists group iterations.
1967+
*
1968+
* <pre><code>GitLab Endpoint: GET /groups/:id/iterations</code></pre>
1969+
*
1970+
* @param groupIdOrPath the group in the form of an Long(ID), String(path), or Group instance
1971+
* @param filter the iteration filter
1972+
* @return the list of group iterations
1973+
* @throws GitLabApiException if any exception occurs
1974+
*/
1975+
public List<Iteration> listGroupIterations(Object groupIdOrPath, IterationFilter filter) throws GitLabApiException {
1976+
MultivaluedMap<String,String> queryParams = (filter == null) ? null : filter.getQueryParams().asMap();
1977+
Response response = get(Response.Status.OK, queryParams, "groups", getGroupIdOrPath(groupIdOrPath), "iterations");
1978+
return (response.readEntity(new GenericType<List<Iteration>>() { }));
1979+
}
19611980
}

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
import org.gitlab4j.api.models.Event;
4949
import org.gitlab4j.api.models.FileUpload;
5050
import org.gitlab4j.api.models.Issue;
51+
import org.gitlab4j.api.models.Iteration;
52+
import org.gitlab4j.api.models.IterationFilter;
5153
import org.gitlab4j.api.models.Member;
5254
import org.gitlab4j.api.models.Namespace;
5355
import org.gitlab4j.api.models.Project;
@@ -4015,4 +4017,19 @@ public void revokeProjectAccessToken(Object projectIdOrPath, Long tokenId) throw
40154017
delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "access_tokens", tokenId);
40164018
}
40174019

4020+
/**
4021+
* Lists project iterations.
4022+
*
4023+
* <pre><code>GitLab Endpoint: GET /projects/:id/iterations</code></pre>
4024+
*
4025+
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
4026+
* @param filter the iteration filter
4027+
* @return the list of project iterations
4028+
* @throws GitLabApiException if any exception occurs
4029+
*/
4030+
public List<Iteration> listProjectIterations(Object projectIdOrPath, IterationFilter filter) throws GitLabApiException {
4031+
MultivaluedMap<String,String> queryParams = (filter == null) ? null : filter.getQueryParams().asMap();
4032+
Response response = get(Response.Status.OK, queryParams, "projects", getProjectIdOrPath(projectIdOrPath), "iterations");
4033+
return (response.readEntity(new GenericType<List<Iteration>>() { }));
4034+
}
40184035
}

src/main/java/org/gitlab4j/api/models/AbstractIssue.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public String toString() {
7878
private Integer mergeRequestsCount;
7979
private Boolean hasTasks;
8080
private String taskStatus;
81+
private Iteration iteration;
8182
private TaskCompletionStatus taskCompletionStatus;
8283

8384
public Assignee getAssignee() {
@@ -325,7 +326,15 @@ public void setTaskStatus(String taskStatus) {
325326
this.taskStatus = taskStatus;
326327
}
327328

328-
public TaskCompletionStatus getTaskCompletionStatus() {
329+
public Iteration getIteration() {
330+
return iteration;
331+
}
332+
333+
public void setIteration(Iteration iteration) {
334+
this.iteration = iteration;
335+
}
336+
337+
public TaskCompletionStatus getTaskCompletionStatus() {
329338
return taskCompletionStatus;
330339
}
331340

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
package org.gitlab4j.api.models;
2+
3+
import java.util.Date;
4+
5+
import org.gitlab4j.api.utils.JacksonJson;
6+
7+
import com.fasterxml.jackson.annotation.JsonCreator;
8+
import com.fasterxml.jackson.annotation.JsonValue;
9+
10+
public class Iteration {
11+
public enum IterationState {
12+
UPCOMMING(1), CURRENT(2), CLOSED(3);
13+
14+
private int value;
15+
16+
IterationState(int value) {
17+
this.value = value;
18+
}
19+
20+
@JsonCreator
21+
public static IterationState fromIntValue(int value) {
22+
for (IterationState it : values()) {
23+
if(it.value == value) {
24+
return it;
25+
}
26+
}
27+
throw new IllegalArgumentException("No enum found for value: " + value);
28+
}
29+
30+
@JsonValue
31+
public int toIntValue() {
32+
return this.value;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return name();
38+
}
39+
}
40+
41+
private Long id;
42+
private Long iid;
43+
private Long sequence;
44+
private Long groupId;
45+
private String title;
46+
private String description;
47+
private IterationState state;
48+
private Date createdAt;
49+
private Date updatedAt;
50+
private Date startDate;
51+
private Date dueDate;
52+
private String webUrl;
53+
public Long getId() {
54+
return id;
55+
}
56+
public void setId(Long id) {
57+
this.id = id;
58+
}
59+
public Long getIid() {
60+
return iid;
61+
}
62+
public void setIid(Long iid) {
63+
this.iid = iid;
64+
}
65+
public Long getSequence() {
66+
return sequence;
67+
}
68+
public void setSequence(Long sequence) {
69+
this.sequence = sequence;
70+
}
71+
public Long getGroupId() {
72+
return groupId;
73+
}
74+
public void setGroupId(Long groupId) {
75+
this.groupId = groupId;
76+
}
77+
public String getTitle() {
78+
return title;
79+
}
80+
public void setTitle(String title) {
81+
this.title = title;
82+
}
83+
public String getDescription() {
84+
return description;
85+
}
86+
public void setDescription(String description) {
87+
this.description = description;
88+
}
89+
public IterationState getState() {
90+
return state;
91+
}
92+
public void setState(IterationState state) {
93+
this.state = state;
94+
}
95+
public Date getCreatedAt() {
96+
return createdAt;
97+
}
98+
public void setCreatedAt(Date createdAt) {
99+
this.createdAt = createdAt;
100+
}
101+
public Date getUpdatedAt() {
102+
return updatedAt;
103+
}
104+
public void setUpdatedAt(Date updatedAt) {
105+
this.updatedAt = updatedAt;
106+
}
107+
public Date getStartDate() {
108+
return startDate;
109+
}
110+
public void setStartDate(Date startDate) {
111+
this.startDate = startDate;
112+
}
113+
public Date getDueDate() {
114+
return dueDate;
115+
}
116+
public void setDueDate(Date dueDate) {
117+
this.dueDate = dueDate;
118+
}
119+
public String getWebUrl() {
120+
return webUrl;
121+
}
122+
public void setWebUrl(String webUrl) {
123+
this.webUrl = webUrl;
124+
}
125+
@Override
126+
public String toString() {
127+
return (JacksonJson.toJsonString(this));
128+
}
129+
}

0 commit comments

Comments
 (0)