1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.api.domain;
18
19 import com.atlassian.jira.rest.client.api.ExpandableResource;
20 import com.google.common.base.Objects;
21 import org.joda.time.DateTime;
22
23 import javax.annotation.Nullable;
24 import javax.ws.rs.core.UriBuilder;
25 import java.net.URI;
26 import java.util.Collection;
27 import java.util.Set;
28
29
30
31
32
33
34 public class Issue extends BasicIssue implements ExpandableResource {
35
36 public Issue(String summary, URI self, String key, Long id, BasicProject project, BasicIssueType issueType, BasicStatus status,
37 String description, @Nullable BasicPriority priority, @Nullable BasicResolution resolution, Collection<Attachment> attachments,
38 @Nullable User reporter, @Nullable User assignee, DateTime creationDate, DateTime updateDate, DateTime dueDate,
39 Collection<Version> affectedVersions, Collection<Version> fixVersions, Collection<BasicComponent> components,
40 @Nullable TimeTracking timeTracking, Collection<IssueField> issueFields, Collection<Comment> comments,
41 @Nullable URI transitionsUri,
42 @Nullable Collection<IssueLink> issueLinks,
43 BasicVotes votes, Collection<Worklog> worklogs, BasicWatchers watchers, Iterable<String> expandos,
44 @Nullable Collection<Subtask> subtasks, @Nullable Collection<ChangelogGroup> changelog, Set<String> labels) {
45 super(self, key, id);
46 this.summary = summary;
47 this.project = project;
48 this.status = status;
49 this.description = description;
50 this.resolution = resolution;
51 this.expandos = expandos;
52 this.comments = comments;
53 this.attachments = attachments;
54 this.issueFields = issueFields;
55 this.issueType = issueType;
56 this.reporter = reporter;
57 this.assignee = assignee;
58 this.creationDate = creationDate;
59 this.updateDate = updateDate;
60 this.dueDate = dueDate;
61 this.transitionsUri = transitionsUri;
62 this.issueLinks = issueLinks;
63 this.votes = votes;
64 this.worklogs = worklogs;
65 this.watchers = watchers;
66 this.fixVersions = fixVersions;
67 this.affectedVersions = affectedVersions;
68 this.components = components;
69 this.priority = priority;
70 this.timeTracking = timeTracking;
71 this.subtasks = subtasks;
72 this.changelog = changelog;
73 this.labels = labels;
74 }
75
76 private final BasicStatus status;
77 private final BasicIssueType issueType;
78 private final BasicProject project;
79 private final URI transitionsUri;
80 private final Iterable<String> expandos;
81 private final Collection<BasicComponent> components;
82 private final String summary;
83 @Nullable
84 private final String description;
85 @Nullable
86 private final User reporter;
87 private final User assignee;
88 @Nullable
89 private final BasicResolution resolution;
90 private final Collection<IssueField> issueFields;
91 private final DateTime creationDate;
92 private final DateTime updateDate;
93 private final DateTime dueDate;
94 private final BasicPriority priority;
95 private final BasicVotes votes;
96 @Nullable
97 private final Collection<Version> fixVersions;
98 @Nullable
99 private final Collection<Version> affectedVersions;
100
101 private final Collection<Comment> comments;
102
103 @Nullable
104 private final Collection<IssueLink> issueLinks;
105
106 private final Collection<Attachment> attachments;
107
108 private final Collection<Worklog> worklogs;
109 private final BasicWatchers watchers;
110
111 @Nullable
112 private final TimeTracking timeTracking;
113 @Nullable
114 private final Collection<Subtask> subtasks;
115 @Nullable
116 private final Collection<ChangelogGroup> changelog;
117 private final Set<String> labels;
118
119 public BasicStatus getStatus() {
120 return status;
121 }
122
123
124
125
126 @Nullable
127 public User getReporter() {
128 return reporter;
129 }
130
131
132
133
134 @Nullable
135 public User getAssignee() {
136 return assignee;
137 }
138
139
140 public String getSummary() {
141 return summary;
142 }
143
144
145
146
147 @Nullable
148 public BasicPriority getPriority() {
149 return priority;
150 }
151
152
153
154
155 @Nullable
156 public Iterable<IssueLink> getIssueLinks() {
157 return issueLinks;
158 }
159
160 @Nullable
161 public Iterable<Subtask> getSubtasks() {
162 return subtasks;
163 }
164
165
166
167
168 public Iterable<IssueField> getFields() {
169 return issueFields;
170 }
171
172
173
174
175
176 @Nullable
177 public IssueField getField(String id) {
178 for (IssueField issueField : issueFields) {
179 if (issueField.getId().equals(id)) {
180 return issueField;
181 }
182 }
183 return null;
184 }
185
186
187
188
189
190
191
192
193
194 @Nullable
195 public IssueField getFieldByName(String name) {
196 for (IssueField issueField : issueFields) {
197 if (issueField.getName().equals(name)) {
198 return issueField;
199 }
200 }
201 return null;
202 }
203
204 @Override
205 public Iterable<String> getExpandos() {
206 return expandos;
207 }
208
209
210
211
212 public BasicIssueType getIssueType() {
213 return issueType;
214 }
215
216
217
218
219 public Iterable<Attachment> getAttachments() {
220 return attachments;
221 }
222
223 public URI getAttachmentsUri() {
224 return UriBuilder.fromUri(getSelf()).path("attachments").build();
225 }
226
227 public URI getWorklogUri() {
228 return UriBuilder.fromUri(getSelf()).path("worklog").build();
229 }
230
231
232
233
234 public Iterable<Comment> getComments() {
235 return comments;
236 }
237
238 public URI getCommentsUri() {
239 return UriBuilder.fromUri(getSelf()).path("comment").build();
240 }
241
242
243
244
245 public BasicProject getProject() {
246 return project;
247 }
248
249
250
251
252 @Nullable
253 public BasicVotes getVotes() {
254 return votes;
255 }
256
257 public Iterable<Worklog> getWorklogs() {
258 return worklogs;
259 }
260
261
262
263
264 @Nullable
265 public BasicWatchers getWatchers() {
266 return watchers;
267 }
268
269 @Nullable
270 public Iterable<Version> getFixVersions() {
271 return fixVersions;
272 }
273
274 @Nullable
275 public URI getTransitionsUri() {
276 return transitionsUri;
277 }
278
279 @Nullable
280 public Iterable<Version> getAffectedVersions() {
281 return affectedVersions;
282 }
283
284 public Iterable<BasicComponent> getComponents() {
285 return components;
286 }
287
288 public Set<String> getLabels() {
289 return labels;
290 }
291
292
293
294
295
296
297
298
299
300 @Nullable
301 public Iterable<ChangelogGroup> getChangelog() {
302 return changelog;
303 }
304
305 public URI getVotesUri() {
306 return UriBuilder.fromUri(getSelf()).path("votes").build();
307 }
308
309
310 @Nullable
311 public BasicResolution getResolution() {
312 return resolution;
313 }
314
315 public DateTime getCreationDate() {
316 return creationDate;
317 }
318
319 public DateTime getUpdateDate() {
320 return updateDate;
321 }
322
323 public DateTime getDueDate() {
324 return dueDate;
325 }
326
327 @Nullable
328 public TimeTracking getTimeTracking() {
329 return timeTracking;
330 }
331
332 @Nullable
333 public String getDescription() {
334 return description;
335 }
336
337 @Override
338 protected Objects.ToStringHelper getToStringHelper() {
339 return super.getToStringHelper().
340 add("project", project).
341 add("status", status).
342 add("description", description).
343 add("expandos", expandos).
344 add("resolution", resolution).
345 add("reporter", reporter).
346 add("assignee", assignee).addValue("\n").
347 add("fields", issueFields).addValue("\n").
348 add("affectedVersions", affectedVersions).addValue("\n").
349 add("fixVersions", fixVersions).addValue("\n").
350 add("components", components).addValue("\n").
351 add("issueType", issueType).
352 add("creationDate", creationDate).
353 add("updateDate", updateDate).addValue("\n").
354 add("dueDate", dueDate).addValue("\n").
355 add("attachments", attachments).addValue("\n").
356 add("comments", comments).addValue("\n").
357 add("transitionsUri", transitionsUri).
358 add("issueLinks", issueLinks).addValue("\n").
359 add("votes", votes).addValue("\n").
360 add("worklogs", worklogs).addValue("\n").
361 add("watchers", watchers).
362 add("timeTracking", timeTracking).
363 add("changelog", changelog).
364 add("labels", labels);
365 }
366 }