Greeting fellow user. I am looking for a solution to a very specific input condition.
Lets say i want to define an input condition based on a list of cars.
Input - If car doesn’t belong to [“HONDA”,“KIA”,“FORD”]
Output - We don’t support the car.
In modeler, we have currently defined this condition as not["HONDA","KIA","FORD"]
We tried defining as not(["HONDA","KIA","FORD"])
as well. But it didn’t work in FEEL
However somehow even if I pass Honda in input object, it still fails to recognize the input is correct.
Am i missing something. Appreciate your inputs.
Many Thanks.
Hi @Nishikant_Karanjkar,
try the following FEEL expression:
not("HONDA", "KIA", "FORD")
Note that the matching is case-sensitive.
Does this help you?
Best regards,
Philipp
Hello,
Apologies for long post.
My Java Test class looks like
public class TestCarDecisionService {
@Rule
public DmnEngineRule dmnEngineRule = new DmnEngineRule();
private DmnEngine dmnEngine;
@Before
public void setup(){
dmnEngine = dmnEngineRule.getDmnEngine();
}
@Test
public void test(){
Car car = new Car("FONDA", Arrays.asList("FONDA"));
try(InputStream inputStream = new FileInputStream("c:\\temp\\carChecker.dmn")){
ObjectValue value = Variables.objectValue(car).create();
VariableMap map = createVariables().putValue("Car", value);
DmnDecisionTableResult result = dmnEngine.evaluateDecisionTable("carChecker", inputStream, map);
System.out.println(result.toString());
System.out.println(result.getResultList().toString());
System.out.println(result.getSingleResult().toString());
} catch (IOException e) {
e.printStackTrace();
}
}
private class Car{
private String name;
private List<String> carType;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Car(String name, List<String> classification) {
this.name = name;
this.carType = classification;
}
}
}
And my DMN table is
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:camunda="http://camunda.org/schema/1.0/dmn" id="Definitions_03ii53t" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.7.1">
<decision id="carChecker" name="carChecker">
<decisionTable id="decisionTable_1" hitPolicy="FIRST">
<input id="input_1" label="carType" camunda:inputVariable="car.carType">
<inputExpression id="inputExpression_1" typeRef="string" expressionLanguage="FEEL">
<text>list contains(car.carType, "HONDA"),
list contains(car.carType, "FORD"),list contains(car.carType, "KIA"),</text>
</inputExpression>
</input>
<output id="output_1" label="carChoice" name="carChoice" typeRef="string" />
<rule id="DecisionRule_1a0ynk0">
<inputEntry id="UnaryTests_1fhlsse">
<text>not("Ford","Kia","Honda")</text>
</inputEntry>
<outputEntry id="LiteralExpression_0av5iv1">
<text>"not a ford kia or honda"</text>
</outputEntry>
</rule>
<rule id="DecisionRule_1j23l7h">
<inputEntry id="UnaryTests_1dbovkg">
<text></text>
</inputEntry>
<outputEntry id="LiteralExpression_19k3ii1">
<text>"A ford, kia or honda"</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>
I want to implment
- The input will be list of car names passed (Car car = new Car(“FONDA”, Arrays.asList(“FONDA”)))
- The condition is if the car object list doesnt belong to list of defined rule i.e. not(“HONDA”,“FORD”,“KIA”)
- Output should be shown as the reject reason ->“not a ford, kia or honda”
I tried few suggestion to use FEEL language however no luck.
I keep getting below exception
FEEL-01016 Simple Expression not supported by FEEL engine
java.lang.UnsupportedOperationException: FEEL-01016 Simple Expression not supported by FEEL engine
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineLogger.simpleExpressionNotSupported(FeelEngineLogger.java:160)
at org.camunda.bpm.dmn.feel.impl.juel.FeelEngineImpl.evaluateSimpleExpression(FeelEngineImpl.java:48)
at org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler.evaluateFeelSimpleExpression(ExpressionEvaluationHandler.java:130)
at org.camunda.bpm.dmn.engine.impl.evaluation.ExpressionEvaluationHandler.evaluateExpression(ExpressionEvaluationHandler.java:59)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInputExpression(DecisionTableEvaluationHandler.java:193)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateInput(DecisionTableEvaluationHandler.java:122)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluateDecisionTable(DecisionTableEvaluationHandler.java:104)
at org.camunda.bpm.dmn.engine.impl.evaluation.DecisionTableEvaluationHandler.evaluate(DecisionTableEvaluationHandler.java:81)
at org.camunda.bpm.dmn.engine.impl.DefaultDmnDecisionContext.evaluateDecision(DefaultDmnDecisionContext.java:85)[carChecker.dmn|attachment](upload://9Iidps1C5hYPS00Ut82sNnVnbPO.dmn) (1.4 KB) [TestCarDecisionService.java.txt|attachment](upload://mm51j9MPahsLUkf63ZLzK6jH99C.txt) (1.9 KB)
Hi,
Have a look at this blog post. Perhaps the sample DMN in this blog post may inspire a solution approach…
regards
Rob
Hello Rob,
Thanks for response. I don’t see the List input validation against list. Could you pls share the DMN tables so can take a closer look ? Many thanks.
Hi @Nishikant_Karanjkar,
Try to use Camunda BPM 7.13.
Hi,
Here’s an example where I used list contains…
regards
Rob
Accreditation_Management_FEEL.dmn (12.4 KB)