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.entity;
20  
21  import java.util.ArrayList;
22  import java.util.List;
23  import javax.persistence.Cacheable;
24  import javax.persistence.Entity;
25  import javax.persistence.FetchType;
26  import javax.persistence.OneToMany;
27  import javax.persistence.Table;
28  import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
29  import org.apache.syncope.core.persistence.api.entity.DerSchema;
30  import org.apache.syncope.core.persistence.api.entity.PlainSchema;
31  import org.apache.syncope.core.persistence.api.entity.VirSchema;
32  
33  @Entity
34  @Table(name = JPAAnyTypeClass.TABLE)
35  @Cacheable
36  public class JPAAnyTypeClass extends AbstractProvidedKeyEntity implements AnyTypeClass {
37  
38      private static final long serialVersionUID = -1750247153774475453L;
39  
40      public static final String TABLE = "AnyTypeClass";
41  
42      @OneToMany(fetch = FetchType.EAGER, mappedBy = "anyTypeClass")
43      private List<JPAPlainSchema> plainSchemas = new ArrayList<>();
44  
45      @OneToMany(fetch = FetchType.EAGER, mappedBy = "anyTypeClass")
46      private List<JPADerSchema> derSchemas = new ArrayList<>();
47  
48      @OneToMany(fetch = FetchType.EAGER, mappedBy = "anyTypeClass")
49      private List<JPAVirSchema> virSchemas = new ArrayList<>();
50  
51      @Override
52      public boolean add(final PlainSchema schema) {
53          checkType(schema, JPAPlainSchema.class);
54          return this.plainSchemas.add((JPAPlainSchema) schema);
55      }
56  
57      @Override
58      public List<? extends PlainSchema> getPlainSchemas() {
59          return plainSchemas;
60      }
61  
62      @Override
63      public boolean add(final DerSchema schema) {
64          checkType(schema, JPADerSchema.class);
65          return this.derSchemas.add((JPADerSchema) schema);
66      }
67  
68      @Override
69      public List<? extends DerSchema> getDerSchemas() {
70          return derSchemas;
71      }
72  
73      @Override
74      public boolean add(final VirSchema schema) {
75          checkType(schema, JPAVirSchema.class);
76          return this.virSchemas.add((JPAVirSchema) schema);
77      }
78  
79      @Override
80      public List<? extends VirSchema> getVirSchemas() {
81          return virSchemas;
82      }
83  }