entity) {
- entity.setPlainAttrsJSON(entity.getPlainAttrList().isEmpty()
+ protected void list2json(final AbstractAttributable entity) {
+ entity.setPlainAttrsJSON(entity.getPlainAttrsList().isEmpty()
? "[]"
- : POJOHelper.serialize(entity.getPlainAttrList()));
+ : POJOHelper.serialize(entity.getPlainAttrsList()));
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MaJPAJSONEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MariaDBEntityFactory.java
similarity index 84%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MaJPAJSONEntityFactory.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MariaDBEntityFactory.java
index c509826cf38..d0a8ccd82d3 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MaJPAJSONEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MariaDBEntityFactory.java
@@ -19,12 +19,12 @@
package org.apache.syncope.core.persistence.jpa.entity;
import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.dao.MaJPAJSONAnySearchDAO;
+import org.apache.syncope.core.persistence.jpa.dao.MariaDBJPAAnySearchDAO;
-public class MaJPAJSONEntityFactory extends JPAJSONEntityFactory {
+public class MariaDBEntityFactory extends AbstractEntityFactory {
@Override
public Class extends AnySearchDAO> anySearchDAOClass() {
- return MaJPAJSONAnySearchDAO.class;
+ return MariaDBJPAAnySearchDAO.class;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OJPAJSONEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MySQLEntityFactory.java
similarity index 85%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OJPAJSONEntityFactory.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MySQLEntityFactory.java
index 0b35c119320..d63807b9567 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OJPAJSONEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MySQLEntityFactory.java
@@ -19,12 +19,12 @@
package org.apache.syncope.core.persistence.jpa.entity;
import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.dao.OJPAJSONAnySearchDAO;
+import org.apache.syncope.core.persistence.jpa.dao.MySQLJPAAnySearchDAO;
-public class OJPAJSONEntityFactory extends JPAJSONEntityFactory {
+public class MySQLEntityFactory extends AbstractEntityFactory {
@Override
public Class extends AnySearchDAO> anySearchDAOClass() {
- return OJPAJSONAnySearchDAO.class;
+ return MySQLJPAAnySearchDAO.class;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MyJPAJSONEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OracleEntityFactory.java
similarity index 85%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MyJPAJSONEntityFactory.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OracleEntityFactory.java
index 3429d477d65..49856e923ce 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/MyJPAJSONEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/OracleEntityFactory.java
@@ -19,12 +19,12 @@
package org.apache.syncope.core.persistence.jpa.entity;
import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.dao.MyJPAJSONAnySearchDAO;
+import org.apache.syncope.core.persistence.jpa.dao.OracleJPAAnySearchDAO;
-public class MyJPAJSONEntityFactory extends JPAJSONEntityFactory {
+public class OracleEntityFactory extends AbstractEntityFactory {
@Override
public Class extends AnySearchDAO> anySearchDAOClass() {
- return MyJPAJSONAnySearchDAO.class;
+ return OracleJPAAnySearchDAO.class;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGJPAJSONEntityFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGEntityFactory.java
similarity index 84%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGJPAJSONEntityFactory.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGEntityFactory.java
index 9da2e9eb197..917d5815687 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGJPAJSONEntityFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/PGEntityFactory.java
@@ -19,12 +19,12 @@
package org.apache.syncope.core.persistence.jpa.entity;
import org.apache.syncope.core.persistence.api.dao.AnySearchDAO;
-import org.apache.syncope.core.persistence.jpa.dao.PGJPAJSONAnySearchDAO;
+import org.apache.syncope.core.persistence.jpa.dao.PGJPAAnySearchDAO;
-public class PGJPAJSONEntityFactory extends JPAJSONEntityFactory {
+public class PGEntityFactory extends AbstractEntityFactory {
@Override
public Class extends AnySearchDAO> anySearchDAOClass() {
- return PGJPAJSONAnySearchDAO.class;
+ return PGJPAAnySearchDAO.class;
}
}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
index 18d30d28c24..83857fcf3ef 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAADynGroupMembership.java
@@ -20,6 +20,7 @@
import jakarta.persistence.Entity;
import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.anyobject.ADynGroupMembership;
@@ -37,7 +38,8 @@ public class JPAADynGroupMembership extends AbstractDynMembership imp
public static final String TABLE = "ADynGroupMembership";
- private Group group;
+ @OneToOne
+ private JPAGroup group;
@ManyToOne
private JPAAnyType anyType;
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
index 1caaf7022e1..2f9c15e9c89 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAMembership.java
@@ -18,7 +18,9 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.anyobject;
+import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.apache.syncope.core.persistence.api.entity.MembershipType;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
@@ -36,9 +38,13 @@ public class JPAAMembership extends AbstractGeneratedKeyEntity implements AMembe
public static final String TABLE = "AMembership";
- private AnyObject leftEnd;
+ @ManyToOne
+ @Column(name = "anyObject_id")
+ private JPAAnyObject leftEnd;
- private Group rightEnd;
+ @ManyToOne
+ @Column(name = "group_id")
+ private JPAGroup rightEnd;
@Override
public MembershipType getType() {
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttr.java
deleted file mode 100644
index 1e55ee4dfae..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttr.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.anyobject;
-
-import jakarta.persistence.CascadeType;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.Valid;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-
-@Entity
-@Table(name = JPAAPlainAttr.TABLE)
-public class JPAAPlainAttr extends AbstractPlainAttr implements APlainAttr {
-
- private static final long serialVersionUID = 8066058729580952116L;
-
- public static final String TABLE = "APlainAttr";
-
- @ManyToOne(fetch = FetchType.EAGER)
- private JPAAnyObject owner;
-
- /**
- * The membership of this attribute; might be {@code NULL} if this attribute is not related to a membership.
- */
- @ManyToOne(fetch = FetchType.EAGER)
- private JPAAMembership membership;
-
- @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private List values = new ArrayList<>();
-
- @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private JPAAPlainAttrUniqueValue uniqueValue;
-
- @Override
- public AnyObject getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(final AnyObject owner) {
- checkType(owner, JPAAnyObject.class);
- this.owner = (JPAAnyObject) owner;
- }
-
- @Override
- public AMembership getMembership() {
- return membership;
- }
-
- @Override
- public void setMembership(final AMembership membership) {
- checkType(membership, JPAAMembership.class);
- this.membership = (JPAAMembership) membership;
- }
-
- @Override
- protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPAAPlainAttrValue.class);
- return values.add((JPAAPlainAttrValue) attrValue);
- }
-
- @Override
- public List extends APlainAttrValue> getValues() {
- return values;
- }
-
- @Override
- public APlainAttrUniqueValue getUniqueValue() {
- return uniqueValue;
- }
-
- @Override
- public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPAAPlainAttrUniqueValue.class);
- this.uniqueValue = (JPAAPlainAttrUniqueValue) uniqueValue;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
deleted file mode 100644
index 4ab111890cd..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrUniqueValue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.anyobject;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
-
-@Entity
-@Table(name = JPAAPlainAttrUniqueValue.TABLE)
-public class JPAAPlainAttrUniqueValue extends AbstractPlainAttrValue implements APlainAttrUniqueValue {
-
- private static final long serialVersionUID = -6412206895091662679L;
-
- public static final String TABLE = "APlainAttrUniqueValue";
-
- @OneToOne(optional = false)
- private JPAAPlainAttr attribute;
-
- @ManyToOne(optional = false)
- @JoinColumn(name = "schema_id")
- private JPAPlainSchema schema;
-
- @Override
- public APlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAAPlainAttr.class);
- this.attribute = (JPAAPlainAttr) attr;
- }
-
- @Override
- public PlainSchema getSchema() {
- return schema;
- }
-
- @Override
- public void setSchema(final PlainSchema schema) {
- checkType(schema, JPAPlainSchema.class);
- this.schema = (JPAPlainSchema) schema;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrValue.java
deleted file mode 100644
index 6f979456959..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAPlainAttrValue.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.anyobject;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.constraints.NotNull;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
-import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-
-@Entity
-@Table(name = JPAAPlainAttrValue.TABLE)
-public class JPAAPlainAttrValue extends AbstractPlainAttrValue implements APlainAttrValue {
-
- private static final long serialVersionUID = -2965487882824889272L;
-
- public static final String TABLE = "APlainAttrValue";
-
- @ManyToOne
- @NotNull
- private JPAAPlainAttr attribute;
-
- @Override
- public APlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAAPlainAttr.class);
- this.attribute = (JPAAPlainAttr) attr;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
index e0dbf1bd41d..ca4baa6a690 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAARelationship.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.anyobject;
+import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
@@ -42,9 +43,13 @@ public class JPAARelationship extends AbstractGeneratedKeyEntity implements ARel
@ManyToOne(fetch = FetchType.EAGER, optional = false)
private JPARelationshipType type;
- private AnyObject leftEnd;
+ @ManyToOne
+ @Column(name = "left_anyObject_id")
+ private JPAAnyObject leftEnd;
- private AnyObject rightEnd;
+ @ManyToOne
+ @Column(name = "right_anyObject_id")
+ private JPAAnyObject rightEnd;
@Override
public RelationshipType getType() {
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
index f3ed177cd33..2f187611c14 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAAnyObject.java
@@ -21,6 +21,7 @@
import jakarta.persistence.Cacheable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
@@ -28,11 +29,13 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
+import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import org.apache.syncope.core.persistence.api.entity.AnyType;
import org.apache.syncope.core.persistence.api.entity.AnyTypeClass;
@@ -51,6 +54,7 @@
@Entity
@Table(name = JPAAnyObject.TABLE, uniqueConstraints =
@UniqueConstraint(columnNames = { "name", "type_id" }))
+@EntityListeners({ JSONAnyObjectListener.class })
@Cacheable
@AnyObjectCheck
public class JPAAnyObject
@@ -67,9 +71,10 @@ public class JPAAnyObject
@ManyToOne(fetch = FetchType.EAGER, optional = false)
private JPAAnyType type;
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
- @Valid
- private List plainAttrs = new ArrayList<>();
+ private String plainAttrs;
+
+ @Transient
+ private final List plainAttrsList = new ArrayList<>();
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
@@ -130,16 +135,33 @@ public List extends ExternalResource> getResources() {
}
@Override
- public boolean add(final APlainAttr attr) {
- checkType(attr, JPAAPlainAttr.class);
- return plainAttrs.add((JPAAPlainAttr) attr);
+ public List extends APlainAttr> getPlainAttrsList() {
+ return plainAttrsList;
}
@Override
- protected List extends APlainAttr> internalGetPlainAttrs() {
+ public String getPlainAttrsJSON() {
return plainAttrs;
}
+ @Override
+ public void setPlainAttrsJSON(final String plainAttrs) {
+ this.plainAttrs = plainAttrs;
+ }
+
+ @Override
+ public boolean add(final APlainAttr attr) {
+ checkType(attr, JSONAPlainAttr.class);
+ return plainAttrsList.add((JSONAPlainAttr) attr);
+ }
+
+ @Override
+ public boolean remove(final APlainAttr attr) {
+ checkType(attr, JSONAPlainAttr.class);
+ return plainAttrsList.removeIf(jsonAttr -> jsonAttr.getSchemaKey().equals(attr.getSchema().getKey())
+ && Objects.equals(jsonAttr.getMembershipKey(), attr.getMembershipKey()));
+ }
+
@Override
public boolean add(final AnyTypeClass auxClass) {
checkType(auxClass, JPAAnyTypeClass.class);
@@ -181,6 +203,8 @@ public boolean add(final AMembership membership) {
@Override
public boolean remove(final AMembership membership) {
checkType(membership, JPAAMembership.class);
+ plainAttrsList.removeIf(attr -> attr.getMembershipKey() != null
+ && attr.getMembershipKey().equals(membership.getKey()));
return this.memberships.remove((JPAAMembership) membership);
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttr.java
similarity index 59%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttr.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttr.java
index 356af7a2d88..be42f7e3934 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttr.java
@@ -18,9 +18,8 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.anyobject;
+import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.ArrayList;
@@ -29,33 +28,21 @@
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.JSONPlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.AMembership;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
import org.apache.syncope.core.spring.ApplicationContextProvider;
-@JsonIgnoreProperties("valuesAsStrings")
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class JPAJSONAPlainAttr extends AbstractPlainAttr implements APlainAttr, JSONPlainAttr {
+public class JSONAPlainAttr extends AbstractPlainAttr implements APlainAttr {
- private static final long serialVersionUID = 806271775349587902L;
+ private static final long serialVersionUID = 8066058729580952116L;
- /**
- * The owner of this attribute.
- */
@JsonIgnore
- private JPAJSONAnyObject owner;
-
- @JsonProperty
- private String schema;
+ private JPAAnyObject owner;
/**
* The membership of this attribute; might be {@code NULL} if this attribute is not related to a membership.
@@ -63,16 +50,10 @@ public class JPAJSONAPlainAttr extends AbstractPlainAttr implements A
@JsonProperty
private String membership;
- /**
- * Values of this attribute (if schema is not UNIQUE).
- */
- private final List values = new ArrayList<>();
+ private List values = new ArrayList<>();
- /**
- * Value of this attribute (if schema is UNIQUE).
- */
@JsonProperty
- private JPAJSONAPlainAttrUniqueValue uniqueValue;
+ private JSONAPlainAttrUniqueValue uniqueValue;
@Override
public AnyObject getOwner() {
@@ -81,55 +62,26 @@ public AnyObject getOwner() {
@Override
public void setOwner(final AnyObject owner) {
- checkType(owner, JPAJSONAnyObject.class);
- this.owner = (JPAJSONAnyObject) owner;
+ this.owner = (JPAAnyObject) owner;
}
@JsonIgnore
@Override
- public String getSchemaKey() {
- return schema;
+ public AMembership getMembership() {
+ return ApplicationContextProvider.getBeanFactory().getBean(AnyObjectDAO.class).findMembership(membership);
}
- @JsonIgnore
@Override
- public JPAPlainSchema getSchema() {
- return Optional.ofNullable(schema).
- flatMap(s -> ApplicationContextProvider.getBeanFactory().getBean(PlainSchemaDAO.class).findById(s)).
- map(JPAPlainSchema.class::cast).
- orElse(null);
+ public void setMembership(final AMembership membership) {
+ this.membership = Optional.ofNullable(membership).map(AMembership::getKey).orElse(null);
}
+ @JsonGetter("membership")
@Override
- public void setSchema(final PlainSchema schema) {
- if (schema != null) {
- this.schema = schema.getKey();
- }
- }
-
- @JsonSetter("schema")
- public void setSchema(final String schema) {
- this.schema = schema;
- }
-
- @JsonIgnore
public String getMembershipKey() {
return membership;
}
- @JsonIgnore
- @Override
- public AMembership getMembership() {
- return ApplicationContextProvider.getBeanFactory().getBean(AnyObjectDAO.class).findMembership(membership);
- }
-
- @Override
- public void setMembership(final AMembership membership) {
- if (membership != null) {
- this.membership = membership.getKey();
- }
- }
-
@JsonSetter("membership")
public void setMembership(final String membership) {
this.membership = membership;
@@ -137,13 +89,7 @@ public void setMembership(final String membership) {
@Override
protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPAJSONAPlainAttrValue.class);
- return values.add((JPAJSONAPlainAttrValue) attrValue);
- }
-
- @Override
- public boolean add(final PlainAttrValue value) {
- return addForMultiValue(value);
+ return values.add((JSONAPlainAttrValue) attrValue);
}
@Override
@@ -151,27 +97,21 @@ public List extends APlainAttrValue> getValues() {
return values;
}
- @JsonIgnore
- public List getPGValues() {
- return values;
- }
-
@Override
- public JPAJSONAPlainAttrUniqueValue getUniqueValue() {
+ public JSONAPlainAttrUniqueValue getUniqueValue() {
return uniqueValue;
}
@JsonIgnore
@Override
public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPAJSONAPlainAttrUniqueValue.class);
- this.uniqueValue = (JPAJSONAPlainAttrUniqueValue) uniqueValue;
+ this.uniqueValue = (JSONAPlainAttrUniqueValue) uniqueValue;
}
@Override
public int hashCode() {
return new HashCodeBuilder().
- append(schema).
+ appendSuper(super.hashCode()).
append(membership).
append(values).
append(uniqueValue).
@@ -189,9 +129,9 @@ public boolean equals(final Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
- final JPAJSONAPlainAttr other = (JPAJSONAPlainAttr) obj;
+ final JSONAPlainAttr other = (JSONAPlainAttr) obj;
return new EqualsBuilder().
- append(schema, other.schema).
+ appendSuper(super.equals(obj)).
append(membership, other.membership).
append(values, other.values).
append(uniqueValue, other.uniqueValue).
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrUniqueValue.java
similarity index 76%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrUniqueValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrUniqueValue.java
index cd8247eef2f..e67cf269484 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrUniqueValue.java
@@ -19,22 +19,18 @@
package org.apache.syncope.core.persistence.jpa.entity.anyobject;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONAPlainAttrUniqueValue extends AbstractPlainAttrValue implements APlainAttrUniqueValue {
+public class JSONAPlainAttrUniqueValue extends AbstractPlainAttrValue implements APlainAttrUniqueValue {
- private static final long serialVersionUID = -4053996864791245312L;
+ private static final long serialVersionUID = 4681561795607192855L;
@JsonIgnore
- private JPAJSONAPlainAttr attr;
+ private JSONAPlainAttr attr;
@Override
public APlainAttr getAttr() {
@@ -43,8 +39,7 @@ public APlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONAPlainAttr.class);
- this.attr = (JPAJSONAPlainAttr) attr;
+ this.attr = (JSONAPlainAttr) attr;
}
@JsonIgnore
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrValue.java
similarity index 73%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrValue.java
index d4815d305c0..bdb458064cf 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAPlainAttrValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAPlainAttrValue.java
@@ -19,21 +19,19 @@
package org.apache.syncope.core.persistence.jpa.entity.anyobject;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
+import jakarta.validation.constraints.NotNull;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONAPlainAttrValue extends AbstractPlainAttrValue implements APlainAttrValue {
+public class JSONAPlainAttrValue extends AbstractPlainAttrValue implements APlainAttrValue {
- private static final long serialVersionUID = 1832825176101443555L;
+ private static final long serialVersionUID = -766808291128424707L;
@JsonIgnore
- private JPAJSONAPlainAttr attr;
+ @NotNull
+ private JSONAPlainAttr attr;
@Override
public APlainAttr getAttr() {
@@ -42,7 +40,6 @@ public APlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONAPlainAttr.class);
- this.attr = (JPAJSONAPlainAttr) attr;
+ this.attr = (JSONAPlainAttr) attr;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAnyObjectListener.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAnyObjectListener.java
similarity index 71%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAnyObjectListener.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAnyObjectListener.java
index c66f43dc5e4..5f46a9effac 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JPAJSONAnyObjectListener.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/anyobject/JSONAnyObjectListener.java
@@ -25,36 +25,36 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.JSONPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
-import org.apache.syncope.core.persistence.jpa.entity.JPAJSONEntityListener;
+import org.apache.syncope.core.persistence.jpa.entity.JSONEntityListener;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-public class JPAJSONAnyObjectListener extends JPAJSONEntityListener {
+public class JSONAnyObjectListener extends JSONEntityListener {
- protected static final TypeReference> TYPEREF =
- new TypeReference>() {
+ protected static final TypeReference> TYPEREF =
+ new TypeReference>() {
};
@Override
- protected List extends JSONPlainAttr> getAttrs(final String plainAttrsJSON) {
+ protected List extends APlainAttr> getAttrs(final String plainAttrsJSON) {
return POJOHelper.deserialize(plainAttrsJSON, TYPEREF);
}
@PostLoad
- public void read(final JPAJSONAnyObject anyObject) {
+ public void read(final JPAAnyObject anyObject) {
super.json2list(anyObject, false);
}
@PrePersist
@PreUpdate
- public void save(final JPAJSONAnyObject anyObject) {
+ public void save(final JPAAnyObject anyObject) {
super.list2json(anyObject);
}
@PostPersist
@PostUpdate
- public void readAfterSave(final JPAJSONAnyObject anyObject) {
+ public void readAfterSave(final JPAAnyObject anyObject) {
super.json2list(anyObject, true);
}
}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
deleted file mode 100644
index a0087dffccd..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrUniqueValue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.group;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
-
-@Entity
-@Table(name = JPAGPlainAttrUniqueValue.TABLE)
-public class JPAGPlainAttrUniqueValue extends AbstractPlainAttrValue implements GPlainAttrUniqueValue {
-
- private static final long serialVersionUID = 4681561795607192855L;
-
- public static final String TABLE = "GPlainAttrUniqueValue";
-
- @OneToOne(optional = false)
- private JPAGPlainAttr attribute;
-
- @ManyToOne(optional = false)
- @JoinColumn(name = "schema_id")
- private JPAPlainSchema schema;
-
- @Override
- public GPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAGPlainAttr.class);
- this.attribute = (JPAGPlainAttr) attr;
- }
-
- @Override
- public PlainSchema getSchema() {
- return schema;
- }
-
- @Override
- public void setSchema(final PlainSchema schema) {
- checkType(schema, JPAPlainSchema.class);
- this.schema = (JPAPlainSchema) schema;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrValue.java
deleted file mode 100644
index 52bc20d6ace..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttrValue.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.group;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.constraints.NotNull;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-
-@Entity
-@Table(name = JPAGPlainAttrValue.TABLE)
-public class JPAGPlainAttrValue extends AbstractPlainAttrValue implements GPlainAttrValue {
-
- private static final long serialVersionUID = -766808291128424707L;
-
- public static final String TABLE = "GPlainAttrValue";
-
- @ManyToOne
- @NotNull
- private JPAGPlainAttr attribute;
-
- @Override
- public GPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAGPlainAttr.class);
- this.attribute = (JPAGPlainAttr) attr;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
index 5541dd4c123..76a2b79f7ed 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGroup.java
@@ -22,13 +22,16 @@
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
import jakarta.persistence.FetchType;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
+import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
+import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
@@ -56,6 +59,7 @@
@Entity
@Table(name = JPAGroup.TABLE)
+@EntityListeners({ JSONGroupListener.class })
@Cacheable
@GroupCheck
public class JPAGroup extends AbstractAny implements Group {
@@ -68,13 +72,16 @@ public class JPAGroup extends AbstractAny implements Group {
@NotNull
private String name;
- protected User userOwner;
+ @ManyToOne
+ private JPAUser userOwner;
- protected Group groupOwner;
+ @ManyToOne
+ private JPAGroup groupOwner;
- @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "owner")
- @Valid
- private List plainAttrs = new ArrayList<>();
+ private String plainAttrs;
+
+ @Transient
+ private final List plainAttrsList = new ArrayList<>();
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(joinColumns =
@@ -157,28 +164,43 @@ public void setGroupOwner(final Group group) {
this.groupOwner = (JPAGroup) group;
}
+ @Override
+ public List extends GPlainAttr> getPlainAttrsList() {
+ return plainAttrsList;
+ }
+
+ @Override
+ public String getPlainAttrsJSON() {
+ return plainAttrs;
+ }
+
+ @Override
+ public void setPlainAttrsJSON(final String plainAttrs) {
+ this.plainAttrs = plainAttrs;
+ }
+
@Override
public boolean add(final GPlainAttr attr) {
- checkType(attr, JPAGPlainAttr.class);
- return plainAttrs.add((JPAGPlainAttr) attr);
+ checkType(attr, JSONGPlainAttr.class);
+ return plainAttrsList.add((JSONGPlainAttr) attr);
}
@Override
public boolean remove(final GPlainAttr attr) {
- checkType(attr, JPAGPlainAttr.class);
- return getPlainAttrs().remove((JPAGPlainAttr) attr);
+ checkType(attr, JSONGPlainAttr.class);
+ return plainAttrsList.removeIf(a -> a.getSchemaKey().equals(attr.getSchema().getKey()));
}
@Override
public Optional extends GPlainAttr> getPlainAttr(final String plainSchema) {
- return getPlainAttrs().stream().
- filter(plainAttr -> plainAttr != null && plainAttr.getSchema() != null
- && plainSchema.equals(plainAttr.getSchema().getKey())).findFirst();
+ return plainAttrsList.stream().
+ filter(attr -> plainSchema.equals(attr.getSchemaKey())).
+ findFirst();
}
@Override
public List extends GPlainAttr> getPlainAttrs() {
- return plainAttrs;
+ return plainAttrsList.stream().toList();
}
@Override
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
index ffce5f8a2f9..fbdc2da7d2b 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPATypeExtension.java
@@ -45,7 +45,8 @@ public class JPATypeExtension extends AbstractGeneratedKeyEntity implements Type
public static final String TABLE = "TypeExtension";
- private Group group;
+ @ManyToOne
+ private JPAGroup group;
@ManyToOne
private JPAAnyType anyType;
@@ -55,7 +56,8 @@ public class JPATypeExtension extends AbstractGeneratedKeyEntity implements Type
@JoinColumn(name = "typeExtension_id"),
inverseJoinColumns =
@JoinColumn(name = "anyTypeClass_id"),
- uniqueConstraints = @UniqueConstraint(columnNames = { "typeExtension_id", "anyTypeClass_id" }))
+ uniqueConstraints =
+ @UniqueConstraint(columnNames = { "typeExtension_id", "anyTypeClass_id" }))
private List auxClasses = new ArrayList<>();
@Override
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttr.java
similarity index 55%
rename from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttr.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttr.java
index 1b3c7aeb76d..bf29de77a9f 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAGPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttr.java
@@ -18,42 +18,36 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.group;
-import jakarta.persistence.CascadeType;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-@Entity
-@Table(name = JPAGPlainAttr.TABLE)
-public class JPAGPlainAttr extends AbstractPlainAttr implements GPlainAttr {
+public class JSONGPlainAttr extends AbstractPlainAttr implements GPlainAttr {
private static final long serialVersionUID = 2848159565890995780L;
- public static final String TABLE = "GPlainAttr";
-
- @ManyToOne(fetch = FetchType.EAGER)
+ @JsonIgnore
private JPAGroup owner;
- @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private List values = new ArrayList<>();
+ /**
+ * Values of this attribute (if schema is not UNIQUE).
+ */
+ private final List values = new ArrayList<>();
- @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private JPAGPlainAttrUniqueValue uniqueValue;
+ /**
+ * Value of this attribute (if schema is UNIQUE).
+ */
+ @JsonProperty
+ private JSONGPlainAttrUniqueValue uniqueValue;
@Override
public Group getOwner() {
@@ -62,14 +56,12 @@ public Group getOwner() {
@Override
public void setOwner(final Group owner) {
- checkType(owner, JPAGroup.class);
this.owner = (JPAGroup) owner;
}
@Override
protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPAGPlainAttrValue.class);
- return values.add((JPAGPlainAttrValue) attrValue);
+ return values.add((JSONGPlainAttrValue) attrValue);
}
@Override
@@ -78,13 +70,41 @@ public List extends GPlainAttrValue> getValues() {
}
@Override
- public GPlainAttrUniqueValue getUniqueValue() {
+ public JSONGPlainAttrUniqueValue getUniqueValue() {
return uniqueValue;
}
+ @JsonIgnore
@Override
public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPAGPlainAttrUniqueValue.class);
- this.uniqueValue = (JPAGPlainAttrUniqueValue) uniqueValue;
+ this.uniqueValue = (JSONGPlainAttrUniqueValue) uniqueValue;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().
+ appendSuper(super.hashCode()).
+ append(values).
+ append(uniqueValue).
+ build();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final JSONGPlainAttr other = (JSONGPlainAttr) obj;
+ return new EqualsBuilder().
+ appendSuper(super.equals(obj)).
+ append(values, other.values).
+ append(uniqueValue, other.uniqueValue).
+ build();
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrUniqueValue.java
similarity index 76%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrUniqueValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrUniqueValue.java
index 539e8fb85b1..a8894024005 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrUniqueValue.java
@@ -19,22 +19,18 @@
package org.apache.syncope.core.persistence.jpa.entity.group;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONGPlainAttrUniqueValue extends AbstractPlainAttrValue implements GPlainAttrUniqueValue {
+public class JSONGPlainAttrUniqueValue extends AbstractPlainAttrValue implements GPlainAttrUniqueValue {
- private static final long serialVersionUID = -4326417972859745823L;
+ private static final long serialVersionUID = 4681561795607192855L;
@JsonIgnore
- private JPAJSONGPlainAttr attr;
+ private JSONGPlainAttr attr;
@Override
public GPlainAttr getAttr() {
@@ -43,8 +39,7 @@ public GPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONGPlainAttr.class);
- this.attr = (JPAJSONGPlainAttr) attr;
+ this.attr = (JSONGPlainAttr) attr;
}
@JsonIgnore
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrValue.java
similarity index 73%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrValue.java
index e662117e2b8..67b1d2a3d18 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGPlainAttrValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGPlainAttrValue.java
@@ -19,21 +19,17 @@
package org.apache.syncope.core.persistence.jpa.entity.group;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.GPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONGPlainAttrValue extends AbstractPlainAttrValue implements GPlainAttrValue {
+public class JSONGPlainAttrValue extends AbstractPlainAttrValue implements GPlainAttrValue {
- private static final long serialVersionUID = 1832825176101443555L;
+ private static final long serialVersionUID = -766808291128424707L;
@JsonIgnore
- private JPAJSONGPlainAttr attr;
+ private JSONGPlainAttr attr;
@Override
public GPlainAttr getAttr() {
@@ -42,7 +38,6 @@ public GPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONGPlainAttr.class);
- this.attr = (JPAJSONGPlainAttr) attr;
+ this.attr = (JSONGPlainAttr) attr;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGroupListener.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGroupListener.java
similarity index 72%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGroupListener.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGroupListener.java
index 104697a68d1..f3e19d228fa 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JPAJSONGroupListener.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/group/JSONGroupListener.java
@@ -25,36 +25,36 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.JSONPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.persistence.jpa.entity.JPAJSONEntityListener;
+import org.apache.syncope.core.persistence.jpa.entity.JSONEntityListener;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-public class JPAJSONGroupListener extends JPAJSONEntityListener {
+public class JSONGroupListener extends JSONEntityListener {
- protected static final TypeReference> TYPEREF =
- new TypeReference>() {
+ protected static final TypeReference> TYPEREF =
+ new TypeReference>() {
};
@Override
- protected List extends JSONPlainAttr> getAttrs(final String plainAttrsJSON) {
+ protected List extends GPlainAttr> getAttrs(final String plainAttrsJSON) {
return POJOHelper.deserialize(plainAttrsJSON, TYPEREF);
}
@PostLoad
- public void read(final JPAJSONGroup group) {
+ public void read(final JPAGroup group) {
super.json2list(group, false);
}
@PrePersist
@PreUpdate
- public void save(final JPAJSONGroup group) {
+ public void save(final JPAGroup group) {
super.list2json(group);
}
@PostPersist
@PostUpdate
- public void readAfterSave(final JPAJSONGroup group) {
+ public void readAfterSave(final JPAGroup group) {
super.json2list(group, true);
}
}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrUniqueValue.java
deleted file mode 100644
index 50ef6583d73..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrUniqueValue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.user;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
-
-@Entity
-@Table(name = JPALAPlainAttrUniqueValue.TABLE)
-public class JPALAPlainAttrUniqueValue extends AbstractPlainAttrValue implements LAPlainAttrUniqueValue {
-
- private static final long serialVersionUID = 1200617357906733442L;
-
- public static final String TABLE = "LAPlainAttrUniqueValue";
-
- @OneToOne(optional = false)
- private JPALAPlainAttr attribute;
-
- @ManyToOne(optional = false)
- @JoinColumn(name = "schema_id")
- private JPAPlainSchema schema;
-
- @Override
- public LAPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPALAPlainAttr.class);
- this.attribute = (JPALAPlainAttr) attr;
- }
-
- @Override
- public PlainSchema getSchema() {
- return schema;
- }
-
- @Override
- public void setSchema(final PlainSchema schema) {
- checkType(schema, JPAPlainSchema.class);
- this.schema = (JPAPlainSchema) schema;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrValue.java
deleted file mode 100644
index dcda659a1e0..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttrValue.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.user;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.constraints.NotNull;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-
-@Entity
-@Table(name = JPALAPlainAttrValue.TABLE)
-public class JPALAPlainAttrValue extends AbstractPlainAttrValue implements LAPlainAttrValue {
-
- private static final long serialVersionUID = 6237793413044604262L;
-
- public static final String TABLE = "LAPlainAttrValue";
-
- @ManyToOne
- @NotNull
- private JPALAPlainAttr attribute;
-
- @Override
- public LAPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPALAPlainAttr.class);
- this.attribute = (JPALAPlainAttr) attr;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALinkedAccount.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALinkedAccount.java
index 25d93d67ef6..b22afe2c916 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALinkedAccount.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALinkedAccount.java
@@ -18,9 +18,9 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.user;
-import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
@@ -28,8 +28,8 @@
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
+import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
@@ -45,7 +45,7 @@
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractGeneratedKeyEntity;
+import org.apache.syncope.core.persistence.jpa.entity.AbstractAttributable;
import org.apache.syncope.core.persistence.jpa.entity.JPAExternalResource;
import org.apache.syncope.core.persistence.jpa.entity.JPAPrivilege;
import org.apache.syncope.core.spring.ApplicationContextProvider;
@@ -55,7 +55,8 @@
@Entity
@Table(name = JPALinkedAccount.TABLE, uniqueConstraints =
@UniqueConstraint(columnNames = { "connObjectKeyValue", "resource_id" }))
-public class JPALinkedAccount extends AbstractGeneratedKeyEntity implements LinkedAccount {
+@EntityListeners({ JSONLinkedAccountListener.class })
+public class JPALinkedAccount extends AbstractAttributable implements LinkedAccount {
private static final long serialVersionUID = -5141654998687601522L;
@@ -82,9 +83,10 @@ public class JPALinkedAccount extends AbstractGeneratedKeyEntity implements Link
private Boolean suspended = false;
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "account")
- @Valid
- private List plainAttrs = new ArrayList<>();
+ private String plainAttrs;
+
+ @Transient
+ private final List plainAttrsList = new ArrayList<>();
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
@@ -192,28 +194,43 @@ public Boolean isSuspended() {
return suspended;
}
+ @Override
+ public List extends LAPlainAttr> getPlainAttrsList() {
+ return plainAttrsList;
+ }
+
+ @Override
+ public String getPlainAttrsJSON() {
+ return plainAttrs;
+ }
+
+ @Override
+ public void setPlainAttrsJSON(final String plainAttrs) {
+ this.plainAttrs = plainAttrs;
+ }
+
@Override
public boolean add(final LAPlainAttr attr) {
- checkType(attr, JPALAPlainAttr.class);
- return plainAttrs.add((JPALAPlainAttr) attr);
+ checkType(attr, JSONLAPlainAttr.class);
+ return plainAttrsList.add((JSONLAPlainAttr) attr);
}
@Override
public boolean remove(final LAPlainAttr attr) {
- checkType(attr, JPALAPlainAttr.class);
- return plainAttrs.remove((JPALAPlainAttr) attr);
+ checkType(attr, JSONLAPlainAttr.class);
+ return plainAttrsList.removeIf(jsonAttr -> jsonAttr.getSchemaKey().equals(attr.getSchema().getKey()));
}
@Override
public Optional extends LAPlainAttr> getPlainAttr(final String plainSchema) {
- return getPlainAttrs().stream().
- filter(plainAttr -> plainAttr != null && plainAttr.getSchema() != null
- && plainSchema.equals(plainAttr.getSchema().getKey())).findFirst();
+ return plainAttrsList.stream().
+ filter(attr -> plainSchema.equals(attr.getSchemaKey())).
+ findFirst();
}
@Override
public List extends LAPlainAttr> getPlainAttrs() {
- return plainAttrs;
+ return plainAttrsList.stream().toList();
}
@Override
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
index 4eadcb8dd89..1a851cf335e 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUDynGroupMembership.java
@@ -19,6 +19,7 @@
package org.apache.syncope.core.persistence.jpa.entity.user;
import jakarta.persistence.Entity;
+import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import org.apache.syncope.core.persistence.api.entity.group.Group;
import org.apache.syncope.core.persistence.api.entity.user.UDynGroupMembership;
@@ -34,7 +35,8 @@ public class JPAUDynGroupMembership extends AbstractDynMembership implemen
public static final String TABLE = "UDynGroupMembership";
- private Group group;
+ @OneToOne
+ private JPAGroup group;
@Override
public Group getGroup() {
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
index 81654b6ba5d..a54a3ac9815 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUMembership.java
@@ -18,7 +18,9 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.user;
+import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.apache.syncope.core.persistence.api.entity.MembershipType;
import org.apache.syncope.core.persistence.api.entity.RelationshipType;
@@ -36,9 +38,13 @@ public class JPAUMembership extends AbstractGeneratedKeyEntity implements UMembe
public static final String TABLE = "UMembership";
- private User leftEnd;
+ @ManyToOne
+ @Column(name = "user_id")
+ private JPAUser leftEnd;
- private Group rightEnd;
+ @ManyToOne
+ @Column(name = "group_id")
+ private JPAGroup rightEnd;
@Override
public MembershipType getType() {
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttr.java
deleted file mode 100644
index 81106c14ba3..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttr.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.user;
-
-import jakarta.persistence.CascadeType;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.Valid;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.UMembership;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-
-@Entity
-@Table(name = JPAUPlainAttr.TABLE)
-public class JPAUPlainAttr extends AbstractPlainAttr implements UPlainAttr {
-
- private static final long serialVersionUID = 6333601983691157406L;
-
- public static final String TABLE = "UPlainAttr";
-
- /**
- * The owner of this attribute.
- */
- @ManyToOne(fetch = FetchType.EAGER)
- private JPAUser owner;
-
- /**
- * The membership of this attribute; might be {@code NULL} if this attribute is not related to a membership.
- */
- @ManyToOne(fetch = FetchType.EAGER)
- private JPAUMembership membership;
-
- /**
- * Values of this attribute (if schema is not UNIQUE).
- */
- @OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private List values = new ArrayList<>();
-
- /**
- * Value of this attribute (if schema is UNIQUE).
- */
- @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private JPAUPlainAttrUniqueValue uniqueValue;
-
- @Override
- public User getOwner() {
- return owner;
- }
-
- @Override
- public void setOwner(final User owner) {
- checkType(owner, JPAUser.class);
- this.owner = (JPAUser) owner;
- }
-
- @Override
- public UMembership getMembership() {
- return membership;
- }
-
- @Override
- public void setMembership(final UMembership membership) {
- checkType(membership, JPAUMembership.class);
- this.membership = (JPAUMembership) membership;
- }
-
- @Override
- protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPAUPlainAttrValue.class);
- return values.add((JPAUPlainAttrValue) attrValue);
- }
-
- @Override
- public List extends UPlainAttrValue> getValues() {
- return values;
- }
-
- @Override
- public UPlainAttrUniqueValue getUniqueValue() {
- return uniqueValue;
- }
-
- @Override
- public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPAUPlainAttrUniqueValue.class);
- this.uniqueValue = (JPAUPlainAttrUniqueValue) uniqueValue;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
deleted file mode 100644
index 1ea5a11d835..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrUniqueValue.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.user;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
-
-@Entity
-@Table(name = JPAUPlainAttrUniqueValue.TABLE)
-public class JPAUPlainAttrUniqueValue extends AbstractPlainAttrValue implements UPlainAttrUniqueValue {
-
- private static final long serialVersionUID = -64080804563305387L;
-
- public static final String TABLE = "UPlainAttrUniqueValue";
-
- @OneToOne(optional = false)
- private JPAUPlainAttr attribute;
-
- @ManyToOne(optional = false)
- @JoinColumn(name = "schema_id")
- private JPAPlainSchema schema;
-
- @Override
- public UPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAUPlainAttr.class);
- this.attribute = (JPAUPlainAttr) attr;
- }
-
- @Override
- public PlainSchema getSchema() {
- return schema;
- }
-
- @Override
- public void setSchema(final PlainSchema schema) {
- checkType(schema, JPAPlainSchema.class);
- this.schema = (JPAPlainSchema) schema;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrValue.java
deleted file mode 100644
index acb62a18b42..00000000000
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUPlainAttrValue.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.jpa.entity.user;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.constraints.NotNull;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-
-@Entity
-@Table(name = JPAUPlainAttrValue.TABLE)
-public class JPAUPlainAttrValue extends AbstractPlainAttrValue implements UPlainAttrValue {
-
- private static final long serialVersionUID = -6259576015647897446L;
-
- public static final String TABLE = "UPlainAttrValue";
-
- @ManyToOne
- @NotNull
- private JPAUPlainAttr attribute;
-
- @Override
- public UPlainAttr getAttr() {
- return attribute;
- }
-
- @Override
- public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAUPlainAttr.class);
- this.attribute = (JPAUPlainAttr) attr;
- }
-}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
index a7c920a3995..f92a002a162 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAURelationship.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.user;
+import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ManyToOne;
@@ -44,9 +45,13 @@ public class JPAURelationship extends AbstractGeneratedKeyEntity implements URel
@ManyToOne(fetch = FetchType.EAGER, optional = false)
private JPARelationshipType type;
- private User leftEnd;
+ @ManyToOne
+ @Column(name = "user_id")
+ private JPAUser leftEnd;
- private AnyObject rightEnd;
+ @ManyToOne
+ @Column(name = "anyObject_id")
+ private JPAAnyObject rightEnd;
@Override
public RelationshipType getType() {
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
index fd1593701bf..c2e50be621d 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAUser.java
@@ -23,6 +23,7 @@
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.EntityListeners;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.FetchType;
@@ -33,12 +34,14 @@
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
+import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.Optional;
import org.apache.syncope.common.keymaster.client.api.ConfParamOps;
import org.apache.syncope.common.lib.types.CipherAlgorithm;
@@ -67,6 +70,7 @@
@Entity
@Table(name = JPAUser.TABLE)
+@EntityListeners({ JSONUserListener.class })
@Cacheable
public class JPAUser
extends AbstractGroupableRelatable
@@ -93,9 +97,10 @@ public class JPAUser
@UniqueConstraint(columnNames = { "user_id", "role_id" }))
protected List roles = new ArrayList<>();
- @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
- @Valid
- protected List plainAttrs = new ArrayList<>();
+ private String plainAttrs;
+
+ @Transient
+ private final List plainAttrsList = new ArrayList<>();
@Lob
protected String token;
@@ -254,16 +259,33 @@ public boolean canDecodeSecrets() {
}
@Override
- public boolean add(final UPlainAttr attr) {
- checkType(attr, JPAUPlainAttr.class);
- return plainAttrs.add((JPAUPlainAttr) attr);
+ public List extends UPlainAttr> getPlainAttrsList() {
+ return plainAttrsList;
}
@Override
- protected List extends UPlainAttr> internalGetPlainAttrs() {
+ public String getPlainAttrsJSON() {
return plainAttrs;
}
+ @Override
+ public void setPlainAttrsJSON(final String plainAttrs) {
+ this.plainAttrs = plainAttrs;
+ }
+
+ @Override
+ public boolean add(final UPlainAttr attr) {
+ checkType(attr, JSONUPlainAttr.class);
+ return plainAttrsList.add((JSONUPlainAttr) attr);
+ }
+
+ @Override
+ public boolean remove(final UPlainAttr attr) {
+ checkType(attr, JSONUPlainAttr.class);
+ return plainAttrsList.removeIf(jsonAttr -> jsonAttr.getSchemaKey().equals(attr.getSchema().getKey())
+ && Objects.equals(jsonAttr.getMembershipKey(), attr.getMembershipKey()));
+ }
+
@Override
public void generateToken(final int tokenLength, final int tokenExpireTime) {
this.token = SecureRandomUtils.generateRandomPassword(tokenLength);
@@ -451,6 +473,8 @@ public boolean add(final UMembership membership) {
@Override
public boolean remove(final UMembership membership) {
checkType(membership, JPAUMembership.class);
+ plainAttrsList.removeIf(attr -> attr.getMembershipKey() != null
+ && attr.getMembershipKey().equals(membership.getKey()));
return this.memberships.remove((JPAUMembership) membership);
}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttr.java
similarity index 62%
rename from core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttr.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttr.java
index 6152ea25429..e0cfebfb774 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPALAPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttr.java
@@ -18,55 +18,43 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.user;
-import jakarta.persistence.CascadeType;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-import jakarta.validation.Valid;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
-import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-@Entity
-@Table(name = JPALAPlainAttr.TABLE)
-public class JPALAPlainAttr extends AbstractPlainAttr implements LAPlainAttr {
+public class JSONLAPlainAttr extends AbstractPlainAttr implements LAPlainAttr {
private static final long serialVersionUID = 7827533741035423694L;
- public static final String TABLE = "LAPlainAttr";
-
/**
* The owner of this attribute.
*/
- @ManyToOne(fetch = FetchType.EAGER)
+ @JsonIgnore
private JPAUser owner;
- @ManyToOne(fetch = FetchType.EAGER)
+ @JsonIgnore
private JPALinkedAccount account;
/**
* Values of this attribute (if schema is not UNIQUE).
*/
- @OneToMany(cascade = CascadeType.MERGE, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private List values = new ArrayList<>();
+ private List values = new ArrayList<>();
/**
* Value of this attribute (if schema is UNIQUE).
*/
- @OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "attribute")
- @Valid
- private JPALAPlainAttrUniqueValue uniqueValue;
+ @JsonProperty
+ private JSONLAPlainAttrUniqueValue uniqueValue;
@Override
public User getOwner() {
@@ -75,7 +63,6 @@ public User getOwner() {
@Override
public void setOwner(final User owner) {
- checkType(owner, JPAUser.class);
this.owner = (JPAUser) owner;
}
@@ -86,14 +73,12 @@ public LinkedAccount getAccount() {
@Override
public void setAccount(final LinkedAccount account) {
- checkType(account, JPALinkedAccount.class);
this.account = (JPALinkedAccount) account;
}
@Override
protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPALAPlainAttrValue.class);
- return values.add((JPALAPlainAttrValue) attrValue);
+ return values.add((JSONLAPlainAttrValue) attrValue);
}
@Override
@@ -102,13 +87,43 @@ public List extends LAPlainAttrValue> getValues() {
}
@Override
- public LAPlainAttrUniqueValue getUniqueValue() {
+ public JSONLAPlainAttrUniqueValue getUniqueValue() {
return uniqueValue;
}
+ @JsonIgnore
@Override
public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPALAPlainAttrUniqueValue.class);
- this.uniqueValue = (JPALAPlainAttrUniqueValue) uniqueValue;
+ this.uniqueValue = (JSONLAPlainAttrUniqueValue) uniqueValue;
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().
+ appendSuper(super.hashCode()).
+ append(account).
+ append(values).
+ append(uniqueValue).
+ build();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final JSONLAPlainAttr other = (JSONLAPlainAttr) obj;
+ return new EqualsBuilder().
+ appendSuper(super.equals(obj)).
+ append(account, other.account).
+ append(values, other.values).
+ append(uniqueValue, other.uniqueValue).
+ build();
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrUniqueValue.java
similarity index 76%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrUniqueValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrUniqueValue.java
index eba787c6e98..2d408e37919 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrUniqueValue.java
@@ -19,22 +19,18 @@
package org.apache.syncope.core.persistence.jpa.entity.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONLAPlainAttrUniqueValue extends AbstractPlainAttrValue implements LAPlainAttrUniqueValue {
+public class JSONLAPlainAttrUniqueValue extends AbstractPlainAttrValue implements LAPlainAttrUniqueValue {
- private static final long serialVersionUID = 4005916774320343497L;
+ private static final long serialVersionUID = 1200617357906733442L;
@JsonIgnore
- private JPAJSONLAPlainAttr attr;
+ private JSONLAPlainAttr attr;
@Override
public LAPlainAttr getAttr() {
@@ -43,8 +39,7 @@ public LAPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONLAPlainAttr.class);
- this.attr = (JPAJSONLAPlainAttr) attr;
+ this.attr = (JSONLAPlainAttr) attr;
}
@JsonIgnore
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrValue.java
similarity index 72%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrValue.java
index 7a3c299bf4d..4e592bdbb45 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLAPlainAttrValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLAPlainAttrValue.java
@@ -19,21 +19,17 @@
package org.apache.syncope.core.persistence.jpa.entity.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONLAPlainAttrValue extends AbstractPlainAttrValue implements LAPlainAttrValue {
+public class JSONLAPlainAttrValue extends AbstractPlainAttrValue implements LAPlainAttrValue {
- private static final long serialVersionUID = -7049546275798013346L;
+ private static final long serialVersionUID = 6237793413044604262L;
@JsonIgnore
- private JPAJSONLAPlainAttr attr;
+ private JSONLAPlainAttr attr;
@Override
public LAPlainAttr getAttr() {
@@ -42,7 +38,6 @@ public LAPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONLAPlainAttr.class);
- this.attr = (JPAJSONLAPlainAttr) attr;
+ this.attr = (JSONLAPlainAttr) attr;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLinkedAccountListener.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLinkedAccountListener.java
similarity index 65%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLinkedAccountListener.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLinkedAccountListener.java
index 2ddf7ee9a7c..ba2a1924762 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONLinkedAccountListener.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONLinkedAccountListener.java
@@ -25,36 +25,36 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.JSONLAPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.entity.JPAJSONEntityListener;
+import org.apache.syncope.core.persistence.jpa.entity.JSONEntityListener;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-public class JPAJSONLinkedAccountListener extends JPAJSONEntityListener {
+public class JSONLinkedAccountListener extends JSONEntityListener {
- protected static final TypeReference> TYPEREF =
- new TypeReference>() {
+ protected static final TypeReference> TYPEREF =
+ new TypeReference>() {
};
@Override
- protected List extends JSONLAPlainAttr> getAttrs(final String plainAttrsJSON) {
+ protected List extends LAPlainAttr> getAttrs(final String plainAttrsJSON) {
return POJOHelper.deserialize(plainAttrsJSON, TYPEREF);
}
@PostLoad
- public void read(final JPAJSONLinkedAccount account) {
- super.json2list(account, false);
+ public void read(final JPALinkedAccount linkedAccount) {
+ super.json2list(linkedAccount, false);
}
@PrePersist
@PreUpdate
- public void save(final JPAJSONLinkedAccount account) {
- super.list2json(account);
+ public void save(final JPALinkedAccount linkedAccount) {
+ super.list2json(linkedAccount);
}
@PostPersist
@PostUpdate
- public void readAfterSave(final JPAJSONLinkedAccount account) {
- super.json2list(account, true);
+ public void readAfterSave(final JPALinkedAccount linkedAccount) {
+ super.json2list(linkedAccount, true);
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttr.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttr.java
similarity index 62%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttr.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttr.java
index 18d10951250..9c503676f63 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttr.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttr.java
@@ -18,9 +18,8 @@
*/
package org.apache.syncope.core.persistence.jpa.entity.user;
+import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.ArrayList;
@@ -28,34 +27,22 @@
import java.util.Optional;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.JSONPlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.user.UMembership;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.user.User;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttr;
-import org.apache.syncope.core.persistence.jpa.entity.JPAPlainSchema;
import org.apache.syncope.core.spring.ApplicationContextProvider;
-@JsonIgnoreProperties("valuesAsStrings")
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class JPAJSONUPlainAttr extends AbstractPlainAttr implements UPlainAttr, JSONPlainAttr {
+public class JSONUPlainAttr extends AbstractPlainAttr implements UPlainAttr {
- private static final long serialVersionUID = 806271775349587902L;
+ private static final long serialVersionUID = 8066058729580952116L;
- /**
- * The owner of this attribute.
- */
@JsonIgnore
- private JPAJSONUser owner;
-
- @JsonProperty
- private String schema;
+ private User owner;
/**
* The membership of this attribute; might be {@code NULL} if this attribute is not related to a membership.
@@ -66,13 +53,13 @@ public class JPAJSONUPlainAttr extends AbstractPlainAttr implements UPlain
/**
* Values of this attribute (if schema is not UNIQUE).
*/
- private final List values = new ArrayList<>();
+ private List values = new ArrayList<>();
/**
* Value of this attribute (if schema is UNIQUE).
*/
@JsonProperty
- private JPAJSONUPlainAttrUniqueValue uniqueValue;
+ private JSONUPlainAttrUniqueValue uniqueValue;
@Override
public User getOwner() {
@@ -81,55 +68,26 @@ public User getOwner() {
@Override
public void setOwner(final User owner) {
- checkType(owner, JPAJSONUser.class);
- this.owner = (JPAJSONUser) owner;
+ this.owner = (JPAUser) owner;
}
@JsonIgnore
@Override
- public String getSchemaKey() {
- return schema;
+ public UMembership getMembership() {
+ return ApplicationContextProvider.getBeanFactory().getBean(UserDAO.class).findMembership(membership);
}
- @JsonIgnore
@Override
- public JPAPlainSchema getSchema() {
- return Optional.ofNullable(schema).
- flatMap(s -> ApplicationContextProvider.getBeanFactory().getBean(PlainSchemaDAO.class).findById(s)).
- map(JPAPlainSchema.class::cast).
- orElse(null);
+ public void setMembership(final UMembership membership) {
+ this.membership = Optional.ofNullable(membership).map(UMembership::getKey).orElse(null);
}
+ @JsonGetter("membership")
@Override
- public void setSchema(final PlainSchema schema) {
- if (schema != null) {
- this.schema = schema.getKey();
- }
- }
-
- @JsonSetter("schema")
- public void setSchema(final String schema) {
- this.schema = schema;
- }
-
- @JsonIgnore
public String getMembershipKey() {
return membership;
}
- @JsonIgnore
- @Override
- public UMembership getMembership() {
- return ApplicationContextProvider.getBeanFactory().getBean(UserDAO.class).findMembership(membership);
- }
-
- @Override
- public void setMembership(final UMembership membership) {
- if (membership != null) {
- this.membership = membership.getKey();
- }
- }
-
@JsonSetter("membership")
public void setMembership(final String membership) {
this.membership = membership;
@@ -137,13 +95,7 @@ public void setMembership(final String membership) {
@Override
protected boolean addForMultiValue(final PlainAttrValue attrValue) {
- checkType(attrValue, JPAJSONUPlainAttrValue.class);
- return values.add((JPAJSONUPlainAttrValue) attrValue);
- }
-
- @Override
- public boolean add(final PlainAttrValue value) {
- return addForMultiValue(value);
+ return values.add((JSONUPlainAttrValue) attrValue);
}
@Override
@@ -152,21 +104,20 @@ public List extends UPlainAttrValue> getValues() {
}
@Override
- public JPAJSONUPlainAttrUniqueValue getUniqueValue() {
+ public JSONUPlainAttrUniqueValue getUniqueValue() {
return uniqueValue;
}
@JsonIgnore
@Override
public void setUniqueValue(final PlainAttrUniqueValue uniqueValue) {
- checkType(uniqueValue, JPAJSONUPlainAttrUniqueValue.class);
- this.uniqueValue = (JPAJSONUPlainAttrUniqueValue) uniqueValue;
+ this.uniqueValue = (JSONUPlainAttrUniqueValue) uniqueValue;
}
@Override
public int hashCode() {
return new HashCodeBuilder().
- append(schema).
+ appendSuper(super.hashCode()).
append(membership).
append(values).
append(uniqueValue).
@@ -184,9 +135,9 @@ public boolean equals(final Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
- final JPAJSONUPlainAttr other = (JPAJSONUPlainAttr) obj;
+ final JSONUPlainAttr other = (JSONUPlainAttr) obj;
return new EqualsBuilder().
- append(schema, other.schema).
+ appendSuper(super.equals(obj)).
append(membership, other.membership).
append(values, other.values).
append(uniqueValue, other.uniqueValue).
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrUniqueValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrUniqueValue.java
similarity index 76%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrUniqueValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrUniqueValue.java
index ab4a8f42ba2..5a825c9c711 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrUniqueValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrUniqueValue.java
@@ -19,22 +19,18 @@
package org.apache.syncope.core.persistence.jpa.entity.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrUniqueValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONUPlainAttrUniqueValue extends AbstractPlainAttrValue implements UPlainAttrUniqueValue {
+public class JSONUPlainAttrUniqueValue extends AbstractPlainAttrValue implements UPlainAttrUniqueValue {
- private static final long serialVersionUID = -4053996864791245312L;
+ private static final long serialVersionUID = 4681561795607192855L;
@JsonIgnore
- private JPAJSONUPlainAttr attr;
+ private JSONUPlainAttr attr;
@Override
public UPlainAttr getAttr() {
@@ -43,8 +39,7 @@ public UPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONUPlainAttr.class);
- this.attr = (JPAJSONUPlainAttr) attr;
+ this.attr = (JSONUPlainAttr) attr;
}
@JsonIgnore
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrValue.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrValue.java
similarity index 73%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrValue.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrValue.java
index 4a4415b1152..c9dac6988c6 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUPlainAttrValue.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUPlainAttrValue.java
@@ -19,21 +19,17 @@
package org.apache.syncope.core.persistence.jpa.entity.user;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
import org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue;
-@JsonIgnoreProperties({ "valueAsString", "value" })
-@JsonInclude(JsonInclude.Include.NON_NULL)
-public class JPAJSONUPlainAttrValue extends AbstractPlainAttrValue implements UPlainAttrValue {
+public class JSONUPlainAttrValue extends AbstractPlainAttrValue implements UPlainAttrValue {
- private static final long serialVersionUID = 1832825176101443555L;
+ private static final long serialVersionUID = -766808291128424707L;
@JsonIgnore
- private JPAJSONUPlainAttr attr;
+ private JSONUPlainAttr attr;
@Override
public UPlainAttr getAttr() {
@@ -42,7 +38,6 @@ public UPlainAttr getAttr() {
@Override
public void setAttr(final PlainAttr> attr) {
- checkType(attr, JPAJSONUPlainAttr.class);
- this.attr = (JPAJSONUPlainAttr) attr;
+ this.attr = (JSONUPlainAttr) attr;
}
}
diff --git a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUserListener.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUserListener.java
similarity index 72%
rename from core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUserListener.java
rename to core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUserListener.java
index 710944b7be8..9bfc856d961 100644
--- a/core/persistence-jpa-json/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JPAJSONUserListener.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/entity/user/JSONUserListener.java
@@ -25,36 +25,36 @@
import jakarta.persistence.PrePersist;
import jakarta.persistence.PreUpdate;
import java.util.List;
-import org.apache.syncope.core.persistence.api.entity.JSONPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.persistence.jpa.entity.JPAJSONEntityListener;
+import org.apache.syncope.core.persistence.jpa.entity.JSONEntityListener;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
-public class JPAJSONUserListener extends JPAJSONEntityListener {
+public class JSONUserListener extends JSONEntityListener {
- protected static final TypeReference> TYPEREF =
- new TypeReference>() {
+ protected static final TypeReference> TYPEREF =
+ new TypeReference>() {
};
@Override
- protected List extends JSONPlainAttr> getAttrs(final String plainAttrsJSON) {
+ protected List extends UPlainAttr> getAttrs(final String plainAttrsJSON) {
return POJOHelper.deserialize(plainAttrsJSON, TYPEREF);
}
@PostLoad
- public void read(final JPAJSONUser user) {
+ public void read(final JPAUser user) {
super.json2list(user, false);
}
@PrePersist
@PreUpdate
- public void save(final JPAJSONUser user) {
+ public void save(final JPAUser user) {
super.list2json(user);
}
@PostPersist
@PostUpdate
- public void readAfterSave(final JPAJSONUser user) {
+ public void readAfterSave(final JPAUser user) {
super.json2list(user, true);
}
}
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainRoutingEntityManagerFactory.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainRoutingEntityManagerFactory.java
index dceb3ce314d..2c39769c2c2 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainRoutingEntityManagerFactory.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/spring/DomainRoutingEntityManagerFactory.java
@@ -28,16 +28,11 @@
import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.metamodel.Metamodel;
import java.io.Closeable;
-import java.util.Collection;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import javax.sql.DataSource;
-import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
-import org.apache.openjpa.jdbc.meta.MappingRepository;
-import org.apache.openjpa.jdbc.meta.MappingTool;
-import org.apache.openjpa.lib.conf.Configurations;
-import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
import org.apache.syncope.common.keymaster.client.api.model.JPADomain;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.core.persistence.jpa.PersistenceProperties;
@@ -59,6 +54,22 @@ public DomainRoutingEntityManagerFactory(final CommonEntityManagerFactoryConf co
protected final Map delegates = new ConcurrentHashMap<>();
+ protected void addToJpaPropertyMap(
+ final DomainEntityManagerFactoryBean emf,
+ final OpenJpaVendorAdapter vendorAdapter,
+ final String dbSchema,
+ final String orm,
+ final String metadataFactory) {
+
+ emf.getJpaPropertyMap().putAll(vendorAdapter.getJpaPropertyMap());
+
+ Optional.ofNullable(dbSchema).
+ ifPresent(s -> emf.getJpaPropertyMap().put("openjpa.jdbc.Schema", s));
+
+ Optional.ofNullable(metadataFactory).
+ ifPresent(m -> emf.getJpaPropertyMap().put("openjpa.MetaDataFactory", m.replace("##orm##", orm)));
+ }
+
public void master(
final PersistenceProperties props,
final JndiObjectFactoryBean dataSource) {
@@ -69,19 +80,20 @@ public void master(
vendorAdapter.setDatabasePlatform(props.getDomain().get(0).getDatabasePlatform());
DomainEntityManagerFactoryBean emf = new DomainEntityManagerFactoryBean();
- emf.setMappingResources(props.getDomain().get(0).getOrm());
emf.setPersistenceUnitName(SyncopeConstants.MASTER_DOMAIN);
+ emf.setMappingResources(props.getDomain().get(0).getOrm());
emf.setDataSource(Objects.requireNonNull((DataSource) dataSource.getObject()));
emf.setJpaVendorAdapter(vendorAdapter);
emf.setCommonEntityManagerFactoryConf(commonEMFConf);
emf.setConnectorManagerRemoteCommitListener(
new ConnectorManagerRemoteCommitListener(SyncopeConstants.MASTER_DOMAIN));
- if (props.getMetaDataFactory() != null) {
- emf.setJpaPropertyMap(Map.of(
- "openjpa.MetaDataFactory",
- props.getMetaDataFactory().replace("##orm##", props.getDomain().get(0).getOrm())));
- }
+ addToJpaPropertyMap(
+ emf,
+ vendorAdapter,
+ props.getDomain().get(0).getDbSchema(),
+ props.getDomain().get(0).getOrm(),
+ props.getMetaDataFactory());
emf.afterPropertiesSet();
@@ -99,18 +111,14 @@ public void domain(
vendorAdapter.setDatabasePlatform(domain.getDatabasePlatform());
DomainEntityManagerFactoryBean emf = new DomainEntityManagerFactoryBean();
- emf.setMappingResources(domain.getOrm());
emf.setPersistenceUnitName(domain.getKey());
+ emf.setMappingResources(domain.getOrm());
emf.setDataSource(dataSource);
emf.setJpaVendorAdapter(vendorAdapter);
emf.setCommonEntityManagerFactoryConf(commonEMFConf);
emf.setConnectorManagerRemoteCommitListener(new ConnectorManagerRemoteCommitListener(domain.getKey()));
- if (metadataFactory != null) {
- emf.setJpaPropertyMap(Map.of(
- "openjpa.MetaDataFactory",
- metadataFactory.replace("##orm##", domain.getOrm())));
- }
+ addToJpaPropertyMap(emf, vendorAdapter, domain.getDbSchema(), domain.getOrm(), metadataFactory);
emf.afterPropertiesSet();
@@ -128,25 +136,6 @@ protected EntityManagerFactory delegate() {
});
}
- public void initJPASchema() {
- OpenJPAEntityManagerFactorySPI emfspi = delegate().unwrap(OpenJPAEntityManagerFactorySPI.class);
- JDBCConfiguration jdbcConf = (JDBCConfiguration) emfspi.getConfiguration();
-
- MappingRepository mappingRepo = jdbcConf.getMappingRepositoryInstance();
- Collection> classes = mappingRepo.loadPersistentTypes(false, getClass().getClassLoader());
-
- String action = "buildSchema(ForeignKeys=true)";
- String props = Configurations.getProperties(action);
- action = Configurations.getClassName(action);
- MappingTool mappingTool = new MappingTool(jdbcConf, action, false, getClass().getClassLoader());
- Configurations.configureInstance(mappingTool, jdbcConf, props, "SynchronizeMappings");
-
- // initialize the schema
- classes.forEach(mappingTool::run);
-
- mappingTool.record();
- }
-
@Override
public EntityManager createEntityManager() {
return delegate().createEntityManager();
diff --git a/core/persistence-jpa-json/src/main/resources/pgjsonb/indexes.xml b/core/persistence-jpa/src/main/resources/META-INF/indexes.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/pgjsonb/indexes.xml
rename to core/persistence-jpa/src/main/resources/META-INF/indexes.xml
diff --git a/core/persistence-jpa-json/src/main/resources/majson/indexes.xml b/core/persistence-jpa/src/main/resources/META-INF/mariadb/indexes.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/majson/indexes.xml
rename to core/persistence-jpa/src/main/resources/META-INF/mariadb/indexes.xml
diff --git a/core/persistence-jpa/src/main/resources/META-INF/mariadb/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/mariadb/spring-orm.xml
new file mode 100644
index 00000000000..408169e456b
--- /dev/null
+++ b/core/persistence-jpa/src/main/resources/META-INF/mariadb/spring-orm.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/persistence-jpa-json/src/main/resources/majson/views.xml b/core/persistence-jpa/src/main/resources/META-INF/mariadb/views.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/majson/views.xml
rename to core/persistence-jpa/src/main/resources/META-INF/mariadb/views.xml
diff --git a/core/persistence-jpa-json/src/main/resources/myjson/indexes.xml b/core/persistence-jpa/src/main/resources/META-INF/mysql/indexes.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/myjson/indexes.xml
rename to core/persistence-jpa/src/main/resources/META-INF/mysql/indexes.xml
diff --git a/core/persistence-jpa/src/main/resources/META-INF/mysql/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/mysql/spring-orm.xml
new file mode 100644
index 00000000000..408169e456b
--- /dev/null
+++ b/core/persistence-jpa/src/main/resources/META-INF/mysql/spring-orm.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/persistence-jpa-json/src/main/resources/myjson/views.xml b/core/persistence-jpa/src/main/resources/META-INF/mysql/views.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/myjson/views.xml
rename to core/persistence-jpa/src/main/resources/META-INF/mysql/views.xml
diff --git a/core/persistence-jpa-json/src/main/resources/ojson/indexes.xml b/core/persistence-jpa/src/main/resources/META-INF/oracle/indexes.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/ojson/indexes.xml
rename to core/persistence-jpa/src/main/resources/META-INF/oracle/indexes.xml
diff --git a/core/persistence-jpa/src/main/resources/META-INF/oracle/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/oracle/spring-orm.xml
new file mode 100644
index 00000000000..ec51dcfa7e1
--- /dev/null
+++ b/core/persistence-jpa/src/main/resources/META-INF/oracle/spring-orm.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/persistence-jpa-json/src/main/resources/ojson/views.xml b/core/persistence-jpa/src/main/resources/META-INF/oracle/views.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/ojson/views.xml
rename to core/persistence-jpa/src/main/resources/META-INF/oracle/views.xml
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
deleted file mode 100644
index 836556d2f84..00000000000
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-oracle.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
deleted file mode 100644
index e51b9b1da7b..00000000000
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm-sqlserver.xml
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- booleanValue
- dateValue
- stringValue
- doubleValue
- longValue
- schema_id
-
-
-
-
-
-
- booleanValue
- dateValue
- stringValue
- doubleValue
- longValue
- schema_id
-
-
-
-
-
-
- booleanValue
- dateValue
- stringValue
- doubleValue
- longValue
- schema_id
-
-
-
-
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
index 1602fecee37..1ae2eed60dd 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring-orm.xml
@@ -33,142 +33,40 @@ under the License.
-
-
+
+
-
-
+
+
+
+
-
-
+
+
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- booleanValue
- schema_id
-
-
- dateValue
- schema_id
-
-
- stringValue
- schema_id
-
-
- doubleValue
- schema_id
-
-
- longValue
- schema_id
-
-
-
-
-
-
- booleanValue
- schema_id
-
-
- dateValue
- schema_id
-
-
- stringValue
- schema_id
-
-
- doubleValue
- schema_id
-
-
- longValue
- schema_id
-
-
-
-
-
-
- booleanValue
- schema_id
-
-
- dateValue
- schema_id
-
-
- stringValue
- schema_id
-
-
- doubleValue
- schema_id
-
-
- longValue
- schema_id
-
-
-
diff --git a/core/persistence-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/core/persistence-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 9465bce8be3..0a01ae2b4d6 100644
--- a/core/persistence-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/core/persistence-jpa/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -16,3 +16,7 @@
# under the License.
org.apache.syncope.core.persistence.jpa.PersistenceContext
org.apache.syncope.core.persistence.jpa.MasterDomain
+org.apache.syncope.core.persistence.jpa.PGPersistenceContext
+org.apache.syncope.core.persistence.jpa.MySQLPersistenceContext
+org.apache.syncope.core.persistence.jpa.MariaDBPersistenceContext
+org.apache.syncope.core.persistence.jpa.OraclePersistenceContext
diff --git a/core/persistence-jpa-json/src/main/resources/pgjsonb/views.xml b/core/persistence-jpa/src/main/resources/META-INF/views.xml
similarity index 100%
rename from core/persistence-jpa-json/src/main/resources/pgjsonb/views.xml
rename to core/persistence-jpa/src/main/resources/META-INF/views.xml
diff --git a/core/persistence-jpa/src/main/resources/domains/MasterContent.xml b/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
index eef05108cf7..256e121b740 100644
--- a/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
+++ b/core/persistence-jpa/src/main/resources/domains/MasterContent.xml
@@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
@@ -18,7 +18,7 @@ specific language governing permissions and limitations
under the License.
-->
-
+
@@ -28,13 +28,14 @@ under the License.
+
-
+
diff --git a/core/persistence-jpa/src/main/resources/indexes.xml b/core/persistence-jpa/src/main/resources/indexes.xml
deleted file mode 100644
index 496730805df..00000000000
--- a/core/persistence-jpa/src/main/resources/indexes.xml
+++ /dev/null
@@ -1,101 +0,0 @@
-
-
-
-
- Additional indexes (in respect to JPA's)
-
- CREATE INDEX Realm_parent_id ON Realm(parent_id)
-
- CREATE INDEX SyncopeUser_realm_id ON SyncopeUser(realm_id)
- CREATE UNIQUE INDEX SyncopeUser_username ON SyncopeUser(username)
-
- CREATE INDEX SyncopeGroup_realm_id ON SyncopeGroup(realm_id)
- CREATE UNIQUE INDEX SyncopeGroup_name ON SyncopeGroup(name)
-
- CREATE INDEX AnyObject_realm_id ON AnyObject(realm_id)
- CREATE UNIQUE INDEX AnyObject_name ON AnyObject(type_id,name)
-
- CREATE INDEX UDynGroupMembers_any_id ON UDynGroupMembers(any_id)
- CREATE INDEX UDynGroupMembers_group_id ON UDynGroupMembers(group_id)
- CREATE INDEX ADynGroupMembers_any_id ON ADynGroupMembers(any_id)
- CREATE INDEX ADynGroupMembers_group_id ON ADynGroupMembers(group_id)
-
- CREATE INDEX DynRoleMembers_any_id ON DynRoleMembers(any_id)
- CREATE INDEX DynRoleMembers_role_id ON DynRoleMembers(role_id)
-
- CREATE INDEX DynRealmMembers_any_id ON DynRealmMembers(any_id)
- CREATE INDEX DynRealmMembers_dynRealm_id ON DynRealmMembers(dynRealm_id)
-
- CREATE INDEX UAttrValue_stringvalueIndex ON UPlainAttrValue(stringvalue)
- CREATE INDEX UAttrValue_datevalueIndex ON UPlainAttrValue(datevalue)
- CREATE INDEX UAttrValue_longvalueIndex ON UPlainAttrValue(longvalue)
- CREATE INDEX UAttrValue_doublevalueIndex ON UPlainAttrValue(doublevalue)
- CREATE INDEX UAttrValue_booleanvalueIndex ON UPlainAttrValue(booleanvalue)
-
- CREATE INDEX AAttrValue_stringvalueIndex ON APlainAttrValue(stringvalue)
- CREATE INDEX AAttrValue_datevalueIndex ON APlainAttrValue(datevalue)
- CREATE INDEX AAttrValue_longvalueIndex ON APlainAttrValue(longvalue)
- CREATE INDEX AAttrValue_doublevalueIndex ON APlainAttrValue(doublevalue)
- CREATE INDEX AAttrValue_booleanvalueIndex ON APlainAttrValue(booleanvalue)
-
- CREATE INDEX GAttrValue_stringvalueIndex ON GPlainAttrValue(stringvalue)
- CREATE INDEX GAttrValue_datevalueIndex ON GPlainAttrValue(datevalue)
- CREATE INDEX GAttrValue_longvalueIndex ON GPlainAttrValue(longvalue)
- CREATE INDEX GAttrValue_doublevalueIndex ON GPlainAttrValue(doublevalue)
- CREATE INDEX GAttrValue_booleanvalueIndex ON GPlainAttrValue(booleanvalue)
-
- CREATE INDEX UMembership_GroupIndex ON UMembership(group_id)
- CREATE INDEX UMembership_UserIndex ON UMembership(user_id)
- CREATE INDEX AMembership_GroupIndex ON AMembership(group_id)
- CREATE INDEX AMembership_AnyObjectIndex ON AMembership(anyObject_id)
-
- CREATE INDEX URelationship_RightIndex ON URelationship(anyObject_id)
- CREATE INDEX URelationship_LeftIndex ON URelationship(user_id)
- CREATE INDEX ARelationship_RightIndex ON ARelationship(right_anyObject_id)
- CREATE INDEX ARelationship_AnyObjectIndex ON ARelationship(left_anyObject_id)
-
- CREATE INDEX UPlainAttrValue_attrIndex on UPlainAttrValue(attribute_id)
- CREATE INDEX UPAttrUniqueValue_attrIndex on UPlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX GPlainAttrValue_attrIndex on GPlainAttrValue(attribute_id)
- CREATE INDEX GPAttrUniqueValue_attrIndex on GPlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX APlainAttrValue_attrIndex on APlainAttrValue(attribute_id)
- CREATE INDEX APAttrUniqueValue_attrIndex on APlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX UPlainAttr_owner_Index on UPlainAttr(owner_id)
- CREATE INDEX UPlainAttr_schema_Index on UPlainAttr(schema_id)
- CREATE INDEX UPlainAttr_membership_Index on UPlainAttr(membership_id)
-
- CREATE INDEX GPlainAttr_owner_Index on GPlainAttr(owner_id)
- CREATE INDEX GPlainAttr_schema_Index on GPlainAttr(schema_id)
-
- CREATE INDEX APlainAttr_owner_Index on APlainAttr(owner_id)
- CREATE INDEX APlainAttr_schema_Index on APlainAttr(schema_id)
- CREATE INDEX APlainAttr_membership_Index on APlainAttr(membership_id)
-
- CREATE INDEX Task_executedIndex ON NotificationTask(executed)
- CREATE INDEX TaskExec1_TaskIdIndex ON PropagationTaskExec(task_id)
- CREATE INDEX TaskExec2_TaskIdIndex ON PullTaskExec(task_id)
- CREATE INDEX TaskExec3_TaskIdIndex ON PushTaskExec(task_id)
- CREATE INDEX TaskExec4_TaskIdIndex ON NotificationTaskExec(task_id)
- CREATE INDEX TaskExec5_TaskIdIndex ON SchedTaskExec(task_id)
- CREATE INDEX ATPullTask_PullTaskIndex ON AnyTemplatePullTask(pullTask_id)
-
diff --git a/core/persistence-jpa/src/main/resources/oracle_indexes.xml b/core/persistence-jpa/src/main/resources/oracle_indexes.xml
deleted file mode 100644
index 91b43e44676..00000000000
--- a/core/persistence-jpa/src/main/resources/oracle_indexes.xml
+++ /dev/null
@@ -1,105 +0,0 @@
-
-
-
-
- Additional indexes (in respect to JPA's)
-
- CREATE INDEX Realm_parent_id ON Realm(parent_id)
-
- CREATE INDEX SyncopeUser_realm_id ON SyncopeUser(realm_id)
- CREATE INDEX SyncopeUser_lower_username ON SyncopeUser(LOWER(username))
-
- CREATE INDEX SyncopeGroup_realm_id ON SyncopeGroup(realm_id)
- CREATE INDEX SyncopeGroup_lower_name ON SyncopeGroup(LOWER(name))
-
- CREATE INDEX AnyObject_realm_id ON AnyObject(realm_id)
- CREATE INDEX AnyObject_lower_name ON AnyObject(type_id,LOWER(name))
-
- CREATE UNIQUE INDEX APlainAttrUniqueValue_U on APlainAttrUniqueValue(booleanValue, dateValue, stringValue, doubleValue, longValue, schema_id)
- CREATE UNIQUE INDEX UPlainAttrUniqueValue_U on UPlainAttrUniqueValue(booleanValue, dateValue, stringValue, doubleValue, longValue, schema_id)
- CREATE UNIQUE INDEX GPlainAttrUniqueValue_U on GPlainAttrUniqueValue(booleanValue, dateValue, stringValue, doubleValue, longValue, schema_id)
-
- CREATE INDEX UDynGroupMembers_any_id ON UDynGroupMembers(any_id)
- CREATE INDEX UDynGroupMembers_group_id ON UDynGroupMembers(group_id)
- CREATE INDEX ADynGroupMembers_any_id ON ADynGroupMembers(any_id)
- CREATE INDEX ADynGroupMembers_group_id ON ADynGroupMembers(group_id)
-
- CREATE INDEX DynRoleMembers_any_id ON DynRoleMembers(any_id)
- CREATE INDEX DynRoleMembers_role_id ON DynRoleMembers(role_id)
-
- CREATE INDEX DynRealmMembers_any_id ON DynRealmMembers(any_id)
- CREATE INDEX DynRealmMembers_dynRealm_id ON DynRealmMembers(dynRealm_id)
-
- CREATE INDEX UAttrValue_stringvalueIndex ON UPlainAttrValue(stringvalue)
- CREATE INDEX UAttrValue_datevalueIndex ON UPlainAttrValue(datevalue)
- CREATE INDEX UAttrValue_longvalueIndex ON UPlainAttrValue(longvalue)
- CREATE INDEX UAttrValue_doublevalueIndex ON UPlainAttrValue(doublevalue)
- CREATE INDEX UAttrValue_booleanvalueIndex ON UPlainAttrValue(booleanvalue)
-
- CREATE INDEX AAttrValue_stringvalueIndex ON APlainAttrValue(stringvalue)
- CREATE INDEX AAttrValue_datevalueIndex ON APlainAttrValue(datevalue)
- CREATE INDEX AAttrValue_longvalueIndex ON APlainAttrValue(longvalue)
- CREATE INDEX AAttrValue_doublevalueIndex ON APlainAttrValue(doublevalue)
- CREATE INDEX AAttrValue_booleanvalueIndex ON APlainAttrValue(booleanvalue)
-
- CREATE INDEX GAttrValue_stringvalueIndex ON GPlainAttrValue(stringvalue)
- CREATE INDEX GAttrValue_datevalueIndex ON GPlainAttrValue(datevalue)
- CREATE INDEX GAttrValue_longvalueIndex ON GPlainAttrValue(longvalue)
- CREATE INDEX GAttrValue_doublevalueIndex ON GPlainAttrValue(doublevalue)
- CREATE INDEX GAttrValue_booleanvalueIndex ON GPlainAttrValue(booleanvalue)
-
- CREATE INDEX UMembership_GroupIndex ON UMembership(group_id)
- CREATE INDEX UMembership_UserIndex ON UMembership(user_id)
- CREATE INDEX AMembership_GroupIndex ON AMembership(group_id)
- CREATE INDEX AMembership_AnyObjectIndex ON AMembership(anyObject_id)
-
- CREATE INDEX URelationship_RightIndex ON URelationship(anyObject_id)
- CREATE INDEX URelationship_LeftIndex ON URelationship(user_id)
- CREATE INDEX ARelationship_RightIndex ON ARelationship(right_anyObject_id)
- CREATE INDEX ARelationship_AnyObjectIndex ON ARelationship(left_anyObject_id)
-
- CREATE INDEX UPlainAttrValue_attrIndex on UPlainAttrValue(attribute_id)
- CREATE INDEX UPAttrUniqueValue_attrIndex on UPlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX GPlainAttrValue_attrIndex on GPlainAttrValue(attribute_id)
- CREATE INDEX GPAttrUniqueValue_attrIndex on GPlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX APlainAttrValue_attrIndex on APlainAttrValue(attribute_id)
- CREATE INDEX APAttrUniqueValue_attrIndex on APlainAttrUniqueValue(attribute_id)
-
- CREATE INDEX UPlainAttr_owner_Index on UPlainAttr(owner_id)
- CREATE INDEX UPlainAttr_schema_Index on UPlainAttr(schema_id)
- CREATE INDEX UPlainAttr_membership_Index on UPlainAttr(membership_id)
-
- CREATE INDEX GPlainAttr_owner_Index on GPlainAttr(owner_id)
- CREATE INDEX GPlainAttr_schema_Index on GPlainAttr(schema_id)
-
- CREATE INDEX APlainAttr_owner_Index on APlainAttr(owner_id)
- CREATE INDEX APlainAttr_schema_Index on APlainAttr(schema_id)
- CREATE INDEX APlainAttr_membership_Index on APlainAttr(membership_id)
-
- CREATE INDEX Task_executedIndex ON NotificationTask(executed)
- CREATE INDEX TaskExec1_TaskIdIndex ON PropagationTaskExec(task_id)
- CREATE INDEX TaskExec2_TaskIdIndex ON PullTaskExec(task_id)
- CREATE INDEX TaskExec3_TaskIdIndex ON PushTaskExec(task_id)
- CREATE INDEX TaskExec4_TaskIdIndex ON NotificationTaskExec(task_id)
- CREATE INDEX TaskExec5_TaskIdIndex ON SchedTaskExec(task_id)
- CREATE INDEX ATPullTask_PullTaskIndex ON AnyTemplatePullTask(pullTask_id)
-
diff --git a/core/persistence-jpa/src/main/resources/sqlserver_views.xml b/core/persistence-jpa/src/main/resources/sqlserver_views.xml
deleted file mode 100644
index 83dd7873a66..00000000000
--- a/core/persistence-jpa/src/main/resources/sqlserver_views.xml
+++ /dev/null
@@ -1,244 +0,0 @@
-
-
-
-
-
-
- CREATE TABLE UDynGroupMembers(
- any_id CHAR(36),
- group_id CHAR(36),
- UNIQUE(any_id, group_id))
-
-
- CREATE TABLE ADynGroupMembers(
- anyType_id VARCHAR(255),
- any_id CHAR(36),
- group_id CHAR(36),
- UNIQUE(anyType_id, any_id, group_id))
-
-
- CREATE TABLE DynRoleMembers(
- any_id CHAR(36),
- role_id VARCHAR(255),
- UNIQUE(any_id, role_id))
-
-
- CREATE TABLE DynRealmMembers(
- any_id CHAR(36),
- dynRealm_id VARCHAR(255),
- UNIQUE(any_id, dynRealm_id))
-
-
-
-
- CREATE VIEW user_search AS
-
- SELECT u.id as any_id, u.* FROM SyncopeUser u
-
-
- CREATE VIEW user_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM UPlainAttrUniqueValue uav, UPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW user_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM UPlainAttrValue uav, UPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW user_search_urelationship AS
-
- SELECT m.user_id AS any_id, m.anyObject_id AS right_any_id, m.type_id AS type
- FROM URelationship m
-
-
- CREATE VIEW user_search_umembership AS
-
- SELECT m.user_id AS any_id, g.id AS group_id, g.name AS group_name
- FROM UMembership m, SyncopeGroup g
- WHERE m.group_id = g.id
-
-
- CREATE VIEW user_search_role AS
-
- SELECT ss.user_id AS any_id, ss.role_id AS role_id
- FROM SyncopeUser_SyncopeRole ss
-
-
- CREATE VIEW user_search_priv AS
-
- SELECT ss.user_id AS any_id, sp.privilege_id AS privilege_id
- FROM SyncopeUser_SyncopeRole ss, SyncopeRole_Privilege sp
- WHERE ss.role_id = sp.role_id
-
-
- CREATE VIEW user_search_dynpriv AS
-
- SELECT any_id, privilege_id
- FROM DynRoleMembers drm, SyncopeRole_Privilege rp
- WHERE drm.role_id = rp.role_id
-
-
- CREATE VIEW user_search_auxClass AS
-
- SELECT st.user_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM SyncopeUser_AnyTypeClass st
-
-
- CREATE VIEW user_search_resource AS
-
- SELECT st.user_id AS any_id, st.resource_id AS resource_id
- FROM SyncopeUser_ExternalResource st
-
-
- CREATE VIEW user_search_group_res AS
-
- SELECT m.user_id AS any_id, st.resource_id AS resource_id
- FROM UMembership m, SyncopeGroup r, SyncopeGroup_ExternalResource st
- WHERE m.group_id = r.id AND st.group_id = r.id
-
-
-
-
- CREATE VIEW anyObject_search AS
-
- SELECT a.id as any_id, a.* FROM AnyObject a
-
-
- CREATE VIEW anyObject_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM APlainAttrUniqueValue uav, APlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW anyObject_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM APlainAttrValue uav, APlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW anyObject_search_arelationship AS
-
- SELECT m.left_anyObject_id AS any_id, m.right_anyObject_id AS right_any_id, m.type_id AS type
- FROM ARelationship m
-
-
- CREATE VIEW anyObject_search_amembership AS
-
- SELECT m.anyObject_id AS any_id, g.id AS group_id, g.name AS group_name
- FROM AMembership m, SyncopeGroup g
- WHERE m.group_id = g.id
-
-
- CREATE VIEW anyObject_search_auxClass AS
-
- SELECT st.anyObject_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM AnyObject_AnyTypeClass st
-
-
- CREATE VIEW anyObject_search_resource AS
-
- SELECT st.anyObject_id AS any_id, st.resource_id AS resource_id
- FROM AnyObject_ExternalResource st
-
-
- CREATE VIEW anyObject_search_group_res AS
-
- SELECT m.anyObject_id AS any_id, st.resource_id AS resource_id
- FROM AMembership m, SyncopeGroup r, SyncopeGroup_ExternalResource st
- WHERE m.group_id = r.id AND st.group_id = r.id
-
-
-
-
- CREATE VIEW group_search AS
-
- SELECT r.id as any_id, r.* FROM SyncopeGroup r
-
-
- CREATE VIEW group_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM GPlainAttrUniqueValue uav, GPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW group_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM GPlainAttrValue uav, GPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW group_search_auxClass AS
-
- SELECT st.group_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM SyncopeGroup_AnyTypeClass st
-
-
- CREATE VIEW group_search_resource AS
-
- SELECT st.group_id AS any_id, st.resource_id AS resource_id
- FROM SyncopeGroup_ExternalResource st
-
-
-
diff --git a/core/persistence-jpa/src/main/resources/views.xml b/core/persistence-jpa/src/main/resources/views.xml
deleted file mode 100644
index e242f0ff922..00000000000
--- a/core/persistence-jpa/src/main/resources/views.xml
+++ /dev/null
@@ -1,244 +0,0 @@
-
-
-
-
-
-
- CREATE TABLE UDynGroupMembers(
- any_id CHAR(36),
- group_id CHAR(36),
- UNIQUE(any_id, group_id))
-
-
- CREATE TABLE ADynGroupMembers(
- anyType_id VARCHAR(255),
- any_id CHAR(36),
- group_id CHAR(36),
- UNIQUE(anyType_id, any_id, group_id))
-
-
- CREATE TABLE DynRoleMembers(
- any_id CHAR(36),
- role_id VARCHAR(255),
- UNIQUE(any_id, role_id))
-
-
- CREATE TABLE DynRealmMembers(
- any_id CHAR(36),
- dynRealm_id VARCHAR(255),
- UNIQUE(any_id, dynRealm_id))
-
-
-
-
- CREATE VIEW user_search AS
-
- SELECT u.id as any_id, u.* FROM SyncopeUser u
-
-
- CREATE VIEW user_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM UPlainAttrUniqueValue uav, UPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW user_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM UPlainAttrValue uav, UPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW user_search_urelationship AS
-
- SELECT m.user_id AS any_id, m.anyObject_id AS right_any_id, m.type_id AS type
- FROM URelationship m
-
-
- CREATE VIEW user_search_umembership AS
-
- SELECT m.user_id AS any_id, g.id AS group_id, g.name AS group_name
- FROM UMembership m, SyncopeGroup g
- WHERE m.group_id = g.id
-
-
- CREATE VIEW user_search_role AS
-
- SELECT ss.user_id AS any_id, ss.role_id AS role_id
- FROM SyncopeUser_SyncopeRole ss
-
-
- CREATE VIEW user_search_priv AS
-
- SELECT ss.user_id AS any_id, sp.privilege_id AS privilege_id
- FROM SyncopeUser_SyncopeRole ss, SyncopeRole_Privilege sp
- WHERE ss.role_id = sp.role_id
-
-
- CREATE VIEW user_search_dynpriv AS
-
- SELECT any_id, privilege_id
- FROM DynRoleMembers drm, SyncopeRole_Privilege rp
- WHERE drm.role_id = rp.role_id
-
-
- CREATE VIEW user_search_auxClass AS
-
- SELECT st.user_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM SyncopeUser_AnyTypeClass st
-
-
- CREATE VIEW user_search_resource AS
-
- SELECT st.user_id AS any_id, st.resource_id AS resource_id
- FROM SyncopeUser_ExternalResource st
-
-
- CREATE VIEW user_search_group_res AS
-
- SELECT m.user_id AS any_id, st.resource_id AS resource_id
- FROM UMembership m, SyncopeGroup r, SyncopeGroup_ExternalResource st
- WHERE m.group_id = r.id AND st.group_id = r.id
-
-
-
-
- CREATE VIEW anyObject_search AS
-
- SELECT a.id as any_id, a.* FROM AnyObject a
-
-
- CREATE VIEW anyObject_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM APlainAttrUniqueValue uav, APlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW anyObject_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM APlainAttrValue uav, APlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW anyObject_search_arelationship AS
-
- SELECT m.left_anyObject_id AS any_id, m.right_anyObject_id AS right_any_id, m.type_id AS type
- FROM ARelationship m
-
-
- CREATE VIEW anyObject_search_amembership AS
-
- SELECT m.anyObject_id AS any_id, g.id AS group_id, g.name AS group_name
- FROM AMembership m, SyncopeGroup g
- WHERE m.group_id = g.id
-
-
- CREATE VIEW anyObject_search_auxClass AS
-
- SELECT st.anyObject_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM AnyObject_AnyTypeClass st
-
-
- CREATE VIEW anyObject_search_resource AS
-
- SELECT st.anyObject_id AS any_id, st.resource_id AS resource_id
- FROM AnyObject_ExternalResource st
-
-
- CREATE VIEW anyObject_search_group_res AS
-
- SELECT m.anyObject_id AS any_id, st.resource_id AS resource_id
- FROM AMembership m, SyncopeGroup r, SyncopeGroup_ExternalResource st
- WHERE m.group_id = r.id AND st.group_id = r.id
-
-
-
-
- CREATE VIEW group_search AS
-
- SELECT r.id as any_id, r.* FROM SyncopeGroup r
-
-
- CREATE VIEW group_search_unique_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM GPlainAttrUniqueValue uav, GPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW group_search_attr AS
-
- SELECT ua.owner_id AS any_id,
- ua.schema_id AS schema_id,
- uav.booleanvalue AS booleanvalue,
- uav.datevalue AS datevalue,
- uav.doublevalue AS doublevalue,
- uav.longvalue AS longvalue,
- uav.stringvalue AS stringvalue
- FROM GPlainAttrValue uav, GPlainAttr ua
- WHERE uav.attribute_id = ua.id
-
-
- CREATE VIEW group_search_auxClass AS
-
- SELECT st.group_id AS any_id, st.anyTypeClass_id AS anyTypeClass_id
- FROM SyncopeGroup_AnyTypeClass st
-
-
- CREATE VIEW group_search_resource AS
-
- SELECT st.group_id AS any_id, st.resource_id AS resource_id
- FROM SyncopeGroup_ExternalResource st
-
-
-
\ No newline at end of file
diff --git a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java
index ab726501f8a..ce7c865b48d 100644
--- a/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java
+++ b/core/persistence-jpa/src/test/java/org/apache/syncope/core/persistence/jpa/AbstractTest.java
@@ -18,22 +18,194 @@
*/
package org.apache.syncope.core.persistence.jpa;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
+import io.zonky.test.db.postgres.embedded.EmbeddedPostgres;
import jakarta.persistence.EntityManager;
-import java.util.Optional;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
import org.apache.syncope.core.persistence.api.entity.EntityFactory;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-import org.apache.syncope.core.persistence.jpa.dao.JPAPlainAttrValueDAO;
-import org.apache.syncope.core.persistence.jpa.dao.repo.PlainSchemaRepoExtImpl;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.test.context.DynamicPropertyRegistry;
+import org.springframework.test.context.DynamicPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
+import org.testcontainers.containers.MariaDBContainer;
+import org.testcontainers.containers.MySQLContainer;
+import org.testcontainers.oracle.OracleContainer;
@SpringJUnitConfig(classes = { MasterDomain.class, PersistenceTestContext.class })
-@DirtiesContext
public abstract class AbstractTest {
+ private static String JDBC_DRIVER;
+
+ private static String DATABASE_PLATFORM;
+
+ private static String ORM = "META-INF/spring-orm.xml";
+
+ private static String INDEXES = "classpath:META-INF/indexes.xml";
+
+ private static String VIEWS = "classpath:META-INF/views.xml";
+
+ private static Supplier
diff --git a/core/persistence-jpa/src/test/resources/simplelogger.properties b/core/persistence-jpa/src/test/resources/simplelogger.properties
index 929ded23352..828cc0f1057 100644
--- a/core/persistence-jpa/src/test/resources/simplelogger.properties
+++ b/core/persistence-jpa/src/test/resources/simplelogger.properties
@@ -19,4 +19,6 @@
# Possible values: "trace", "debug", "info", "warn", or "error"
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.log.org.springframework.jdbc.core.JdbcTemplate=error
+org.slf4j.simpleLogger.log.org.springframework.jdbc.datasource.DataSourceUtils=error
+org.slf4j.simpleLogger.log.com.github.dockerjava.zerodep.shaded=error
diff --git a/core/persistence-jpa-json/src/test/resources/simplelogger.properties b/core/persistence-jpa/src/test/resources/test.properties
similarity index 75%
rename from core/persistence-jpa-json/src/test/resources/simplelogger.properties
rename to core/persistence-jpa/src/test/resources/test.properties
index 4f528c65c98..e772d2ea882 100644
--- a/core/persistence-jpa-json/src/test/resources/simplelogger.properties
+++ b/core/persistence-jpa/src/test/resources/test.properties
@@ -14,8 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
-# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
-# Possible values: "trace", "debug", "info", "warn", or "error"
-org.slf4j.simpleLogger.defaultLogLevel=debug
-org.slf4j.simpleLogger.log.org.springframework.jdbc.core.JdbcTemplate=error
+docker.mysql.version=${docker.mysql.version}
+docker.mariadb.version=${docker.mariadb.version}
+docker.oracle.version=${docker.oracle.version}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/PersistenceContext.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/PersistenceContext.java
index 30d54ef4dd5..f5a716fa907 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/PersistenceContext.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/PersistenceContext.java
@@ -211,13 +211,13 @@
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jRealm;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jRole;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jVirSchema;
-import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.anyobject.JSONAPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAnyObject;
-import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.group.JSONGPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGroup;
import org.apache.syncope.core.persistence.neo4j.entity.task.Neo4jTaskUtilsFactory;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLAPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONLAPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONUPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUser;
import org.apache.syncope.core.persistence.neo4j.spring.CacheCleaningTransactionExecutionListener;
import org.apache.syncope.core.persistence.neo4j.spring.DomainRoutingDriver;
@@ -356,23 +356,23 @@ public PlatformTransactionManager transactionManager(
}
@Bean(name = "uPlainAttrsConverter")
- public Neo4jPersistentPropertyToMapConverter> uPlainAttrsConverter() {
- return new PlainAttrsConverter<>(Neo4jUPlainAttr.class);
+ public Neo4jPersistentPropertyToMapConverter> uPlainAttrsConverter() {
+ return new PlainAttrsConverter<>(JSONUPlainAttr.class);
}
@Bean(name = "laPlainAttrsConverter")
- public Neo4jPersistentPropertyToMapConverter> laPlainAttrsConverter() {
- return new PlainAttrsConverter<>(Neo4jLAPlainAttr.class);
+ public Neo4jPersistentPropertyToMapConverter> laPlainAttrsConverter() {
+ return new PlainAttrsConverter<>(JSONLAPlainAttr.class);
}
@Bean(name = "gPlainAttrsConverter")
- public Neo4jPersistentPropertyToMapConverter> gPlainAttrsConverter() {
- return new PlainAttrsConverter<>(Neo4jGPlainAttr.class);
+ public Neo4jPersistentPropertyToMapConverter> gPlainAttrsConverter() {
+ return new PlainAttrsConverter<>(JSONGPlainAttr.class);
}
@Bean(name = "aPlainAttrsConverter")
- public Neo4jPersistentPropertyToMapConverter> aPlainAttrsConverter() {
- return new PlainAttrsConverter<>(Neo4jAPlainAttr.class);
+ public Neo4jPersistentPropertyToMapConverter> aPlainAttrsConverter() {
+ return new PlainAttrsConverter<>(JSONAPlainAttr.class);
}
@ConditionalOnMissingBean
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/AbstractAnyRepoExt.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/AbstractAnyRepoExt.java
index 11a84440b1e..c342094a1c7 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/AbstractAnyRepoExt.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/AbstractAnyRepoExt.java
@@ -63,11 +63,8 @@
import org.apache.syncope.core.persistence.neo4j.entity.EntityCacheKey;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jDynRealm;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jExternalResource;
-import org.apache.syncope.core.persistence.neo4j.entity.Neo4jPlainAttr;
import org.apache.syncope.core.provisioning.api.serialization.POJOHelper;
import org.apache.syncope.core.spring.security.AuthContextUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.data.neo4j.core.Neo4jClient;
import org.springframework.data.neo4j.core.Neo4jTemplate;
import org.springframework.transaction.annotation.Propagation;
@@ -76,8 +73,6 @@
public abstract class AbstractAnyRepoExt, N extends AbstractAny>>
extends AbstractDAO implements AnyRepoExt {
- protected static final Logger LOG = LoggerFactory.getLogger(AnyRepoExt.class);
-
/**
* Split an attribute value recurring on provided literals/tokens.
*
@@ -196,7 +191,7 @@ public List findByPlainAttrValue(
if (attrValue instanceof PlainAttrUniqueValue plainAttrUniqueValue) {
attr.setUniqueValue(plainAttrUniqueValue);
} else {
- ((Neo4jPlainAttr>) attr).add(attrValue);
+ attr.add(attrValue);
}
String op;
@@ -315,7 +310,7 @@ public List findByDerAttrValue(final DerSchema derSchema, final String value,
} else {
PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
attrValue.setStringValue(attrValues.get(i));
- ((Neo4jPlainAttr>) attr).add(attrValue);
+ attr.add(attrValue);
}
String op;
@@ -467,13 +462,13 @@ public List findByResourcesContaining(final ExternalResource resource) {
protected void checkBeforeSave(final A any) {
// check UNIQUE constraints
any.getPlainAttrs().stream().filter(attr -> attr.getUniqueValue() != null).forEach(attr -> {
- PlainSchema schema = attr.getSchema();
- Optional other = findByPlainAttrUniqueValue(schema, attr.getUniqueValue(), false);
+ Optional other = findByPlainAttrUniqueValue(attr.getSchema(), attr.getUniqueValue(), false);
if (other.isEmpty() || other.get().getKey().equals(any.getKey())) {
- LOG.debug("No duplicate value found for {}", attr.getUniqueValue().getValueAsString());
+ LOG.debug("No duplicate value found for {}={}",
+ attr.getSchema().getKey(), attr.getUniqueValue().getValueAsString());
} else {
- throw new DuplicateException(
- "Value " + attr.getUniqueValue().getValueAsString() + " existing for " + schema.getKey());
+ throw new DuplicateException("Duplicate value found for "
+ + attr.getSchema().getKey() + "=" + attr.getUniqueValue().getValueAsString());
}
});
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/PlainSchemaRepoExtImpl.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/PlainSchemaRepoExtImpl.java
index 35ae122a3fb..1801040b9c4 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/PlainSchemaRepoExtImpl.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/dao/repo/PlainSchemaRepoExtImpl.java
@@ -29,13 +29,14 @@
import org.apache.syncope.core.persistence.api.entity.PlainAttr;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.entity.Schema;
+import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttr;
+import org.apache.syncope.core.persistence.api.entity.group.GPlainAttr;
+import org.apache.syncope.core.persistence.api.entity.user.LAPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.EntityCacheKey;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jImplementation;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jPlainSchema;
import org.apache.syncope.core.persistence.neo4j.entity.Neo4jSchema;
-import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAnyObject;
-import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGPlainAttr;
import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGroup;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLinkedAccount;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUser;
@@ -92,11 +93,11 @@ public List extends PlainSchema> findByAnyTypeClasses(final Collection> boolean hasAttrs(final PlainSchema schema, final Class reference) {
String label;
- if (reference.isAssignableFrom(Neo4jGPlainAttr.class)) {
+ if (GPlainAttr.class.isAssignableFrom(reference)) {
label = Neo4jGroup.NODE;
- } else if (reference.isAssignableFrom(Neo4jAPlainAttr.class)) {
+ } else if (APlainAttr.class.isAssignableFrom(reference)) {
label = Neo4jAnyObject.NODE;
- } else if (reference.isAssignableFrom(Neo4jAPlainAttr.class)) {
+ } else if (LAPlainAttr.class.isAssignableFrom(reference)) {
label = Neo4jLinkedAccount.NODE;
} else {
label = Neo4jUser.NODE;
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractAny.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractAny.java
index 5ec435f3d8d..0ee52709ed1 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractAny.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractAny.java
@@ -154,18 +154,25 @@ public void setStatus(final String status) {
this.status = status;
}
- protected abstract Map>> plainAttrs();
+ protected abstract Map plainAttrs();
+
+ @Override
+ public Optional getPlainAttr(final String plainSchema) {
+ return Optional.ofNullable(plainAttrs().get(plainSchema));
+ }
+
+ protected abstract void setPlainAttrOwner(P plainAttr);
@SuppressWarnings("unchecked")
- protected void doComplete(final Map>> plainAttrs) {
+ protected void doComplete(final Map plainAttrs) {
for (var itor = plainAttrs.entrySet().iterator(); itor.hasNext();) {
var entry = itor.next();
Optional.ofNullable(entry.getValue()).ifPresent(attr -> {
- attr.setSchemaKey(entry.getKey());
+ ((AbstractPlainAttr>) attr).setSchema(entry.getKey());
if (attr.getSchema() == null) {
itor.remove();
} else {
- ((Neo4jPlainAttr) attr).setOwner(this);
+ setPlainAttrOwner(attr);
attr.getValues().forEach(value -> value.setAttr(attr));
Optional.ofNullable(attr.getUniqueValue()).ifPresent(value -> value.setAttr(attr));
}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractGroupableRelatable.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractGroupableRelatable.java
index 3ae320a11fb..d2e428f3345 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractGroupableRelatable.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractGroupableRelatable.java
@@ -46,15 +46,13 @@ public abstract class AbstractGroupableRelatable<
@Override
public boolean remove(final P attr) {
- Neo4jPlainAttr neo4jAttr = (Neo4jPlainAttr) attr;
-
- if (neo4jAttr.getMembershipKey() == null) {
- return plainAttrs().put(neo4jAttr.getSchemaKey(), null) != null;
+ if (attr.getMembershipKey() == null) {
+ return plainAttrs().put(attr.getSchemaKey(), null) != null;
}
return memberships().stream().
- filter(m -> m.getKey().equals(neo4jAttr.getMembershipKey())).findFirst().
- map(membership -> membership.plainAttrs().put(neo4jAttr.getSchemaKey(), null) != null).
+ filter(m -> m.getKey().equals(attr.getMembershipKey())).findFirst().
+ map(membership -> membership.plainAttrs().put(attr.getSchemaKey(), null) != null).
orElse(false);
}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractMembership.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractMembership.java
index 1ec2dbce14f..a7da8b1ed69 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractMembership.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractMembership.java
@@ -31,8 +31,8 @@ public abstract class AbstractMembership, P extends PlainAttr
private static final long serialVersionUID = -6360036936818368868L;
- protected abstract Map>> plainAttrs();
-
+ protected abstract Map plainAttrs();
+
public abstract List extends P> getPlainAttrs();
public abstract Optional extends P> getPlainAttr(String plainSchema);
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttr.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttr.java
index 6c7ec437768..fade9522ddb 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttr.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttr.java
@@ -21,12 +21,12 @@
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSetter;
import jakarta.validation.constraints.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.core.persistence.api.attrvalue.PlainAttrValidationManager;
import org.apache.syncope.core.persistence.api.dao.PlainSchemaDAO;
import org.apache.syncope.core.persistence.api.entity.Any;
@@ -35,36 +35,28 @@
import org.apache.syncope.core.persistence.api.entity.PlainAttrUniqueValue;
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
-import org.apache.syncope.core.persistence.common.validation.PlainAttrCheck;
import org.apache.syncope.core.spring.ApplicationContextProvider;
@JsonIgnoreProperties("valuesAsStrings")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
-@PlainAttrCheck
-public abstract class AbstractPlainAttr>
- extends AbstractProvidedKeyNode
- implements PlainAttr, Neo4jPlainAttr {
+public abstract class AbstractPlainAttr> implements PlainAttr {
private static final long serialVersionUID = -9115431608821806124L;
@JsonIgnore
@NotNull
- protected String schemaKey;
-
- /**
- * The membership of this attribute; might be {@code NULL} if this attribute is not related to a membership.
- */
- @JsonProperty("membership")
- protected String membershipKey;
+ private String schemaKey;
+ @JsonIgnore
@Override
- public String getSchemaKey() {
- return schemaKey;
+ public String getKey() {
+ return null;
}
+ @JsonIgnore
@Override
- public void setSchemaKey(final String schemaKey) {
- this.schemaKey = schemaKey;
+ public String getSchemaKey() {
+ return schemaKey;
}
@JsonIgnore
@@ -79,25 +71,23 @@ public Neo4jPlainSchema getSchema() {
@JsonIgnore
@Override
public void setSchema(final PlainSchema schema) {
- checkType(schema, Neo4jPlainSchema.class);
if (schema != null) {
this.schemaKey = schema.getKey();
}
}
- @Override
- public String getMembershipKey() {
- return membershipKey;
+ @JsonIgnore
+ public void setSchema(final String schemaKey) {
+ this.schemaKey = schemaKey;
}
- @JsonSetter("membership")
+ protected abstract boolean addForMultiValue(PlainAttrValue attrValue);
+
@Override
- public void setMembershipKey(final String membershipKey) {
- this.membershipKey = membershipKey;
+ public void add(final PlainAttrValue attrValue) {
+ addForMultiValue(attrValue);
}
- protected abstract boolean addForMultiValue(PlainAttrValue attrValue);
-
private void checkNonNullSchema() {
if (getSchema() == null) {
throw new IllegalStateException("First set owner then schema and finally add values");
@@ -147,4 +137,29 @@ public List getValuesAsStrings() {
return Collections.unmodifiableList(result);
}
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().
+ append(schemaKey).
+ build();
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ @SuppressWarnings("unchecked")
+ final AbstractPlainAttr other = (AbstractPlainAttr) obj;
+ return new EqualsBuilder().
+ append(schemaKey, other.schemaKey).
+ build();
+ }
}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttrValue.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttrValue.java
index 5f248a91bde..ca7e752af1a 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttrValue.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AbstractPlainAttrValue.java
@@ -18,6 +18,7 @@
*/
package org.apache.syncope.core.persistence.neo4j.entity;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.time.OffsetDateTime;
@@ -33,17 +34,19 @@
import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.PlainSchema;
import org.apache.syncope.core.persistence.api.utils.FormatUtils;
-import org.apache.syncope.core.persistence.common.validation.PlainAttrValueCheck;
import org.apache.syncope.core.spring.ApplicationContextProvider;
import org.apache.syncope.core.spring.security.Encryptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
@JsonIgnoreProperties({ "valueAsString", "value" })
@JsonInclude(JsonInclude.Include.NON_NULL)
-@PlainAttrValueCheck
-public abstract class AbstractPlainAttrValue extends AbstractProvidedKeyNode implements PlainAttrValue {
+public abstract class AbstractPlainAttrValue implements PlainAttrValue {
private static final long serialVersionUID = -9141923816611244785L;
+ protected static final Logger LOG = LoggerFactory.getLogger(PlainAttrValue.class);
+
private static final Pattern SPRING_ENV_PROPERTY = Pattern.compile("^\\$\\{.*\\}$");
private String stringValue;
@@ -58,6 +61,12 @@ public abstract class AbstractPlainAttrValue extends AbstractProvidedKeyNode imp
private byte[] binaryValue;
+ @JsonIgnore
+ @Override
+ public String getKey() {
+ return null;
+ }
+
@Override
public Boolean getBooleanValue() {
return booleanValue;
@@ -100,15 +109,7 @@ public void setLongValue(final Long longValue) {
@Override
public String getStringValue() {
- // workaround for Oracle DB considering empty string values as NULL (SYNCOPE-664)
- return dateValue == null
- && booleanValue == null
- && longValue == null
- && doubleValue == null
- && binaryValue == null
- && stringValue == null
- ? StringUtils.EMPTY
- : stringValue;
+ return stringValue;
}
@Override
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AttributableValidator.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AttributableValidator.java
deleted file mode 100644
index 2f4f4d63b7e..00000000000
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/AttributableValidator.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.neo4j.entity;
-
-import jakarta.validation.ConstraintValidatorContext;
-import java.util.concurrent.atomic.AtomicReference;
-import org.apache.syncope.core.persistence.common.validation.AbstractValidator;
-import org.apache.syncope.core.persistence.common.validation.PlainAttrValidator;
-import org.apache.syncope.core.persistence.common.validation.PlainAttrValueValidator;
-
-public class AttributableValidator extends AbstractValidator> {
-
- private static final PlainAttrValidator ATTR_VALIDATOR = new PlainAttrValidator();
-
- private static final PlainAttrValueValidator ATTR_VALUE_VALIDATOR = new PlainAttrValueValidator();
-
- @Override
- public boolean isValid(final Neo4jAttributable> entity, final ConstraintValidatorContext context) {
- context.disableDefaultConstraintViolation();
-
- AtomicReference isValid = new AtomicReference<>(Boolean.TRUE);
- entity.getPlainAttrs().forEach(attr -> {
- isValid.getAndSet(isValid.get() && ATTR_VALIDATOR.isValid(attr, context));
- attr.getValues().forEach(
- value -> isValid.getAndSet(isValid.get() && ATTR_VALUE_VALIDATOR.isValid(value, context)));
- });
-
- return isValid.get();
- }
-}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jEntityFactory.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jEntityFactory.java
index 5c8932c111b..10b0a5a71b4 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jEntityFactory.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jEntityFactory.java
@@ -118,16 +118,16 @@
import org.apache.syncope.core.persistence.neo4j.entity.am.Neo4jSAML2SPClientApp;
import org.apache.syncope.core.persistence.neo4j.entity.am.Neo4jSAML2SPEntity;
import org.apache.syncope.core.persistence.neo4j.entity.am.Neo4jWAConfigEntry;
+import org.apache.syncope.core.persistence.neo4j.entity.anyobject.JSONAPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.anyobject.JSONAPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.neo4j.entity.anyobject.JSONAPlainAttrValue;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jADynGroupMembership;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAMembership;
-import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAPlainAttrValue;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jARelationship;
import org.apache.syncope.core.persistence.neo4j.entity.anyobject.Neo4jAnyObject;
-import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGPlainAttrValue;
+import org.apache.syncope.core.persistence.neo4j.entity.group.JSONGPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.group.JSONGPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.neo4j.entity.group.JSONGPlainAttrValue;
import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jGroup;
import org.apache.syncope.core.persistence.neo4j.entity.group.Neo4jTypeExtension;
import org.apache.syncope.core.persistence.neo4j.entity.keymaster.Neo4jConfParam;
@@ -153,16 +153,16 @@
import org.apache.syncope.core.persistence.neo4j.entity.task.Neo4jPullTask;
import org.apache.syncope.core.persistence.neo4j.entity.task.Neo4jPushTask;
import org.apache.syncope.core.persistence.neo4j.entity.task.Neo4jSchedTask;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLAPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLAPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLAPlainAttrValue;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONLAPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONLAPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONLAPlainAttrValue;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONUPlainAttr;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONUPlainAttrUniqueValue;
+import org.apache.syncope.core.persistence.neo4j.entity.user.JSONUPlainAttrValue;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jLinkedAccount;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jSecurityQuestion;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUDynGroupMembership;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUMembership;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUPlainAttrUniqueValue;
-import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUPlainAttrValue;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jURelationship;
import org.apache.syncope.core.persistence.neo4j.entity.user.Neo4jUser;
import org.apache.syncope.core.spring.security.SecureRandomUtils;
@@ -239,33 +239,33 @@ public E newEntity(final Class reference) {
} else if (reference.equals(PlainSchema.class)) {
result = (E) new Neo4jPlainSchema();
} else if (reference.equals(APlainAttr.class)) {
- result = (E) new Neo4jAPlainAttr();
+ result = (E) new JSONAPlainAttr();
} else if (reference.equals(APlainAttrValue.class)) {
- result = (E) new Neo4jAPlainAttrValue();
+ result = (E) new JSONAPlainAttrValue();
} else if (reference.equals(APlainAttrUniqueValue.class)) {
- result = (E) new Neo4jAPlainAttrUniqueValue();
+ result = (E) new JSONAPlainAttrUniqueValue();
} else if (reference.equals(UPlainAttr.class)) {
- result = (E) new Neo4jUPlainAttr();
+ result = (E) new JSONUPlainAttr();
} else if (reference.equals(UPlainAttrValue.class)) {
- result = (E) new Neo4jUPlainAttrValue();
+ result = (E) new JSONUPlainAttrValue();
} else if (reference.equals(UPlainAttrUniqueValue.class)) {
- result = (E) new Neo4jUPlainAttrUniqueValue();
+ result = (E) new JSONUPlainAttrUniqueValue();
} else if (reference.equals(LAPlainAttr.class)) {
- result = (E) new Neo4jLAPlainAttr();
+ result = (E) new JSONLAPlainAttr();
} else if (reference.equals(LAPlainAttrValue.class)) {
- result = (E) new Neo4jLAPlainAttrValue();
+ result = (E) new JSONLAPlainAttrValue();
} else if (reference.equals(LAPlainAttrUniqueValue.class)) {
- result = (E) new Neo4jLAPlainAttrUniqueValue();
+ result = (E) new JSONLAPlainAttrUniqueValue();
} else if (reference.equals(DerSchema.class)) {
result = (E) new Neo4jDerSchema();
} else if (reference.equals(VirSchema.class)) {
result = (E) new Neo4jVirSchema();
} else if (reference.equals(GPlainAttr.class)) {
- result = (E) new Neo4jGPlainAttr();
+ result = (E) new JSONGPlainAttr();
} else if (reference.equals(GPlainAttrValue.class)) {
- result = (E) new Neo4jGPlainAttrValue();
+ result = (E) new JSONGPlainAttrValue();
} else if (reference.equals(GPlainAttrUniqueValue.class)) {
- result = (E) new Neo4jGPlainAttrUniqueValue();
+ result = (E) new JSONGPlainAttrUniqueValue();
} else if (reference.equals(Report.class)) {
result = (E) new Neo4jReport();
} else if (reference.equals(ReportExec.class)) {
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jPlainAttr.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jPlainAttr.java
deleted file mode 100644
index dcaa0f56af4..00000000000
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/Neo4jPlainAttr.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.persistence.neo4j.entity;
-
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.PlainAttr;
-import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
-
-public interface Neo4jPlainAttr> extends PlainAttr {
-
- String getSchemaKey();
-
- void setSchemaKey(String schemaKey);
-
- String getMembershipKey();
-
- void setMembershipKey(String membershipKey);
-
- boolean add(PlainAttrValue value);
-}
diff --git a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/Neo4jAPlainAttr.java b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/JSONAPlainAttr.java
similarity index 72%
rename from core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/Neo4jAPlainAttr.java
rename to core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/JSONAPlainAttr.java
index 24bccca19b1..f68d0ea0c2b 100644
--- a/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/Neo4jAPlainAttr.java
+++ b/core/persistence-neo4j/src/main/java/org/apache/syncope/core/persistence/neo4j/entity/anyobject/JSONAPlainAttr.java
@@ -18,10 +18,13 @@
*/
package org.apache.syncope.core.persistence.neo4j.entity.anyobject;
+import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonSetter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
@@ -32,10 +35,9 @@
import org.apache.syncope.core.persistence.api.entity.anyobject.APlainAttrValue;
import org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject;
import org.apache.syncope.core.persistence.neo4j.entity.AbstractPlainAttr;
-import org.apache.syncope.core.persistence.neo4j.entity.Neo4jPlainAttr;
import org.apache.syncope.core.spring.ApplicationContextProvider;
-public class Neo4jAPlainAttr extends AbstractPlainAttr