View Javadoc

1   package org.apache.continuum.taskqueue;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.continuum.utils.build.BuildTrigger;
23  import org.apache.maven.continuum.model.scm.ScmResult;
24  import org.codehaus.plexus.taskqueue.Task;
25  
26  import java.io.Serializable;
27  
28  /**
29   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
30   * @version $Id: BuildProjectTask.java 1391353 2012-09-28 07:50:49Z brett $
31   */
32  public class BuildProjectTask
33      implements Task, Serializable
34  {
35      private static final long serialVersionUID = 3647734422022017812L;
36  
37      private final int projectId;
38  
39      private final int buildDefinitionId;
40  
41      private final long timestamp;
42  
43      private BuildTrigger buildTrigger;
44  
45      private long maxExecutionTime;
46  
47      private final String projectName;
48  
49      private final String buildDefinitionLabel;
50  
51      private ScmResult scmResult;
52  
53      int projectGroupId;
54  
55      public BuildProjectTask( int projectId, int buildDefinitionId, BuildTrigger buildTrigger, String projectName,
56                               String buildDefinitionLabel, ScmResult scmResult, int projectGroupId )
57      {
58          this.projectId = projectId;
59  
60          this.buildDefinitionId = buildDefinitionId;
61  
62          this.timestamp = System.currentTimeMillis();
63  
64          this.buildTrigger = buildTrigger;
65  
66          this.projectName = projectName;
67  
68          this.buildDefinitionLabel = buildDefinitionLabel;
69  
70          this.scmResult = scmResult;
71  
72          this.projectGroupId = projectGroupId;
73      }
74  
75      public int getProjectId()
76      {
77          return projectId;
78      }
79  
80      public int getBuildDefinitionId()
81      {
82          return buildDefinitionId;
83      }
84  
85      public long getTimestamp()
86      {
87          return timestamp;
88      }
89  
90      public BuildTrigger getBuildTrigger()
91      {
92          return buildTrigger;
93      }
94  
95      public void setBuildTrigger( BuildTrigger buildTrigger )
96      {
97          this.buildTrigger = buildTrigger;
98      }
99  
100     public void setMaxExecutionTime( long maxExecutionTime )
101     {
102         this.maxExecutionTime = maxExecutionTime;
103     }
104 
105     public long getMaxExecutionTime()
106     {
107         return maxExecutionTime;
108     }
109 
110     public String getProjectName()
111     {
112         return projectName;
113     }
114 
115     public String getBuildDefinitionLabel()
116     {
117         return buildDefinitionLabel;
118     }
119 
120     public ScmResult getScmResult()
121     {
122         return scmResult;
123     }
124 
125     public int getProjectGroupId()
126     {
127         return projectGroupId;
128     }
129 
130     public boolean equals( Object obj )
131     {
132         if ( obj == null )
133         {
134             return false;
135         }
136         if ( obj == this )
137         {
138             return true;
139         }
140         if ( !( obj instanceof BuildProjectTask ) )
141         {
142             return false;
143         }
144         BuildProjectTask buildProjectTask = (BuildProjectTask) obj;
145         return buildProjectTask.getBuildDefinitionId() == this.getBuildDefinitionId() &&
146             buildProjectTask.getProjectId() == this.getProjectId() &&
147             buildProjectTask.getBuildTrigger().getTrigger() == this.buildTrigger.getTrigger();
148     }
149 
150     public int hashCode()
151     {
152         return this.getBuildDefinitionId() + this.getProjectId() + this.buildTrigger.getTrigger();
153     }
154 
155     public int getHashCode()
156     {
157         return this.hashCode();
158     }
159 }