Search in sources :

Example 11 with PlainAttrValue

use of org.apache.syncope.core.persistence.api.entity.PlainAttrValue in project syncope by apache.

the class AbstractAnyDataBinder method evaluateMandatoryCondition.

private List<String> evaluateMandatoryCondition(final Provision provision, final Any<?> any) {
    List<String> missingAttrNames = new ArrayList<>();
    MappingUtils.getPropagationItems(provision.getMapping().getItems()).forEach(mapItem -> {
        IntAttrName intAttrName = null;
        try {
            intAttrName = intAttrNameParser.parse(mapItem.getIntAttrName(), provision.getAnyType().getKind());
        } catch (ParseException e) {
            LOG.error("Invalid intAttrName '{}', ignoring", mapItem.getIntAttrName(), e);
        }
        if (intAttrName != null && intAttrName.getSchemaType() != null) {
            List<PlainAttrValue> values = mappingManager.getIntValues(provision, mapItem, intAttrName, any);
            if (values.isEmpty() && JexlUtils.evaluateMandatoryCondition(mapItem.getMandatoryCondition(), any)) {
                missingAttrNames.add(mapItem.getIntAttrName());
            }
        }
    });
    return missingAttrNames;
}
Also used : ArrayList(java.util.ArrayList) PlainAttrValue(org.apache.syncope.core.persistence.api.entity.PlainAttrValue) ParseException(java.text.ParseException) IntAttrName(org.apache.syncope.core.provisioning.api.IntAttrName)

Example 12 with PlainAttrValue

use of org.apache.syncope.core.persistence.api.entity.PlainAttrValue in project syncope by apache.

the class AbstractAnyDAO method findByPlainAttrValue.

@Override
@SuppressWarnings("unchecked")
public List<A> findByPlainAttrValue(final String schemaKey, final PlainAttrValue attrValue) {
    PlainSchema schema = plainSchemaDAO().find(schemaKey);
    if (schema == null) {
        LOG.error("Invalid schema name '{}'", schemaKey);
        return Collections.<A>emptyList();
    }
    String entityName = schema.isUniqueConstraint() ? anyUtils().plainAttrUniqueValueClass().getName() : anyUtils().plainAttrValueClass().getName();
    Query query = findByPlainAttrValueQuery(entityName);
    query.setParameter("schemaKey", schemaKey);
    query.setParameter("stringValue", attrValue.getStringValue());
    query.setParameter("booleanValue", attrValue.getBooleanValue() == null ? null : ((AbstractPlainAttrValue) attrValue).getBooleanAsInteger(attrValue.getBooleanValue()));
    if (attrValue.getDateValue() == null) {
        query.setParameter("dateValue", null);
    } else {
        query.setParameter("dateValue", attrValue.getDateValue(), TemporalType.TIMESTAMP);
    }
    query.setParameter("longValue", attrValue.getLongValue());
    query.setParameter("doubleValue", attrValue.getDoubleValue());
    List<A> result = new ArrayList<>();
    ((List<PlainAttrValue>) query.getResultList()).stream().forEach(value -> {
        A any = (A) value.getAttr().getOwner();
        if (!result.contains(any)) {
            result.add(any);
        }
    });
    return result;
}
Also used : Query(javax.persistence.Query) ArrayList(java.util.ArrayList) AbstractPlainAttrValue(org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue) PlainAttrValue(org.apache.syncope.core.persistence.api.entity.PlainAttrValue) AbstractPlainAttrValue(org.apache.syncope.core.persistence.jpa.entity.AbstractPlainAttrValue) PlainSchema(org.apache.syncope.core.persistence.api.entity.PlainSchema)

Aggregations

PlainAttrValue (org.apache.syncope.core.persistence.api.entity.PlainAttrValue)12 PlainSchema (org.apache.syncope.core.persistence.api.entity.PlainSchema)8 ParseException (java.text.ParseException)7 ArrayList (java.util.ArrayList)7 IntAttrName (org.apache.syncope.core.provisioning.api.IntAttrName)6 ParsingValidationException (org.apache.syncope.core.persistence.api.attrvalue.validation.ParsingValidationException)5 User (org.apache.syncope.core.persistence.api.entity.user.User)5 AttrSchemaType (org.apache.syncope.common.lib.types.AttrSchemaType)4 AnyUtils (org.apache.syncope.core.persistence.api.entity.AnyUtils)4 AnyObject (org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject)4 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)4 ItemTransformer (org.apache.syncope.core.provisioning.api.data.ItemTransformer)4 Attribute (org.identityconnectors.framework.common.objects.Attribute)4 Collections (java.util.Collections)3 List (java.util.List)3 Optional (java.util.Optional)3 Pair (org.apache.commons.lang3.tuple.Pair)3 AttrTO (org.apache.syncope.common.lib.to.AttrTO)3 UserTO (org.apache.syncope.common.lib.to.UserTO)3 DerSchema (org.apache.syncope.core.persistence.api.entity.DerSchema)3