View Javadoc

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