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