View Javadoc

1   /*
2    =================== DO NOT EDIT THIS FILE ====================
3    Generated by Modello
4    any modifications will be overwritten.
5    ==============================================================
6    */
7   
8   package org.apache.maven.continuum.model.project;
9   
10    //---------------------------------/
11   //- Imported classes and packages -/
12  //---------------------------------/
13  
14  import org.apache.continuum.model.project.ProjectScmRoot;
15  import org.apache.continuum.model.release.ContinuumReleaseResult;
16  import org.apache.continuum.model.repository.AbstractPurgeConfiguration;
17  import org.apache.continuum.model.repository.DirectoryPurgeConfiguration;
18  import org.apache.continuum.model.repository.DistributedDirectoryPurgeConfiguration;
19  import org.apache.continuum.model.repository.LocalRepository;
20  import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
21  import org.apache.maven.continuum.model.scm.ChangeFile;
22  import org.apache.maven.continuum.model.scm.ChangeSet;
23  import org.apache.maven.continuum.model.scm.ScmResult;
24  import org.apache.maven.continuum.model.system.Installation;
25  import org.apache.maven.continuum.model.system.NotificationAddress;
26  import org.apache.maven.continuum.model.system.Profile;
27  import org.apache.maven.continuum.model.system.SystemConfiguration;
28  import org.apache.maven.continuum.project.ContinuumProjectState;
29  
30  /**
31   * 
32   *         This class is a single continuum build.
33   *       
34   * 
35   * @version $Revision$ $Date$
36   */
37  @SuppressWarnings( "all" )
38  public class BuildResult
39      implements java.io.Serializable
40  {
41  
42        //--------------------------/
43       //- Class/Member Variables -/
44      //--------------------------/
45  
46      /**
47       * Field project.
48       */
49      private Project project;
50  
51      /**
52       * Field buildDefinition.
53       */
54      private BuildDefinition buildDefinition = null;
55  
56      /**
57       * Field id.
58       */
59      private int id = 0;
60  
61      /**
62       * Field buildNumber.
63       */
64      private int buildNumber = 0;
65  
66      /**
67       * Field username.
68       */
69      private String username;
70  
71      /**
72       * Field state.
73       */
74      private int state = 0;
75  
76      /**
77       * Field trigger.
78       */
79      private int trigger = 0;
80  
81      /**
82       * Field startTime.
83       */
84      private long startTime = 0L;
85  
86      /**
87       * Field endTime.
88       */
89      private long endTime = 0L;
90  
91      /**
92       * Field error.
93       */
94      private String error;
95  
96      /**
97       * Field success.
98       */
99      private boolean success = false;
100 
101     /**
102      * Field exitCode.
103      */
104     private int exitCode = 0;
105 
106     /**
107      * Field scmResult.
108      */
109     private ScmResult scmResult;
110 
111     /**
112      * Field modifiedDependencies.
113      */
114     private java.util.List<ProjectDependency> modifiedDependencies;
115 
116     /**
117      * Field lastChangedDate.
118      */
119     private long lastChangedDate = 0L;
120 
121     /**
122      * Field buildUrl.
123      */
124     private String buildUrl = "";
125 
126 
127       //-----------/
128      //- Methods -/
129     //-----------/
130 
131     /**
132      * Method addModifiedDependency.
133      * 
134      * @param projectDependency
135      */
136     public void addModifiedDependency( ProjectDependency projectDependency )
137     {
138         getModifiedDependencies().add( projectDependency );
139     } //-- void addModifiedDependency( ProjectDependency )
140 
141     /**
142      * Method breakProjectAssociation.
143      * 
144      * @param project
145      */
146     public void breakProjectAssociation( Project project )
147     {
148         if ( this.project != project )
149         {
150             throw new IllegalStateException( "project isn't associated." );
151         }
152 
153         this.project = null;
154     } //-- void breakProjectAssociation( Project )
155 
156     /**
157      * Method createProjectAssociation.
158      * 
159      * @param project
160      */
161     public void createProjectAssociation( Project project )
162     {
163         if ( this.project != null )
164         {
165             breakProjectAssociation( this.project );
166         }
167 
168         this.project = project;
169     } //-- void createProjectAssociation( Project )
170 
171     /**
172      * Method equals.
173      * 
174      * @param other
175      * @return boolean
176      */
177     public boolean equals( Object other )
178     {
179         if ( this == other )
180         {
181             return true;
182         }
183 
184         if ( !( other instanceof BuildResult ) )
185         {
186             return false;
187         }
188 
189         BuildResult that = (BuildResult) other;
190         boolean result = true;
191 
192         result = result && id == that.id;
193 
194         return result;
195     } //-- boolean equals( Object )
196 
197     /**
198      * Get the buildDefinition field.
199      * 
200      * @return BuildDefinition
201      */
202     public BuildDefinition getBuildDefinition()
203     {
204         return this.buildDefinition;
205     } //-- BuildDefinition getBuildDefinition()
206 
207     /**
208      * Get the buildNumber field.
209      * 
210      * @return int
211      */
212     public int getBuildNumber()
213     {
214         return this.buildNumber;
215     } //-- int getBuildNumber()
216 
217     /**
218      * Get the buildUrl field.
219      * 
220      * @return String
221      */
222     public String getBuildUrl()
223     {
224         return this.buildUrl;
225     } //-- String getBuildUrl()
226 
227     /**
228      * Get the endTime field.
229      * 
230      * @return long
231      */
232     public long getEndTime()
233     {
234         return this.endTime;
235     } //-- long getEndTime()
236 
237     /**
238      * Get the error field.
239      * 
240      * @return String
241      */
242     public String getError()
243     {
244         return this.error;
245     } //-- String getError()
246 
247     /**
248      * Get the exitCode field.
249      * 
250      * @return int
251      */
252     public int getExitCode()
253     {
254         return this.exitCode;
255     } //-- int getExitCode()
256 
257     /**
258      * Get the id field.
259      * 
260      * @return int
261      */
262     public int getId()
263     {
264         return this.id;
265     } //-- int getId()
266 
267     /**
268      * Get the lastChangedDate field.
269      * 
270      * @return long
271      */
272     public long getLastChangedDate()
273     {
274         return this.lastChangedDate;
275     } //-- long getLastChangedDate()
276 
277     /**
278      * Method getModifiedDependencies.
279      * 
280      * @return List
281      */
282     public java.util.List<ProjectDependency> getModifiedDependencies()
283     {
284         if ( this.modifiedDependencies == null )
285         {
286             this.modifiedDependencies = new java.util.ArrayList<ProjectDependency>();
287         }
288 
289         return this.modifiedDependencies;
290     } //-- java.util.List<ProjectDependency> getModifiedDependencies()
291 
292     /**
293      * Get the project field.
294      * 
295      * @return Project
296      */
297     public Project getProject()
298     {
299         return this.project;
300     } //-- Project getProject()
301 
302     /**
303      * Get the scmResult field.
304      * 
305      * @return ScmResult
306      */
307     public ScmResult getScmResult()
308     {
309         return this.scmResult;
310     } //-- ScmResult getScmResult()
311 
312     /**
313      * Get the startTime field.
314      * 
315      * @return long
316      */
317     public long getStartTime()
318     {
319         return this.startTime;
320     } //-- long getStartTime()
321 
322     /**
323      * Get the state field.
324      * 
325      * @return int
326      */
327     public int getState()
328     {
329         return this.state;
330     } //-- int getState()
331 
332     /**
333      * Get the trigger field.
334      * 
335      * @return int
336      */
337     public int getTrigger()
338     {
339         return this.trigger;
340     } //-- int getTrigger()
341 
342     /**
343      * Get the username field.
344      * 
345      * @return String
346      */
347     public String getUsername()
348     {
349         return this.username;
350     } //-- String getUsername()
351 
352     /**
353      * Method hashCode.
354      * 
355      * @return int
356      */
357     public int hashCode()
358     {
359         int result = 17;
360 
361         result = 37 * result + (int) id;
362 
363         return result;
364     } //-- int hashCode()
365 
366     /**
367      * Get the success field.
368      * 
369      * @return boolean
370      */
371     public boolean isSuccess()
372     {
373         return this.success;
374     } //-- boolean isSuccess()
375 
376     /**
377      * Method removeModifiedDependency.
378      * 
379      * @param projectDependency
380      */
381     public void removeModifiedDependency( ProjectDependency projectDependency )
382     {
383         getModifiedDependencies().remove( projectDependency );
384     } //-- void removeModifiedDependency( ProjectDependency )
385 
386     /**
387      * Set the buildDefinition field.
388      * 
389      * @param buildDefinition
390      */
391     public void setBuildDefinition( BuildDefinition buildDefinition )
392     {
393         this.buildDefinition = buildDefinition;
394     } //-- void setBuildDefinition( BuildDefinition )
395 
396     /**
397      * Set the buildNumber field.
398      * 
399      * @param buildNumber
400      */
401     public void setBuildNumber( int buildNumber )
402     {
403         this.buildNumber = buildNumber;
404     } //-- void setBuildNumber( int )
405 
406     /**
407      * Set the buildUrl field.
408      * 
409      * @param buildUrl
410      */
411     public void setBuildUrl( String buildUrl )
412     {
413         this.buildUrl = buildUrl;
414     } //-- void setBuildUrl( String )
415 
416     /**
417      * Set the endTime field.
418      * 
419      * @param endTime
420      */
421     public void setEndTime( long endTime )
422     {
423         this.endTime = endTime;
424     } //-- void setEndTime( long )
425 
426     /**
427      * Set the error field.
428      * 
429      * @param error
430      */
431     public void setError( String error )
432     {
433         this.error = error;
434     } //-- void setError( String )
435 
436     /**
437      * Set the exitCode field.
438      * 
439      * @param exitCode
440      */
441     public void setExitCode( int exitCode )
442     {
443         this.exitCode = exitCode;
444     } //-- void setExitCode( int )
445 
446     /**
447      * Set the id field.
448      * 
449      * @param id
450      */
451     public void setId( int id )
452     {
453         this.id = id;
454     } //-- void setId( int )
455 
456     /**
457      * Set the lastChangedDate field.
458      * 
459      * @param lastChangedDate
460      */
461     public void setLastChangedDate( long lastChangedDate )
462     {
463         this.lastChangedDate = lastChangedDate;
464     } //-- void setLastChangedDate( long )
465 
466     /**
467      * Set the modifiedDependencies field.
468      * 
469      * @param modifiedDependencies
470      */
471     public void setModifiedDependencies( java.util.List<ProjectDependency> modifiedDependencies )
472     {
473         this.modifiedDependencies = modifiedDependencies;
474     } //-- void setModifiedDependencies( java.util.List )
475 
476     /**
477      * Set the project field.
478      * 
479      * @param project
480      */
481     public void setProject( Project project )
482     {
483         if ( this.project != null )
484         {
485             this.project.breakBuildResultAssociation( this );
486         }
487 
488         this.project = project;
489 
490         if ( project != null )
491         {
492             this.project.createBuildResultAssociation( this );
493         }
494     } //-- void setProject( Project )
495 
496     /**
497      * Set the scmResult field.
498      * 
499      * @param scmResult
500      */
501     public void setScmResult( ScmResult scmResult )
502     {
503         this.scmResult = scmResult;
504     } //-- void setScmResult( ScmResult )
505 
506     /**
507      * Set the startTime field.
508      * 
509      * @param startTime
510      */
511     public void setStartTime( long startTime )
512     {
513         this.startTime = startTime;
514     } //-- void setStartTime( long )
515 
516     /**
517      * Set the state field.
518      * 
519      * @param state
520      */
521     public void setState( int state )
522     {
523         this.state = state;
524     } //-- void setState( int )
525 
526     /**
527      * Set the success field.
528      * 
529      * @param success
530      */
531     public void setSuccess( boolean success )
532     {
533         this.success = success;
534     } //-- void setSuccess( boolean )
535 
536     /**
537      * Set the trigger field.
538      * 
539      * @param trigger
540      */
541     public void setTrigger( int trigger )
542     {
543         this.trigger = trigger;
544     } //-- void setTrigger( int )
545 
546     /**
547      * Set the username field.
548      * 
549      * @param username
550      */
551     public void setUsername( String username )
552     {
553         this.username = username;
554     } //-- void setUsername( String )
555 
556     /**
557      * Method toString.
558      * 
559      * @return String
560      */
561     public java.lang.String toString()
562     {
563         StringBuilder buf = new StringBuilder( 128 );
564 
565         buf.append( "id = '" );
566         buf.append( getId() );
567         buf.append( "'" );
568 
569         return buf.toString();
570     } //-- java.lang.String toString()
571 
572     
573             public String getElapsedTime()
574             {
575                 return getTimeDifference( startTime, getSystemTime() );
576             }
577 
578             public String getDurationTime()
579             {
580                 return getTimeDifference( startTime, endTime );
581             }
582             private long getSystemTime()
583             {
584                 return java.util.Calendar.getInstance().getTime().getTime();
585             }
586 
587             private String getTimeDifference( long startTime, long endTime )
588             {
589                 long start = startTime;
590                 long end = endTime;
591 
592                 if ( start == 0 )
593                 {
594                     return "";
595                 }
596 
597                 if ( end == 0 )
598                 {
599                     end = getSystemTime();
600                 }
601 
602                 int timeInSeconds = (int) ( ( end - start ) / 1000 );
603                 int days, hours, minutes, seconds;
604                 days = timeInSeconds / 86400;
605                 timeInSeconds = timeInSeconds - ( days * 86400 );
606                 hours = timeInSeconds / 3600;
607                 timeInSeconds = timeInSeconds - ( hours * 3600 );
608                 minutes = timeInSeconds / 60;
609                 timeInSeconds = timeInSeconds - ( minutes * 60 );
610                 seconds = timeInSeconds;
611 
612                 String elapsedTime = "";
613                 if ( days > 0 )
614                 {
615                     elapsedTime = days + " d ";
616                     elapsedTime += hours + " h ";
617                     elapsedTime += minutes + " min ";
618                     elapsedTime += seconds + " sec";
619                 }
620                 else
621                 {
622                     if ( hours > 0 )
623                     {
624                         elapsedTime = hours + " h ";
625                         elapsedTime += minutes + " min ";
626                         elapsedTime += seconds + " sec";
627                     }
628                     else
629                     {
630                         if ( minutes > 0 )
631                         {
632                             elapsedTime = minutes + " min ";
633                             elapsedTime += seconds + " sec";
634                         }
635                         else
636                         {
637                             elapsedTime = seconds + " sec";
638                         }
639                     }
640                 }
641 
642                 return elapsedTime;
643             }
644           
645 }