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 java.util.ArrayList;
20  import java.util.HashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  /**
25   * Result of importing some jobs into Rundeck
26   * 
27   * @author Vincent Behar
28   */
29  public class RundeckJobsImportResult implements Serializable {
30  
31      private static final long serialVersionUID = 1L;
32  
33      private final List<RundeckJob> succeededJobs = new ArrayList<RundeckJob>();
34  
35      private final List<RundeckJob> skippedJobs = new ArrayList<RundeckJob>();
36  
37      private final Map<RundeckJob, String> failedJobs = new HashMap<RundeckJob, String>();
38  
39      public void addSucceededJob(RundeckJob job) {
40          succeededJobs.add(job);
41      }
42  
43      public void addSkippedJob(RundeckJob job) {
44          skippedJobs.add(job);
45      }
46  
47      public void addFailedJob(RundeckJob job, String errorMessage) {
48          failedJobs.put(job, errorMessage);
49      }
50  
51      public List<RundeckJob> getSucceededJobs() {
52          return succeededJobs;
53      }
54  
55      public List<RundeckJob> getSkippedJobs() {
56          return skippedJobs;
57      }
58  
59      public Map<RundeckJob, String> getFailedJobs() {
60          return failedJobs;
61      }
62  
63      @Override
64      public String toString() {
65          return "RundeckJobsImportResult [succeededJobs=" + succeededJobs + ", skippedJobs=" + skippedJobs
66                 + ", failedJobs=" + failedJobs + "]";
67      }
68  
69      @Override
70      public int hashCode() {
71          final int prime = 31;
72          int result = 1;
73          result = prime * result + ((failedJobs == null) ? 0 : failedJobs.hashCode());
74          result = prime * result + ((skippedJobs == null) ? 0 : skippedJobs.hashCode());
75          result = prime * result + ((succeededJobs == null) ? 0 : succeededJobs.hashCode());
76          return result;
77      }
78  
79      @Override
80      public boolean equals(Object obj) {
81          if (this == obj)
82              return true;
83          if (obj == null)
84              return false;
85          if (getClass() != obj.getClass())
86              return false;
87          RundeckJobsImportResult other = (RundeckJobsImportResult) obj;
88          if (failedJobs == null) {
89              if (other.failedJobs != null)
90                  return false;
91          } else if (!failedJobs.equals(other.failedJobs))
92              return false;
93          if (skippedJobs == null) {
94              if (other.skippedJobs != null)
95                  return false;
96          } else if (!skippedJobs.equals(other.skippedJobs))
97              return false;
98          if (succeededJobs == null) {
99              if (other.succeededJobs != null)
100                 return false;
101         } else if (!succeededJobs.equals(other.succeededJobs))
102             return false;
103         return true;
104     }
105 
106 }