1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.engine;
\r
21 import java.util.List;
\r
23 import compbio.engine.client.ConfiguredExecutable;
\r
24 import compbio.engine.client.EngineUtil;
\r
25 import compbio.util.annotation.Immutable;
\r
28 public final class Job {
\r
30 private final ClusterJobId jobId;
\r
31 private final String taskId;
\r
32 private final ConfiguredExecutable<?> cexecutable;
\r
34 public Job(String taskId, String jobId, ConfiguredExecutable<?> cexecutable) {
\r
35 if (!EngineUtil.isValidJobId(taskId)) {
\r
36 throw new IllegalArgumentException("TaskId " + taskId
\r
37 + " is not valid!");
\r
39 if (jobId == null) {
\r
40 throw new NullPointerException("Cluster JobId must be provided!");
\r
42 if (cexecutable == null) {
\r
43 throw new NullPointerException(
\r
44 "ConfiguredExecutable must be provided!");
\r
46 this.jobId = new ClusterJobId(jobId);
\r
47 this.taskId = taskId;
\r
48 this.cexecutable = cexecutable;
\r
51 public ClusterJobId getJobId() {
\r
55 public String getTaskId() {
\r
59 public ConfiguredExecutable<?> getConfExecutable() {
\r
64 public int hashCode() {
\r
65 final int prime = 31;
\r
67 result = prime * result + ((jobId == null) ? 0 : jobId.hashCode());
\r
68 result = prime * result + ((taskId == null) ? 0 : taskId.hashCode());
\r
73 public boolean equals(Object obj) {
\r
78 if (getClass() != obj.getClass())
\r
80 Job other = (Job) obj;
\r
81 if (jobId == null) {
\r
82 if (other.jobId != null)
\r
84 } else if (!jobId.equals(other.jobId))
\r
86 if (taskId == null) {
\r
87 if (other.taskId != null)
\r
89 } else if (!taskId.equals(other.taskId))
\r
95 public String toString() {
\r
96 return "Job [cexecutable=" + cexecutable + ", jobId=" + jobId
\r
97 + ", taskId=" + taskId + "]";
\r
100 public static Job getByTaskId(String taskId, List<Job> jobs) {
\r
101 for (Job j : jobs) {
\r
102 if (taskId.equals(j.getTaskId())) {
\r
109 public static Job getByJobId(String jobId, List<Job> jobs) {
\r
110 for (Job j : jobs) {
\r
111 if (jobId.equals(j.getJobId())) {
\r