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.user;
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.user.LAPlainAttr;
34 import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
35 import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
36 import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
37 import org.apache.syncope.core.persistence.api.entity.user.User;
38 import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
39
40 @Entity
41 @Table(name = JPALAPlainAttr.TABLE)
42 public class JPALAPlainAttr extends AbstractPlainAttr<User> implements LAPlainAttr {
43
44 private static final long serialVersionUID = 7827533741035423694L;
45
46 public static final String TABLE = "LAPlainAttr";
47
48
49
50
51 @ManyToOne(fetch = FetchType.EAGER)
52 private JPAUser owner;
53
54 @ManyToOne(fetch = FetchType.EAGER)
55 private JPALinkedAccount account;
56
57
58
59
60 @OneToMany(cascade = CascadeType.MERGE, orphanRemoval = true, mappedBy = "attribute")
61 @Valid
62 private List<JPALAPlainAttrValue> values = new ArrayList<>();
63
64
65
66
67 @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
68 @Valid
69 private JPALAPlainAttrUniqueValue uniqueValue;
70
71 @Override
72 public User getOwner() {
73 return owner;
74 }
75
76 @Override
77 public void setOwner(final User owner) {
78 checkType(owner, JPAUser.class);
79 this.owner = (JPAUser) owner;
80 }
81
82 @Override
83 public LinkedAccount getAccount() {
84 return account;
85 }
86
87 @Override
88 public void setAccount(final LinkedAccount account) {
89 checkType(account, JPALinkedAccount.class);
90 this.account = (JPALinkedAccount) account;
91 }
92
93 @Override
94 protected boolean addForMultiValue(final PlainAttrValue attrValue) {
95 checkType(attrValue, JPALAPlainAttrValue.class);
96 return values.add((JPALAPlainAttrValue) attrValue);
97 }
98
99 @Override
100 public List<? extends LAPlainAttrValue> getValues() {
101 return values;
102 }
103
104 @Override
105 public LAPlainAttrUniqueValue getUniqueValue() {
106 return uniqueValue;
107 }
108
109 @Override
110 public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
111 checkType(uniqueValue, JPALAPlainAttrUniqueValue.class);
112 this.uniqueValue = (JPALAPlainAttrUniqueValue) uniqueValue;
113 }
114 }