1 /**
2 * Copyright 2005-2006 the original author or authors.
3 *
4 * Licensed under the Gnu General Pubic License, Version 2.0 (the
5 * "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/gpl-license.php
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the Gnu General Public License for more details.
14 */
15 package org.figure8.join.businessobjects.artifact;
16
17 import org.figure8.join.core.EntityObject;
18 import org.figure8.join.businessobjects.commons.Release;
19
20 import java.util.Date;
21 import java.util.List;
22 import java.util.ArrayList;
23 /**
24 * A deliverable is an artifact representing a work delivery for
25 * the software project. A deliverable is typed and supplied for
26 * realizing a specific <code>Release</code>.
27 * <br/>
28 * Such a delivery must contain information about the supplier, the
29 * version of the delivery and some comments.
30 * <br/>
31 * A <b>key</b> must also be provided to have a unique identifier
32 * of this deliverable. Keys are typically generated by type handler
33 * that exactly knows how to guarantee key unicity.
34 *
35 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
36 * @version $Revision: 1.2 $
37 *
38 * @see org.figure8.join.businessobjects.commons.Release
39 * @see org.figure8.join.businessobjects.artifact.DeliverableType
40 *
41 * @hibernate.class table="join_deliverables" lazy="true"
42 * @hibernate.cache usage="read-write"
43 *
44 * @hibernate.query name="join.deliverable_findByKey"
45 * query="from Deliverable del left join fetch del.assemblies where del.key = :delKey"
46 * @hibernate.query name="join.deliverable_findByType"
47 * query="from Deliverable del where del.deliverableType = :delType order by del.creationDate desc"
48 * @hibernate.query name="join.deliverable_findBySupplierId"
49 * query="from Deliverable del where del.supplierId = :userId order by del.creationDate desc"
50 * @hibernate.query name="join.deliverable_findByTypeAndRelease"
51 * query="from Deliverable del where del.deliverableType = :delType and del.release = :delRelease order by del.creationDate desc"
52 */
53 public class Deliverable extends EntityObject implements Artifact{
54
55
56
57 /** Deliverable key */
58 private String key;
59 /** The deliverable comments */
60 private String comments;
61 /** Deliverable version info */
62 private String versionInfo;
63 /** The deliverable creation date */
64 private Date creationDate;
65 /** The deliverable supplier identifier */
66 private String supplierId;
67 /** A list of <code>Assembly</code> objects containing deliverable */
68 private List assemblies = new ArrayList();
69
70 /** The deliverable release */
71 private Release release;
72 /** The deliverable type */
73 private DeliverableType deliverableType;
74
75
76
77
78 /** Creates a new instance of Deliverable */
79 public Deliverable(){
80 }
81
82 /**
83 * Creates a new instance of Deliverable with mandatory fields.
84 * @param versionInfo Information on this deliverable version
85 * @param comments Comments on deliverable
86 * @param supplierId Identifier of supplier
87 * @param release Release this deliverable has been realized for
88 * @param type The type of this delierable
89 */
90 public Deliverable(String versionInfo, String comments, String supplierId, Release release, DeliverableType type){
91
92 this.comments = comments;
93 this.versionInfo = versionInfo;
94 this.supplierId = supplierId;
95 this.release = release;
96 this.deliverableType = type;
97 this.creationDate = new Date();
98
99 this.key = deliverableType.generateDeliverableKey(this);
100 }
101
102
103
104
105 /**
106 * @hibernate.property column="s_key"
107 * length="50" not-null="true"
108 * unique="true" update="false"
109 * @return This deliverable unique key
110 */
111 public String getKey(){
112 return key;
113 }
114 /** @param key This deliverable unique key */
115 public void setKey(String key){
116 this.key = key;
117 }
118
119 /**
120 * @hibernate.property column="s_comments" length="255"
121 * @return Comments on this deliverable
122 */
123 public String getComments(){
124 return comments;
125 }
126 /** @param comments Comments on this deliverable */
127 public void setComments(String comments){
128 this.comments = comments;
129 }
130
131 /** @param info Version information for this deliverable */
132 public void setVersionInfo(String info){
133 this.versionInfo = info;
134 }
135
136 /**
137 * @hibernate.property column="d_creation"
138 * not-null="true" type="timestamp"
139 * update="false"
140 * @return Creation date of this deliverable
141 */
142 public Date getCreationDate(){
143 return creationDate;
144 }
145 /** @param creationDate The deliverable creation timestamp */
146 public void setCreationDate(Date creationDate){
147 this.creationDate = creationDate;
148 }
149
150 /**
151 * @hibernate.property column="s_supplierid"
152 * length="20" not-null="true"
153 * @return The id of user that supplies deliverable
154 */
155 public String getSupplierId(){
156 return supplierId;
157 }
158 /** @param supplier The id of person who makes delivery */
159 public void setSupplierId(String supplier){
160 this.supplierId = supplier;
161 }
162
163 /**
164 * @hibernate.bag lazy="true" cascade="save-update" table="assemblies_deliverables" inverse="true"
165 * @hibernate.collection-key column="n_deliverable_fk"
166 * @hibernate.collection-many-to-many column="n_assembly_fk" class="org.figure8.join.businessobjects.artifact.Assembly"
167 * @return A set of {@code Assembly} objects containing this deliverable
168 */
169 public List getAssemblies(){
170 return assemblies;
171 }
172 /** @param assemblies A set of assemblies containing this deliverable */
173 public void setAssemblies(List assemblies){
174 this.assemblies = assemblies;
175 }
176
177 /** @param release Release this deliverable has been done for */
178 public void setRelease(Release release){
179 this.release = release;
180 }
181
182 /**
183 * @hibernate.many-to-one column="n_deliverabletype_fk" not-null="true"
184 * @return The type of this deliverable
185 */
186 public DeliverableType getDeliverableType(){
187 return deliverableType;
188 }
189 /** @param type The type of this deliverable */
190 public void setDeliverableType(DeliverableType type){
191 this.deliverableType = type;
192 }
193
194
195
196
197 /**
198 * Retrieve the unique identifier of this artifact. (ie : it's key)
199 * @return The unique identifier of this deliverable
200 */
201 public String getUniqueId(){
202 return key;
203 }
204
205 /**
206 * Retrieve the version information on this deliverable.
207 * @hibernate.property column="s_version"
208 * length="20" not-null="true"
209 * @return Version information as character string
210 */
211 public String getVersionInfo(){
212 return versionInfo;
213 }
214
215 /**
216 * Return the category information on this deliverable, ie :
217 * the key of its associated {@link DeliverableType}
218 * @return The category information as character string
219 */
220 public String getCategoryInfo(){
221 return deliverableType.getKey();
222 }
223
224 /**
225 * Retrieve the release that has cause this artifact creation
226 * @hibernate.many-to-one column="n_release_fk" not-null="true"
227 * @return The release this artifact has been realized for
228 */
229 public Release getRelease(){
230 return release;
231 }
232 }