Examples of JexlContext


Examples of org.apache.commons.jexl2.JexlContext

    }

    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.JexlContext

        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.JexlContext

                    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.JexlContext

        }

        // Evaluate AccountLink expression
        String evalAccountLink = null;
        if (StringUtils.isNotBlank(attrUtil.getAccountLink(resource))) {
            final JexlContext jexlContext = new MapContext();
            JexlUtil.addFieldsToContext(subject, jexlContext);
            JexlUtil.addAttrsToContext(subject.getAttributes(), jexlContext);
            JexlUtil.addDerAttrsToContext(subject.getDerivedAttributes(), subject.getAttributes(), jexlContext);
            evalAccountLink = JexlUtil.evaluate(attrUtil.getAccountLink(resource), jexlContext);
        }
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

     *                      describes the &quot;lifecycle&quot; of the
     *                      instances of this class.
     */
    public AbstractStateMachine(final URL scxmlDocument) {
        // default is JEXL
        this(scxmlDocument, new JexlContext(), new JexlEvaluator());
    }
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

        return getExecutor(scxml, null);
    }

    public static SCXMLExecutor getExecutor(SCXML scxml,
            SCXMLSemantics semantics) {
        Context context = new JexlContext();
        Evaluator evaluator = new JexlEvaluator();
        EventDispatcher ed = new SimpleDispatcher();
        Tracer trc = new Tracer();
        return getExecutor(context, evaluator, scxml, ed, trc, semantics);
    }
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

    }

    public static SCXMLExecutor getExecutor(Evaluator evaluator, SCXML scxml) {
        EventDispatcher ed = new SimpleDispatcher();
        Tracer trc = new Tracer();
        Context context = new JexlContext();
        return getExecutor(context, evaluator, scxml, ed, trc);
    }
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

            SCXML scxml = SCXMLDigester.digest(invoke01,
                new SimpleErrorHandler());
            exec = new SCXMLExecutor(new JexlEvaluator(), new SimpleDispatcher(),
                new SimpleErrorReporter());
            assertNotNull(exec);
            exec.setRootContext(new JexlContext());
            exec.setStateMachine(scxml);
            exec.registerInvokerClass("scxml", SimpleSCXMLInvoker.class);
            exec.go();
            Set currentStates = exec.getCurrentStatus().getStates();
            assertEquals(1, currentStates.size());
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

    /**
     * Test the stateless model, simultaneous executions
     */
    public void testDatamodelSimultaneousJexl() {
        exec01 = SCXMLTestHelper.getExecutor(datamodel01jexl,
            new JexlContext(), new JexlEvaluator());
        assertNotNull(exec01);
        exec02 = SCXMLTestHelper.getExecutor(datamodel01jexl,
            new JexlContext(), new JexlEvaluator());
        assertNotNull(exec02);
        assertFalse(exec01 == exec02);
        runtest();
    }
View Full Code Here

Examples of org.apache.commons.scxml.env.jexl.JexlContext

        runtest();
    }

    public void testDatamodelNamespacePrefixedXPaths() {
        exec01 = SCXMLTestHelper.getExecutor(datamodel02jexl,
            new JexlContext(), new JexlEvaluator());
        assertNotNull(exec01);
        exec02 = SCXMLTestHelper.getExecutor(datamodel02jsp,
            new ELContext(), new ELEvaluator());
        assertNotNull(exec02);
        assertFalse(exec01 == exec02);
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.