Search in sources :

Example 6 with DataAssociation

use of org.jbpm.workflow.core.impl.DataAssociation in project kogito-runtimes by kiegroup.

the class IntermediateThrowEventHandler method handleSignalNode.

public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final Parser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            String signalName = ((Element) xmlNode).getAttribute("signalRef");
            String variable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE), parser);
            String inputVariable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE_INPUT), parser);
            signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
            actionNode.setMetaData(EVENT_TYPE, "signal");
            actionNode.setMetaData(Metadata.REF, signalName);
            actionNode.setMetaData(Metadata.VARIABLE, variable);
            List<DataAssociation> inputs = actionNode.getIoSpecification().getDataInputAssociation();
            if (!inputs.isEmpty()) {
                String type = inputs.get(0).getTarget().getType();
                actionNode.setMetaData(SIGNAL_TYPE, type);
            }
            // check if signal should be send async
            if (actionNode.getIoSpecification().containsInputLabel("async")) {
                signalName = "ASYNC-" + signalName;
            }
            DroolsConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, inputVariable, (String) actionNode.getMetaData("customScope")));
            actionNode.setAction(action);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : SignalProcessInstanceAction(org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Element(org.w3c.dom.Element) ActionNode(org.jbpm.workflow.core.node.ActionNode)

Example 7 with DataAssociation

use of org.jbpm.workflow.core.impl.DataAssociation in project kogito-runtimes by kiegroup.

the class AbstractNodeHandler method writeCatchIO.

protected void writeCatchIO(IOSpecification ioSpecification, StringBuilder xmlDump) {
    for (DataDefinition output : ioSpecification.getDataOutput().values()) {
        xmlDump.append("        <dataOutput id=\"" + output.getId() + "\" name=\"" + output.getLabel() + "\" />" + EOL);
    }
    for (DataAssociation output : ioSpecification.getDataOutputAssociation()) {
        xmlDump.append("      <dataOutputAssociation>" + EOL);
        writeDataAssociation(output, xmlDump);
        xmlDump.append("      </dataOutputAssociation>" + EOL);
    }
}
Also used : DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) DataDefinition(org.jbpm.workflow.core.impl.DataDefinition)

Example 8 with DataAssociation

use of org.jbpm.workflow.core.impl.DataAssociation in project kogito-runtimes by kiegroup.

the class ExtendedNodeBuilder method buildDataAssociation.

protected void buildDataAssociation(PackageBuildContext context, Collection<DataAssociation> dataAssociations, Map<String, Object> parameters) {
    for (DataAssociation dataAssociation : dataAssociations) {
        Transformation transformation = dataAssociation.getTransformation();
        if (transformation != null) {
            DataTransformer transformer = DataTransformerRegistry.get().find(transformation.getLanguage());
            transformation.setCompiledExpression(transformer.compile(transformation.getExpression(), parameters));
        }
        List<Assignment> assignments = dataAssociation.getAssignments();
        if (assignments != null) {
            for (Assignment assignment : assignments) {
                if (assignment.getDialect() != null) {
                    ProcessDialect processDialect = ProcessDialectRegistry.getDialect(assignment.getDialect());
                    processDialect.getAssignmentBuilder().build(context, assignment, dataAssociation.getSources(), dataAssociation.getTarget());
                }
            }
        }
    }
}
Also used : Assignment(org.jbpm.workflow.core.node.Assignment) Transformation(org.jbpm.workflow.core.node.Transformation) DataTransformer(org.kie.api.runtime.process.DataTransformer) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) ProcessDialect(org.jbpm.process.builder.dialect.ProcessDialect)

Example 9 with DataAssociation

use of org.jbpm.workflow.core.impl.DataAssociation in project kogito-runtimes by kiegroup.

the class IntermediateCatchEventHandler method handleSignalNode.

protected void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    super.handleNode(node, element, uri, localName, parser);
    EventNode eventNode = (EventNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            String type = ((Element) xmlNode).getAttribute("signalRef");
            if (type != null && type.trim().length() > 0) {
                type = checkSignalAndConvertToRealSignalNam(parser, type);
                List<EventFilter> eventFilters = new ArrayList<EventFilter>();
                EventTypeFilter eventFilter = new EventTypeFilter();
                eventFilter.setType(type);
                eventFilters.add(eventFilter);
                eventNode.setEventFilters(eventFilters);
            }
            List<DataAssociation> inputs = eventNode.getIoSpecification().getDataInputAssociation();
            if (!inputs.isEmpty()) {
                String signalType = inputs.get(0).getTarget().getType();
                eventNode.setMetaData(SIGNAL_TYPE, signalType);
            }
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : EventNode(org.jbpm.workflow.core.node.EventNode) EventTypeFilter(org.jbpm.process.core.event.EventTypeFilter) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) EventFilter(org.jbpm.process.core.event.EventFilter)

Example 10 with DataAssociation

use of org.jbpm.workflow.core.impl.DataAssociation in project kogito-runtimes by kiegroup.

the class IntermediateThrowEventHandler method handleSignalNode.

public void handleSignalNode(final Node node, final Element element, final String uri, final String localName, final ExtensibleXmlParser parser) throws SAXException {
    ActionNode actionNode = (ActionNode) node;
    org.w3c.dom.Node xmlNode = element.getFirstChild();
    while (xmlNode != null) {
        String nodeName = xmlNode.getNodeName();
        if ("signalEventDefinition".equals(nodeName)) {
            String signalName = ((Element) xmlNode).getAttribute("signalRef");
            String variable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE), parser);
            String inputVariable = findVariable((String) actionNode.getMetaData(MAPPING_VARIABLE_INPUT), parser);
            signalName = checkSignalAndConvertToRealSignalNam(parser, signalName);
            actionNode.setMetaData(EVENT_TYPE, "signal");
            actionNode.setMetaData(Metadata.REF, signalName);
            actionNode.setMetaData(Metadata.VARIABLE, variable);
            List<DataAssociation> inputs = actionNode.getIoSpecification().getDataInputAssociation();
            if (!inputs.isEmpty()) {
                String type = inputs.get(0).getTarget().getType();
                actionNode.setMetaData(SIGNAL_TYPE, type);
            }
            // check if signal should be send async
            if (actionNode.getIoSpecification().containsInputLabel("async")) {
                signalName = "ASYNC-" + signalName;
            }
            DroolsConsequenceAction action = createJavaAction(new SignalProcessInstanceAction(signalName, variable, inputVariable, (String) actionNode.getMetaData("customScope")));
            actionNode.setAction(action);
        }
        xmlNode = xmlNode.getNextSibling();
    }
}
Also used : SignalProcessInstanceAction(org.jbpm.process.instance.impl.actions.SignalProcessInstanceAction) DroolsConsequenceAction(org.jbpm.workflow.core.impl.DroolsConsequenceAction) DataAssociation(org.jbpm.workflow.core.impl.DataAssociation) Element(org.w3c.dom.Element) ActionNode(org.jbpm.workflow.core.node.ActionNode)

Aggregations

DataAssociation (org.jbpm.workflow.core.impl.DataAssociation)18 DataDefinition (org.jbpm.workflow.core.impl.DataDefinition)9 Assignment (org.jbpm.workflow.core.node.Assignment)7 Element (org.w3c.dom.Element)5 Transformation (org.jbpm.workflow.core.node.Transformation)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 VariableScope (org.jbpm.process.core.context.variable.VariableScope)3 DroolsConsequenceAction (org.jbpm.workflow.core.impl.DroolsConsequenceAction)3 ActionNode (org.jbpm.workflow.core.node.ActionNode)3 EventNode (org.jbpm.workflow.core.node.EventNode)3 VariableDeclarator (com.github.javaparser.ast.body.VariableDeclarator)1 AssignExpr (com.github.javaparser.ast.expr.AssignExpr)1 Expression (com.github.javaparser.ast.expr.Expression)1 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)1 NameExpr (com.github.javaparser.ast.expr.NameExpr)1 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)1 VariableDeclarationExpr (com.github.javaparser.ast.expr.VariableDeclarationExpr)1 ClassOrInterfaceType (com.github.javaparser.ast.type.ClassOrInterfaceType)1 Thread.currentThread (java.lang.Thread.currentThread)1