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.lib.search;
20  
21  import java.util.Map;
22  import org.apache.cxf.jaxrs.ext.search.fiql.FiqlParser;
23  
24  /**
25   * Extends {@link AbstractFiqlSearchConditionBuilder} by providing some additional facilities for searching
26   * groups in Syncope.
27   */
28  public class GroupFiqlSearchConditionBuilder
29          extends AbstractFiqlSearchConditionBuilder<GroupProperty, GroupPartialCondition, GroupCompleteCondition> {
30  
31      private static final long serialVersionUID = 6275686371606165706L;
32  
33      @Override
34      protected Builder newBuilderInstance() {
35          return new Builder(properties);
36      }
37  
38      @Override
39      public GroupProperty is(final String property) {
40          return newBuilderInstance().is(property);
41      }
42  
43      public GroupCompleteCondition withMembers(final String member, final String... moreMembers) {
44          return newBuilderInstance().
45                  is(SpecialAttr.MEMBER.toString()).
46                  withMembers(member, moreMembers);
47      }
48  
49      public GroupCompleteCondition withoutMembers(final String member, final String... moreMembers) {
50          return newBuilderInstance().
51                  is(SpecialAttr.MEMBER.toString()).
52                  withoutMembers(member, moreMembers);
53      }
54  
55      protected static class Builder extends AbstractFiqlSearchConditionBuilder.Builder<
56              GroupProperty, GroupPartialCondition, GroupCompleteCondition>
57              implements GroupProperty, GroupCompleteCondition, GroupPartialCondition {
58  
59          public Builder(final Map<String, String> properties) {
60              super(properties);
61          }
62  
63          public Builder(final Builder parent) {
64              super(parent);
65          }
66  
67          @Override
68          public GroupProperty is(final String property) {
69              Builder b = new Builder(this);
70              b.result = property;
71              return b;
72          }
73  
74          @Override
75          public GroupCompleteCondition withMembers(final String member, final String... moreMembers) {
76              this.result = SpecialAttr.MEMBER.toString();
77              return condition(FiqlParser.EQ, member, (Object[]) moreMembers);
78          }
79  
80          @Override
81          public GroupCompleteCondition withoutMembers(final String member, final String... moreMembers) {
82              this.result = SpecialAttr.MEMBER.toString();
83              return condition(FiqlParser.NEQ, member, (Object[]) moreMembers);
84          }
85      }
86  }