Package org.apache.syncope.core.persistence.beans

Examples of org.apache.syncope.core.persistence.beans.AbstractVirAttr


     */
    public void fillVirtual(final AbstractAttributable attributable, final Collection<AttributeTO> vAttrs,
            final AttributableUtil attrUtil) {

        for (AttributeTO attributeTO : vAttrs) {
            AbstractVirAttr virAttr = attributable.getVirtualAttribute(attributeTO.getSchema());
            if (virAttr == null) {
                AbstractVirSchema virSchema = getVirtualSchema(attributeTO.getSchema(), attrUtil.virSchemaClass());
                if (virSchema != null) {
                    virAttr = attrUtil.newVirAttr();
                    virAttr.setVirtualSchema(virSchema);
                    virAttr.setOwner(attributable);
                    attributable.addVirtualAttribute(virAttr);
                    virAttr.setValues(attributeTO.getValues());
                }
            } else {
                virAttr.setValues(attributeTO.getValues());
            }
        }
    }
View Full Code Here


            for (AttributeTO vattrTO : attributableTO.getVirtualAttributes()) {
                AbstractVirSchema uVirSchema = getVirtualSchema(vattrTO.getSchema(), attributableUtil.virSchemaClass());

                if (uVirSchema != null) {
                    AbstractVirAttr vattr = attributableUtil.newVirAttr();
                    vattr.setVirtualSchema(uVirSchema);
                    vattr.setOwner(attributable);
                    attributable.addVirtualAttribute(vattr);
                }
            }
        }
View Full Code Here

            case UserVirtualSchema:
            case RoleVirtualSchema:
            case MembershipVirtualSchema:
                for (AbstractAttributable attributable : attributables) {
                    AbstractVirAttr virAttr = attributable.getVirtualAttribute(mappingItem.getIntAttrName());
                    if (virAttr != null) {
                        if (virAttr.getValues() != null) {
                            for (String value : virAttr.getValues()) {
                                attrValue = new UAttrValue();
                                attrValue.setStringValue(value);
                                values.add(attrValue);
                            }
                        }
                        if (vAttrsToBeRemoved != null && vAttrsToBeUpdated != null) {
                            if (vAttrsToBeUpdated.containsKey(mappingItem.getIntAttrName())) {
                                virAttr.setValues(
                                        vAttrsToBeUpdated.get(mappingItem.getIntAttrName()).getValuesToBeAdded());
                            } else if (vAttrsToBeRemoved.contains(mappingItem.getIntAttrName())) {
                                virAttr.getValues().clear();
                            } else {
                                throw new IllegalArgumentException("Don't need to update virtual attribute '"
                                        + mappingItem.getIntAttrName() + "'");
                            }
                        }
View Full Code Here

        // 1. virtual attributes to be removed
        for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeRemoved, attributableUtil.virtualSchemaClass());

            if (virtualSchema != null) {
                AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());

                if (virtualAttribute == null) {
                    LOG.debug("No virtual attribute found for schema {}", virtualSchema.getName());
                } else {
                    attributable.removeVirtualAttribute(virtualAttribute);
                    virAttrDAO.delete(virtualAttribute);
                }

                for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                    if (virtualSchema.getName().equals(mapping.getIntAttrName())
                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
                            && mapping.getResource() != null
                            && attributable.getResources().contains(mapping.getResource())) {

                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());

                        // TODO: must be avoided to use virtual attribute as AccountId
                        if (mapping.isAccountid() && virtualAttribute != null
                                && !virtualAttribute.getValues().isEmpty()) {

                            propByRes.addOldAccountId(mapping.getResource().getName(), virtualAttribute.getValues().get(
                                    0));
                        }
                    }
                }
            }
        }

        LOG.debug("Virtual attributes to be removed:\n{}", propByRes);

        // 2. virtual attributes to be updated
        for (AttributeMod vAttrToBeUpdated : vAttrsToBeUpdated) {
            AbstractVirSchema virtualSchema = getVirtualSchema(vAttrToBeUpdated.getSchema(), attributableUtil.
                    virtualSchemaClass());

            if (virtualSchema != null) {
                for (SchemaMapping mapping : resourceDAO.findAllMappings()) {
                    if (virtualSchema.getName().equals(mapping.getIntAttrName())
                            && mapping.getIntMappingType() == attributableUtil.virtualIntMappingType()
                            && mapping.getResource() != null
                            && attributable.getResources().contains(mapping.getResource())) {

                        propByRes.add(PropagationOperation.UPDATE, mapping.getResource().getName());
                    }
                }

                AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(virtualSchema.getName());

                if (virtualAttribute == null) {
                    virtualAttribute = attributableUtil.newVirtualAttribute();
                    virtualAttribute.setVirtualSchema(virtualSchema);
                    attributable.addVirtualAttribute(virtualAttribute);
                }

                final List<String> values = new ArrayList<String>(virtualAttribute.getValues());
                values.removeAll(vAttrToBeUpdated.getValuesToBeRemoved());
                values.addAll(vAttrToBeUpdated.getValuesToBeAdded());

                virtualAttribute.setValues(values);

                // Owner cannot be specified before otherwise a virtual attribute remove will be invalidated.
                virtualAttribute.setOwner(attributable);
            }
        }

        LOG.debug("Virtual attributes to be added:\n{}", propByRes);
View Full Code Here

     */
    public void fillVirtual(final AbstractAttributable attributable, final List<AttributeTO> vAttrs,
            final AttributableUtil attributableUtil) {

        for (AttributeTO attributeTO : vAttrs) {
            AbstractVirAttr virtualAttribute = attributable.getVirtualAttribute(attributeTO.getSchema());

            if (virtualAttribute == null) {
                AbstractVirSchema virtualSchema = getVirtualSchema(attributeTO.getSchema(), attributableUtil.
                        virtualSchemaClass());

                if (virtualSchema != null) {
                    virtualAttribute = attributableUtil.newVirtualAttribute();
                    virtualAttribute.setVirtualSchema(virtualSchema);
                    virtualAttribute.setOwner(attributable);
                    attributable.addVirtualAttribute(virtualAttribute);
                    virtualAttribute.setValues(attributeTO.getValues());
                }

            } else {
                virtualAttribute.setValues(attributeTO.getValues());
            }

        }
    }
View Full Code Here

            for (AttributeTO vattrTO : attributableTO.getVirtualAttributes()) {
                AbstractVirSchema uVirSchema = getVirtualSchema(vattrTO.getSchema(),
                        attributableUtil.virtualSchemaClass());

                if (uVirSchema != null) {
                    AbstractVirAttr vattr = attributableUtil.newVirtualAttribute();
                    vattr.setVirtualSchema(uVirSchema);
                    vattr.setOwner(attributable);
                    attributable.addVirtualAttribute(vattr);
                }
            }
        }
View Full Code Here

            case UserVirtualSchema:
            case RoleVirtualSchema:
            case MembershipVirtualSchema:
                for (AbstractAttributable attributable : attributables) {
                    AbstractVirAttr virAttr = attributable.getVirtualAttribute(mapping.getIntAttrName());
                    if (virAttr != null) {
                        if (virAttr.getValues() != null) {
                            for (String value : virAttr.getValues()) {
                                AbstractAttrValue attrValue = new UAttrValue();
                                attrValue.setStringValue(value);
                                values.add(attrValue);
                            }
                        }
                        if (vAttrsToBeRemoved != null && vAttrsToBeUpdated != null) {
                            if (vAttrsToBeUpdated.containsKey(mapping.getIntAttrName())) {
                                virAttr.setValues(vAttrsToBeUpdated.get(mapping.getIntAttrName()).getValuesToBeAdded());
                            } else if (vAttrsToBeRemoved.contains(mapping.getIntAttrName())) {
                                virAttr.getValues().clear();
                            } else {
                                throw new RuntimeException("Virtual attribute has not to be updated");
                            }
                        }
                    }
View Full Code Here

        // 1. virtual attributes to be removed
        for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
            AbstractVirSchema virSchema = getVirtualSchema(vAttrToBeRemoved, attrUtil.virSchemaClass());
            if (virSchema != null) {
                AbstractVirAttr virAttr = attributable.getVirtualAttribute(virSchema.getName());
                if (virAttr == null) {
                    LOG.debug("No virtual attribute found for schema {}", virSchema.getName());
                } else {
                    attributable.removeVirtualAttribute(virAttr);
                    virAttrDAO.delete(virAttr);
                }

                for (ExternalResource resource : resourceDAO.findAll()) {
                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
                        if (virSchema.getName().equals(mapItem.getIntAttrName())
                                && mapItem.getIntMappingType() == attrUtil.virIntMappingType()
                                && attributable.getResources().contains(resource)) {

                            propByRes.add(ResourceOperation.UPDATE, resource.getName());

                            // Using virtual attribute as AccountId must be avoided
                            if (mapItem.isAccountid() && virAttr != null && !virAttr.getValues().isEmpty()) {
                                propByRes.addOldAccountId(resource.getName(), virAttr.getValues().get(0));
                            }
                        }
                    }
                }
            }
        }

        LOG.debug("Virtual attributes to be removed:\n{}", propByRes);

        // 2. virtual attributes to be updated
        for (AttributeMod vAttrToBeUpdated : vAttrsToBeUpdated) {
            AbstractVirSchema virSchema = getVirtualSchema(vAttrToBeUpdated.getSchema(), attrUtil.virSchemaClass());
            if (virSchema != null) {
                for (ExternalResource resource : resourceDAO.findAll()) {
                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
                        if (virSchema.getName().equals(mapItem.getIntAttrName())
                                && mapItem.getIntMappingType() == attrUtil.virIntMappingType()
                                && attributable.getResources().contains(resource)) {

                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
                        }
                    }
                }

                AbstractVirAttr virAttr = attributable.getVirtualAttribute(virSchema.getName());
                if (virAttr == null) {
                    virAttr = attrUtil.newVirAttr();
                    virAttr.setVirtualSchema(virSchema);
                    attributable.addVirtualAttribute(virAttr);
                }

                final List<String> values = new ArrayList<String>(virAttr.getValues());
                values.removeAll(vAttrToBeUpdated.getValuesToBeRemoved());
                values.addAll(vAttrToBeUpdated.getValuesToBeAdded());

                virAttr.setValues(values);

                // Owner cannot be specified before otherwise a virtual attribute remove will be invalidated.
                virAttr.setOwner(attributable);
            }
        }

        LOG.debug("Virtual attributes to be added:\n{}", propByRes);
View Full Code Here

     */
    public void fillVirtual(final AbstractAttributable attributable, final Collection<AttributeTO> vAttrs,
            final AttributableUtil attrUtil) {

        for (AttributeTO attributeTO : vAttrs) {
            AbstractVirAttr virAttr = attributable.getVirtualAttribute(attributeTO.getSchema());
            if (virAttr == null) {
                AbstractVirSchema virSchema = getVirtualSchema(attributeTO.getSchema(), attrUtil.virSchemaClass());
                if (virSchema != null) {
                    virAttr = attrUtil.newVirAttr();
                    virAttr.setVirtualSchema(virSchema);
                    virAttr.setOwner(attributable);
                    attributable.addVirtualAttribute(virAttr);
                    virAttr.setValues(attributeTO.getValues());
                }
            } else {
                virAttr.setValues(attributeTO.getValues());
            }
        }
    }
View Full Code Here

            for (AttributeTO vattrTO : attributableTO.getVirtualAttributes()) {
                AbstractVirSchema uVirSchema = getVirtualSchema(vattrTO.getSchema(), attributableUtil.virSchemaClass());

                if (uVirSchema != null) {
                    AbstractVirAttr vattr = attributableUtil.newVirAttr();
                    vattr.setVirtualSchema(uVirSchema);
                    vattr.setOwner(attributable);
                    attributable.addVirtualAttribute(vattr);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.syncope.core.persistence.beans.AbstractVirAttr

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.