View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.common.rest.api.beans;
20  
21  import io.swagger.v3.oas.annotations.Parameter;
22  import io.swagger.v3.oas.annotations.media.Schema;
23  import java.util.Optional;
24  import javax.validation.constraints.NotNull;
25  import javax.ws.rs.DefaultValue;
26  import javax.ws.rs.PathParam;
27  import javax.ws.rs.QueryParam;
28  import org.apache.syncope.common.lib.types.AnyTypeKind;
29  import org.apache.syncope.common.lib.types.TaskType;
30  import org.apache.syncope.common.rest.api.service.JAXRSService;
31  
32  public class TaskQuery extends AbstractQuery {
33  
34      private static final long serialVersionUID = -8792519310029596796L;
35  
36      public static class Builder extends AbstractQuery.Builder<TaskQuery, Builder> {
37  
38          public Builder(final TaskType type) {
39              super();
40              getInstance().setType(type);
41          }
42  
43          @Override
44          protected TaskQuery newInstance() {
45              return new TaskQuery();
46          }
47  
48          public Builder resource(final String resource) {
49              getInstance().setResource(resource);
50              return this;
51          }
52  
53          public Builder notification(final String notification) {
54              getInstance().setNotification(notification);
55              return this;
56          }
57  
58          public Builder anyTypeKind(final AnyTypeKind anyTypeKind) {
59              getInstance().setAnyTypeKind(anyTypeKind);
60              return this;
61          }
62  
63          public Builder entityKey(final String entityKey) {
64              getInstance().setEntityKey(entityKey);
65              return this;
66          }
67  
68          public Builder details(final boolean details) {
69              getInstance().setDetails(details);
70              return this;
71          }
72      }
73  
74      private TaskType type;
75  
76      private String resource;
77  
78      private String notification;
79  
80      private AnyTypeKind anyTypeKind;
81  
82      private String entityKey;
83  
84      private Boolean details;
85  
86      public TaskType getType() {
87          return type;
88      }
89  
90      @NotNull
91      @PathParam("type")
92      public void setType(final TaskType type) {
93          this.type = type;
94      }
95  
96      @Parameter(name = JAXRSService.PARAM_RESOURCE, description = "resource key to match", schema =
97              @Schema(implementation = String.class, example = "resource-ldap"))
98      public String getResource() {
99          return resource;
100     }
101 
102     @QueryParam(JAXRSService.PARAM_RESOURCE)
103     public void setResource(final String resource) {
104         this.resource = resource;
105     }
106 
107     @Parameter(name = JAXRSService.PARAM_NOTIFICATION, description = "notification key to match", schema =
108             @Schema(implementation = String.class, example = "4bf255f1-85a0-43d6-8988-128dad646f08"))
109     public String getNotification() {
110         return notification;
111     }
112 
113     @QueryParam(JAXRSService.PARAM_NOTIFICATION)
114     public void setNotification(final String notification) {
115         this.notification = notification;
116     }
117 
118     @Parameter(name = JAXRSService.PARAM_ANYTYPE_KIND, description = "entity type to match", schema =
119             @Schema(implementation = AnyTypeKind.class))
120     public AnyTypeKind getAnyTypeKind() {
121         return anyTypeKind;
122     }
123 
124     @QueryParam(JAXRSService.PARAM_ANYTYPE_KIND)
125     public void setAnyTypeKind(final AnyTypeKind anyTypeKind) {
126         this.anyTypeKind = anyTypeKind;
127     }
128 
129     @Parameter(name = JAXRSService.PARAM_ENTITY_KEY, description = "entity key to match", schema =
130             @Schema(implementation = String.class, example = "50592942-73ec-44c4-a377-e859524245e4"))
131     public String getEntityKey() {
132         return entityKey;
133     }
134 
135     @QueryParam(JAXRSService.PARAM_ENTITY_KEY)
136     public void setEntityKey(final String entityKey) {
137         this.entityKey = entityKey;
138     }
139 
140     @Parameter(name = JAXRSService.PARAM_DETAILS, description = "whether detailed information about executions is to "
141             + "be included", schema =
142             @Schema(implementation = Boolean.class))
143     public Boolean getDetails() {
144         return Optional.ofNullable(details).orElse(Boolean.TRUE);
145     }
146 
147     @QueryParam(JAXRSService.PARAM_DETAILS)
148     @DefaultValue("true")
149     public void setDetails(final Boolean details) {
150         this.details = details;
151     }
152 }