Examples of MapContext


Examples of org.apache.commons.jexl2.MapContext

    }

    public static boolean evaluateMandatoryCondition(final String mandatoryCondition,
            final AbstractAttributable attributable) {

        JexlContext jexlContext = new MapContext();
        addAttrsToContext(attributable.getAttributes(), jexlContext);
        addDerAttrsToContext(attributable.getDerivedAttributes(), attributable.getAttributes(), jexlContext);
        addVirAttrsToContext(attributable.getVirtualAttributes(), jexlContext);

        return Boolean.parseBoolean(evaluate(mandatoryCondition, jexlContext));
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

        return Boolean.parseBoolean(evaluate(mandatoryCondition, jexlContext));
    }

    public static String evaluate(final String expression, final AbstractAttributableTO attributableTO) {
        final JexlContext context = new MapContext();

        addFieldsToContext(attributableTO, context);

        for (AttributeTO attr : attributableTO.getAttributes()) {
            List<String> values = attr.getValues();
            String expressionValue = values.isEmpty()
                    ? StringUtils.EMPTY
                    : values.get(0);

            LOG.debug("Add attribute {} with value {}", attr.getSchema(), expressionValue);

            context.set(attr.getSchema(), expressionValue);
        }
        for (AttributeTO derAttr : attributableTO.getDerivedAttributes()) {
            List<String> values = derAttr.getValues();
            String expressionValue = values.isEmpty()
                    ? StringUtils.EMPTY
                    : values.get(0);

            LOG.debug("Add derived attribute {} with value {}", derAttr.getSchema(), expressionValue);

            context.set(derAttr.getSchema(), expressionValue);
        }
        for (AttributeTO virAttr : attributableTO.getVirtualAttributes()) {
            List<String> values = virAttr.getValues();
            String expressionValue = values.isEmpty()
                    ? StringUtils.EMPTY
                    : values.get(0);

            LOG.debug("Add virtual attribute {} with value {}", virAttr.getSchema(), expressionValue);

            context.set(virAttr.getSchema(), expressionValue);
        }

        // Evaluate expression using the context prepared before
        return evaluate(expression, context);
    }
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

     * @param attributes the set of attributes against which evaluate this derived attribute
     * @return the value of this derived attribute
     */
    public String getValue(final Collection<? extends AbstractAttr> attributes) {
        // Prepare context using user attributes
        final JexlContext jexlContext = new MapContext();
        JexlUtil.addAttrsToContext(attributes, jexlContext);
        JexlUtil.addFieldsToContext(getOwner(), jexlContext);

        // Evaluate expression using the context prepared before
        return JexlUtil.evaluate(getDerivedSchema().getExpression(), jexlContext);
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

                    if (role.getResourceNames().contains(task.getResource().getName())
                            && StringUtils.isNotBlank(task.getResource().getRmapping().getAccountLink())) {

                        LOG.debug("Evaluating accountLink for {}", role);

                        final JexlContext jexlContext = new MapContext();
                        JexlUtil.addFieldsToContext(role, jexlContext);
                        JexlUtil.addAttrsToContext(role.getAttributes(), jexlContext);
                        JexlUtil.addDerAttrsToContext(role.getDerivedAttributes(), role.getAttributes(), jexlContext);
                        final String roleAccountLink =
                                JexlUtil.evaluate(task.getResource().getRmapping().getAccountLink(), jexlContext);
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

     *
     * @return the newly created context
     */
    private JexlContext createContext()
    {
        JexlContext ctx = new MapContext();
        initializeContext(ctx);
        return ctx;
    }
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

    }

    private boolean evaluateMandatoryCondition(final String mandatoryCondition,
            final List<? extends AbstractAttr> attributes) {

        JexlContext jexlContext = new MapContext();
        jexlUtil.addAttrsToContext(attributes, jexlContext);

        return Boolean.parseBoolean(jexlUtil.evaluate(mandatoryCondition, jexlContext));
    }
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

        return result;
    }

    public String evaluate(final String expression, final AbstractAttributable attributable) {

        final JexlContext jexlContext = new MapContext();

        if (attributable instanceof SyncopeUser) {
            SyncopeUser user = (SyncopeUser) attributable;

            jexlContext.set("username", user.getUsername() != null
                    ? user.getUsername()
                    : StringUtils.EMPTY);
            jexlContext.set("creationDate", user.getCreationDate() != null
                    ? user.getDateFormatter().format(user.getCreationDate())
                    : StringUtils.EMPTY);
            jexlContext.set("lastLoginDate", user.getLastLoginDate() != null
                    ? user.getDateFormatter().format(user.getLastLoginDate())
                    : StringUtils.EMPTY);
            jexlContext.set("failedLogins", user.getFailedLogins() != null
                    ? user.getFailedLogins()
                    : StringUtils.EMPTY);
            jexlContext.set("changePwdDate", user.getChangePwdDate() != null
                    ? user.getDateFormatter().format(user.getChangePwdDate())
                    : StringUtils.EMPTY);
        }

        addAttrsToContext(attributable.getAttributes(), jexlContext);
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

    public JexlContext addAttrsToContext(final Collection<? extends AbstractAttr> attributes,
            final JexlContext jexlContext) {

        JexlContext context = jexlContext == null
                ? new MapContext()
                : jexlContext;

        for (AbstractAttr attribute : attributes) {
            List<String> attributeValues = attribute.getValuesAsStrings();
            String expressionValue = attributeValues.isEmpty()
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

    public JexlContext addDerAttrsToContext(final Collection<? extends AbstractDerAttr> derAttributes,
            final Collection<? extends AbstractAttr> attributes, final JexlContext jexlContext) {

        JexlContext context = jexlContext == null
                ? new MapContext()
                : jexlContext;

        for (AbstractDerAttr attribute : derAttributes) {
            String expressionValue = attribute.getValue(attributes);
            if (expressionValue == null) {
View Full Code Here

Examples of org.apache.commons.jexl2.MapContext

        return context;
    }

    public String evaluate(final String expression, final AbstractAttributableTO attributableTO) {

        final JexlContext context = new MapContext();

        if (attributableTO instanceof UserTO) {
            UserTO user = (UserTO) attributableTO;

            context.set("username", user.getUsername() != null
                    ? user.getUsername()
                    : StringUtils.EMPTY);
            context.set("password", user.getPassword() != null
                    ? user.getPassword()
                    : StringUtils.EMPTY);
        }

        for (AttributeTO attribute : attributableTO.getAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }
        for (AttributeTO attribute : attributableTO.getDerivedAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }
        for (AttributeTO attribute : attributableTO.getVirtualAttributes()) {
            List<String> attributeValues = attribute.getValues();
            String expressionValue = attributeValues.isEmpty()
                    ? StringUtils.EMPTY
                    : attributeValues.get(0);

            LOG.debug("Add attribute {} with value {}", new Object[] { attribute.getSchema(), expressionValue });

            context.set(attribute.getSchema(), expressionValue);
        }

        // Evaluate expression using the context prepared before
        return evaluate(expression, context);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.