View Javadoc

1   /*
2    * Copyright 2011 Vincent Behar
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.rundeck.api.domain;
17  
18  import java.io.Serializable;
19  import org.apache.commons.lang.StringUtils;
20  
21  /**
22   * Represents a Rundeck job
23   * 
24   * @author Vincent Behar
25   */
26  public class RundeckJob implements Serializable {
27  
28      private static final long serialVersionUID = 1L;
29  
30      private String id;
31  
32      private String name;
33  
34      private String group;
35  
36      private String project;
37  
38      private String description;
39  
40      private long averageDuration = -1L;
41  
42      /**
43       * @return the fullname : group + name (exact format is : "group/name")
44       */
45      public String getFullName() {
46          StringBuilder fullName = new StringBuilder();
47          if (StringUtils.isNotBlank(group)) {
48              fullName.append(group).append("/");
49          }
50          fullName.append(name);
51          return fullName.toString();
52      }
53  
54      public String getId() {
55          return id;
56      }
57  
58      public void setId(String id) {
59          this.id = id;
60      }
61  
62      public String getName() {
63          return name;
64      }
65  
66      public void setName(String name) {
67          this.name = name;
68      }
69  
70      public String getGroup() {
71          return group;
72      }
73  
74      public void setGroup(String group) {
75          this.group = group;
76      }
77  
78      public String getProject() {
79          return project;
80      }
81  
82      public void setProject(String project) {
83          this.project = project;
84      }
85  
86      public String getDescription() {
87          return description;
88      }
89  
90      public void setDescription(String description) {
91          this.description = description;
92      }
93  
94      @Override
95      public String toString() {
96          return "RundeckJob [id=" + id + ", name=" + name + ", group=" + group + ", project=" + project
97                 + ", description=" + description + ", averageDuration="+averageDuration+"]";
98      }
99  
100     @Override
101     public int hashCode() {
102         final int prime = 31;
103         int result = 1;
104         result = prime * result + ((description == null) ? 0 : description.hashCode());
105         result = prime * result + ((group == null) ? 0 : group.hashCode());
106         result = prime * result + ((id == null) ? 0 : id.hashCode());
107         result = prime * result + ((name == null) ? 0 : name.hashCode());
108         result = prime * result + ((project == null) ? 0 : project.hashCode());
109         result = prime * result + (int) (averageDuration ^ (averageDuration >>> 32));
110         return result;
111     }
112 
113     @Override
114     public boolean equals(Object obj) {
115         if (this == obj)
116             return true;
117         if (obj == null)
118             return false;
119         if (getClass() != obj.getClass())
120             return false;
121         RundeckJob other = (RundeckJob) obj;
122         if (description == null) {
123             if (other.description != null)
124                 return false;
125         } else if (!description.equals(other.description))
126             return false;
127         if (group == null) {
128             if (other.group != null)
129                 return false;
130         } else if (!group.equals(other.group))
131             return false;
132         if (id == null) {
133             if (other.id != null)
134                 return false;
135         } else if (!id.equals(other.id))
136             return false;
137         if (name == null) {
138             if (other.name != null)
139                 return false;
140         } else if (!name.equals(other.name))
141             return false;
142         if (project == null) {
143             if (other.project != null)
144                 return false;
145         } else if (!project.equals(other.project))
146             return false;
147         if (averageDuration != other.averageDuration) {
148             return false;
149         }
150         return true;
151     }
152 
153 
154     public long getAverageDuration() {
155         return averageDuration;
156     }
157 
158     public void setAverageDuration(long averageDuration) {
159         this.averageDuration = averageDuration;
160     }
161 }