Search in sources :

Example 1 with SequenceFlowPropertyWriter

use of org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter in project kie-wb-common by kiegroup.

the class SequenceFlowConverter method toFlowElement.

public SequenceFlowPropertyWriter toFlowElement(Edge<?, ?> edge, ElementContainer process) {
    ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent();
    SequenceFlow definition = content.getDefinition();
    org.eclipse.bpmn2.SequenceFlow seq = bpmn2.createSequenceFlow();
    SequenceFlowPropertyWriter p = propertyWriterFactory.of(seq);
    seq.setId(edge.getUUID());
    BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
    BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
    p.setSource(pSrc);
    p.setTarget(pTgt);
    seq.setId(edge.getUUID());
    seq.setName(definition.getGeneral().getName().getValue());
    p.setConnection(content);
    SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
    ScriptTypeValue scriptTypeValue = executionSet.getConditionExpression().getValue();
    String language = scriptTypeValue.getLanguage();
    String script = scriptTypeValue.getScript();
    if (script != null) {
        FormalExpression formalExpression = bpmn2.createFormalExpression();
        String uri = Scripts.scriptLanguageToUri(language);
        formalExpression.setLanguage(uri);
        formalExpression.setBody(asCData(script));
        seq.setConditionExpression(formalExpression);
    }
    process.addChildElement(p);
    process.addChildEdge(p.getEdge());
    return p;
}
Also used : BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) SequenceFlowPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) FormalExpression(org.eclipse.bpmn2.FormalExpression) ScriptTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)

Aggregations

FormalExpression (org.eclipse.bpmn2.FormalExpression)1 Factories.bpmn2 (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2)1 BasePropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter)1 SequenceFlowPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter)1 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)1 SequenceFlowExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet)1 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)1 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)1