Skip to content

Commit f3cb01c

Browse files
committed
Fixes
1 parent 0e54dbd commit f3cb01c

File tree

8 files changed

+389
-108
lines changed

8 files changed

+389
-108
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;
@@ -3999,4 +4001,19 @@ public void revokeProjectAccessToken(Object projectIdOrPath, Long tokenId) throw
39994001
delete(Response.Status.NO_CONTENT, null, "projects", getProjectIdOrPath(projectIdOrPath), "access_tokens", tokenId);
40004002
}
40014003

4004+
/**
4005+
* Lists project iterations.
4006+
*
4007+
* <pre><code>GitLab Endpoint: GET /projects/:id/iterations</code></pre>
4008+
*
4009+
* @param projectIdOrPath the project in the form of a Long(ID), String(path), or Project instance
4010+
* @param filter the iteration filter
4011+
* @return the list of project iterations
4012+
* @throws GitLabApiException if any exception occurs
4013+
*/
4014+
public List<Iteration> listProjectIterations(Object projectIdOrPath, IterationFilter filter) throws GitLabApiException {
4015+
MultivaluedMap<String,String> queryParams = (filter == null) ? null : filter.getQueryParams().asMap();
4016+
Response response = get(Response.Status.OK, queryParams, "projects", getProjectIdOrPath(projectIdOrPath), "iterations");
4017+
return (response.readEntity(new GenericType<List<Iteration>>() { }));
4018+
}
40024019
}

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

Lines changed: 113 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -2,115 +2,128 @@
22

33
import java.util.Date;
44

5-
import org.gitlab4j.api.utils.JacksonJsonEnumHelper;
5+
import org.gitlab4j.api.utils.JacksonJson;
66

77
import com.fasterxml.jackson.annotation.JsonCreator;
88
import com.fasterxml.jackson.annotation.JsonValue;
99

1010
public class Iteration {
11-
public enum IterationState {
12-
Opened, Upcomming, Current, Closed;
11+
public enum IterationState {
12+
UPCOMMING(1), CURRENT(2), CLOSED(3);
1313

14-
private static JacksonJsonEnumHelper<IterationState> enumHelper = new JacksonJsonEnumHelper<>(IterationState.class, true, true);
14+
private int value;
1515

16-
@JsonCreator
17-
public static IterationState forValue(String value) {
18-
return enumHelper.forValue(value);
16+
IterationState(int value) {
17+
this.value = value;
1918
}
2019

21-
@JsonValue
22-
public String toValue() {
23-
return (enumHelper.toString(this));
24-
}
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+
}
2529

26-
@Override
27-
public String toString() {
28-
return (enumHelper.toString(this));
29-
}
30-
}
30+
@JsonValue
31+
public int toIntValue() {
32+
return this.value;
33+
}
34+
35+
@Override
36+
public String toString() {
37+
return name();
38+
}
39+
}
3140

32-
private Long id;
33-
private Long iid;
34-
private Long sequence;
35-
private Long groupId;
36-
private String title;
37-
private String descripion;
38-
private IterationState state;
39-
private Date createdAt;
40-
private Date updatedAt;
41-
private Date startDate;
42-
private Date dueDate;
43-
private String webUrl;
44-
public Long getId() {
45-
return id;
46-
}
47-
public void setId(Long id) {
48-
this.id = id;
49-
}
50-
public Long getIid() {
51-
return iid;
52-
}
53-
public void setIid(Long iid) {
54-
this.iid = iid;
55-
}
56-
public Long getSequence() {
57-
return sequence;
58-
}
59-
public void setSequence(Long sequence) {
60-
this.sequence = sequence;
61-
}
62-
public Long getGroupId() {
63-
return groupId;
64-
}
65-
public void setGroupId(Long groupId) {
66-
this.groupId = groupId;
67-
}
68-
public String getTitle() {
69-
return title;
70-
}
71-
public void setTitle(String title) {
72-
this.title = title;
73-
}
74-
public String getDescripion() {
75-
return descripion;
76-
}
77-
public void setDescripion(String descripion) {
78-
this.descripion = descripion;
79-
}
80-
public IterationState getState() {
81-
return state;
82-
}
83-
public void setState(IterationState state) {
84-
this.state = state;
85-
}
86-
public Date getCreatedAt() {
87-
return createdAt;
88-
}
89-
public void setCreatedAt(Date createdAt) {
90-
this.createdAt = createdAt;
91-
}
92-
public Date getUpdatedAt() {
93-
return updatedAt;
94-
}
95-
public void setUpdatedAt(Date updatedAt) {
96-
this.updatedAt = updatedAt;
97-
}
98-
public Date getStartDate() {
99-
return startDate;
100-
}
101-
public void setStartDate(Date startDate) {
102-
this.startDate = startDate;
103-
}
104-
public Date getDueDate() {
105-
return dueDate;
106-
}
107-
public void setDueDate(Date dueDate) {
108-
this.dueDate = dueDate;
109-
}
110-
public String getWebUrl() {
111-
return webUrl;
112-
}
113-
public void setWebUrl(String webUrl) {
114-
this.webUrl = webUrl;
115-
}
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+
}
116129
}

0 commit comments

Comments
 (0)