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 javax.persistence.Entity;
22  import javax.persistence.FetchType;
23  import javax.persistence.ManyToOne;
24  import javax.persistence.OneToOne;
25  import javax.persistence.PrimaryKeyJoinColumn;
26  import javax.persistence.Table;
27  import javax.validation.constraints.NotNull;
28  import org.apache.syncope.common.lib.types.AttrSchemaType;
29  import org.apache.syncope.core.persistence.api.entity.AnyType;
30  import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
31  import org.apache.syncope.core.persistence.api.entity.ExternalResource;
32  import org.apache.syncope.core.persistence.api.entity.VirSchema;
33  
34  @Entity
35  @Table(name = JPAVirSchema.TABLE)
36  @PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
37  public class JPAVirSchema extends AbstractSchema implements VirSchema {
38  
39      private static final long serialVersionUID = 3274006935328590141L;
40  
41      public static final String TABLE = "VirSchema";
42  
43      @OneToOne(fetch = FetchType.EAGER)
44      private JPAAnyTypeClass anyTypeClass;
45  
46      private Boolean readonly = false;
47  
48      @NotNull
49      @ManyToOne
50      private JPAExternalResource resource;
51  
52      @NotNull
53      @ManyToOne
54      private JPAAnyType anyType;
55  
56      @NotNull
57      private String extAttrName;
58  
59      @Override
60      public AnyTypeClass getAnyTypeClass() {
61          return anyTypeClass;
62      }
63  
64      @Override
65      public void setAnyTypeClass(final AnyTypeClass anyTypeClass) {
66          checkType(anyTypeClass, JPAAnyTypeClass.class);
67          this.anyTypeClass = (JPAAnyTypeClass) anyTypeClass;
68      }
69  
70      @Override
71      public AttrSchemaType getType() {
72          return AttrSchemaType.String;
73      }
74  
75      @Override
76      public String getMandatoryCondition() {
77          return Boolean.FALSE.toString().toLowerCase();
78      }
79  
80      @Override
81      public boolean isMultivalue() {
82          return true;
83      }
84  
85      @Override
86      public boolean isUniqueConstraint() {
87          return false;
88      }
89  
90      @Override
91      public boolean isReadonly() {
92          return readonly;
93      }
94  
95      @Override
96      public void setReadonly(final boolean readonly) {
97          this.readonly = readonly;
98      }
99  
100     @Override
101     public ExternalResource getResource() {
102         return resource;
103     }
104 
105     @Override
106     public void setResource(final ExternalResource resource) {
107         checkType(resource, JPAExternalResource.class);
108         this.resource = (JPAExternalResource) resource;
109     }
110 
111     @Override
112     public AnyType getAnyType() {
113         return anyType;
114     }
115 
116     @Override
117     public void setAnyType(final AnyType anyType) {
118         checkType(anyType, JPAAnyType.class);
119         this.anyType = (JPAAnyType) anyType;
120     }
121 
122     @Override
123     public String getExtAttrName() {
124         return extAttrName;
125     }
126 
127     @Override
128     public void setExtAttrName(final String extAttrName) {
129         this.extAttrName = extAttrName;
130     }
131 }