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.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.EnumType;
24  import javax.persistence.Enumerated;
25  import javax.persistence.FetchType;
26  import javax.persistence.Lob;
27  import javax.persistence.OneToOne;
28  import javax.persistence.PrimaryKeyJoinColumn;
29  import javax.persistence.Table;
30  import javax.validation.constraints.NotNull;
31  import org.apache.syncope.common.lib.types.AttrSchemaType;
32  import org.apache.syncope.common.lib.types.CipherAlgorithm;
33  import org.apache.syncope.common.lib.types.IdRepoImplementationType;
34  import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
35  import org.apache.syncope.core.persistence.api.entity.Implementation;
36  import org.apache.syncope.core.persistence.api.entity.PlainSchema;
37  import org.apache.syncope.core.persistence.jpa.validation.entity.PlainSchemaCheck;
38  
39  @Entity
40  @Table(name = JPAPlainSchema.TABLE)
41  @PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
42  @PlainSchemaCheck
43  public class JPAPlainSchema extends AbstractSchema implements PlainSchema {
44  
45      private static final long serialVersionUID = -8621028596062054739L;
46  
47      public static final String TABLE = "PlainSchema";
48  
49      @OneToOne(fetch = FetchType.EAGER)
50      private JPAAnyTypeClass anyTypeClass;
51  
52      @NotNull
53      @Enumerated(EnumType.STRING)
54      private AttrSchemaType type = AttrSchemaType.String;
55  
56      @NotNull
57      private String mandatoryCondition = Boolean.FALSE.toString();
58  
59      private Boolean multivalue = false;
60  
61      private Boolean uniqueConstraint = false;
62  
63      private Boolean readonly = false;
64  
65      @Column(nullable = true)
66      private String conversionPattern;
67  
68      @Column(nullable = true)
69      @Lob
70      private String enumerationValues;
71  
72      @Column(nullable = true)
73      @Lob
74      private String enumerationKeys;
75  
76      @Column(nullable = true)
77      private String secretKey;
78  
79      @Column(nullable = true)
80      @Enumerated(EnumType.STRING)
81      private CipherAlgorithm cipherAlgorithm;
82  
83      @Column(nullable = true)
84      private String mimeType;
85  
86      @OneToOne
87      private JPAImplementation validator;
88  
89      @Override
90      public AnyTypeClass getAnyTypeClass() {
91          return anyTypeClass;
92      }
93  
94      @Override
95      public void setAnyTypeClass(final AnyTypeClass anyTypeClass) {
96          checkType(anyTypeClass, JPAAnyTypeClass.class);
97          this.anyTypeClass = (JPAAnyTypeClass) anyTypeClass;
98      }
99  
100     @Override
101     public AttrSchemaType getType() {
102         return type;
103     }
104 
105     @Override
106     public void setType(final AttrSchemaType type) {
107         this.type = type;
108     }
109 
110     @Override
111     public String getMandatoryCondition() {
112         return mandatoryCondition;
113     }
114 
115     @Override
116     public void setMandatoryCondition(final String condition) {
117         this.mandatoryCondition = condition;
118     }
119 
120     @Override
121     public boolean isMultivalue() {
122         return multivalue;
123     }
124 
125     @Override
126     public void setMultivalue(final boolean multivalue) {
127         this.multivalue = multivalue;
128     }
129 
130     @Override
131     public boolean isUniqueConstraint() {
132         return uniqueConstraint;
133     }
134 
135     @Override
136     public void setUniqueConstraint(final boolean uniquevalue) {
137         this.uniqueConstraint = uniquevalue;
138     }
139 
140     @Override
141     public boolean isReadonly() {
142         return readonly;
143     }
144 
145     @Override
146     public void setReadonly(final boolean readonly) {
147         this.readonly = readonly;
148     }
149 
150     @Override
151     public Implementation getValidator() {
152         return validator;
153     }
154 
155     @Override
156     public void setValidator(final Implementation validator) {
157         checkType(validator, JPAImplementation.class);
158         checkImplementationType(validator, IdRepoImplementationType.VALIDATOR);
159         this.validator = (JPAImplementation) validator;
160     }
161 
162     @Override
163     public String getEnumerationValues() {
164         return enumerationValues;
165     }
166 
167     @Override
168     public void setEnumerationValues(final String enumerationValues) {
169         this.enumerationValues = enumerationValues;
170     }
171 
172     @Override
173     public String getEnumerationKeys() {
174         return enumerationKeys;
175     }
176 
177     @Override
178     public void setEnumerationKeys(final String enumerationKeys) {
179         this.enumerationKeys = enumerationKeys;
180     }
181 
182     @Override
183     public String getConversionPattern() {
184         return conversionPattern;
185     }
186 
187     @Override
188     public void setConversionPattern(final String conversionPattern) {
189         this.conversionPattern = conversionPattern;
190     }
191 
192     @Override
193     public String getSecretKey() {
194         return secretKey;
195     }
196 
197     @Override
198     public void setSecretKey(final String secretKey) {
199         this.secretKey = secretKey;
200     }
201 
202     @Override
203     public CipherAlgorithm getCipherAlgorithm() {
204         return cipherAlgorithm;
205     }
206 
207     @Override
208     public void setCipherAlgorithm(final CipherAlgorithm cipherAlgorithm) {
209         this.cipherAlgorithm = cipherAlgorithm;
210     }
211 
212     @Override
213     public String getMimeType() {
214         return mimeType;
215     }
216 
217     @Override
218     public void setMimeType(final String mimeType) {
219         this.mimeType = mimeType;
220     }
221 
222 }