1
2
3
4
5
6
7
8 package org.apache.maven.continuum.model.project;
9
10
11
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
32
33
34
35
36 @SuppressWarnings( "all" )
37 public class BuildResult
38 implements java.io.Serializable
39 {
40
41
42
43
44
45
46
47
48 private Project project;
49
50
51
52
53 private BuildDefinition buildDefinition = null;
54
55
56
57
58 private int id = 0;
59
60
61
62
63 private int buildNumber = 0;
64
65
66
67
68 private int state = 0;
69
70
71
72
73 private int trigger = 0;
74
75
76
77
78 private long startTime = 0L;
79
80
81
82
83 private long endTime = 0L;
84
85
86
87
88 private String error;
89
90
91
92
93 private boolean success = false;
94
95
96
97
98 private int exitCode = 0;
99
100
101
102
103 private ScmResult scmResult;
104
105
106
107
108 private java.util.List<ProjectDependency> modifiedDependencies;
109
110
111
112
113 private long lastChangedDate = 0L;
114
115
116
117
118 private String buildUrl = "";
119
120
121
122
123
124
125
126
127
128
129
130 public void addModifiedDependency( ProjectDependency projectDependency )
131 {
132 getModifiedDependencies().add( projectDependency );
133 }
134
135
136
137
138
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 }
149
150
151
152
153
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 }
164
165
166
167
168
169
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 }
190
191
192
193
194
195
196 public BuildDefinition getBuildDefinition()
197 {
198 return this.buildDefinition;
199 }
200
201
202
203
204
205
206 public int getBuildNumber()
207 {
208 return this.buildNumber;
209 }
210
211
212
213
214
215
216 public String getBuildUrl()
217 {
218 return this.buildUrl;
219 }
220
221
222
223
224
225
226 public long getEndTime()
227 {
228 return this.endTime;
229 }
230
231
232
233
234
235
236 public String getError()
237 {
238 return this.error;
239 }
240
241
242
243
244
245
246 public int getExitCode()
247 {
248 return this.exitCode;
249 }
250
251
252
253
254
255
256 public int getId()
257 {
258 return this.id;
259 }
260
261
262
263
264
265
266 public long getLastChangedDate()
267 {
268 return this.lastChangedDate;
269 }
270
271
272
273
274
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 }
285
286
287
288
289
290
291 public Project getProject()
292 {
293 return this.project;
294 }
295
296
297
298
299
300
301 public ScmResult getScmResult()
302 {
303 return this.scmResult;
304 }
305
306
307
308
309
310
311 public long getStartTime()
312 {
313 return this.startTime;
314 }
315
316
317
318
319
320
321 public int getState()
322 {
323 return this.state;
324 }
325
326
327
328
329
330
331 public int getTrigger()
332 {
333 return this.trigger;
334 }
335
336
337
338
339
340
341 public int hashCode()
342 {
343 int result = 17;
344
345 result = 37 * result + (int) id;
346
347 return result;
348 }
349
350
351
352
353
354
355 public boolean isSuccess()
356 {
357 return this.success;
358 }
359
360
361
362
363
364
365 public void removeModifiedDependency( ProjectDependency projectDependency )
366 {
367 getModifiedDependencies().remove( projectDependency );
368 }
369
370
371
372
373
374
375 public void setBuildDefinition( BuildDefinition buildDefinition )
376 {
377 this.buildDefinition = buildDefinition;
378 }
379
380
381
382
383
384
385 public void setBuildNumber( int buildNumber )
386 {
387 this.buildNumber = buildNumber;
388 }
389
390
391
392
393
394
395 public void setBuildUrl( String buildUrl )
396 {
397 this.buildUrl = buildUrl;
398 }
399
400
401
402
403
404
405 public void setEndTime( long endTime )
406 {
407 this.endTime = endTime;
408 }
409
410
411
412
413
414
415 public void setError( String error )
416 {
417 this.error = error;
418 }
419
420
421
422
423
424
425 public void setExitCode( int exitCode )
426 {
427 this.exitCode = exitCode;
428 }
429
430
431
432
433
434
435 public void setId( int id )
436 {
437 this.id = id;
438 }
439
440
441
442
443
444
445 public void setLastChangedDate( long lastChangedDate )
446 {
447 this.lastChangedDate = lastChangedDate;
448 }
449
450
451
452
453
454
455 public void setModifiedDependencies( java.util.List<ProjectDependency> modifiedDependencies )
456 {
457 this.modifiedDependencies = modifiedDependencies;
458 }
459
460
461
462
463
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 }
479
480
481
482
483
484
485 public void setScmResult( ScmResult scmResult )
486 {
487 this.scmResult = scmResult;
488 }
489
490
491
492
493
494
495 public void setStartTime( long startTime )
496 {
497 this.startTime = startTime;
498 }
499
500
501
502
503
504
505 public void setState( int state )
506 {
507 this.state = state;
508 }
509
510
511
512
513
514
515 public void setSuccess( boolean success )
516 {
517 this.success = success;
518 }
519
520
521
522
523
524
525 public void setTrigger( int trigger )
526 {
527 this.trigger = trigger;
528 }
529
530
531
532
533
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 }
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 }