Skip to content

Commit

Permalink
Merge branch 'apache:main' into Upgrade-org.mvelmvel2-version-to-2.5.…
Browse files Browse the repository at this point in the history
…2.Final
  • Loading branch information
AnnJoy23 authored Jan 22, 2025
2 parents 19fcab4 + 4478a4c commit 67e332a
Show file tree
Hide file tree
Showing 153 changed files with 2,729 additions and 805 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class ProjectRuntime implements KieRuntimeBuilder {
private static final ProjectModel model = new ProjectModel();
private static final java.util.Map<String, KieBase> kbases = initKieBases();

private org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);

public static final ProjectRuntime INSTANCE = new ProjectRuntime();

private static java.util.Map<String, KieBase> initKieBases() {
Expand Down Expand Up @@ -88,7 +90,6 @@ private KieBase getKieBaseForSession(String sessionName) {
}

private org.kie.api.runtime.KieSessionConfiguration getConfForSession(String sessionName) {
org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);
switch(sessionName) {
// populated via codegen
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ProjectRuntime implements KieRuntimeBuilder {
private static final ProjectModel model = new ProjectModel();
private static final java.util.Map<String, KieBase> kbases = initKieBases();

private org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);

public static final ProjectRuntime INSTANCE = new ProjectRuntime();

private static java.util.Map<String, KieBase> initKieBases() {
Expand Down Expand Up @@ -89,7 +91,6 @@ private KieBase getKieBaseForSession(String sessionName) {
}

private org.kie.api.runtime.KieSessionConfiguration getConfForSession(String sessionName) {
org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);
switch(sessionName) {
// populated via codegen
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class ProjectRuntime implements KieRuntimeBuilder {
private static final ProjectModel model = new ProjectModel();
private static final java.util.Map<String, KieBase> kbases = initKieBases();

private org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);

public static final ProjectRuntime INSTANCE = new ProjectRuntime();

private static java.util.Map<String, KieBase> initKieBases() {
Expand Down Expand Up @@ -89,7 +91,6 @@ private KieBase getKieBaseForSession(String sessionName) {
}

private org.kie.api.runtime.KieSessionConfiguration getConfForSession(String sessionName) {
org.drools.core.SessionConfiguration conf = org.drools.core.impl.RuleBaseFactory.newKnowledgeSessionConfiguration().as(SessionConfiguration.KEY);
switch(sessionName) {
// populated via codegen
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private static class JSR223WrappingEC implements EvaluationContext {
private final List<FEELEvent> events;
// Defaulting FEELDialect to FEEL
private final FEELDialect dialect = FEELDialect.FEEL;

public JSR223WrappingEC(Map<String, Object> values, List<FEELEvent> events) {
this.values = Collections.unmodifiableMap(values);
this.events = events;
Expand Down Expand Up @@ -253,7 +253,7 @@ public Object getRootObject() {
}

@Override
public FEELDialect getDialect() {
public FEELDialect getFEELDialect() {
return dialect;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.kie.dmn.feel.FEEL;
import org.kie.dmn.feel.codegen.feel11.ProcessedExpression;
import org.kie.dmn.feel.lang.CompiledExpression;
import org.kie.dmn.feel.lang.FEELDialect;
import org.kie.dmn.feel.lang.impl.CompiledExpressionImpl;
import org.kie.dmn.feel.lang.impl.EvaluationContextImpl;
import org.kie.dmn.feel.lang.impl.FEELImpl;
Expand Down Expand Up @@ -98,13 +99,28 @@ public EvaluatorResult evaluate(DMNRuntimeEventManager dmrem, DMNResult dmnr) {
captured.getSeverity().toString(),
MsgUtil.clipString(expressionNode.getText(), 50),
captured.getMessage());
if (captured.getSeverity() == Severity.ERROR) { // as FEEL events are being cycled, compute it here.
resultType = ResultType.FAILURE;
}
resultType = getFEELDialectAdaptedResultType(captured.getSeverity(), val, feelInstance.getFeelDialect());
}
return new EvaluatorResultImpl(val, resultType);
}

/**
* If FEELDialect is "BFEEL" and returned object is != <code>null</code>, then result type is <b>success</b>, regardless of
* given <code>Severity</code>.
* Otherwise, if severity is <code>Severity.ERROR</code>, result type is <b>failure</b>
* @param severity
* @param value
* @param feelDialect
* @return
*/
static ResultType getFEELDialectAdaptedResultType(Severity severity, Object value, FEELDialect feelDialect) {
if ((feelDialect == FEELDialect.BFEEL && value != null) || severity != Severity.ERROR) {
return ResultType.SUCCESS;
} else {
return ResultType.FAILURE;
}
}

private static DMNMessage.Severity dmnSeverityFromFEELSeverity(FEELEvent.Severity severity) {
switch (severity) {
case ERROR:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.kie.dmn.core.util.Msg;
import org.kie.dmn.core.util.MsgUtil;
import org.kie.dmn.core.util.NamespaceUtil;
import org.kie.dmn.feel.lang.FEELDialect;
import org.kie.dmn.feel.lang.FEELProfile;
import org.kie.dmn.feel.lang.Type;
import org.kie.dmn.feel.lang.types.AliasFEELType;
Expand Down Expand Up @@ -210,7 +211,7 @@ public DMNModel compile(Definitions dmndefs, Collection<DMNModel> dmnModels, Res
model.setRuntimeTypeCheck(((DMNCompilerConfigurationImpl) dmnCompilerConfig).getOption(RuntimeTypeCheckOption.class).isRuntimeTypeCheck());
DMNCompilerConfigurationImpl cc = (DMNCompilerConfigurationImpl) dmnCompilerConfig;
List<FEELProfile> helperFEELProfiles = cc.getFeelProfiles();
DMNFEELHelper feel = new DMNFEELHelper(cc.getRootClassLoader(), helperFEELProfiles);
DMNFEELHelper feel = new DMNFEELHelper(cc.getRootClassLoader(), helperFEELProfiles, model.getFeelDialect());
DMNCompilerContext ctx = new DMNCompilerContext(feel);
ctx.setRelativeResolver(relativeResolver);
List<DMNModel> toMerge = new ArrayList<>();
Expand Down
Loading

0 comments on commit 67e332a

Please sign in to comment.