You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2013/10/10 16:38:00 UTC
svn commit: r1531003 [5/9] - in /syncope/trunk: ./
common/src/main/java/org/apache/syncope/common/
common/src/main/java/org/apache/syncope/common/mod/
common/src/main/java/org/apache/syncope/common/to/
common/src/main/java/org/apache/syncope/common/uti...
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrTemplate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrTemplate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrUniqueValue.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrUniqueValue.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrUniqueValue.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RAttrUniqueValue.java Thu Oct 10 14:37:56 2013
@@ -25,7 +25,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractAttrUniqueValue;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
@Entity
public class RAttrUniqueValue extends AbstractAttrUniqueValue {
@@ -63,12 +63,12 @@ public class RAttrUniqueValue extends Ab
@SuppressWarnings("unchecked")
@Override
- public <T extends AbstractSchema> T getSchema() {
+ public <T extends AbstractNormalSchema> T getSchema() {
return (T) schema;
}
@Override
- public <T extends AbstractSchema> void setSchema(final T schema) {
+ public <T extends AbstractNormalSchema> void setSchema(final T schema) {
if (!(schema instanceof RSchema)) {
throw new ClassCastException("expected type RSchema, found: " + schema.getClass().getName());
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttr.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttr.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttr.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttr.java Thu Oct 10 14:37:56 2013
@@ -18,9 +18,11 @@
*/
package org.apache.syncope.core.persistence.beans.role;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
@@ -33,8 +35,9 @@ public class RDerAttr extends AbstractDe
@ManyToOne
private SyncopeRole owner;
- @ManyToOne(fetch = FetchType.EAGER, optional = false)
- private RDerSchema derivedSchema;
+ @Column(nullable = false)
+ @OneToOne(cascade = CascadeType.MERGE)
+ private RDerAttrTemplate template;
@SuppressWarnings("unchecked")
@Override
@@ -51,17 +54,17 @@ public class RDerAttr extends AbstractDe
this.owner = (SyncopeRole) owner;
}
- @SuppressWarnings("unchecked")
- @Override
- public <T extends AbstractDerSchema> T getDerivedSchema() {
- return (T) derivedSchema;
+ public RDerAttrTemplate getTemplate() {
+ return template;
+ }
+
+ public void setTemplate(final RDerAttrTemplate template) {
+ this.template = template;
}
+ @SuppressWarnings("unchecked")
@Override
- public <T extends AbstractDerSchema> void setDerivedSchema(final T derivedSchema) {
- if (!(derivedSchema instanceof RDerSchema)) {
- throw new ClassCastException("expected type RDerSchema, found: " + derivedSchema.getClass().getName());
- }
- this.derivedSchema = (RDerSchema) derivedSchema;
+ public <T extends AbstractDerSchema> T getSchema() {
+ return template == null ? null : (T) template.getSchema();
}
}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java?rev=1531003&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java Thu Oct 10 14:37:56 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.beans.role;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
+
+@Entity
+public class RDerAttrTemplate extends AbstractAttrTemplate<RDerSchema> {
+
+ private static final long serialVersionUID = -3424574558427502145L;
+
+ @ManyToOne
+ private SyncopeRole owner;
+
+ @ManyToOne
+ @JoinColumn(name = "schema_name")
+ private RDerSchema schema;
+
+ @Override
+ public RDerSchema getSchema() {
+ return schema;
+ }
+
+ @Override
+ public void setSchema(final RDerSchema schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public SyncopeRole getOwner() {
+ return owner;
+ }
+
+ @Override
+ public void setOwner(final SyncopeRole owner) {
+ this.owner = owner;
+ }
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RDerAttrTemplate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RSchema.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RSchema.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RSchema.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RSchema.java Thu Oct 10 14:37:56 2013
@@ -20,11 +20,11 @@ package org.apache.syncope.core.persiste
import javax.persistence.Cacheable;
import javax.persistence.Entity;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
@Entity
@Cacheable
-public class RSchema extends AbstractSchema {
+public class RSchema extends AbstractNormalSchema {
private static final long serialVersionUID = -7417234690221851342L;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttr.java Thu Oct 10 14:37:56 2013
@@ -18,11 +18,11 @@
*/
package org.apache.syncope.core.persistence.beans.role;
-import java.util.ArrayList;
-import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
import javax.persistence.Entity;
-import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToOne;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
@@ -35,8 +35,9 @@ public class RVirAttr extends AbstractVi
@ManyToOne
private SyncopeRole owner;
- @ManyToOne(fetch = FetchType.EAGER)
- private RVirSchema virtualSchema;
+ @Column(nullable = false)
+ @OneToOne(cascade = CascadeType.MERGE)
+ private RVirAttrTemplate template;
@SuppressWarnings("unchecked")
@Override
@@ -52,25 +53,17 @@ public class RVirAttr extends AbstractVi
this.owner = (SyncopeRole) owner;
}
- @SuppressWarnings("unchecked")
- @Override
- public <T extends AbstractVirSchema> T getVirtualSchema() {
- return (T) virtualSchema;
+ public RVirAttrTemplate getTemplate() {
+ return template;
}
- @Override
- public <T extends AbstractVirSchema> void setVirtualSchema(final T virtualSchema) {
- if (!(virtualSchema instanceof RVirSchema)) {
- throw new ClassCastException("expected type RVirSchema, found: " + virtualSchema.getClass().getName());
- }
- this.virtualSchema = (RVirSchema) virtualSchema;
+ public void setTemplate(final RVirAttrTemplate template) {
+ this.template = template;
}
+ @SuppressWarnings("unchecked")
@Override
- public List<String> getValues() {
- if (values == null) {
- values = new ArrayList<String>();
- }
- return values;
+ public <T extends AbstractVirSchema> T getSchema() {
+ return template == null ? null : (T) template.getSchema();
}
}
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java?rev=1531003&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java Thu Oct 10 14:37:56 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.beans.role;
+
+import javax.persistence.Entity;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
+
+@Entity
+public class RVirAttrTemplate extends AbstractAttrTemplate<RVirSchema> {
+
+ private static final long serialVersionUID = -3424574558427502145L;
+
+ @ManyToOne
+ private SyncopeRole owner;
+
+ @ManyToOne
+ @JoinColumn(name = "schema_name")
+ private RVirSchema schema;
+
+ @Override
+ public RVirSchema getSchema() {
+ return schema;
+ }
+
+ @Override
+ public void setSchema(final RVirSchema schema) {
+ this.schema = schema;
+ }
+
+ @Override
+ public SyncopeRole getOwner() {
+ return owner;
+ }
+
+ @Override
+ public void setOwner(final SyncopeRole owner) {
+ this.owner = owner;
+ }
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/RVirAttrTemplate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/role/SyncopeRole.java Thu Oct 10 14:37:56 2013
@@ -43,9 +43,11 @@ import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
+import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
import org.apache.syncope.core.persistence.beans.AbstractSchema;
import org.apache.syncope.core.persistence.beans.AbstractVirAttr;
import org.apache.syncope.core.persistence.beans.AbstractVirSchema;
@@ -53,12 +55,15 @@ import org.apache.syncope.core.persisten
import org.apache.syncope.core.persistence.beans.Entitlement;
import org.apache.syncope.core.persistence.beans.ExternalResource;
import org.apache.syncope.core.persistence.beans.PasswordPolicy;
+import org.apache.syncope.core.persistence.beans.membership.MAttrTemplate;
+import org.apache.syncope.core.persistence.beans.membership.MDerAttrTemplate;
+import org.apache.syncope.core.persistence.beans.membership.MVirAttrTemplate;
import org.apache.syncope.core.persistence.beans.user.SyncopeUser;
import org.apache.syncope.core.persistence.validation.entity.SyncopeRoleCheck;
@Entity
@Table(uniqueConstraints =
-@UniqueConstraint(columnNames = {"name", "parent_id"}))
+ @UniqueConstraint(columnNames = {"name", "parent_id"}))
@Cacheable
@SyncopeRoleCheck
public class SyncopeRole extends AbstractAttributable {
@@ -82,22 +87,46 @@ public class SyncopeRole extends Abstrac
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
- @JoinColumn(name = "role_id"),
- inverseJoinColumns =
- @JoinColumn(name = "entitlement_name"))
+ @JoinColumn(name = "role_id"),
+ inverseJoinColumns =
+ @JoinColumn(name = "entitlement_name"))
private Set<Entitlement> entitlements;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<RAttr> attributes;
+ private List<RAttrTemplate> rAttrTemplates;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<RDerAttr> derivedAttributes;
+ private List<RDerAttrTemplate> rDerAttrTemplates;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<RVirAttr> virtualAttributes;
+ private List<RVirAttrTemplate> rVirAttrTemplates;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<MAttrTemplate> mAttrTemplates;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<MDerAttrTemplate> mDerAttrTemplates;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<MVirAttrTemplate> mVirAttrTemplates;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<RAttr> attrs;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<RDerAttr> derAttrs;
+
+ @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
+ @Valid
+ private List<RVirAttr> virAttrs;
@Basic(optional = true)
@Min(0)
@@ -107,17 +136,22 @@ public class SyncopeRole extends Abstrac
@Basic(optional = true)
@Min(0)
@Max(1)
- private Integer inheritAttributes;
+ private Integer inheritTemplates;
+
+ @Basic(optional = true)
+ @Min(0)
+ @Max(1)
+ private Integer inheritAttrs;
@Basic(optional = true)
@Min(0)
@Max(1)
- private Integer inheritDerivedAttributes;
+ private Integer inheritDerAttrs;
@Basic(optional = true)
@Min(0)
@Max(1)
- private Integer inheritVirtualAttributes;
+ private Integer inheritVirAttrs;
@Basic(optional = true)
@Min(0)
@@ -140,9 +174,9 @@ public class SyncopeRole extends Abstrac
*/
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(joinColumns =
- @JoinColumn(name = "role_id"),
- inverseJoinColumns =
- @JoinColumn(name = "resource_name"))
+ @JoinColumn(name = "role_id"),
+ inverseJoinColumns =
+ @JoinColumn(name = "resource_name"))
@Valid
private Set<ExternalResource> resources;
@@ -150,15 +184,26 @@ public class SyncopeRole extends Abstrac
super();
entitlements = new HashSet<Entitlement>();
- attributes = new ArrayList<RAttr>();
- derivedAttributes = new ArrayList<RDerAttr>();
- virtualAttributes = new ArrayList<RVirAttr>();
+
+ rAttrTemplates = new ArrayList<RAttrTemplate>();
+ rDerAttrTemplates = new ArrayList<RDerAttrTemplate>();
+ rVirAttrTemplates = new ArrayList<RVirAttrTemplate>();
+ mAttrTemplates = new ArrayList<MAttrTemplate>();
+ mDerAttrTemplates = new ArrayList<MDerAttrTemplate>();
+ mVirAttrTemplates = new ArrayList<MVirAttrTemplate>();
+
+ attrs = new ArrayList<RAttr>();
+ derAttrs = new ArrayList<RDerAttr>();
+ virAttrs = new ArrayList<RVirAttr>();
+
inheritOwner = getBooleanAsInteger(false);
- inheritAttributes = getBooleanAsInteger(false);
- inheritDerivedAttributes = getBooleanAsInteger(false);
- inheritVirtualAttributes = getBooleanAsInteger(false);
+ inheritTemplates = getBooleanAsInteger(false);
+ inheritAttrs = getBooleanAsInteger(false);
+ inheritDerAttrs = getBooleanAsInteger(false);
+ inheritVirAttrs = getBooleanAsInteger(false);
inheritPasswordPolicy = getBooleanAsInteger(false);
inheritAccountPolicy = getBooleanAsInteger(false);
+
resources = new HashSet<ExternalResource>();
}
@@ -231,102 +276,170 @@ public class SyncopeRole extends Abstrac
}
}
+ public boolean isInheritTemplates() {
+ return isBooleanAsInteger(inheritTemplates);
+ }
+
+ public void setInheritTemplates(final boolean inheritAttrTemplates) {
+ this.inheritTemplates = getBooleanAsInteger(inheritAttrTemplates);
+ }
+
+ @SuppressWarnings({"unchecked", "rawtypes"})
+ public <T extends AbstractAttrTemplate> List<T> getAttrTemplates(final Class<T> reference) {
+ List<T> result = null;
+
+ if (reference.equals(RAttrTemplate.class)) {
+ result = (List<T>) rAttrTemplates;
+ } else if (reference.equals(RDerAttrTemplate.class)) {
+ result = (List<T>) rDerAttrTemplates;
+ } else if (reference.equals(RVirAttrTemplate.class)) {
+ result = (List<T>) rVirAttrTemplates;
+ } else if (reference.equals(MAttrTemplate.class)) {
+ result = (List<T>) mAttrTemplates;
+ } else if (reference.equals(MDerAttrTemplate.class)) {
+ result = (List<T>) mDerAttrTemplates;
+ } else if (reference.equals(MVirAttrTemplate.class)) {
+ result = (List<T>) mVirAttrTemplates;
+ }
+
+ return result;
+ }
+
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> T getAttrTemplate(
+ final Class<T> reference, final String schemaName) {
+
+ T result = null;
+
+ for (T template : findInheritedTemplates(reference)) {
+ if (schemaName.equals(template.getSchema().getName())) {
+ result = template;
+ }
+ }
+
+ return result;
+ }
+
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> List<K> getAttrTemplateSchemas(
+ final Class<T> reference) {
+
+ List<K> result = new ArrayList<K>();
+
+ for (T template : findInheritedTemplates(reference)) {
+ result.add(template.getSchema());
+ }
+
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> List<T> findInheritedTemplates(
+ final Class<T> reference) {
+
+ List<T> result = new ArrayList<T>(getAttrTemplates(reference));
+
+ if (isInheritTemplates() && getParent() != null) {
+ result.addAll(getParent().findInheritedTemplates(reference));
+ }
+
+ return result;
+ }
+
@Override
- public <T extends AbstractAttr> boolean addAttribute(final T attribute) {
- if (!(attribute instanceof RAttr)) {
- throw new ClassCastException("attribute is expected to be typed RAttr: " + attribute.getClass().getName());
+ public <T extends AbstractAttr> boolean addAttr(final T attr) {
+ if (!(attr instanceof RAttr)) {
+ throw new ClassCastException("attribute is expected to be typed RAttr: " + attr.getClass().getName());
}
- return attributes.add((RAttr) attribute);
+ return attrs.add((RAttr) attr);
}
@Override
- public <T extends AbstractAttr> boolean removeAttribute(final T attribute) {
- if (!(attribute instanceof RAttr)) {
- throw new ClassCastException("attribute is expected to be typed RAttr: " + attribute.getClass().getName());
+ public <T extends AbstractAttr> boolean removeAttr(final T attr) {
+ if (!(attr instanceof RAttr)) {
+ throw new ClassCastException("attribute is expected to be typed RAttr: " + attr.getClass().getName());
}
- return attributes.remove((RAttr) attribute);
+ return attrs.remove((RAttr) attr);
}
@Override
- public List<? extends AbstractAttr> getAttributes() {
- return attributes;
+ public List<? extends AbstractAttr> getAttrs() {
+ return attrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setAttributes(final List<? extends AbstractAttr> attributes) {
- this.attributes.clear();
- if (attributes != null && !attributes.isEmpty()) {
- this.attributes.addAll((List<RAttr>) attributes);
+ public void setAttrs(final List<? extends AbstractAttr> attrs) {
+ this.attrs.clear();
+ if (attrs != null && !attrs.isEmpty()) {
+ this.attrs.addAll((List<RAttr>) attrs);
}
}
@Override
- public <T extends AbstractDerAttr> boolean addDerivedAttribute(final T derAttr) {
+ public <T extends AbstractDerAttr> boolean addDerAttr(final T derAttr) {
if (!(derAttr instanceof RDerAttr)) {
throw new ClassCastException("attribute is expected to be typed RDerAttr: " + derAttr.getClass().getName());
}
- return derivedAttributes.add((RDerAttr) derAttr);
+ return derAttrs.add((RDerAttr) derAttr);
}
@Override
- public <T extends AbstractDerAttr> boolean removeDerivedAttribute(final T derAttr) {
+ public <T extends AbstractDerAttr> boolean removeDerAttr(final T derAttr) {
if (!(derAttr instanceof RDerAttr)) {
throw new ClassCastException("attribute is expected to be typed RDerAttr: " + derAttr.getClass().getName());
}
- return derivedAttributes.remove((RDerAttr) derAttr);
+ return derAttrs.remove((RDerAttr) derAttr);
}
@Override
- public List<? extends AbstractDerAttr> getDerivedAttributes() {
- return derivedAttributes;
+ public List<? extends AbstractDerAttr> getDerAttrs() {
+ return derAttrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setDerivedAttributes(final List<? extends AbstractDerAttr> derivedAttributes) {
- this.derivedAttributes.clear();
- if (derivedAttributes != null && !derivedAttributes.isEmpty()) {
- this.derivedAttributes.addAll((List<RDerAttr>) derivedAttributes);
+ public void setDerAttrs(final List<? extends AbstractDerAttr> derAttrs) {
+ this.derAttrs.clear();
+ if (derAttrs != null && !derAttrs.isEmpty()) {
+ this.derAttrs.addAll((List<RDerAttr>) derAttrs);
}
}
@Override
- public <T extends AbstractVirAttr> boolean addVirtualAttribute(final T virAttr) {
+ public <T extends AbstractVirAttr> boolean addVirAttr(final T virAttr) {
if (!(virAttr instanceof RVirAttr)) {
throw new ClassCastException("attribute is expected to be typed RVirAttr: " + virAttr.getClass().getName());
}
- return virtualAttributes.add((RVirAttr) virAttr);
+ return virAttrs.add((RVirAttr) virAttr);
}
@Override
- public <T extends AbstractVirAttr> boolean removeVirtualAttribute(final T virAttr) {
+ public <T extends AbstractVirAttr> boolean removeVirAttr(final T virAttr) {
if (!(virAttr instanceof RVirAttr)) {
throw new ClassCastException("attribute is expected to be typed RVirAttr: " + virAttr.getClass().getName());
}
- return virtualAttributes.remove((RVirAttr) virAttr);
+ return virAttrs.remove((RVirAttr) virAttr);
}
@Override
- public List<? extends AbstractVirAttr> getVirtualAttributes() {
- return virtualAttributes;
+ public List<? extends AbstractVirAttr> getVirAttrs() {
+ return virAttrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setVirtualAttributes(final List<? extends AbstractVirAttr> virtualAttributes) {
- this.virtualAttributes.clear();
- if (virtualAttributes != null && !virtualAttributes.isEmpty()) {
- this.virtualAttributes.addAll((List<RVirAttr>) virtualAttributes);
+ public void setVirAttrs(final List<? extends AbstractVirAttr> virAttrs) {
+ this.virAttrs.clear();
+ if (virAttrs != null && !virAttrs.isEmpty()) {
+ this.virAttrs.addAll((List<RVirAttr>) virAttrs);
}
}
- public boolean isInheritAttributes() {
- return isBooleanAsInteger(inheritAttributes);
+ public boolean isInheritAttrs() {
+ return isBooleanAsInteger(inheritAttrs);
}
- public void setInheritAttributes(final boolean inheritAttributes) {
- this.inheritAttributes = getBooleanAsInteger(inheritAttributes);
+ public void setInheritAttrs(final boolean inheritAttrs) {
+ this.inheritAttrs = getBooleanAsInteger(inheritAttrs);
}
/**
@@ -335,21 +448,21 @@ public class SyncopeRole extends Abstrac
* @return a list of inherited and only inherited attributes.
*/
@SuppressWarnings("unchecked")
- public List<RAttr> findInheritedAttributes() {
+ public List<RAttr> findInheritedAttrs() {
final Map<RSchema, RAttr> result = new HashMap<RSchema, RAttr>();
- if (isInheritAttributes() && getParent() != null) {
- final Map<AbstractSchema, AbstractAttr> attrMap = getAttrMap();
+ if (isInheritAttrs() && getParent() != null) {
+ final Map<AbstractNormalSchema, AbstractAttr> attrMap = getAttrMap();
// Add attributes not specialized
- for (RAttr attr : (Collection<RAttr>) getParent().getAttributes()) {
+ for (RAttr attr : (Collection<RAttr>) getParent().getAttrs()) {
if (!attrMap.containsKey(attr.getSchema())) {
result.put((RSchema) attr.getSchema(), attr);
}
}
// Add attributes not specialized and not already added
- for (RAttr attr : getParent().findInheritedAttributes()) {
+ for (RAttr attr : getParent().findInheritedAttrs()) {
if (!attrMap.containsKey(attr.getSchema()) && !result.containsKey((RSchema) attr.getSchema())) {
result.put((RSchema) attr.getSchema(), attr);
}
@@ -359,12 +472,12 @@ public class SyncopeRole extends Abstrac
return new ArrayList<RAttr>(result.values());
}
- public boolean isInheritDerivedAttributes() {
- return isBooleanAsInteger(inheritDerivedAttributes);
+ public boolean isInheritDerAttrs() {
+ return isBooleanAsInteger(inheritDerAttrs);
}
- public void setInheritDerivedAttributes(final boolean inheritDerivedAttributes) {
- this.inheritDerivedAttributes = getBooleanAsInteger(inheritDerivedAttributes);
+ public void setInheritDerAttrs(final boolean inheritDerAttrs) {
+ this.inheritDerAttrs = getBooleanAsInteger(inheritDerAttrs);
}
@@ -374,24 +487,25 @@ public class SyncopeRole extends Abstrac
* @return a list of inherited and only inherited attributes.
*/
@SuppressWarnings("unchecked")
- public List<RDerAttr> findInheritedDerivedAttributes() {
+ public List<RDerAttr> findInheritedDerAttrs() {
final Map<RDerSchema, RDerAttr> result = new HashMap<RDerSchema, RDerAttr>();
- if (isInheritDerivedAttributes() && getParent() != null) {
+ if (isInheritDerAttrs() && getParent() != null) {
final Map<AbstractDerSchema, AbstractDerAttr> attrMap = getDerAttrMap();
// Add attributes not specialized
- for (RDerAttr attr : (Collection<RDerAttr>) getParent().getDerivedAttributes()) {
- if (!attrMap.containsKey(attr.getDerivedSchema())) {
- result.put((RDerSchema) attr.getDerivedSchema(), attr);
+ for (RDerAttr attr : (Collection<RDerAttr>) getParent().getDerAttrs()) {
+ if (!attrMap.containsKey(attr.getSchema())) {
+ result.put((RDerSchema) attr.getSchema(), attr);
}
}
// Add attributes not specialized and not already added
- for (RDerAttr attr : getParent().findInheritedDerivedAttributes()) {
- if (!attrMap.containsKey(attr.getDerivedSchema())
- && !result.containsKey((RDerSchema) attr.getDerivedSchema())) {
- result.put((RDerSchema) attr.getDerivedSchema(), attr);
+ for (RDerAttr attr : getParent().findInheritedDerAttrs()) {
+ if (!attrMap.containsKey(attr.getSchema())
+ && !result.containsKey((RDerSchema) attr.getSchema())) {
+
+ result.put((RDerSchema) attr.getSchema(), attr);
}
}
}
@@ -399,12 +513,12 @@ public class SyncopeRole extends Abstrac
return new ArrayList<RDerAttr>(result.values());
}
- public boolean isInheritVirtualAttributes() {
- return isBooleanAsInteger(inheritVirtualAttributes);
+ public boolean isInheritVirAttrs() {
+ return isBooleanAsInteger(inheritVirAttrs);
}
- public void setInheritVirtualAttributes(final boolean inheritVirtualAttributes) {
- this.inheritVirtualAttributes = getBooleanAsInteger(inheritVirtualAttributes);
+ public void setInheritVirAttrs(final boolean inheritVirAttrs) {
+ this.inheritVirAttrs = getBooleanAsInteger(inheritVirAttrs);
}
@@ -414,24 +528,25 @@ public class SyncopeRole extends Abstrac
* @return a list of inherited and only inherited attributes.
*/
@SuppressWarnings("unchecked")
- public List<RVirAttr> findInheritedVirtualAttributes() {
+ public List<RVirAttr> findInheritedVirAttrs() {
final Map<RVirSchema, RVirAttr> result = new HashMap<RVirSchema, RVirAttr>();
- if (isInheritVirtualAttributes() && getParent() != null) {
+ if (isInheritVirAttrs() && getParent() != null) {
final Map<AbstractVirSchema, AbstractVirAttr> attrMap = getVirAttrMap();
// Add attributes not specialized
- for (RVirAttr attr : (Collection<RVirAttr>) getParent().getVirtualAttributes()) {
- if (!attrMap.containsKey(attr.getVirtualSchema())) {
- result.put((RVirSchema) attr.getVirtualSchema(), attr);
+ for (RVirAttr attr : (Collection<RVirAttr>) getParent().getVirAttrs()) {
+ if (!attrMap.containsKey(attr.getSchema())) {
+ result.put((RVirSchema) attr.getSchema(), attr);
}
}
// Add attributes not specialized and not already added
- for (RVirAttr attr : getParent().findInheritedVirtualAttributes()) {
- if (!attrMap.containsKey(attr.getVirtualSchema())
- && !result.containsKey((RVirSchema) attr.getVirtualSchema())) {
- result.put((RVirSchema) attr.getVirtualSchema(), attr);
+ for (RVirAttr attr : getParent().findInheritedVirAttrs()) {
+ if (!attrMap.containsKey(attr.getSchema())
+ && !result.containsKey((RVirSchema) attr.getSchema())) {
+
+ result.put((RVirSchema) attr.getSchema(), attr);
}
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/SyncopeUser.java Thu Oct 10 14:37:56 2013
@@ -84,15 +84,15 @@ public class SyncopeUser extends Abstrac
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<UAttr> attributes;
+ private List<UAttr> attrs;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<UDerAttr> derivedAttributes;
+ private List<UDerAttr> derAttrs;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
@Valid
- private List<UVirAttr> virtualAttributes;
+ private List<UVirAttr> virAttrs;
private String workflowId;
@@ -159,9 +159,9 @@ public class SyncopeUser extends Abstrac
super();
memberships = new ArrayList<Membership>();
- attributes = new ArrayList<UAttr>();
- derivedAttributes = new ArrayList<UDerAttr>();
- virtualAttributes = new ArrayList<UVirAttr>();
+ attrs = new ArrayList<UAttr>();
+ derAttrs = new ArrayList<UDerAttr>();
+ virAttrs = new ArrayList<UVirAttr>();
passwordHistory = new ArrayList<String>();
failedLogins = 0;
suspended = getBooleanAsInteger(Boolean.FALSE);
@@ -284,95 +284,95 @@ public class SyncopeUser extends Abstrac
}
@Override
- public <T extends AbstractAttr> boolean addAttribute(final T attribute) {
- if (!(attribute instanceof UAttr)) {
- throw new ClassCastException("attribute is expected to be typed UAttr: " + attribute.getClass().getName());
+ public <T extends AbstractAttr> boolean addAttr(final T attr) {
+ if (!(attr instanceof UAttr)) {
+ throw new ClassCastException("attribute is expected to be typed UAttr: " + attr.getClass().getName());
}
- return attributes.add((UAttr) attribute);
+ return attrs.add((UAttr) attr);
}
@Override
- public <T extends AbstractAttr> boolean removeAttribute(final T attribute) {
- if (!(attribute instanceof UAttr)) {
- throw new ClassCastException("attribute is expected to be typed UAttr: " + attribute.getClass().getName());
+ public <T extends AbstractAttr> boolean removeAttr(final T attr) {
+ if (!(attr instanceof UAttr)) {
+ throw new ClassCastException("attribute is expected to be typed UAttr: " + attr.getClass().getName());
}
- return attributes.remove((UAttr) attribute);
+ return attrs.remove((UAttr) attr);
}
@Override
- public List<? extends AbstractAttr> getAttributes() {
- return attributes;
+ public List<? extends AbstractAttr> getAttrs() {
+ return attrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setAttributes(final List<? extends AbstractAttr> attributes) {
- this.attributes.clear();
- if (attributes != null && !attributes.isEmpty()) {
- this.attributes.addAll((List<UAttr>) attributes);
+ public void setAttrs(final List<? extends AbstractAttr> attrs) {
+ this.attrs.clear();
+ if (attrs != null && !attrs.isEmpty()) {
+ this.attrs.addAll((List<UAttr>) attrs);
}
}
@Override
- public <T extends AbstractDerAttr> boolean addDerivedAttribute(final T derAttr) {
+ public <T extends AbstractDerAttr> boolean addDerAttr(final T derAttr) {
if (!(derAttr instanceof UDerAttr)) {
throw new ClassCastException("attribute is expected to be typed UDerAttr: " + derAttr.getClass().getName());
}
- return derivedAttributes.add((UDerAttr) derAttr);
+ return derAttrs.add((UDerAttr) derAttr);
}
@Override
- public <T extends AbstractDerAttr> boolean removeDerivedAttribute(final T derAttr) {
+ public <T extends AbstractDerAttr> boolean removeDerAttr(final T derAttr) {
if (!(derAttr instanceof UDerAttr)) {
throw new ClassCastException("attribute is expected to be typed UDerAttr: " + derAttr.getClass().getName());
}
- return derivedAttributes.remove((UDerAttr) derAttr);
+ return derAttrs.remove((UDerAttr) derAttr);
}
@Override
- public List<? extends AbstractDerAttr> getDerivedAttributes() {
- return derivedAttributes;
+ public List<? extends AbstractDerAttr> getDerAttrs() {
+ return derAttrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setDerivedAttributes(final List<? extends AbstractDerAttr> derivedAttributes) {
- this.derivedAttributes.clear();
- if (derivedAttributes != null && !derivedAttributes.isEmpty()) {
- this.derivedAttributes.addAll((List<UDerAttr>) derivedAttributes);
+ public void setDerAttrs(final List<? extends AbstractDerAttr> derAttr) {
+ this.derAttrs.clear();
+ if (derAttr != null && !derAttr.isEmpty()) {
+ this.derAttrs.addAll((List<UDerAttr>) derAttr);
}
}
@Override
- public <T extends AbstractVirAttr> boolean addVirtualAttribute(final T virAttr) {
+ public <T extends AbstractVirAttr> boolean addVirAttr(final T virAttr) {
if (!(virAttr instanceof UVirAttr)) {
throw new ClassCastException("attribute is expected to be typed UVirAttr: " + virAttr.getClass().getName());
}
- return virtualAttributes.add((UVirAttr) virAttr);
+ return virAttrs.add((UVirAttr) virAttr);
}
@Override
- public <T extends AbstractVirAttr> boolean removeVirtualAttribute(final T virAttr) {
+ public <T extends AbstractVirAttr> boolean removeVirAttr(final T virAttr) {
if (!(virAttr instanceof UVirAttr)) {
throw new ClassCastException("attribute is expected to be typed UVirAttr: " + virAttr.getClass().getName());
}
- return virtualAttributes.remove((UVirAttr) virAttr);
+ return virAttrs.remove((UVirAttr) virAttr);
}
@Override
- public List<? extends AbstractVirAttr> getVirtualAttributes() {
- return virtualAttributes;
+ public List<? extends AbstractVirAttr> getVirAttrs() {
+ return virAttrs;
}
@SuppressWarnings("unchecked")
@Override
- public void setVirtualAttributes(final List<? extends AbstractVirAttr> virtualAttributes) {
- this.virtualAttributes.clear();
- if (virtualAttributes != null && !virtualAttributes.isEmpty()) {
- this.virtualAttributes.addAll((List<UVirAttr>) virtualAttributes);
+ public void setVirAttrs(final List<? extends AbstractVirAttr> virAttrs) {
+ this.virAttrs.clear();
+ if (virAttrs != null && !virAttrs.isEmpty()) {
+ this.virAttrs.addAll((List<UVirAttr>) virAttrs);
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttr.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttr.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttr.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttr.java Thu Oct 10 14:37:56 2013
@@ -32,7 +32,7 @@ import javax.validation.Valid;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
/**
* User attribute.
@@ -104,16 +104,12 @@ public class UAttr extends AbstractAttr
@SuppressWarnings("unchecked")
@Override
- public <T extends AbstractSchema> T getSchema() {
+ public <T extends AbstractNormalSchema> T getSchema() {
return (T) schema;
}
- @Override
- public <T extends AbstractSchema> void setSchema(final T schema) {
- if (!(schema instanceof USchema)) {
- throw new ClassCastException("schema is expected to be typed USchema: " + schema.getClass().getName());
- }
- this.schema = (USchema) schema;
+ public void setSchema(final USchema schema) {
+ this.schema = schema;
}
@Override
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttrUniqueValue.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttrUniqueValue.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttrUniqueValue.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UAttrUniqueValue.java Thu Oct 10 14:37:56 2013
@@ -25,7 +25,7 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.beans.AbstractAttrUniqueValue;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
@Entity
public class UAttrUniqueValue extends AbstractAttrUniqueValue {
@@ -63,12 +63,12 @@ public class UAttrUniqueValue extends Ab
@SuppressWarnings("unchecked")
@Override
- public <T extends AbstractSchema> T getSchema() {
+ public <T extends AbstractNormalSchema> T getSchema() {
return (T) schema;
}
@Override
- public <T extends AbstractSchema> void setSchema(final T schema) {
+ public <T extends AbstractNormalSchema> void setSchema(final T schema) {
if (!(schema instanceof USchema)) {
throw new ClassCastException("expected type USchema, found: " + schema.getClass().getName());
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UDerAttr.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UDerAttr.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UDerAttr.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UDerAttr.java Thu Oct 10 14:37:56 2013
@@ -34,7 +34,7 @@ public class UDerAttr extends AbstractDe
private SyncopeUser owner;
@ManyToOne(fetch = FetchType.EAGER)
- private UDerSchema derivedSchema;
+ private UDerSchema derSchema;
@SuppressWarnings("unchecked")
@Override
@@ -53,15 +53,11 @@ public class UDerAttr extends AbstractDe
@SuppressWarnings("unchecked")
@Override
- public <T extends AbstractDerSchema> T getDerivedSchema() {
- return (T) derivedSchema;
+ public <T extends AbstractDerSchema> T getSchema() {
+ return (T) derSchema;
}
- @Override
- public <T extends AbstractDerSchema> void setDerivedSchema(final T derivedSchema) {
- if (!(derivedSchema instanceof UDerSchema)) {
- throw new ClassCastException("expected type UDerSchema, found: " + derivedSchema.getClass().getName());
- }
- this.derivedSchema = (UDerSchema) derivedSchema;
+ public void setSchema(final UDerSchema derSchema) {
+ this.derSchema = derSchema;
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/USchema.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/USchema.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/USchema.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/USchema.java Thu Oct 10 14:37:56 2013
@@ -20,11 +20,11 @@ package org.apache.syncope.core.persiste
import javax.persistence.Cacheable;
import javax.persistence.Entity;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
@Entity
@Cacheable
-public class USchema extends AbstractSchema {
+public class USchema extends AbstractNormalSchema {
private static final long serialVersionUID = -2776513645999914610L;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/beans/user/UVirAttr.java Thu Oct 10 14:37:56 2013
@@ -18,8 +18,6 @@
*/
package org.apache.syncope.core.persistence.beans.user;
-import java.util.ArrayList;
-import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
@@ -36,7 +34,7 @@ public class UVirAttr extends AbstractVi
private SyncopeUser owner;
@ManyToOne(fetch = FetchType.EAGER)
- private UVirSchema virtualSchema;
+ private UVirSchema virSchema;
@SuppressWarnings("unchecked")
@Override
@@ -54,23 +52,11 @@ public class UVirAttr extends AbstractVi
@SuppressWarnings("unchecked")
@Override
- public <T extends AbstractVirSchema> T getVirtualSchema() {
- return (T) virtualSchema;
+ public <T extends AbstractVirSchema> T getSchema() {
+ return (T) virSchema;
}
- @Override
- public <T extends AbstractVirSchema> void setVirtualSchema(final T virtualSchema) {
- if (!(virtualSchema instanceof UVirSchema)) {
- throw new ClassCastException("expected type UVirSchema, found: " + virtualSchema.getClass().getName());
- }
- this.virtualSchema = (UVirSchema) virtualSchema;
- }
-
- @Override
- public List<String> getValues() {
- if (values == null) {
- values = new ArrayList<String>();
- }
- return values;
+ public void setSchema(final UVirSchema virSchema) {
+ this.virSchema = virSchema;
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrDAO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrDAO.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrDAO.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrDAO.java Thu Oct 10 14:37:56 2013
@@ -18,19 +18,12 @@
*/
package org.apache.syncope.core.persistence.dao;
-import java.util.List;
-
import org.apache.syncope.core.persistence.beans.AbstractAttr;
-import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
public interface AttrDAO extends DAO {
<T extends AbstractAttr> T find(Long id, Class<T> reference);
- <T extends AbstractAttr> List<T> findAll(Class<T> reference);
-
- <T extends AbstractAttr> T save(T attribute) throws InvalidEntityException;
-
<T extends AbstractAttr> void delete(Long id, Class<T> reference);
<T extends AbstractAttr> void delete(T attribute);
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java?rev=1531003&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java Thu Oct 10 14:37:56 2013
@@ -0,0 +1,35 @@
+/*
+ * 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.dao;
+
+import java.util.List;
+import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
+import org.apache.syncope.core.persistence.beans.AbstractSchema;
+
+public interface AttrTemplateDAO extends DAO {
+
+ <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> T find(Long id, Class<T> reference);
+
+ <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> List<Number> findBySchemaName(
+ String schemaName, Class<T> reference);
+
+ <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> void delete(Long id, Class<T> reference);
+
+ <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> void delete(T attrTemplate);
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/AttrTemplateDAO.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/DerSchemaDAO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/DerSchemaDAO.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/DerSchemaDAO.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/DerSchemaDAO.java Thu Oct 10 14:37:56 2013
@@ -31,9 +31,9 @@ public interface DerSchemaDAO extends DA
<T extends AbstractDerSchema> List<T> findAll(Class<T> reference);
- <T extends AbstractDerSchema> T save(T derivedSchema) throws InvalidEntityException;
+ <T extends AbstractDerAttr> List<T> findAttrs(AbstractDerSchema schema, Class<T> reference);
- <T extends AbstractDerAttr> List<T> getAttributes(AbstractDerSchema schema, Class<T> reference);
+ <T extends AbstractDerSchema> T save(T derivedSchema) throws InvalidEntityException;
void delete(String name, AttributableUtil attributableUtil);
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/SchemaDAO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/SchemaDAO.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/SchemaDAO.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/SchemaDAO.java Thu Oct 10 14:37:56 2013
@@ -20,19 +20,19 @@ package org.apache.syncope.core.persiste
import java.util.List;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
import org.apache.syncope.core.persistence.validation.entity.InvalidEntityException;
import org.apache.syncope.core.util.AttributableUtil;
public interface SchemaDAO extends DAO {
- <T extends AbstractSchema> T find(String name, Class<T> reference);
+ <T extends AbstractNormalSchema> T find(String name, Class<T> reference);
- <T extends AbstractSchema> List<T> findAll(Class<T> reference);
+ <T extends AbstractNormalSchema> List<T> findAll(Class<T> reference);
- <T extends AbstractAttr> List<T> getAttributes(AbstractSchema schema, Class<T> reference);
+ <T extends AbstractAttr> List<T> findAttrs(AbstractNormalSchema schema, Class<T> reference);
- <T extends AbstractSchema> T save(T schema) throws InvalidEntityException;
+ <T extends AbstractNormalSchema> T save(T schema) throws InvalidEntityException;
void delete(String name, AttributableUtil attributableUtil);
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/VirSchemaDAO.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/VirSchemaDAO.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/VirSchemaDAO.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/VirSchemaDAO.java Thu Oct 10 14:37:56 2013
@@ -30,9 +30,9 @@ public interface VirSchemaDAO extends DA
<T extends AbstractVirSchema> List<T> findAll(Class<T> reference);
- <T extends AbstractVirSchema> T save(T virtualSchema) throws InvalidEntityException;
+ <T extends AbstractVirAttr> List<T> findAttrs(AbstractVirSchema virSchema, Class<T> reference);
- <T extends AbstractVirAttr> List<T> getAttributes(AbstractVirSchema virtualSchema, Class<T> reference);
+ <T extends AbstractVirSchema> T save(T virtualSchema) throws InvalidEntityException;
void delete(String name, AttributableUtil attributableUtil);
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractAttributableDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractAttributableDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractAttributableDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AbstractAttributableDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -36,7 +36,7 @@ import org.apache.syncope.common.service
import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
import org.apache.syncope.core.persistence.beans.ExternalResource;
import org.apache.syncope.core.persistence.dao.AttributableDAO;
import org.apache.syncope.core.persistence.dao.DerSchemaDAO;
@@ -149,7 +149,7 @@ public abstract class AbstractAttributab
if (!used.contains(identifiers.get(i))) {
// verify schema existence and get schema type
- AbstractSchema schema = schemaDAO.find(identifiers.get(i), attrUtil.schemaClass());
+ AbstractNormalSchema schema = schemaDAO.find(identifiers.get(i), attrUtil.schemaClass());
if (schema == null) {
LOG.error("Invalid schema name '{}'", identifiers.get(i));
throw new InvalidSearchConditionException("Invalid schema name " + identifiers.get(i));
@@ -204,11 +204,13 @@ public abstract class AbstractAttributab
protected abstract <T extends AbstractAttributable> T findInternal(final Long id);
+ protected abstract TypedQuery<AbstractAttrValue> findByAttrValueQuery(final String entityName);
+
@Override
public <T extends AbstractAttributable> List<T> findByAttrValue(final String schemaName,
final AbstractAttrValue attrValue, final AttributableUtil attrUtil) {
- AbstractSchema schema = schemaDAO.find(schemaName, attrUtil.schemaClass());
+ AbstractNormalSchema schema = schemaDAO.find(schemaName, attrUtil.schemaClass());
if (schema == null) {
LOG.error("Invalid schema name '{}'", schemaName);
return Collections.<T>emptyList();
@@ -218,14 +220,7 @@ public abstract class AbstractAttributab
? attrUtil.attrUniqueValueClass().getName()
: attrUtil.attrValueClass().getName();
- TypedQuery<AbstractAttrValue> query = entityManager.createQuery("SELECT e FROM " + entityName + " e"
- + " WHERE e.attribute.schema.name = :schemaName AND (e.stringValue IS NOT NULL"
- + " AND e.stringValue = :stringValue)"
- + " OR (e.booleanValue IS NOT NULL AND e.booleanValue = :booleanValue)"
- + " OR (e.dateValue IS NOT NULL AND e.dateValue = :dateValue)"
- + " OR (e.longValue IS NOT NULL AND e.longValue = :longValue)"
- + " OR (e.doubleValue IS NOT NULL AND e.doubleValue = :doubleValue)",
- AbstractAttrValue.class);
+ TypedQuery<AbstractAttrValue> query = findByAttrValueQuery(entityName);
query.setParameter("schemaName", schemaName);
query.setParameter("stringValue", attrValue.getStringValue());
@@ -255,7 +250,7 @@ public abstract class AbstractAttributab
public <T extends AbstractAttributable> AbstractAttributable findByAttrUniqueValue(final String schemaName,
final AbstractAttrValue attrUniqueValue, final AttributableUtil attrUtil) {
- AbstractSchema schema = schemaDAO.find(schemaName, attrUtil.schemaClass());
+ AbstractNormalSchema schema = schemaDAO.find(schemaName, attrUtil.schemaClass());
if (schema == null) {
LOG.error("Invalid schema name '{}'", schemaName);
return null;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -18,8 +18,6 @@
*/
package org.apache.syncope.core.persistence.dao.impl;
-import java.util.List;
-import javax.persistence.TypedQuery;
import org.apache.syncope.core.persistence.beans.AbstractAttr;
import org.apache.syncope.core.persistence.dao.AttrDAO;
import org.springframework.stereotype.Repository;
@@ -29,24 +27,11 @@ public class AttrDAOImpl extends Abstrac
@Override
public <T extends AbstractAttr> T find(final Long id, final Class<T> reference) {
-
return entityManager.find(reference, id);
}
@Override
- public <T extends AbstractAttr> List<T> findAll(final Class<T> reference) {
- TypedQuery<T> query = entityManager.createQuery("SELECT e FROM " + reference.getSimpleName() + " e", reference);
- return query.getResultList();
- }
-
- @Override
- public <T extends AbstractAttr> T save(final T attribute) {
- return entityManager.merge(attribute);
- }
-
- @Override
public <T extends AbstractAttr> void delete(final Long id, final Class<T> reference) {
-
T attribute = find(id, reference);
if (attribute == null) {
return;
@@ -58,7 +43,7 @@ public class AttrDAOImpl extends Abstrac
@Override
public <T extends AbstractAttr> void delete(final T attribute) {
if (attribute.getOwner() != null) {
- attribute.getOwner().removeAttribute(attribute);
+ attribute.getOwner().removeAttr(attribute);
}
entityManager.remove(attribute);
Added: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java?rev=1531003&view=auto
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java (added)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -0,0 +1,71 @@
+/*
+ * 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.dao.impl;
+
+import java.util.List;
+import javax.persistence.Query;
+import org.apache.syncope.core.persistence.beans.AbstractAttrTemplate;
+import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.dao.AttrTemplateDAO;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public class AttrTemplateDAOImpl extends AbstractDAOImpl implements AttrTemplateDAO {
+
+ @Override
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> T find(
+ final Long id, final Class<T> reference) {
+
+ return entityManager.find(reference, id);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> List<Number> findBySchemaName(
+ final String schemaName, final Class<T> reference) {
+
+ Query query = entityManager.createNativeQuery(
+ "SELECT id FROM " + reference.getSimpleName() + " WHERE schema_name=?1");
+ query.setParameter(1, schemaName);
+
+ return query.getResultList();
+ }
+
+ @Override
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> void delete(
+ final Long id, final Class<T> reference) {
+
+ T attrTemplate = find(id, reference);
+ if (attrTemplate == null) {
+ return;
+ }
+
+ delete(attrTemplate);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T extends AbstractAttrTemplate<K>, K extends AbstractSchema> void delete(final T attrTemplate) {
+ if (attrTemplate.getOwner() != null) {
+ attrTemplate.getOwner().getAttrTemplates(attrTemplate.getClass()).remove(attrTemplate);
+ }
+
+ entityManager.remove(attrTemplate);
+ }
+}
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttrTemplateDAOImpl.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/AttributableSearchDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -41,7 +41,7 @@ import org.apache.syncope.common.types.A
import org.apache.syncope.common.types.AttributeSchemaType;
import org.apache.syncope.core.persistence.beans.AbstractAttrValue;
import org.apache.syncope.core.persistence.beans.AbstractAttributable;
-import org.apache.syncope.core.persistence.beans.AbstractSchema;
+import org.apache.syncope.core.persistence.beans.AbstractNormalSchema;
import org.apache.syncope.core.persistence.dao.AttributableSearchDAO;
import org.apache.syncope.core.persistence.dao.RoleDAO;
import org.apache.syncope.core.persistence.dao.SchemaDAO;
@@ -390,7 +390,7 @@ public class AttributableSearchDAOImpl e
}
private void fillAttributeQuery(final StringBuilder query, final AbstractAttrValue attrValue,
- final AbstractSchema schema, final AttributeCond cond, final boolean not, final List<Object> parameters) {
+ final AbstractNormalSchema schema, final AttributeCond cond, final boolean not, final List<Object> parameters) {
String column = (cond instanceof AttributableCond)
? cond.getSchema()
@@ -515,7 +515,7 @@ public class AttributableSearchDAOImpl e
private String getQuery(final AttributeCond cond, final boolean not, final List<Object> parameters,
final AttributableUtil attrUtil) {
- AbstractSchema schema = schemaDAO.find(cond.getSchema(), attrUtil.schemaClass());
+ AbstractNormalSchema schema = schemaDAO.find(cond.getSchema(), attrUtil.schemaClass());
if (schema == null) {
LOG.warn("Ignoring invalid schema '{}'", cond.getSchema());
return EMPTY_ATTR_QUERY;
@@ -566,7 +566,7 @@ public class AttributableSearchDAOImpl e
return EMPTY_ATTR_QUERY;
}
- AbstractSchema schema = attrUtil.newSchema();
+ AbstractNormalSchema schema = attrUtil.newSchema();
schema.setName(attributableField.getName());
for (AttributeSchemaType type : AttributeSchemaType.values()) {
if (attributableField.getType().isAssignableFrom(type.getType())) {
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/ContentLoader.java Thu Oct 10 14:37:56 2013
@@ -18,7 +18,6 @@
*/
package org.apache.syncope.core.persistence.dao.impl;
-import static org.apache.syncope.core.persistence.dao.impl.AbstractContentDealer.LOG;
import java.io.InputStream;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerAttrDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerAttrDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerAttrDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerAttrDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -40,8 +40,8 @@ public class DerAttrDAOImpl extends Abst
}
@Override
- public <T extends AbstractDerAttr> T save(final T derivedAttribute) {
- return entityManager.merge(derivedAttribute);
+ public <T extends AbstractDerAttr> T save(final T derAttr) {
+ return entityManager.merge(derAttr);
}
@Override
@@ -55,11 +55,11 @@ public class DerAttrDAOImpl extends Abst
}
@Override
- public <T extends AbstractDerAttr> void delete(final T derivedAttribute) {
- if (derivedAttribute.getOwner() != null) {
- derivedAttribute.getOwner().removeDerivedAttribute(derivedAttribute);
+ public <T extends AbstractDerAttr> void delete(final T derAttr) {
+ if (derAttr.getOwner() != null) {
+ derAttr.getOwner().removeDerAttr(derAttr);
}
- entityManager.remove(derivedAttribute);
+ entityManager.remove(derAttr);
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/DerSchemaDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -19,12 +19,16 @@
package org.apache.syncope.core.persistence.dao.impl;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.persistence.TypedQuery;
+import org.apache.syncope.common.types.AttributableType;
import org.apache.syncope.core.persistence.beans.AbstractDerAttr;
import org.apache.syncope.core.persistence.beans.AbstractDerSchema;
+import org.apache.syncope.core.persistence.beans.user.UDerAttr;
import org.apache.syncope.core.persistence.beans.user.UMappingItem;
+import org.apache.syncope.core.persistence.dao.AttrTemplateDAO;
import org.apache.syncope.core.persistence.dao.DerAttrDAO;
import org.apache.syncope.core.persistence.dao.DerSchemaDAO;
import org.apache.syncope.core.persistence.dao.ResourceDAO;
@@ -36,7 +40,10 @@ import org.springframework.stereotype.Re
public class DerSchemaDAOImpl extends AbstractDAOImpl implements DerSchemaDAO {
@Autowired
- private DerAttrDAO derivedAttributeDAO;
+ private DerAttrDAO derAttrDAO;
+
+ @Autowired
+ private AttrTemplateDAO attrTemplateDAO;
@Autowired
private ResourceDAO resourceDAO;
@@ -53,44 +60,56 @@ public class DerSchemaDAOImpl extends Ab
}
@Override
- public <T extends AbstractDerSchema> T save(final T derivedSchema) {
- return entityManager.merge(derivedSchema);
+ public <T extends AbstractDerAttr> List<T> findAttrs(
+ final AbstractDerSchema schema, final Class<T> reference) {
+
+ final StringBuilder queryString =
+ new StringBuilder("SELECT e FROM ").append(reference.getSimpleName()).append(" e WHERE e.");
+ if (reference.equals(UDerAttr.class)) {
+ queryString.append("derSchema");
+ } else {
+ queryString.append("template.schema");
+ }
+ queryString.append("=:schema");
+
+ TypedQuery<T> query = entityManager.createQuery(queryString.toString(), reference);
+ query.setParameter("schema", schema);
+
+ return query.getResultList();
+ }
+
+ @Override
+ public <T extends AbstractDerSchema> T save(final T derSchema) {
+ return entityManager.merge(derSchema);
}
@Override
+ @SuppressWarnings("unchecked")
public void delete(final String name, final AttributableUtil attributableUtil) {
- final AbstractDerSchema derivedSchema = find(name, attributableUtil.derSchemaClass());
- if (derivedSchema == null) {
+ final AbstractDerSchema schema = find(name, attributableUtil.derSchemaClass());
+ if (schema == null) {
return;
}
- List<? extends AbstractDerAttr> attributes = getAttributes(derivedSchema, attributableUtil.derAttrClass());
-
- final Set<Long> derivedAttributeIds = new HashSet<Long>(attributes.size());
-
- Class<? extends AbstractDerAttr> attributeClass = null;
- for (AbstractDerAttr attribute : attributes) {
- derivedAttributeIds.add(attribute.getId());
- attributeClass = attribute.getClass();
+ final Set<Long> attrIds = new HashSet<Long>();
+ for (AbstractDerAttr attr : findAttrs(schema, attributableUtil.derAttrClass())) {
+ attrIds.add(attr.getId());
}
-
- for (Long derivedAttributeId : derivedAttributeIds) {
- derivedAttributeDAO.delete(derivedAttributeId, attributeClass);
+ for (Long attrId : attrIds) {
+ derAttrDAO.delete(attrId, attributableUtil.derAttrClass());
}
- resourceDAO.deleteMapping(name, attributableUtil.derIntMappingType(), UMappingItem.class);
-
- entityManager.remove(derivedSchema);
- }
+ if (attributableUtil.getType() != AttributableType.USER) {
+ for (Iterator<Number> it = attrTemplateDAO.
+ findBySchemaName(schema.getName(), attributableUtil.derAttrTemplateClass()).iterator();
+ it.hasNext();) {
- @Override
- public <T extends AbstractDerAttr> List<T> getAttributes(final AbstractDerSchema derivedSchema,
- final Class<T> reference) {
+ attrTemplateDAO.delete(it.next().longValue(), attributableUtil.derAttrTemplateClass());
+ }
+ }
- TypedQuery<T> query = entityManager.createQuery("SELECT e FROM " + reference.getSimpleName() + " e"
- + " WHERE e.derivedSchema=:schema", reference);
- query.setParameter("schema", derivedSchema);
+ resourceDAO.deleteMapping(name, attributableUtil.derIntMappingType(), UMappingItem.class);
- return query.getResultList();
+ entityManager.remove(schema);
}
}
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/PolicyDAOImpl.java
URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/PolicyDAOImpl.java?rev=1531003&r1=1531002&r2=1531003&view=diff
==============================================================================
--- syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/PolicyDAOImpl.java (original)
+++ syncope/trunk/core/src/main/java/org/apache/syncope/core/persistence/dao/impl/PolicyDAOImpl.java Thu Oct 10 14:37:56 2013
@@ -18,12 +18,6 @@
*/
package org.apache.syncope.core.persistence.dao.impl;
-import static org.apache.syncope.common.types.PolicyType.ACCOUNT;
-import static org.apache.syncope.common.types.PolicyType.GLOBAL_ACCOUNT;
-import static org.apache.syncope.common.types.PolicyType.GLOBAL_PASSWORD;
-import static org.apache.syncope.common.types.PolicyType.GLOBAL_SYNC;
-import static org.apache.syncope.common.types.PolicyType.PASSWORD;
-import static org.apache.syncope.common.types.PolicyType.SYNC;
import java.util.List;
import javax.persistence.TypedQuery;
import org.apache.syncope.common.types.EntityViolationType;