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