private Map<DerSchema, String> getValues(final Any<?> any, final Set<DerSchema> schemas) { Map<DerSchema, String> result = new HashMap<>(schemas.size()); schemas.forEach(schema -> { JexlContext jexlContext = new MapContext(); JexlUtils.addPlainAttrsToContext(any.getPlainAttrs(), jexlContext); JexlUtils.addFieldsToContext(any, jexlContext); result.put(schema, JexlUtils.evaluate(schema.getExpression(), jexlContext)); }); return result; }
public static boolean evaluateMandatoryCondition(final String mandatoryCondition, final Any<?> any) { JexlContext jexlContext = new MapContext(); addPlainAttrsToContext(any.getPlainAttrs(), jexlContext); addDerAttrsToContext(any, jexlContext); return Boolean.parseBoolean(evaluate(mandatoryCondition, jexlContext)); }
any, provision, any.getPlainAttrs());
/** * Build __NAME__ for propagation. * First look if there is a defined connObjectLink for the given resource (and in * this case evaluate as JEXL); otherwise, take given connObjectKey. * * @param any given any object * @param provision external resource * @param connObjectKey connector object key * @return the value to be propagated as __NAME__ */ public static Name evaluateNAME(final Any<?> any, final Provision provision, final String connObjectKey) { if (StringUtils.isBlank(connObjectKey)) { // LOG error but avoid to throw exception: leave it to the external resource LOG.warn("Missing ConnObjectKey value for {}: ", provision.getResource()); } // Evaluate connObjectKey expression String connObjectLink = provision == null || provision.getMapping() == null ? null : provision.getMapping().getConnObjectLink(); String evalConnObjectLink = null; if (StringUtils.isNotBlank(connObjectLink)) { JexlContext jexlContext = new MapContext(); JexlUtils.addFieldsToContext(any, jexlContext); JexlUtils.addPlainAttrsToContext(any.getPlainAttrs(), jexlContext); JexlUtils.addDerAttrsToContext(any, jexlContext); evalConnObjectLink = JexlUtils.evaluate(connObjectLink, jexlContext); } return getName(evalConnObjectLink, connObjectKey); }
@Override public List<PlainAttrValue> beforePropagation( final Item item, final Entity entity, final List<PlainAttrValue> values) { if (StringUtils.isNotBlank(propagationJEXL) && values != null) { values.forEach(value -> { Object originalValue = value.getValue(); if (originalValue != null) { JexlContext jexlContext = new MapContext(); if (entity != null) { JexlUtils.addFieldsToContext(entity, jexlContext); if (entity instanceof Any) { JexlUtils.addPlainAttrsToContext(((Any<?>) entity).getPlainAttrs(), jexlContext); JexlUtils.addDerAttrsToContext(((Any<?>) entity), jexlContext); } } jexlContext.set("value", originalValue.toString()); value.setBinaryValue(null); value.setBooleanValue(null); value.setDateValue(null); value.setDoubleValue(null); value.setLongValue(null); value.setStringValue(JexlUtils.evaluate(propagationJEXL, jexlContext)); } }); return values; } return JEXLItemTransformer.super.beforePropagation(item, entity, values); }
getInstance(any.getType().getKind()).dao().findAllowedSchemas(any, PlainSchema.class); for (PlainAttr<?> attr : ((Any<?>) any).getPlainAttrs()) { if (attr != null && !allowedPlainSchemas.forSelfContains(attr.getSchema().getKey())) { return raiseNotAllowedViolation(context, attr.getSchema().getKey(), null);