Search in sources :

Example 1 with SequenceFlowExecutionSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet 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)

Example 2 with SequenceFlowExecutionSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet in project kie-wb-common by kiegroup.

the class SequenceFlowConverter method convertEdge.

public BpmnEdge convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes) {
    Edge<View<SequenceFlow>, Node> edge = factoryManager.newEdge(seq.getId(), SequenceFlow.class);
    SequenceFlow definition = edge.getContent().getDefinition();
    SequenceFlowPropertyReader p = propertyReaderFactory.of(seq);
    definition.setGeneral(new BPMNGeneralSet(new Name(seq.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new SequenceFlowExecutionSet(new Priority(p.getPriority()), new ConditionExpression(p.getConditionExpression())));
    return BpmnEdge.of(edge, nodes.get(p.getSourceId()), p.getSourceConnection(), nodes.get(p.getTargetId()), p.getTargetConnection());
}
Also used : SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) Priority(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.Priority) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.ConditionExpression) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Node(org.kie.workbench.common.stunner.core.graph.Node) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SequenceFlowPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 3 with SequenceFlowExecutionSet

use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet in project kie-wb-common by kiegroup.

the class ConditionalComboBoxFieldRendererTest method initWithDefinitionSet.

@Test
public void initWithDefinitionSet() throws Exception {
    resetMocks();
    SequenceFlow sequenceFlow = new SequenceFlow.SequenceFlowBuilder().build();
    SequenceFlowExecutionSet sequenceFlowExecutionSet = sequenceFlow.getExecutionSet();
    ConditionExpression conditionExpression = sequenceFlowExecutionSet.getConditionExpression();
    // static mock
    PowerMockito.mockStatic(ClientBindingUtils.class);
    BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlow, "executionSet")).willReturn(sequenceFlowExecutionSet);
    BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlowExecutionSet, "conditionExpression")).willReturn(conditionExpression);
    // instances mock
    when(conditionalComboBoxFieldDefinition.getRelatedField()).thenReturn("executionSet.conditionExpression");
    when(renderingContext.getModel()).thenReturn(null);
    when(renderingContext.getParentContext()).thenReturn(renderingContextParent);
    when(renderingContextParent.getModel()).thenReturn(sequenceFlow);
    when(adapterManager.forProperty()).thenReturn(Mockito.mock(PropertyAdapter.class));
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("value");
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, never()).setReadOnly(true);
    verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(false);
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("");
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(true);
    when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn(null);
    conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
    verify(conditionalComboBoxFieldRenderer, atLeastOnce()).setReadOnly(true);
}
Also used : SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ConditionExpression(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.ConditionExpression) PropertyAdapter(org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)3 SequenceFlowExecutionSet (org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet)3 ConditionExpression (org.kie.workbench.common.stunner.bpmn.definition.property.connectors.ConditionExpression)2 FormalExpression (org.eclipse.bpmn2.FormalExpression)1 Test (org.junit.Test)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 BpmnNode (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode)1 SequenceFlowPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SequenceFlowPropertyReader)1 Priority (org.kie.workbench.common.stunner.bpmn.definition.property.connectors.Priority)1 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)1 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)1 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)1 ScriptTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTypeValue)1 PropertyAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1 View (org.kie.workbench.common.stunner.core.graph.content.view.View)1 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1