1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.persistence.jpa.entity.group;
20
21 import java.util.ArrayList;
22 import java.util.List;
23 import javax.persistence.CascadeType;
24 import javax.persistence.Entity;
25 import javax.persistence.FetchType;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.OneToMany;
28 import javax.persistence.OneToOne;
29 import javax.persistence.Table;
30 import javax.validation.Valid;
31 import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
32 import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
33 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
34 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
35 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
36 import org.apache.syncope.core.persistence.api.entity.group.Group;
37 import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
38
39 @Entity
40 @Table(name = JPAGPlainAttr.TABLE)
41 public class JPAGPlainAttr extends AbstractPlainAttr<Group> implements GPlainAttr {
42
43 private static final long serialVersionUID = 2848159565890995780L;
44
45 public static final String TABLE = "GPlainAttr";
46
47 @ManyToOne(fetch = FetchType.EAGER)
48 private JPAGroup owner;
49
50 @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, orphanRemoval = true, mappedBy = "attribute")
51 @Valid
52 private List<JPAGPlainAttrValue> values = new ArrayList<>();
53
54 @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
55 @Valid
56 private JPAGPlainAttrUniqueValue uniqueValue;
57
58 @Override
59 public Group getOwner() {
60 return owner;
61 }
62
63 @Override
64 public void setOwner(final Group owner) {
65 checkType(owner, JPAGroup.class);
66 this.owner = (JPAGroup) owner;
67 }
68
69 @Override
70 protected boolean addForMultiValue(final PlainAttrValue attrValue) {
71 checkType(attrValue, JPAGPlainAttrValue.class);
72 return values.add((JPAGPlainAttrValue) attrValue);
73 }
74
75 @Override
76 public List<? extends GPlainAttrValue> getValues() {
77 return values;
78 }
79
80 @Override
81 public GPlainAttrUniqueValue getUniqueValue() {
82 return uniqueValue;
83 }
84
85 @Override
86 public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
87 checkType(uniqueValue, JPAGPlainAttrUniqueValue.class);
88 this.uniqueValue = (JPAGPlainAttrUniqueValue) uniqueValue;
89 }
90 }