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;
20
21 import org.apache.syncope.core.persistence.api.entity.Entity;
22 import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
23 import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrUniqueValue;
24 import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
25 import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
26 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
27 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
28 import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
29 import org.apache.syncope.core.persistence.api.entity.group.Group;
30 import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
31 import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
32 import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
33 import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
34 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
35 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue;
36 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
37 import org.apache.syncope.core.persistence.api.entity.user.User;
38 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAJSONAPlainAttr;
39 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAJSONAPlainAttrUniqueValue;
40 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAJSONAPlainAttrValue;
41 import org.apache.syncope.core.persistence.jpa.entity.anyobject.JPAJSONAnyObject;
42 import org.apache.syncope.core.persistence.jpa.entity.group.JPAJSONGPlainAttr;
43 import org.apache.syncope.core.persistence.jpa.entity.group.JPAJSONGPlainAttrUniqueValue;
44 import org.apache.syncope.core.persistence.jpa.entity.group.JPAJSONGPlainAttrValue;
45 import org.apache.syncope.core.persistence.jpa.entity.group.JPAJSONGroup;
46 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONLAPlainAttr;
47 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONLAPlainAttrUniqueValue;
48 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONLAPlainAttrValue;
49 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONLinkedAccount;
50 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONUPlainAttr;
51 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONUPlainAttrUniqueValue;
52 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONUPlainAttrValue;
53 import org.apache.syncope.core.persistence.jpa.entity.user.JPAJSONUser;
54 import org.apache.syncope.core.spring.security.SecureRandomUtils;
55
56 public abstract class JPAJSONEntityFactory extends JPAEntityFactory {
57
58 @SuppressWarnings("unchecked")
59 @Override
60 public <E extends Entity> E newEntity(final Class<E> reference) {
61 E result;
62
63 if (reference.equals(User.class)) {
64 result = (E) new JPAJSONUser();
65 ((JPAJSONUser) result).setKey(SecureRandomUtils.generateRandomUUID().toString());
66 } else if (reference.equals(LinkedAccount.class)) {
67 result = (E) new JPAJSONLinkedAccount();
68 ((JPAJSONLinkedAccount) result).setKey(SecureRandomUtils.generateRandomUUID().toString());
69 } else if (reference.equals(Group.class)) {
70 result = (E) new JPAJSONGroup();
71 ((JPAJSONGroup) result).setKey(SecureRandomUtils.generateRandomUUID().toString());
72 } else if (reference.equals(AnyObject.class)) {
73 result = (E) new JPAJSONAnyObject();
74 ((JPAJSONAnyObject) result).setKey(SecureRandomUtils.generateRandomUUID().toString());
75 } else if (reference.equals(APlainAttr.class)) {
76 result = (E) new JPAJSONAPlainAttr();
77 } else if (reference.equals(APlainAttrValue.class)) {
78 result = (E) new JPAJSONAPlainAttrValue();
79 } else if (reference.equals(APlainAttrUniqueValue.class)) {
80 result = (E) new JPAJSONAPlainAttrUniqueValue();
81 } else if (reference.equals(GPlainAttr.class)) {
82 result = (E) new JPAJSONGPlainAttr();
83 } else if (reference.equals(GPlainAttrValue.class)) {
84 result = (E) new JPAJSONGPlainAttrValue();
85 } else if (reference.equals(GPlainAttrUniqueValue.class)) {
86 result = (E) new JPAJSONGPlainAttrUniqueValue();
87 } else if (reference.equals(UPlainAttr.class)) {
88 result = (E) new JPAJSONUPlainAttr();
89 } else if (reference.equals(UPlainAttrValue.class)) {
90 result = (E) new JPAJSONUPlainAttrValue();
91 } else if (reference.equals(UPlainAttrUniqueValue.class)) {
92 result = (E) new JPAJSONUPlainAttrUniqueValue();
93 } else if (reference.equals(LAPlainAttr.class)) {
94 result = (E) new JPAJSONLAPlainAttr();
95 } else if (reference.equals(LAPlainAttrValue.class)) {
96 result = (E) new JPAJSONLAPlainAttrValue();
97 } else if (reference.equals(LAPlainAttrUniqueValue.class)) {
98 result = (E) new JPAJSONLAPlainAttrUniqueValue();
99 } else {
100 result = super.newEntity(reference);
101 }
102
103 return result;
104 }
105
106 @Override
107 public Class<? extends User> userClass() {
108 return JPAJSONUser.class;
109 }
110
111 @Override
112 public Class<? extends Group> groupClass() {
113 return JPAJSONGroup.class;
114 }
115
116 @Override
117 public Class<? extends AnyObject> anyObjectClass() {
118 return JPAJSONAnyObject.class;
119 }
120 }