001/* 002 $Id: JobData.java 3207 2009-04-09 06:48:11Z gregory $ 003 004 Copyright (C) 2006 Gregory Vincic, Olle Mansson 005 Copyright (C) 2007 Gregory Vincic 006 007 This file is part of Proteios. 008 Available at http://www.proteios.org/ 009 010 Proteios is free software; you can redistribute it and/or modify it 011 under the terms of the GNU General Public License as published by 012 the Free Software Foundation; either version 2 of the License, or 013 (at your option) any later version. 014 015 Proteios is distributed in the hope that it will be useful, but 016 WITHOUT ANY WARRANTY; without even the implied warranty of 017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 018 General Public License for more details. 019 020 You should have received a copy of the GNU General Public License 021 along with this program; if not, write to the Free Software 022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 023 02111-1307, USA. 024 */ 025package org.proteios.core.data; 026 027import java.util.Date; 028import java.util.HashMap; 029import java.util.Map; 030import java.util.Set; 031 032/** 033 * This class holds information about a job. 034 * 035 * @author Nicklas 036 * @version 2.0 037 * @see org.proteios.core.Job 038 * @see <a 039 * href="../../../../../../../development/overview/data/plugins.html">Plugin/jobs 040 * overview</a> 041 * @base.modified $Date: 2009-04-09 08:48:11 +0200 (Thu, 09 Apr 2009) $ 042 * @hibernate.class table="`Jobs`" lazy="false" 043 */ 044public class JobData 045 extends OwnedData 046 implements NameableData, RemovableData 047{ 048 public JobData() 049 {} 050 051 /* 052 * From the NameableData interface 053 * ------------------------------------------- 054 */ 055 private String name; 056 057 058 public String getName() 059 { 060 return name; 061 } 062 063 064 public void setName(String name) 065 { 066 this.name = name; 067 } 068 069 private String description; 070 071 072 public String getDescription() 073 { 074 return description; 075 } 076 077 078 public void setDescription(String description) 079 { 080 this.description = description; 081 } 082 083 // ------------------------------------------- 084 /* 085 * From the RemovableData interface 086 * ------------------------------------------- 087 */ 088 private boolean removed; 089 090 091 public boolean isRemoved() 092 { 093 return removed; 094 } 095 096 097 public void setRemoved(boolean removed) 098 { 099 this.removed = removed; 100 } 101 102 // ------------------------------------------- 103 private int type; 104 105 106 /** 107 * The type of job: 1 = run plugin, 2 = other 108 * 109 * @hibernate.property column="`type`" type="int" not-null="true" 110 */ 111 public int getType() 112 { 113 return type; 114 } 115 116 117 public void setType(int type) 118 { 119 this.type = type; 120 } 121 122 private PluginDefinitionData pluginDefinition; 123 124 125 /** 126 * The plugin that executes the job. 127 * 128 * @hibernate.many-to-one column="`plugindefinition_id`" not-null="false" 129 * outer-join="false" update="false" 130 */ 131 public PluginDefinitionData getPluginDefinition() 132 { 133 return pluginDefinition; 134 } 135 136 137 public void setPluginDefinition(PluginDefinitionData pluginDefinition) 138 { 139 this.pluginDefinition = pluginDefinition; 140 } 141 142 private PluginConfigurationData pluginConfiguration; 143 144 145 /** 146 * The plugin configuration for the plugin. 147 * 148 * @hibernate.many-to-one column="`pluginconfiguration_id`" not-null="false" 149 * outer-join="false" update="false" 150 */ 151 public PluginConfigurationData getPluginConfiguration() 152 { 153 return pluginConfiguration; 154 } 155 156 157 public void setPluginConfiguration( 158 PluginConfigurationData pluginConfiguration) 159 { 160 this.pluginConfiguration = pluginConfiguration; 161 } 162 163 private int status; 164 165 166 /** 167 * Get the status of the job. 1 = waiting, 2 = running, 3 = completed ok, 4 = 168 * error 169 * 170 * @hibernate.property column="`status`" type="int" not-null="true" 171 */ 172 public int getStatus() 173 { 174 return status; 175 } 176 177 178 public void setStatus(int status) 179 { 180 this.status = status; 181 } 182 183 /** 184 * The maximum allowed length of the status message. 185 */ 186 public static final int MAX_STATUS_MESSAGE_LENGTH = 65535; 187 private String statusMessage; 188 189 190 /** 191 * Get a status message. 192 * 193 * @hibernate.property column="`status_message`" type="text" 194 * not-null="false" 195 */ 196 public String getStatusMessage() 197 { 198 return statusMessage; 199 } 200 201 202 public void setStatusMessage(String statusMessage) 203 { 204 this.statusMessage = statusMessage; 205 } 206 207 private int estimatedExecutionTime; 208 209 210 /** 211 * Get the estimated execution time of the job. 0 = < 1 minute, 1 = 1 - 10 212 * minutes, 2 = < 1 hour, 3 = > 1 hour 213 * 214 * @hibernate.property column="`execution_time`" type="int" not-null="true" 215 */ 216 public int getEstimatedExecutionTime() 217 { 218 return estimatedExecutionTime; 219 } 220 221 222 public void setEstimatedExecutionTime(int estimatedExecutionTime) 223 { 224 this.estimatedExecutionTime = estimatedExecutionTime; 225 } 226 227 private int percentComplete; 228 229 230 /** 231 * If the job is running, how many percent has been completed. 232 * 233 * @hibernate.property column="`percent_complete`" type="int" 234 * not-null="true" 235 */ 236 public int getPercentComplete() 237 { 238 return percentComplete; 239 } 240 241 242 public void setPercentComplete(int percentComplete) 243 { 244 this.percentComplete = percentComplete; 245 } 246 247 private int priority; 248 249 250 /** 251 * The jobs priority. A lower value means a higher priority. 252 * 253 * @hibernate.property column="`priority`" type="int" not-null="true" 254 */ 255 public int getPriority() 256 { 257 return priority; 258 } 259 260 261 public void setPriority(int priority) 262 { 263 this.priority = priority; 264 } 265 266 private int activeProjectId; 267 268 269 /** 270 * The ID of the project that should be made active when running this job. 271 * 272 * @hibernate.property column="`project_id`" type="int" not-null="true" 273 */ 274 public int getActiveProjectId() 275 { 276 return activeProjectId; 277 } 278 279 280 public void setActiveProjectId(int activeProjectId) 281 { 282 this.activeProjectId = activeProjectId; 283 } 284 285 private JobData blocker = null; 286 287 288 /** 289 * @return job that should be done before executing this one null if no 290 * blocker is specified 291 * @hibernate.many-to-one column="`blockerjob_id`" update="true" 292 * not-null="false" 293 */ 294 public JobData getBlocker() 295 { 296 return blocker; 297 } 298 299 300 /** 301 * @param blocker job that this job is waiting for 302 */ 303 public void setBlocker(JobData blocker) 304 { 305 this.blocker = blocker; 306 } 307 308 private Date created; 309 310 311 /** 312 * Get the date and time the job was created. 313 * 314 * @hibernate.property column="`created`" type="timestamp" not-null="true" 315 * update="false" 316 */ 317 public Date getCreated() 318 { 319 return created; 320 } 321 322 323 public void setCreated(Date created) 324 { 325 this.created = created; 326 } 327 328 private Date started; 329 330 331 /** 332 * Get the date and time the job was started or null if the job hasn't been 333 * started. 334 * 335 * @hibernate.property column="`started`" type="timestamp" not-null="false" 336 */ 337 public Date getStarted() 338 { 339 return started; 340 } 341 342 343 public void setStarted(Date started) 344 { 345 this.started = started; 346 } 347 348 private Date ended; 349 350 351 /** 352 * Get the date and time the job was ended or null if the job hasn't ended. 353 * 354 * @hibernate.property column="`ended`" type="timestamp" not-null="false" 355 */ 356 public Date getEnded() 357 { 358 return ended; 359 } 360 361 362 public void setEnded(Date ended) 363 { 364 this.ended = ended; 365 } 366 367 /** 368 * The maximum allowed length of the server name. 369 */ 370 public static final int MAX_SERVER_LENGTH = 255; 371 private String server; 372 373 374 /** 375 * The name of the server where the job is executing. 376 * 377 * @hibernate.property column="`server`" type="string" length="255" 378 * not-null="false" 379 */ 380 public String getServer() 381 { 382 return server; 383 } 384 385 386 public void setServer(String server) 387 { 388 this.server = server; 389 } 390 391 @SuppressWarnings("unchecked") 392 private Map<String, ParameterValueData> parameters; 393 394 395 /** 396 * The parameters for this job. 397 * 398 * @hibernate.map table="`JobParameters`" lazy="true" cascade="all" 399 * @hibernate.collection-key column="`job_id`" 400 * @hibernate.collection-index column="`name`" type="string" length="255" 401 * @hibernate.collection-many-to-many column="`value_id`" 402 * class="org.proteios.core.data.ParameterValueData" 403 */ 404 @SuppressWarnings("unchecked") 405 public Map<String, ParameterValueData> getParameters() 406 { 407 if (parameters == null) 408 parameters = new HashMap<String, ParameterValueData>(); 409 return parameters; 410 } 411 412 413 @SuppressWarnings("unchecked") 414 void setParameters(Map<String, ParameterValueData> parameters) 415 { 416 this.parameters = parameters; 417 } 418 419 private Set<MessageData> messages; 420 421 422 /** 423 * This is the inverse end. 424 * 425 * @see MessageData#getJob() 426 * @hibernate.set lazy="true" inverse="true" cascade="delete" 427 * @hibernate.collection-key column="`job_id`" 428 * @hibernate.collection-one-to-many class="org.proteios.core.data.MessageData" 429 */ 430 Set<MessageData> getMessages() 431 { 432 return messages; 433 } 434 435 436 void setMessages(Set<MessageData> messages) 437 { 438 this.messages = messages; 439 } 440}