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

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


        return entityManager.merge(derivedSchema);
    }

    @Override
    public void delete(final String name, final AttributableUtil attributableUtil) {
        final AbstractDerSchema derivedSchema = find(name, attributableUtil.derSchemaClass());
        if (derivedSchema == null) {
            return;
        }

        List<? extends AbstractDerAttr> attributes = getAttributes(derivedSchema, attributableUtil.derAttrClass());
View Full Code Here


        if (derSchemaDAO.find(derSchemaTO.getName(), attrUtil.derSchemaClass()) != null) {
            throw new EntityExistsException(attrUtil.schemaClass().getSimpleName()
                    + " '" + derSchemaTO.getName() + "'");
        }

        AbstractDerSchema derivedSchema = derSchemaDAO.save(binder.create(derSchemaTO, attrUtil.newDerSchema()));

        auditManager.audit(Category.schema, SchemaSubCategory.createDerived, Result.success,
                "Successfully created derived schema: " + kind + "/" + derivedSchema.getName());

        response.setStatus(HttpServletResponse.SC_CREATED);
        return binder.getDerivedSchemaTO(derivedSchema);
    }
View Full Code Here

    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/delete/{schema}")
    public DerivedSchemaTO delete(@PathVariable("kind") final String kind,
            @PathVariable("schema") final String derivedSchemaName) {

        Class<? extends AbstractDerSchema> reference = getAttributableUtil(kind).derSchemaClass();
        AbstractDerSchema derivedSchema = derSchemaDAO.find(derivedSchemaName, reference);
        if (derivedSchema == null) {
            throw new NotFoundException("Derived schema '" + derivedSchemaName + "'");
        }

        DerivedSchemaTO schemaToDelete = binder.getDerivedSchemaTO(derivedSchema);

        derSchemaDAO.delete(derivedSchemaName, getAttributableUtil(kind));

        auditManager.audit(Category.schema, SchemaSubCategory.deleteDerived, Result.success,
                "Successfully deleted derived schema: " + kind + "/" + derivedSchema.getName());

        return schemaToDelete;
    }
View Full Code Here

    @RequestMapping(method = RequestMethod.GET, value = "/{kind}/read/{derivedSchema}")
    public DerivedSchemaTO read(@PathVariable("kind") final String kind,
            @PathVariable("derivedSchema") final String derivedSchemaName) {

        Class<? extends AbstractDerSchema> reference = getAttributableUtil(kind).derSchemaClass();
        AbstractDerSchema derivedSchema = derSchemaDAO.find(derivedSchemaName, reference);
        if (derivedSchema == null) {
            throw new NotFoundException("Derived schema '" + derivedSchemaName + "'");
        }

        auditManager.audit(Category.schema, SchemaSubCategory.readDerived, Result.success,
                "Successfully read derived schema: " + kind + "/" + derivedSchema.getName());

        return binder.getDerivedSchemaTO(derivedSchema);
    }
View Full Code Here

    @RequestMapping(method = RequestMethod.POST, value = "/{kind}/update")
    public DerivedSchemaTO update(@RequestBody final DerivedSchemaTO derivedSchemaTO,
            @PathVariable("kind") final String kind) {

        Class<? extends AbstractDerSchema> reference = getAttributableUtil(kind).derSchemaClass();
        AbstractDerSchema derivedSchema = derSchemaDAO.find(derivedSchemaTO.getName(), reference);
        if (derivedSchema == null) {
            throw new NotFoundException("Derived schema '" + derivedSchemaTO.getName() + "'");
        }

        derivedSchema = binder.update(derivedSchemaTO, derivedSchema);
        derivedSchema = derSchemaDAO.save(derivedSchema);

        auditManager.audit(Category.schema, SchemaSubCategory.updateDerived, Result.success,
                "Successfully updated derived schema: " + kind + "/" + derivedSchema.getName());

        return binder.getDerivedSchemaTO(derivedSchema);
    }
View Full Code Here

    @Override
    public <T extends AbstractAttributable> List<T> findByDerAttrValue(final String schemaName, final String value,
            final AttributableUtil attrUtil)
            throws InvalidSearchConditionException {

        AbstractDerSchema schema = derSchemaDAO.find(schemaName, attrUtil.derSchemaClass());
        if (schema == null) {
            LOG.error("Invalid schema name '{}'", schemaName);
            return Collections.<T>emptyList();
        }

        // query string
        final StringBuilder querystring = new StringBuilder();

        boolean subquery = false;
        for (String clause : getWhereClause(schema.getExpression(), value, attrUtil)) {
            if (querystring.length() > 0) {
                subquery = true;
                querystring.append(" AND a.owner_id IN ( ");
            }
View Full Code Here

        LOG.debug("Attributes to be updated:\n{}", propByRes);

        // 5. derived attributes to be removed
        for (String derAttrToBeRemoved : attributableMod.getDerivedAttributesToBeRemoved()) {
            AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeRemoved, attrUtil.derSchemaClass());
            if (derSchema != null) {
                AbstractDerAttr derAttr = attributable.getDerivedAttribute(derSchema.getName());
                if (derAttr == null) {
                    LOG.debug("No derived attribute found for schema {}", derSchema.getName());
                } else {
                    derAttrDAO.delete(derAttr);
                }

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

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

                            if (mapItem.isAccountid() && derAttr != null
                                    && !derAttr.getValue(attributable.getAttributes()).isEmpty()) {

                                propByRes.addOldAccountId(resource.getName(),
                                        derAttr.getValue(attributable.getAttributes()));
                            }
                        }
                    }
                }
            }
        }

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

        // 6. derived attributes to be added
        for (String derAttrToBeAdded : attributableMod.getDerivedAttributesToBeAdded()) {
            AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeAdded, attrUtil.derSchemaClass());
            if (derSchema != null) {
                for (ExternalResource resource : resourceDAO.findAll()) {
                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
                        if (derSchema.getName().equals(mapItem.getIntAttrName())
                                && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
                                && attributable.getResources().contains(resource)) {

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

        if (!invalidValues.isEmpty()) {
            scce.addException(invalidValues);
        }

        // 2. derived attributes
        AbstractDerSchema derivedSchema;
        AbstractDerAttr derivedAttribute;
        for (AttributeTO attributeTO : attributableTO.getDerivedAttributes()) {

            derivedSchema = getDerivedSchema(attributeTO.getSchema(), attributableUtil.derSchemaClass());
View Full Code Here

        LOG.debug("Attributes to be updated:\n{}", propByRes);

        // 5. derived attributes to be removed
        for (String derAttrToBeRemoved : attributableMod.getDerivedAttributesToBeRemoved()) {
            AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeRemoved, attrUtil.derSchemaClass());
            if (derSchema != null) {
                AbstractDerAttr derAttr = attributable.getDerivedAttribute(derSchema.getName());
                if (derAttr == null) {
                    LOG.debug("No derived attribute found for schema {}", derSchema.getName());
                } else {
                    derAttrDAO.delete(derAttr);
                }

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

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

                            if (mapItem.isAccountid() && derAttr != null
                                    && !derAttr.getValue(attributable.getAttributes()).isEmpty()) {

                                propByRes.addOldAccountId(resource.getName(),
                                        derAttr.getValue(attributable.getAttributes()));
                            }
                        }
                    }
                }
            }
        }

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

        // 6. derived attributes to be added
        for (String derAttrToBeAdded : attributableMod.getDerivedAttributesToBeAdded()) {
            AbstractDerSchema derSchema = getDerivedSchema(derAttrToBeAdded, attrUtil.derSchemaClass());
            if (derSchema != null) {
                for (ExternalResource resource : resourceDAO.findAll()) {
                    for (AbstractMappingItem mapItem : attrUtil.getMappingItems(resource, MappingPurpose.PROPAGATION)) {
                        if (derSchema.getName().equals(mapItem.getIntAttrName())
                                && mapItem.getIntMappingType() == attrUtil.derIntMappingType()
                                && attributable.getResources().contains(resource)) {

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

        if (!invalidValues.isEmpty()) {
            scce.addException(invalidValues);
        }

        // 2. derived attributes
        AbstractDerSchema derivedSchema;
        AbstractDerAttr derivedAttribute;
        for (AttributeTO attributeTO : attributableTO.getDerivedAttributes()) {

            derivedSchema = getDerivedSchema(attributeTO.getSchema(), attributableUtil.derSchemaClass());
View Full Code Here

TOP

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

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.