View Javadoc

1   /*
2    * Copyright 2012 DTO Labs, Inc. (http://dtolabs.com)
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  
18  /*
19  * ExecutionQueryParameters.java
20  * 
21  * User: Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
22  * Created: 9/13/12 3:54 PM
23  * 
24  */
25  package org.rundeck.api;
26  
27  import org.rundeck.api.domain.RundeckExecution;
28  import org.rundeck.api.query.ExecutionQuery;
29  
30  
31  /**
32   * ExecutionQueryParameters adds parameters to a {@link ApiPathBuilder} from a {@link ExecutionQuery} object.
33   *
34   *
35   * @author Greg Schueler <a href="mailto:greg@dtosolutions.com">greg@dtosolutions.com</a>
36   */
37  class ExecutionQueryParameters extends QueryParameterBuilder {
38      ExecutionQuery query;
39  
40      ExecutionQueryParameters(final ExecutionQuery query) {
41          this.query = query;
42      }
43  
44      public boolean buildParameters(final ApiPathBuilder builder, final boolean doPost) {
45          boolean seen = false;
46  
47          seen |= visit("jobFilter", query.getJob(), doPost, builder);
48          seen |= visit("jobExactFilter", query.getJobExact(), doPost, builder);
49          seen |= visit("excludeJobFilter", query.getExcludeJob(), doPost, builder);
50          seen |= visit("excludeJobExactFilter", query.getExcludeJobExact(), doPost, builder);
51          seen |= visit("project", query.getProject(), doPost, builder);
52          seen |= visit("groupPath", query.getGroupPath(), doPost, builder);
53          seen |= visit("groupPathExact", query.getGroupPathExact(), doPost, builder);
54          seen |= visit("excludeGroupPath", query.getExcludeGroupPath(), doPost, builder);
55          seen |= visit("excludeGroupPathExact", query.getExcludeGroupPathExact(), doPost, builder);
56          seen |= visit("descFilter", query.getDescription(), doPost, builder);
57          seen |= visit("userFilter", query.getUser(), doPost, builder);
58          if(null!=query.getAdhoc()){
59              seen |= visit("adhoc", query.getAdhoc(), doPost, builder);
60          }
61  
62          seen |= visit("statusFilter", stringVal(query.getStatus()), doPost, builder);
63          seen |= visit("abortedbyFilter", query.getAbortedby(), doPost, builder);
64          seen |= visit("jobListFilter", query.getJobList(), doPost, builder);
65          seen |= visit("jobIdListFilter", query.getJobIdList(), doPost, builder);
66          seen |= visit("excludeJobIdListFilter", query.getExcludeJobIdList(), doPost, builder);
67          seen |= visit("excludeJobListFilter", query.getExcludeJobList(), doPost, builder);
68          seen |= visit("begin", query.getBegin(), doPost, builder);
69          seen |= visit("end", query.getEnd(), doPost, builder);
70          seen |= visit("recentFilter", query.getRecent(), doPost, builder);
71  
72          return seen;
73      }
74  
75      public static String stringVal(final RundeckExecution.ExecutionStatus status) {
76          return null != status ? status.toString().toLowerCase() : null;
77      }
78  
79  }