1 package org.apache.continuum.buildqueue;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.continuum.dao.BuildQueueDao;
23 import org.apache.continuum.dao.ScheduleDao;
24 import org.apache.maven.continuum.model.project.BuildQueue;
25 import org.apache.maven.continuum.model.project.Schedule;
26 import org.apache.maven.continuum.store.ContinuumStoreException;
27
28 import java.util.List;
29 import javax.annotation.Resource;
30
31
32
33
34
35
36 public class DefaultBuildQueueService
37 implements BuildQueueService
38 {
39 @Resource
40 private BuildQueueDao buildQueueDao;
41
42 @Resource
43 private ScheduleDao scheduleDao;
44
45 public BuildQueue addBuildQueue( BuildQueue buildQueue )
46 throws BuildQueueServiceException
47 {
48 try
49 {
50 return buildQueueDao.addBuildQueue( buildQueue );
51 }
52 catch ( ContinuumStoreException e )
53 {
54 throw new BuildQueueServiceException( e );
55 }
56 }
57
58 public List<BuildQueue> getAllBuildQueues()
59 throws BuildQueueServiceException
60 {
61 try
62 {
63 return buildQueueDao.getAllBuildQueues();
64 }
65 catch ( ContinuumStoreException e )
66 {
67 throw new BuildQueueServiceException( e );
68 }
69 }
70
71 public BuildQueue getBuildQueue( int buildQueueId )
72 throws BuildQueueServiceException
73 {
74 try
75 {
76 return buildQueueDao.getBuildQueue( buildQueueId );
77 }
78 catch ( ContinuumStoreException e )
79 {
80 throw new BuildQueueServiceException( e );
81 }
82 }
83
84 public BuildQueue getBuildQueueByName( String buildQueueName )
85 throws BuildQueueServiceException
86 {
87 try
88 {
89 return buildQueueDao.getBuildQueueByName( buildQueueName );
90 }
91 catch ( ContinuumStoreException e )
92 {
93 throw new BuildQueueServiceException( e );
94 }
95 }
96
97 public void removeBuildQueue( BuildQueue buildQueue )
98 throws BuildQueueServiceException
99 {
100 try
101 {
102
103 List<Schedule> schedules = scheduleDao.getAllSchedulesByName();
104 for ( Schedule schedule : schedules )
105 {
106 List<BuildQueue> buildQueues = schedule.getBuildQueues();
107 if ( buildQueues.contains( buildQueue ) )
108 {
109 buildQueues.remove( buildQueue );
110 }
111 schedule.setBuildQueues( buildQueues );
112
113 scheduleDao.updateSchedule( schedule );
114 }
115
116 buildQueueDao.removeBuildQueue( buildQueue );
117 }
118 catch ( ContinuumStoreException e )
119 {
120 throw new BuildQueueServiceException( e );
121 }
122 }
123
124 public BuildQueue updateBuildQueue( BuildQueue buildQueue )
125 throws BuildQueueServiceException
126 {
127 try
128 {
129 return buildQueueDao.storeBuildQueue( buildQueue );
130 }
131 catch ( ContinuumStoreException e )
132 {
133 throw new BuildQueueServiceException( e );
134 }
135 }
136
137 public BuildQueueDao getBuildQueueDao()
138 {
139 return buildQueueDao;
140 }
141
142 public void setBuildQueueDao( BuildQueueDao buildQueueDao )
143 {
144 this.buildQueueDao = buildQueueDao;
145 }
146
147 public ScheduleDao getScheduleDao()
148 {
149 return scheduleDao;
150 }
151
152 public void setScheduleDao( ScheduleDao scheduleDao )
153 {
154 this.scheduleDao = scheduleDao;
155 }
156
157 }