Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
28   259   26   1.17
4   107   0.93   12
24     1.08  
2    
 
 
  Project       Line # 40 27 25 42.6% 0.42592594
  Project.ProjectComparator       Line # 249 1 1 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
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    * This is a POJO Business Domain Object modelling a project.
33    *
34    * <p>
35    * Hibernate Bean.
36    * </p>
37    *
38    * @author ready
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    * Project's current status.
54    *
55    * <p>
56    * Invariant : never <tt>null</tt>.
57    * </p>
58    */
59    private Status status;
60   
61    private int options;
62   
63    /**
64    * The list of Components that belong to this project.
65    *
66    * <p>
67    * Project - Component is a 1-N relationship.
68    * </p>
69    */
70    private List<Component> components = new ArrayList<Component>();
71   
72    /**
73    * The list of Versions of this Project.
74    *
75    * <p>
76    * Project - Version is a 1-N relationship.
77    * </p>
78    */
79    private List<Version> versions = new ArrayList<Version>();
80   
81    /**
82    * The Permissions of all Users on this Project.
83    *
84    * <p>
85    * Project - Permission is a 1-N relationship.
86    * </p>
87    *
88    * PENDING: Does this relationship need to be navigatable ?
89    */
90    // TODO: it would be a Set, not list
91    private Set<Permission> permissions = new TreeSet<Permission>(Permission.PERMISSION_PROPERTIES_COMPARATOR);
92   
93    /**
94    * The Users who are responsible for this Project.
95    *
96    * Project - User (owners) is a M-N relationship.
97    */
98    private List<User> owners = new ArrayList<User>();
99   
100    /**
101    * The custom fields associated to this Project.
102    *
103    * <p>
104    * Project - CustomField is a M-N relationship.
105    * </p>
106    *
107    * <p>
108    * All Issues of this Project will have these custom fields.
109    * </p>
110    */
111    private List<CustomField> customFields = new ArrayList<CustomField>();
112   
113    /**
114    * Project - ProjectScript is a 1-N relationship.
115    */
116    private List<ProjectScript> scripts = new ArrayList<ProjectScript>();
117   
118    /*
119    * This class used to have a <code>issues</code> attribute, which was a
120    * Collection<Issue>. This has been removed because the association Project -
121    * Issue doesn't need to be navigatable in this direction.
122    */
123   
124    /**
125    * Default constructor (required by Hibernate).
126    *
127    * <p>
128    * PENDING: should be <code>private</code> so that it can only be used by
129    * Hibernate, to ensure that the fields which form an instance's identity
130    * are always initialized/never <tt>null</tt>.
131    * </p>
132    */
 
133  6 toggle public Project() {
134    }
135   
 
136  0 toggle public Project(String name) {
137  0 setName(name);
138  0 this.status = Status.ACTIVE;
139    }
140   
 
141  0 toggle public String getName() {
142  0 return name;
143    }
144   
 
145  1 toggle public void setName(String name) {
146  1 if (name == null) {
147  0 throw new IllegalArgumentException("null name");
148    }
149  1 this.name = name;
150    }
151   
 
152  0 toggle public String getDescription() {
153  0 return description;
154    }
155   
 
156  1 toggle public void setDescription(String description) {
157  1 this.description = description;
158    }
159   
160    /**
161    * @return project's current status
162    */
 
163  0 toggle public Status getStatus() {
164  0 return status;
165    }
166   
167    /**
168    *
169    * @param status
170    * @throws IllegalArgumentException
171    * status is <tt>null</tt>
172    */
 
173  1 toggle public void setStatus(Status status) {
174  1 if (status == null) {
175  0 throw new IllegalArgumentException("null status");
176    }
177  1 this.status = status;
178    }
179   
 
180  0 toggle public int getOptions() {
181  0 return options;
182    }
183   
 
184  1 toggle public void setOptions(int options) {
185  1 this.options = options;
186    }
187   
 
188  1 toggle public List<Component> getComponents() {
189  1 return components;
190    }
191   
 
192  1 toggle public void setComponents(List<Component> getComponents) {
193  1 this.components = getComponents;
194    }
195   
 
196  0 toggle public List<Version> getVersions() {
197  0 return versions;
198    }
199   
 
200  2 toggle public void setVersions(List<Version> getVersions) {
201  2 this.versions = getVersions;
202    }
203   
 
204  0 toggle public List<CustomField> getCustomFields() {
205  0 return customFields;
206    }
207   
 
208  1 toggle public void setCustomFields(List<CustomField> getCustomFields) {
209  1 this.customFields = getCustomFields;
210    }
211   
 
212  0 toggle public List<User> getOwners() {
213  0 return owners;
214    }
215   
 
216  1 toggle public void setOwners(List<User> getOwners) {
217  1 this.owners = getOwners;
218    }
219   
 
220  0 toggle public Set<Permission> getPermissions() {
221  0 return permissions;
222    }
223   
 
224  0 toggle public void setPermissions(Set<Permission> getPermissions) {
225  0 this.permissions = getPermissions;
226    }
227   
 
228  0 toggle public List<ProjectScript> getScripts() {
229  0 return scripts;
230    }
231   
 
232  0 toggle public void setScripts(List<ProjectScript> getScripts) {
233  0 this.scripts = getScripts;
234    }
235   
236    /**
237    * @return <tt>Project [id=id, name=name]</tt>
238    */
 
239  0 toggle @Override
240    public String toString() {
241   
242  0 return new ToStringBuilder(this).append("id", this.getId()).append("name",
243    this.getName()).append("description", getDescription()).append("owners", getOwners()).toString();
244    }
245   
246    /**
247    * Comparator for comparing projects by name
248    */
 
249    public static final class ProjectComparator implements Comparator<Project>, Serializable {
250    /**
251    *
252    */
253    private static final long serialVersionUID = 1L;
 
254  0 toggle public int compare(Project o1, Project o2) {
255  0 return new CompareToBuilder().append(o1.getName(), o2.getName()).append(
256    o1.getId(), o2.getId()).toComparison();
257    }
258    }
259    }