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