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.anyobject;
20  
21  import javax.persistence.Entity;
22  import javax.persistence.Table;
23  import org.apache.syncope.core.persistence.api.entity.MembershipType;
24  import org.apache.syncope.core.persistence.api.entity.RelationshipType;
25  import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
26  import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
27  import org.apache.syncope.core.persistence.api.entity.group.Group;
28  import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
29  import org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup;
30  
31  @Entity
32  @Table(name = JPAAMembership.TABLE)
33  public class JPAAMembership extends AbstractGeneratedKeyEntity implements AMembership {
34  
35      private static final long serialVersionUID = 1503557547394601405L;
36  
37      public static final String TABLE = "AMembership";
38  
39      private AnyObject leftEnd;
40  
41      private Group rightEnd;
42  
43      @Override
44      public MembershipType getType() {
45          return MembershipType.getInstance();
46      }
47  
48      @Override
49      public void setType(final RelationshipType type) {
50          // cannot be changed
51      }
52  
53      @Override
54      public AnyObject getLeftEnd() {
55          return leftEnd;
56      }
57  
58      @Override
59      public void setLeftEnd(final AnyObject leftEnd) {
60          checkType(leftEnd, JPAAnyObject.class);
61          this.leftEnd = (JPAAnyObject) leftEnd;
62      }
63  
64      @Override
65      public Group getRightEnd() {
66          return rightEnd;
67      }
68  
69      @Override
70      public void setRightEnd(final Group rightEnd) {
71          checkType(rightEnd, JPAGroup.class);
72          this.rightEnd = (JPAGroup) rightEnd;
73      }
74  }