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

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


        }

        T created;
        switch (schemaType) {
            case VIRTUAL:
                AbstractVirSchema virSchema = attrUtil.newVirSchema();
                binder.create((VirSchemaTO) schemaTO, virSchema);
                virSchema = virSchemaDAO.save(virSchema);
                created = (T) binder.getVirSchemaTO(virSchema);
                break;
            case DERIVED:
View Full Code Here


        final AttributableUtil attrUtil = AttributableUtil.getInstance(attrType);

        T read;
        switch (schemaType) {
            case VIRTUAL:
                AbstractVirSchema virSchema = virSchemaDAO.find(schemaName, attrUtil.virSchemaClass());
                if (virSchema == null) {
                    throw new NotFoundException("Virtual Schema '" + schemaName + "'");
                }

                read = (T) binder.getVirSchemaTO(virSchema);
View Full Code Here

            throw new NotFoundException(schemaType + "/" + attrType + "/" + schemaTO.getName());
        }

        switch (schemaType) {
            case VIRTUAL:
                AbstractVirSchema virSchema = virSchemaDAO.find(schemaTO.getName(), attrUtil.virSchemaClass());
                if (virSchema == null) {
                    throw new NotFoundException("Virtual Schema '" + schemaTO.getName() + "'");
                }

                binder.update((VirSchemaTO) schemaTO, virSchema);
View Full Code Here

            externalResources.addAll(((Membership) attributable).getSyncopeUser().getResources());
        }

        // 1. virtual attributes to be removed
        for (String vAttrToBeRemoved : vAttrsToBeRemoved) {
            AbstractVirSchema virSchema = getVirSchema(vAttrToBeRemoved, attrUtil.virSchemaClass());
            if (virSchema != null) {
                AbstractVirAttr virAttr = attributable.getVirAttr(virSchema.getName());
                if (virAttr == null) {
                    LOG.debug("No virtual attribute found for schema {}", virSchema.getName());
                } else {
                    attributable.removeVirAttr(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()
                                && externalResources.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 = getVirSchema(vAttrToBeUpdated.getSchema(), attrUtil.virSchemaClass());
            AbstractVirAttr virAttr = null;
            if (virSchema != null) {
                virAttr = attributable.getVirAttr(virSchema.getName());
                if (virAttr == null) {
                    virAttr = attrUtil.newVirAttr();
                    setVirAttrSchema(attributable, virAttr, virSchema);
                    if (virAttr.getSchema() == null) {
                        LOG.debug("Ignoring {} because no valid schema or template was found", vAttrToBeUpdated);
                    } else {
                        attributable.addVirAttr(virAttr);
                    }
                }
            }

            if (virSchema != null && virAttr != null && virAttr.getSchema() != null) {
                for (ExternalResource resource : resourceDAO.findAll()) {
                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
                        if (virSchema.getName().equals(mapItem.getIntAttrName())
                                && mapItem.getIntMappingType() == attrUtil.virIntMappingType()
                                && externalResources.contains(resource)) {

                            propByRes.add(ResourceOperation.UPDATE, resource.getName());
                        }
View Full Code Here

            final AttributableUtil attrUtil) {

        for (AttributeTO attributeTO : vAttrs) {
            AbstractVirAttr virAttr = attributable.getVirAttr(attributeTO.getSchema());
            if (virAttr == null) {
                AbstractVirSchema virSchema = getVirSchema(attributeTO.getSchema(), attrUtil.virSchemaClass());
                if (virSchema != null) {
                    virAttr = attrUtil.newVirAttr();
                    setVirAttrSchema(attributable, virAttr, virSchema);
                    if (virAttr.getSchema() == null) {
                        LOG.debug("Ignoring {} because no valid schema or template was found", attributeTO);
View Full Code Here

        // 3. user and role virtual attributes will be evaluated by the propagation manager only (if needed).
        if (AttributableType.USER == attributableUtil.getType()
                || AttributableType.ROLE == attributableUtil.getType()) {

            for (AttributeTO vattrTO : attributableTO.getVirAttrs()) {
                AbstractVirSchema virSchema = getVirSchema(vattrTO.getSchema(), attributableUtil.virSchemaClass());

                if (virSchema != null) {
                    AbstractVirAttr virAttr = attributableUtil.newVirAttr();
                    setVirAttrSchema(attributable, virAttr, virSchema);
                    if (virAttr.getSchema() == null) {
View Full Code Here

    }

    @Override
    @SuppressWarnings("unchecked")
    public void delete(final String name, final AttributableUtil attributableUtil) {
        final AbstractVirSchema schema = find(name, attributableUtil.virSchemaClass());
        if (schema == null) {
            return;
        }

        final Set<Long> attrIds = new HashSet<Long>();
        for (AbstractVirAttr attr : findAttrs(schema, attributableUtil.virAttrClass())) {
            attrIds.add(attr.getId());
        }
        for (Long attrId : attrIds) {
            virAttrDAO.delete(attrId, attributableUtil.virAttrClass());
        }

        if (attributableUtil.getType() != AttributableType.USER) {
            for (Iterator<Number> it = attrTemplateDAO.
                    findBySchemaName(schema.getName(), attributableUtil.virAttrTemplateClass()).iterator();
                    it.hasNext();) {

                attrTemplateDAO.delete(it.next().longValue(), attributableUtil.virAttrTemplateClass());
            }
        }
View Full Code Here

    public void delete() {
        UVirSchema virtualdata = virSchemaDAO.find("virtualdata", UVirSchema.class);

        virSchemaDAO.delete(virtualdata.getName(), AttributableUtil.getInstance(AttributableType.USER));

        AbstractVirSchema actual = virSchemaDAO.find("virtualdata", UVirSchema.class);
        assertNull("delete did not work", actual);

        // ------------- //

        RVirSchema rvirtualdata = virSchemaDAO.find("rvirtualdata", RVirSchema.class);
View Full Code Here

TOP

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

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.