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;
}
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;
}
Aggregations