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.core.persistence.api.dao;
20  
21  import java.time.OffsetDateTime;
22  import java.util.Collection;
23  import java.util.List;
24  import java.util.Optional;
25  import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
26  import org.apache.syncope.core.persistence.api.entity.Any;
27  import org.apache.syncope.core.persistence.api.entity.DerSchema;
28  import org.apache.syncope.core.persistence.api.entity.ExternalResource;
29  import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
30  import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
31  import org.apache.syncope.core.persistence.api.entity.PlainSchema;
32  import org.apache.syncope.core.persistence.api.entity.Schema;
33  
34  public interface AnyDAO<A extends Any<?>> extends DAO<A> {
35  
36      int DEFAULT_PAGE_SIZE = 500;
37  
38      List<A> findByKeys(List<String> keys);
39  
40      OffsetDateTime findLastChange(String key);
41  
42      A authFind(String key);
43  
44      A find(String key);
45  
46      List<A> findByPlainAttrValue(PlainSchema schema, PlainAttrValue attrValue, boolean ignoreCaseMatch);
47  
48      Optional<A> findByPlainAttrUniqueValue(
49              PlainSchema schema, PlainAttrUniqueValue attrUniqueValue, boolean ignoreCaseMatch);
50  
51      /**
52       * Find any objects by derived attribute value. This method could fail if one or more string literals contained
53       * into the derived attribute value provided derive from identifier (schema key) replacement. When you are going to
54       * specify a derived attribute expression you must be quite sure that string literals used to build the expression
55       * cannot be found into the attribute values used to replace attribute schema keys used as identifiers.
56       *
57       * @param schema derived schema
58       * @param value derived attribute value
59       * @param ignoreCaseMatch whether comparison for string values should take case into account or not
60       * @return list of any objects
61       */
62      List<A> findByDerAttrValue(DerSchema schema, String value, boolean ignoreCaseMatch);
63  
64      List<A> findByResource(ExternalResource resource);
65  
66      /**
67       * @return the search condition to match all entities
68       */
69      SearchCond getAllMatchingCond();
70  
71      /**
72       * @return the total number of any objects of type {@link A}
73       */
74      int count();
75  
76      /**
77       * Find any objects without any limitation, according to given page and items per page.
78       *
79       * @param page search result page
80       * @param itemsPerPage items per search result page
81       * @return any objects of type {@link A} matching the provided conditions
82       */
83      List<A> findAll(int page, int itemsPerPage);
84  
85      /**
86       * Find any objects' keys without any limitation, according to given page and items per page.
87       *
88       * @param page search result page
89       * @param itemsPerPage items per search result page
90       * @return any objects' keys matching the provided conditions
91       */
92      List<String> findAllKeys(int page, int itemsPerPage);
93  
94      <S extends Schema> AllowedSchemas<S> findAllowedSchemas(A any, Class<S> reference);
95  
96      A save(A any);
97  
98      void delete(String key);
99  
100     void delete(A any);
101 
102     List<String> findDynRealms(String key);
103 
104     Collection<String> findAllResourceKeys(String key);
105 }