Search in sources :

Example 6 with ActionDescr

use of org.drools.drl.ast.descr.ActionDescr in project kogito-runtimes by kiegroup.

the class ActionNodeBuilder method build.

public void build(Process process, ProcessDescr processDescr, ProcessBuildContext context, Node node) {
    super.build(process, processDescr, context, node);
    ActionNode actionNode = (ActionNode) node;
    DroolsConsequenceAction action = (DroolsConsequenceAction) actionNode.getAction();
    ActionDescr actionDescr = new ActionDescr();
    actionDescr.setText(action.getConsequence());
    actionDescr.setResource(processDescr.getResource());
    ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
    dialect.getActionBuilder().build(context, action, actionDescr, actionNode);
    WorkflowProcess wfProcess = (WorkflowProcess) process;
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("imports", wfProcess.getImports());
    parameters.put("classloader", context.getConfiguration().getClassLoader());
    buildDataAssociation(context, ((ActionNode) node).getInAssociations(), parameters);
    buildDataAssociation(context, ((ActionNode) node).getOutAssociations(), parameters);
}
Also used : DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) HashMap(java.util.HashMap) ActionDescr(org.drools.drl.ast.descr.ActionDescr) ActionNode(org.jbpm.workflow.core.node.ActionNode) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) WorkflowProcess(org.jbpm.workflow.core.WorkflowProcess)

Example 7 with ActionDescr

use of org.drools.drl.ast.descr.ActionDescr in project kogito-runtimes by kiegroup.

the class ProcessBuilderImpl method buildContexts.

public void buildContexts(ContextContainer contextContainer, ProcessBuildContext buildContext) {
    List<Context> exceptionScopes = contextContainer.getContexts(ExceptionScope.EXCEPTION_SCOPE);
    if (exceptionScopes != null) {
        for (Context context : exceptionScopes) {
            // TODO: OCRAM: add compensation scope to process builder????
            ExceptionScope exceptionScope = (ExceptionScope) context;
            for (ExceptionHandler exceptionHandler : exceptionScope.getExceptionHandlers().values()) {
                if (exceptionHandler instanceof ActionExceptionHandler) {
                    DroolsConsequenceAction action = (DroolsConsequenceAction) ((ActionExceptionHandler) exceptionHandler).getAction();
                    ActionDescr actionDescr = new ActionDescr();
                    actionDescr.setText(action.getConsequence());
                    actionDescr.setResource(buildContext.getProcessDescr().getResource());
                    ProcessDialect dialect = ProcessDialectRegistry.getDialect(action.getDialect());
                    dialect.getActionBuilder().build(buildContext, action, actionDescr, (ProcessImpl) buildContext.getProcess());
                }
            }
        }
    }
}
Also used : Context(org.jbpm.process.core.Context) ProcessBuildContext(org.jbpm.process.builder.ProcessBuildContext) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler) ExceptionHandler(org.jbpm.process.core.context.exception.ExceptionHandler) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) ActionDescr(org.drools.drl.ast.descr.ActionDescr) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect) ExceptionScope(org.jbpm.process.core.context.exception.ExceptionScope) ActionExceptionHandler(org.jbpm.process.core.context.exception.ActionExceptionHandler)

Aggregations

ActionDescr (org.drools.drl.ast.descr.ActionDescr)7 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)7 ProcessDialect (org.jbpm.process.builder.dialect.ProcessDialect)5 ActionNode (org.jbpm.workflow.core.node.ActionNode)5 StringReader (java.io.StringReader)3 ArrayList (java.util.ArrayList)3 KnowledgeBuilderImpl (org.drools.compiler.builder.impl.KnowledgeBuilderImpl)3 InternalKnowledgePackage (org.drools.core.definitions.InternalKnowledgePackage)3 SemanticKnowledgeBuilderConfigurationImpl (org.jbpm.compiler.xml.compiler.SemanticKnowledgeBuilderConfigurationImpl)3 KogitoProcessContextImpl (org.jbpm.process.instance.KogitoProcessContextImpl)3 Action (org.jbpm.process.instance.impl.Action)3 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)3 DroolsAction (org.jbpm.workflow.core.DroolsAction)3 Test (org.junit.jupiter.api.Test)3 KogitoProcessContext (org.kie.kogito.internal.process.runtime.KogitoProcessContext)3 KogitoProcessRuntime (org.kie.kogito.internal.process.runtime.KogitoProcessRuntime)3 DialectCompiletimeRegistry (org.drools.compiler.compiler.DialectCompiletimeRegistry)2 PackageBuildContext (org.drools.compiler.rule.builder.PackageBuildContext)2 MVELDialectRuntimeData (org.drools.mvel.MVELDialectRuntimeData)2 MVELDialect (org.drools.mvel.builder.MVELDialect)2