1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.itracker.model;
20
21 import org.apache.commons.lang.builder.ToStringBuilder;
22 import org.itracker.core.resources.ITrackerResources;
23
24
25
26
27
28
29 public class IssueRelation extends AbstractEntity {
30
31
32
33
34 private static final long serialVersionUID = 1L;
35
36 private Issue issue;
37
38 private Issue relatedIssue;
39
40
41
42
43 private Type type;
44
45 private Integer matchingRelationId;
46
47
48
49
50
51
52
53
54
55
56 public IssueRelation() {
57 }
58
59 public IssueRelation(Issueef="../../../org/itracker/model/Issue.html#Issue">Issue issue, Issue relatedIssue, Type relationType) {
60 setIssue(issue);
61 setRelatedIssue(relatedIssue);
62 setRelationType(relationType);
63 }
64
65 public Issue getIssue() {
66 return issue;
67 }
68
69 public void setIssue(Issue issue) {
70 if (issue == null) {
71 throw new IllegalArgumentException("null issue");
72 }
73 this.issue = issue;
74 }
75
76 public Issue getRelatedIssue() {
77 return relatedIssue;
78 }
79
80 public void setRelatedIssue(Issue relatedIssue) {
81 if (relatedIssue == null) {
82 throw new IllegalArgumentException("null relatedIssue");
83 }
84 this.relatedIssue = relatedIssue;
85 }
86
87 public Type getRelationType() {
88 return type;
89 }
90
91 public void setRelationType(Type type) {
92 this.type = type;
93 }
94
95 public Integer getMatchingRelationId() {
96 return matchingRelationId;
97 }
98
99 public void setMatchingRelationId(Integer matchingRelationId) {
100 this.matchingRelationId = matchingRelationId;
101 }
102
103
104 @Override
105 public String toString() {
106 return new ToStringBuilder(this).append("id", getId())
107 .append("issue", getIssue()).append("relatedIssue", getRelatedIssue())
108 .append("type", getRelationType()).toString();
109 }
110
111 public static enum Type implements IntCodeEnum<Type> {
112
113
114
115
116 RELATED_P(1),
117
118
119
120
121 RELATED_C(2),
122
123
124
125
126 DUPLICATE_P(3),
127
128
129
130
131 DUPLICATE_C(4),
132
133
134
135
136 CLONED_P(5),
137
138
139
140
141 CLONED_C(6),
142
143
144
145
146 SPLIT_P(7),
147
148
149
150
151 SPLIT_C(8),
152
153
154
155
156 DEPENDENT_P(9),
157
158
159
160
161 DEPENDENT_C(10);
162
163
164
165 private final Integer code;
166
167 private Type(Integer code) {
168 this.code = code;
169 }
170
171 public Integer getCode() {
172 return code;
173 }
174
175 public Type fromCode(Integer code) {
176 return Type.valueOf(code);
177 }
178
179 public static Type valueOf(Integer code) {
180 for (Type val: values()) {
181 if (val.code.compareTo(code) == 0) {
182 return val;
183 }
184 }
185 throw new IllegalArgumentException("Unknown code : " + code);
186 }
187
188
189
190
191
192 public String getLanguageKeyCode() {
193 String key = ITrackerResources.KEY_BASE_ISSUE_RELATION + getCode();
194 return key;
195 }
196
197
198 }
199
200 }