Search in sources :

Example 1 with ConditionOr

use of com.adaptris.core.services.conditional.conditions.ConditionOr in project interlok by adaptris.

the class DoWhileTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    ConditionMetadata condition = new ConditionMetadata();
    condition.setMetadataKey("key1");
    condition.setOperator(new NotNull());
    ConditionMetadata condition2 = new ConditionMetadata();
    condition2.setMetadataKey("key2");
    condition2.setOperator(new IsNull());
    ConditionOr conditionOr = new ConditionOr();
    conditionOr.getConditions().add(condition);
    conditionOr.getConditions().add(condition2);
    ThenService thenSrvc = new ThenService();
    thenSrvc.setService(new LogMessageService());
    doWhile.setCondition(conditionOr);
    doWhile.setThen(thenSrvc);
    DoWhile doWhile = new DoWhile();
    doWhile.setCondition(conditionOr);
    doWhile.setThen(thenSrvc);
    return doWhile;
}
Also used : ConditionOr(com.adaptris.core.services.conditional.conditions.ConditionOr) LogMessageService(com.adaptris.core.services.LogMessageService) ConditionMetadata(com.adaptris.core.services.conditional.conditions.ConditionMetadata) IsNull(com.adaptris.core.services.conditional.operator.IsNull) NotNull(com.adaptris.core.services.conditional.operator.NotNull)

Example 2 with ConditionOr

use of com.adaptris.core.services.conditional.conditions.ConditionOr in project interlok by adaptris.

the class WhileTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    ConditionMetadata condition = new ConditionMetadata();
    condition.setMetadataKey("key1");
    condition.setOperator(new NotNull());
    ConditionMetadata condition2 = new ConditionMetadata();
    condition2.setMetadataKey("key2");
    condition2.setOperator(new IsNull());
    ConditionOr conditionOr = new ConditionOr();
    conditionOr.getConditions().add(condition);
    conditionOr.getConditions().add(condition2);
    ThenService thenSrvc = new ThenService();
    thenSrvc.setService(new LogMessageService());
    logicalExpression.setCondition(conditionOr);
    logicalExpression.setThen(thenSrvc);
    // We init and start the service in the setup, lets stop it.
    try {
        StopMe(logicalExpression);
    } catch (Exception e) {
    }
    return logicalExpression;
}
Also used : ConditionOr(com.adaptris.core.services.conditional.conditions.ConditionOr) LogMessageService(com.adaptris.core.services.LogMessageService) ConditionMetadata(com.adaptris.core.services.conditional.conditions.ConditionMetadata) IsNull(com.adaptris.core.services.conditional.operator.IsNull) NotNull(com.adaptris.core.services.conditional.operator.NotNull) ServiceException(com.adaptris.core.ServiceException) CoreException(com.adaptris.core.CoreException)

Example 3 with ConditionOr

use of com.adaptris.core.services.conditional.conditions.ConditionOr in project interlok by adaptris.

the class IfElseTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    IfElse result = new IfElse();
    ConditionMetadata condition = new ConditionMetadata();
    condition.setMetadataKey("key1");
    condition.setOperator(new NotNull());
    Equals equals = new Equals();
    equals.setValue("myValue");
    ConditionMetadata condition2 = new ConditionMetadata();
    condition2.setMetadataKey("key2");
    condition2.setOperator(equals);
    ConditionOr conditionOr = new ConditionOr();
    ConditionExpression conditionExpression = new ConditionExpression();
    conditionExpression.setAlgorithm("(%message{key1} - 10) == %message{key2}");
    conditionOr.getConditions().add(conditionExpression);
    conditionOr.getConditions().add(condition2);
    ConditionAnd conditionAnd = new ConditionAnd();
    conditionAnd.getConditions().add(condition);
    conditionAnd.getConditions().add(conditionOr);
    conditionAnd.getConditions().add(new ConditionFunction("function evaluateScript(message) { return message.getMetadataValue('mykey').equals('myvalue');}"));
    ThenService thenSrvc = new ThenService();
    ElseService elseSrvc = new ElseService();
    thenSrvc.setService(new LogMessageService());
    elseSrvc.setService(new LogMessageService());
    result.setCondition(conditionAnd);
    result.setThen(thenSrvc);
    result.setOtherwise(elseSrvc);
    return result;
}
Also used : ConditionAnd(com.adaptris.core.services.conditional.conditions.ConditionAnd) ConditionFunction(com.adaptris.core.services.conditional.conditions.ConditionFunction) Equals(com.adaptris.core.services.conditional.operator.Equals) ConditionOr(com.adaptris.core.services.conditional.conditions.ConditionOr) ConditionExpression(com.adaptris.core.services.conditional.conditions.ConditionExpression) LogMessageService(com.adaptris.core.services.LogMessageService) ConditionMetadata(com.adaptris.core.services.conditional.conditions.ConditionMetadata) NotNull(com.adaptris.core.services.conditional.operator.NotNull)

Aggregations

LogMessageService (com.adaptris.core.services.LogMessageService)3 ConditionMetadata (com.adaptris.core.services.conditional.conditions.ConditionMetadata)3 ConditionOr (com.adaptris.core.services.conditional.conditions.ConditionOr)3 NotNull (com.adaptris.core.services.conditional.operator.NotNull)3 IsNull (com.adaptris.core.services.conditional.operator.IsNull)2 CoreException (com.adaptris.core.CoreException)1 ServiceException (com.adaptris.core.ServiceException)1 ConditionAnd (com.adaptris.core.services.conditional.conditions.ConditionAnd)1 ConditionExpression (com.adaptris.core.services.conditional.conditions.ConditionExpression)1 ConditionFunction (com.adaptris.core.services.conditional.conditions.ConditionFunction)1 Equals (com.adaptris.core.services.conditional.operator.Equals)1