Search in sources :

Example 56 with Expression

use of io.atlasmap.v2.Expression in project oozie by apache.

the class CoordInputLogicEvaluatorUtil method validateInputLogic.

/**
 * Validate input logic.
 *
 * @throws JDOMException the JDOM exception
 * @throws CommandException in case of error
 */
public void validateInputLogic() throws JDOMException, CommandException {
    JexlEngine jexl = new OozieJexlEngine();
    String expression = CoordUtils.getInputLogic(coordAction.getActionXml().toString());
    if (StringUtils.isEmpty(expression)) {
        return;
    }
    Expression e = jexl.createExpression(expression);
    JexlContext jc = new OozieJexlParser(jexl, new CoordInputLogicBuilder(new CoordInputLogicEvaluatorPhaseValidate(coordAction)));
    try {
        Object result = e.evaluate(jc);
        log.debug("Input logic expression is [{0}] and evaluate result is [{1}]", expression, result);
    } catch (RuntimeException re) {
        throw new CommandException(ErrorCode.E1028, re.getCause().getMessage());
    }
}
Also used : JexlEngine(org.apache.commons.jexl2.JexlEngine) Expression(org.apache.commons.jexl2.Expression) JexlContext(org.apache.commons.jexl2.JexlContext) CommandException(org.apache.oozie.command.CommandException)

Example 57 with Expression

use of io.atlasmap.v2.Expression in project xtext-core by eclipse.

the class Expression_EqualImpl method basicSetLeft.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLeft(Expression newLeft, NotificationChain msgs) {
    Expression oldLeft = left;
    left = newLeft;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Bug385636Package.EXPRESSION_EQUAL__LEFT, oldLeft, newLeft);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.resource.bug385636.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 58 with Expression

use of io.atlasmap.v2.Expression in project xtext-core by eclipse.

the class Expression_Not_GreaterImpl method basicSetLeft.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLeft(Expression newLeft, NotificationChain msgs) {
    Expression oldLeft = left;
    left = newLeft;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Bug385636Package.EXPRESSION_NOT_GREATER__LEFT, oldLeft, newLeft);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.resource.bug385636.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 59 with Expression

use of io.atlasmap.v2.Expression in project xtext-core by eclipse.

the class Expression_Smaller_EqualImpl method basicSetLeft.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetLeft(Expression newLeft, NotificationChain msgs) {
    Expression oldLeft = left;
    left = newLeft;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Bug385636Package.EXPRESSION_SMALLER_EQUAL__LEFT, oldLeft, newLeft);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Expression(org.eclipse.xtext.resource.bug385636.Expression) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 60 with Expression

use of io.atlasmap.v2.Expression in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionsServiceTest method testProcessOldExpressionActionWithoutRoot.

@Test
public void testProcessOldExpressionActionWithoutRoot() throws Exception {
    DefaultAtlasSession session = mock(DefaultAtlasSession.class);
    FieldGroup fieldGroup = new FieldGroup();
    fieldGroup.setPath("/fields<>");
    fieldGroup.setCollectionType(CollectionType.LIST);
    Field field1 = new SimpleField();
    field1.setPath("/fields<0>");
    field1.setValue("one");
    fieldGroup.getField().add(field1);
    Field field2 = new SimpleField();
    field2.setPath("/fields<1>");
    field2.setValue("two");
    fieldGroup.getField().add(field2);
    Field field3 = new SimpleField();
    field3.setPath("/fields<3>");
    field3.setValue("four");
    fieldGroup.getField().add(field3);
    Expression action = new Expression();
    action.setExpression("capitalize(${0})");
    fieldGroup.setActions(new ArrayList<Action>());
    fieldGroup.getActions().add(action);
    Field answer = fieldActionsService.processActions(session, fieldGroup);
    assertEquals(FieldGroup.class, answer.getClass());
    FieldGroup answerGroup = (FieldGroup) answer;
    assertEquals(3, answerGroup.getField().size());
    Field f = answerGroup.getField().get(0);
    assertEquals("/$ATLASMAP<0>", f.getPath());
    assertEquals("One", f.getValue());
    f = answerGroup.getField().get(1);
    assertEquals("/$ATLASMAP<1>", f.getPath());
    assertEquals("Two", f.getValue());
    f = answerGroup.getField().get(2);
    assertEquals("/$ATLASMAP<2>", f.getPath());
    assertEquals("Four", f.getValue());
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) Action(io.atlasmap.v2.Action) FieldGroup(io.atlasmap.v2.FieldGroup) Expression(io.atlasmap.v2.Expression) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)34 Expression (org.apache.commons.jexl2.Expression)28 Expression (io.atlasmap.v2.Expression)26 JexlContext (org.apache.commons.jexl2.JexlContext)25 JexlEngine (org.apache.commons.jexl2.JexlEngine)22 Field (io.atlasmap.v2.Field)21 FieldGroup (io.atlasmap.v2.FieldGroup)20 MapContext (org.apache.commons.jexl2.MapContext)20 SimpleField (io.atlasmap.v2.SimpleField)16 Test (org.testng.annotations.Test)13 PropertyField (io.atlasmap.v2.PropertyField)9 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)7 Expression (io.atlasmap.expression.Expression)6 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ParseException (io.atlasmap.expression.parser.ParseException)4 Action (io.atlasmap.v2.Action)4 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)4