1 /**
2 * Copyright 2005-2007 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.environment;
16
17 import org.figure8.join.core.EntityObject;
18 import org.figure8.join.businessobjects.commons.Status;
19 import org.figure8.join.businessobjects.commons.Target;
20 import org.figure8.join.businessobjects.artifact.Assembly;
21
22 import java.util.Date;
23 /**
24 * This is an entity object that represent a deployment of an Assembly done
25 * onto an environement. Such a deployment represents also a process and thus
26 * can be tracked through the application of a Status onto entity. Deployments
27 * can be scoped using the appropriate deployment Target.
28 * <br/>
29 * The runtime context of a deployment is always an environment mapping (i.e.
30 * when a logical environment is mapped onto a physical environment hosting
31 * resources)
32 *
33 * @see org.figure8.join.businessobjects.commons.Status
34 * @see org.figure8.join.businessobjects.commons.Target
35 * @see org.figure8.join.businessobjects.artifact.Assembly
36 * @see org.figure8.join.businessobjects.environment.EnvironmentMapping
37 *
38 * @author <a href="mailto:laurent.broudoux@free.fr">Laurent Broudoux</a>
39 * @version $Revision: 1.4 $
40 *
41 * @hibernate.class table="join_deployments" lazy="true"
42 * @hibernate.cache usage="read-write"
43 *
44 * @hibernate.query name="join.deployment_findRealizing"
45 * query="from Deployment dep left join fetch dep.assembly
46 * where dep.assigneeId is not null and dep.realizationDate is null order by dep.creationDate desc"
47 * @hibernate.query name="join.deployment_findPreparing"
48 * query="from Deployment dep left join fetch dep.assembly
49 * where dep.assigneeId is null and dep.realizationDate is null order by dep.creationDate desc"
50 * @hibernate.query name="join.deployment_findByLogicalEnvironment"
51 * query="from Deployment dep left join fetch dep.assembly
52 * where dep.environmentMapping.logicalEnvironment = :logicalEnv order by dep.creationDate desc"
53 * @hibernate.query name="join.deployment_findByPhysicalEnvironment"
54 * query="from Deployment dep left join fetch dep.assembly
55 * where dep.environmentMapping.physicalEnvironment = :physicalEnv order by dep.creationDate desc"
56 * @hibernate.query name="join.deployment_findActivesForEnvironmentMapping"
57 * query="from Deployment dep left join fetch dep.assembly
58 * where dep.environmentMapping = :envMapping and dep.realizationDate is not null
59 * and dep.status.cancelled=false order by dep.creationDate desc"
60 */
61 public class Deployment extends EntityObject{
62
63
64
65 /** Identifier of user who asked for deployment */
66 private String applicantId;
67 /** Comments on deployment demand made by applicants */
68 private String applicantComments;
69 /** Identifier of user assigned to deployment relaization */
70 private String assigneeId;
71 /** Comments on deployment relalization made by assignee */
72 private String assigneeComments;
73 /** The deployment demand creation date */
74 private Date creationDate;
75 /** The deployment demand assignation date */
76 private Date assignationDate;
77 /** The deployment realization date */
78 private Date realizationDate;
79 /** The date applicant wished the delpoyment's done */
80 private Date wishedDate;
81
82 /** The deployment current status */
83 private Status status;
84 /** The deployment target used for process */
85 private Target target;
86 /** The assembly that is deployed during this deployment */
87 private Assembly assembly;
88 /** The runtime environment context to use for deployment */
89 private EnvironmentMapping environmentMapping;
90
91
92
93
94 /** Creates a new instance of Deployment */
95 public Deployment(){
96 }
97
98 /**
99 * Creates a new instance of Deployment with mandatory attributes.
100 * @param applicantId Identifier of user who asked for deployment
101 * @param applicantComments Comments on deployment demand made by applicant
102 * @param mapping runtime environment context to use for deployment
103 * @param assembly Assembly to deploy onto environment
104 * @param target The target of deployment process
105 */
106 public Deployment(String applicantId, String applicantComments,
107 EnvironmentMapping mapping, Assembly assembly, Target target){
108
109 this.applicantId = applicantId;
110 this.applicantComments = applicantComments;
111 creationDate = new Date();
112
113 this.environmentMapping = mapping;
114 this.assembly = assembly;
115 this.target = target;
116 }
117
118
119
120
121 /**
122 * @hibernate.property column="s_applicantid"
123 * length="20" not-null="true" update="false"
124 * @return The identifier of user who asked for deployment
125 */
126 public String getApplicantId(){
127 return applicantId;
128 }
129 /** @param applicantId The identifier of user who asked for deployment */
130 public void setApplicantId(String applicantId){
131 this.applicantId = applicantId;
132 }
133
134 /**
135 * @hibernate.property column="s_applicantcomments" length="255" update="false"
136 * @return The comments made by applicant on deployment demand
137 */
138 public String getApplicantComments(){
139 return applicantComments;
140 }
141 /** @param comments The comments made by applicant on deployment demand */
142 public void setApplicantComments(String comments){
143 this.applicantComments = comments;
144 }
145
146 /**
147 * @hibernate.property column="s_assigneeid" length="20"
148 * @return The identifier of user assigned to deployment realization
149 */
150 public String getAssigneeId(){
151 return assigneeId;
152 }
153 /** @param assigneeId The identifier of user assigned to deployment realization */
154 public void setAssigneeId(String assigneeId){
155 this.assigneeId = assigneeId;
156 }
157
158 /**
159 * @hibernate.property column="s_assigneecomments" length="255"
160 * @return The comments on deployment from assignee
161 */
162 public String getAssigneeComments(){
163 return assigneeComments;
164 }
165 /** @param comments The comments on deployment from assignee */
166 public void setAssigneeComments(String comments){
167 this.assigneeComments = comments;
168 }
169
170 /**
171 * @hibernate.property column="d_creation"
172 * not-null="true" type="timestamp"
173 * update="false"
174 * @return The creation date of the deployment demand
175 */
176 public Date getCreationDate(){
177 return creationDate;
178 }
179 /** @param creationDate The creation date of the deployment demand */
180 public void setCreationDate(Date creationDate){
181 this.creationDate = creationDate;
182 }
183
184 /**
185 * @hibernate.property column="d_assignation" type="timestamp"
186 * @return The deployment demand assignation date
187 */
188 public Date getAssignationDate(){
189 return assignationDate;
190 }
191 /** @param assignationDate The date deployment realization is assigned to an integrator */
192 public void setAssignationDate(Date assignationDate){
193 this.assignationDate = assignationDate;
194 }
195
196 /**
197 * @hibernate.property column="d_realization" type="timestamp"
198 * @return The deployment realization date
199 */
200 public Date getRealizationDate(){
201 return realizationDate;
202 }
203 /** @param realizationDate The deployment realization timestamp */
204 public void setRealizationDate(Date realizationDate){
205 this.realizationDate = realizationDate;
206 }
207
208 /**
209 * @hibernate.property column="d_wished" type="timestamp"
210 * @return The date applicant wished the deployment's done
211 */
212 public Date getWishedDate(){
213 return wishedDate;
214 }
215 /** @param wishedDate The date application wished the deployment's done */
216 public void setWishedDate(Date wishedDate){
217 this.wishedDate = wishedDate;
218 }
219
220 /**
221 * @hibernate.many-to-one column="n_status_fk"
222 * @return The current status of this Deployment
223 */
224 public Status getStatus(){
225 return status;
226 }
227 /** @param status The current status of this deployment */
228 public void setStatus(Status status){
229 this.status = status;
230 }
231
232 /**
233 * @hibernate.many-to-one column="n_target_fk"
234 * @return The deployment target to use for process
235 */
236 public Target getTarget(){
237 return target;
238 }
239 /** @param target The deployment target to use for process */
240 public void setTarget(Target target){
241 this.target = target;
242 }
243
244 /**
245 * @hibernate.many-to-one column="n_assembly_fk"
246 * @return The assembly to deploy during this deployment
247 */
248 public Assembly getAssembly(){
249 return assembly;
250 }
251 /** @param assembly The assembly that is deployed during this deployment */
252 public void setAssembly(Assembly assembly){
253 this.assembly = assembly;
254 }
255
256 /**
257 * @hibernate.many-to-one column="n_envmapping_fk"
258 * @return The mapping that is runtime environment context for deployment
259 */
260 public EnvironmentMapping getEnvironmentMapping(){
261 return environmentMapping;
262 }
263 /** @param environmentMapping The mapping that is runtime environment context for deployment */
264 public void setEnvironmentMapping(EnvironmentMapping environmentMapping){
265 this.environmentMapping = environmentMapping;
266 }
267
268 /** @return Flag telling if this deployment is completed */
269 public boolean completed(){
270 return (realizationDate != null);
271 }
272 }