1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.atlassian.jira.rest.client.internal.json.gen;
18
19 import com.atlassian.jira.rest.client.api.domain.input.FieldInput;
20 import com.atlassian.jira.rest.client.api.domain.input.IssueInput;
21 import org.codehaus.jettison.json.JSONException;
22 import org.codehaus.jettison.json.JSONObject;
23
24
25
26
27
28
29 public class IssueInputJsonGenerator implements JsonGenerator<IssueInput> {
30
31 private final ComplexIssueInputFieldValueJsonGenerator complexIssueInputFieldValueJsonGenerator = new ComplexIssueInputFieldValueJsonGenerator();
32
33 @Override
34 public JSONObject generate(IssueInput issue) throws JSONException {
35 final JSONObject jsonObject = new JSONObject();
36 final JSONObject fields = new JSONObject();
37
38 if (issue != null && issue.getFields() != null) {
39 for (final FieldInput field : issue.getFields().values()) {
40 if (field.getValue() != null) {
41 fields.put(field.getId(), complexIssueInputFieldValueJsonGenerator.generateFieldValueForJson(field
42 .getValue()));
43 }
44 }
45 }
46
47 jsonObject.put("fields", fields);
48 return jsonObject;
49 }
50 }