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.jpa.dao;
20  
21  import java.util.List;
22  import java.util.Optional;
23  import org.apache.syncope.core.persistence.api.dao.AnyMatchDAO;
24  import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
25  import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
26  import org.apache.syncope.core.persistence.api.dao.DerSchemaDAO;
27  import org.apache.syncope.core.persistence.api.dao.DynRealmDAO;
28  import org.apache.syncope.core.persistence.api.dao.JPAJSONAnyDAO;
29  import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
30  import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
31  import org.apache.syncope.core.persistence.api.dao.UserDAO;
32  import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
33  import org.apache.syncope.core.persistence.api.entity.DerSchema;
34  import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
35  import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
36  import org.apache.syncope.core.persistence.api.entity.PlainSchema;
37  import org.apache.syncope.core.persistence.api.entity.group.Group;
38  import org.apache.syncope.core.persistence.api.search.SearchCondVisitor;
39  import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
40  import org.springframework.context.ApplicationEventPublisher;
41  
42  public class JPAJSONGroupDAO extends JPAGroupDAO {
43  
44      protected final JPAJSONAnyDAO anyDAO;
45  
46      public JPAJSONGroupDAO(
47              final AnyUtilsFactory anyUtilsFactory,
48              final ApplicationEventPublisher publisher,
49              final PlainSchemaDAO plainSchemaDAO,
50              final DerSchemaDAO derSchemaDAO,
51              final DynRealmDAO dynRealmDAO,
52              final AnyMatchDAO anyMatchDAO,
53              final PlainAttrDAO plainAttrDAO,
54              final UserDAO userDAO,
55              final AnyObjectDAO anyObjectDAO,
56              final AnySearchDAO searchDAO,
57              final SearchCondVisitor searchCondVisitor,
58              final JPAJSONAnyDAO anyDAO) {
59  
60          super(anyUtilsFactory,
61                  publisher,
62                  plainSchemaDAO,
63                  derSchemaDAO,
64                  dynRealmDAO,
65                  anyMatchDAO,
66                  plainAttrDAO,
67                  userDAO,
68                  anyObjectDAO,
69                  searchDAO,
70                  searchCondVisitor);
71          this.anyDAO = anyDAO;
72      }
73  
74      @Override
75      public List<Group> findByPlainAttrValue(
76              final PlainSchema schema,
77              final PlainAttrValue attrValue,
78              final boolean ignoreCaseMatch) {
79  
80          return anyDAO.findByPlainAttrValue(
81                  JPAGroup.TABLE, anyUtils(), schema, attrValue, ignoreCaseMatch);
82      }
83  
84      @Override
85      public Optional<Group> findByPlainAttrUniqueValue(
86              final PlainSchema schema,
87              final PlainAttrUniqueValue attrUniqueValue,
88              final boolean ignoreCaseMatch) {
89  
90          return anyDAO.findByPlainAttrUniqueValue(
91                  JPAGroup.TABLE, anyUtils(), schema, attrUniqueValue, ignoreCaseMatch);
92      }
93  
94      @Override
95      public List<Group> findByDerAttrValue(
96              final DerSchema schema,
97              final String value,
98              final boolean ignoreCaseMatch) {
99  
100         return anyDAO.findByDerAttrValue(JPAGroup.TABLE, anyUtils(), schema, value, ignoreCaseMatch);
101     }
102 
103     @Override
104     public Group save(final Group group) {
105         anyDAO.checkBeforeSave(JPAGroup.TABLE, anyUtils(), group);
106         return super.save(group);
107     }
108 }