1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.rundeck.api.query;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.rundeck.api.domain.RundeckExecution;
29
30 import java.util.*;
31
32
33
34
35
36
37
38
39 public class ExecutionQuery {
40 private RundeckExecution.ExecutionStatus status;
41 private String abortedby;
42 private List<String> jobList;
43 private List<String> jobIdList;
44 private List<String> excludeJobList;
45 private List<String> excludeJobIdList;
46 private Date begin;
47 private Date end;
48 private String recent;
49 private String job;
50 private String jobExact;
51 private String excludeJob;
52 private String excludeJobExact;
53 private String project;
54 private String groupPath;
55 private String groupPathExact;
56 private String excludeGroupPath;
57 private String excludeGroupPathExact;
58 private String user;
59 private String description;
60 private Boolean adhoc;
61
62 private ExecutionQuery() {
63 }
64
65 private ExecutionQuery(ExecutionQuery query) {
66 this.status = query.getStatus();
67 this.abortedby = query.getAbortedby();
68 this.jobList = query.getJobList();
69 this.jobIdList = query.getJobIdList();
70 this.excludeJobList = query.getExcludeJobList();
71 this.excludeJobIdList = query.getExcludeJobIdList();
72 this.begin = query.getBegin();
73 this.end = query.getEnd();
74 this.recent = query.getRecent();
75 this.job = query.getJob();
76 this.jobExact = query.getJobExact();
77 this.excludeJob = query.getExcludeJob();
78 this.excludeJobExact = query.getExcludeJobExact();
79 this.project = query.getProject();
80 this.groupPath = query.getGroupPath();
81 this.groupPathExact = query.getGroupPathExact();
82 this.excludeGroupPath = query.getExcludeGroupPath();
83 this.excludeGroupPathExact = query.getExcludeGroupPathExact();
84 this.description = query.getDescription();
85 this.user = query.getUser();
86 this.adhoc = query.getAdhoc();
87 }
88
89
90
91
92 public boolean notBlank() {
93 return null!=status ||
94 !StringUtils.isBlank(abortedby) ||
95 !StringUtils.isBlank(recent) ||
96 !StringUtils.isBlank(job) ||
97 !StringUtils.isBlank(jobExact) ||
98 !StringUtils.isBlank(excludeJob) ||
99 !StringUtils.isBlank(excludeJobExact) ||
100 !StringUtils.isBlank(groupPath) ||
101 !StringUtils.isBlank(groupPathExact) ||
102 !StringUtils.isBlank(excludeGroupPath) ||
103 !StringUtils.isBlank(excludeGroupPathExact) ||
104 !StringUtils.isBlank(description) ||
105
106 (null!=adhoc) ||
107
108 (null != jobList && jobList.size() > 0) ||
109 (null != jobIdList && jobIdList.size() > 0) ||
110 (null != excludeJobList && excludeJobList.size() > 0) ||
111 (null != excludeJobIdList && excludeJobIdList.size() > 0) ||
112
113 (null != begin ) ||
114 (null != end )
115 ;
116 }
117
118 public RundeckExecution.ExecutionStatus getStatus() {
119 return status;
120 }
121
122 public String getAbortedby() {
123 return abortedby;
124 }
125
126 public List<String> getJobList() {
127 return jobList;
128 }
129
130 public List<String> getExcludeJobList() {
131 return excludeJobList;
132 }
133
134 public List<String> getExcludeJobIdList() {
135 return excludeJobIdList;
136 }
137
138 public Date getBegin() {
139 return begin;
140 }
141
142 public Date getEnd() {
143 return end;
144 }
145
146 public String getRecent() {
147 return recent;
148 }
149
150 public String getJob() {
151 return job;
152 }
153
154 public String getJobExact() {
155 return jobExact;
156 }
157
158 public String getProject() {
159 return project;
160 }
161
162 public String getGroupPath() {
163 return groupPath;
164 }
165
166 public String getGroupPathExact() {
167 return groupPathExact;
168 }
169
170 public String getDescription() {
171 return description;
172 }
173
174 public List<String> getJobIdList() {
175 return jobIdList;
176 }
177
178
179
180
181 public static Builder builder() {
182 return new Builder();
183 }
184
185 public String getUser() {
186 return user;
187 }
188
189 public Boolean getAdhoc() {
190 return adhoc;
191 }
192
193 public String getExcludeJob() {
194 return excludeJob;
195 }
196
197 public String getExcludeJobExact() {
198 return excludeJobExact;
199 }
200
201 public String getExcludeGroupPath() {
202 return excludeGroupPath;
203 }
204
205 public String getExcludeGroupPathExact() {
206 return excludeGroupPathExact;
207 }
208
209
210
211
212
213 public static class Builder {
214 ExecutionQuery query;
215
216 public Builder() {
217 query = new ExecutionQuery();
218 }
219
220
221
222
223 public Builder status(RundeckExecution.ExecutionStatus status) {
224 query.status = status;
225 return this;
226 }
227
228
229
230
231 public Builder abortedby(String abortedby) {
232 query.abortedby = abortedby;
233 return this;
234 }
235
236
237
238
239 public Builder jobList(List<String> list) {
240 query.jobList = list;
241 return this;
242 }
243
244
245
246 public Builder jobIdList(List<String> list) {
247 query.jobIdList = list;
248 return this;
249 }
250
251
252
253
254 public Builder excludeJobList(List<String> list) {
255 query.excludeJobList = list;
256 return this;
257 }
258
259
260
261
262 public Builder excludeJobIdList(List<String> list) {
263 query.excludeJobIdList = list;
264 return this;
265 }
266
267
268
269
270 public Builder begin(Date begin) {
271 query.begin = begin;
272 return this;
273 }
274
275
276
277
278 public Builder end(Date end) {
279 query.end = end;
280 return this;
281 }
282
283
284
285
286
287 public Builder recent(String recent) {
288 query.recent = recent;
289 return this;
290 }
291
292
293
294
295 public Builder job(String job) {
296 query.job = job;
297 return this;
298 }
299
300
301
302
303 public Builder jobExact(String exact) {
304 query.jobExact = exact;
305 return this;
306 }
307
308
309
310 public Builder excludeJob(String job) {
311 query.excludeJob = job;
312 return this;
313 }
314
315
316
317
318 public Builder excludeJobExact(String exact) {
319 query.excludeJobExact = exact;
320 return this;
321 }
322
323
324
325
326 public Builder project(String project) {
327 query.project = project;
328 return this;
329 }
330
331
332
333
334 public Builder groupPath(String path) {
335 query.groupPath = path;
336 return this;
337 }
338
339
340
341
342 public Builder groupPathExact(String exact) {
343 query.groupPathExact = exact;
344 return this;
345 }
346
347
348
349 public Builder excludeGroupPath(String excludeGroupPath) {
350 query.excludeGroupPath = excludeGroupPath;
351 return this;
352 }
353
354
355
356
357 public Builder excludeGroupPathExact(String excludeGroupPathExact) {
358 query.excludeGroupPathExact = excludeGroupPathExact;
359 return this;
360 }
361
362
363
364
365 public Builder description(String description) {
366 query.description = description;
367 return this;
368 }
369
370
371
372
373 public Builder user(String user) {
374 query.user = user;
375 return this;
376 }
377
378
379
380
381 public Builder adhoc(Boolean adhoc) {
382 query.adhoc = adhoc;
383 return this;
384 }
385
386
387
388
389 public ExecutionQuery build() {
390 return new ExecutionQuery(query);
391 }
392 }
393 }