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 java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.Comparator;
24 import java.util.List;
25 import java.util.Set;
26 import java.util.TreeSet;
27
28 import org.apache.commons.lang.builder.CompareToBuilder;
29 import org.apache.commons.lang.builder.ToStringBuilder;
30
31
32
33
34
35
36
37
38
39
40 public class Project extends AbstractEntity implements Comparable<Entity> {
41
42 public static final ProjectComparator PROJECT_COMPARATOR = new ProjectComparator();
43
44
45
46 private static final long serialVersionUID = 1L;
47
48 private String name;
49
50 private String description;
51
52
53
54
55
56
57
58
59 private Status status;
60
61 private int options;
62
63
64
65
66
67
68
69
70 private List<Component> components = new ArrayList<Component>();
71
72
73
74
75
76
77
78
79 private List<Version> versions = new ArrayList<Version>();
80
81
82
83
84
85
86
87
88
89
90
91 private Set<Permission> permissions = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR);
92
93
94
95
96
97
98 private List<User> owners = new ArrayList<User>();
99
100
101
102
103
104
105
106
107
108
109
110
111 private List<CustomField> customFields = new ArrayList<CustomField>();
112
113
114
115
116 private List<ProjectScript> scripts = new ArrayList<ProjectScript>();
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 public Project() {
134 }
135
136 public Project(String name) {
137 setName(name);
138 this.status = Status.ACTIVE;
139 }
140
141 public String getName() {
142 return name;
143 }
144
145 public void setName(String name) {
146 if (name == null) {
147 throw new IllegalArgumentException("null name");
148 }
149 this.name = name;
150 }
151
152 public String getDescription() {
153 return description;
154 }
155
156 public void setDescription(String description) {
157 this.description = description;
158 }
159
160
161
162
163 public Status getStatus() {
164 return status;
165 }
166
167
168
169
170
171
172
173 public void setStatus(Status status) {
174 if (status == null) {
175 throw new IllegalArgumentException("null status");
176 }
177 this.status = status;
178 }
179
180 public int getOptions() {
181 return options;
182 }
183
184 public void setOptions(int options) {
185 this.options = options;
186 }
187
188 public List<Component> getComponents() {
189 return components;
190 }
191
192 public void setComponents(List<Component> getComponents) {
193 this.components = getComponents;
194 }
195
196 public List<Version> getVersions() {
197 return versions;
198 }
199
200 public void setVersions(List<Version> getVersions) {
201 this.versions = getVersions;
202 }
203
204 public List<CustomField> getCustomFields() {
205 return customFields;
206 }
207
208 public void setCustomFields(List<CustomField> getCustomFields) {
209 this.customFields = getCustomFields;
210 }
211
212 public List<User> getOwners() {
213 return owners;
214 }
215
216 public void setOwners(List<User> getOwners) {
217 this.owners = getOwners;
218 }
219
220 public Set<Permission> getPermissions() {
221 return permissions;
222 }
223
224 public void setPermissions(Set<Permission> getPermissions) {
225 this.permissions = getPermissions;
226 }
227
228 public List<ProjectScript> getScripts() {
229 return scripts;
230 }
231
232 public void setScripts(List<ProjectScript> getScripts) {
233 this.scripts = getScripts;
234 }
235
236
237
238
239 @Override
240 public String toString() {
241
242 return new ToStringBuilder(this).append("id", this.getId()).append("name",
243 this.getName()).append("description", getDescription()).append("owners", getOwners()).toString();
244 }
245
246
247
248
249 public static final class ProjectComparator implements Comparator<Project>, Serializable {
250
251
252
253 private static final long serialVersionUID = 1L;
254 public int compare(Project o1, Project o2) {
255 return new CompareToBuilder().append(o1.getName(), o2.getName()).append(
256 o1.getId(), o2.getId()).toComparison();
257 }
258 }
259 }