Search in sources :

Example 1 with BasePropertyWriter

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

the class AbstractProcessConverter method convertEdges.

public void convertEdges(ElementContainer p, DefinitionsBuildingContext context) {
    context.childEdges().forEach(e -> {
        BasePropertyWriter pSrc = p.getChildElement(e.getSourceNode().getUUID());
        // if it's null, then it's a root: skip it
        if (pSrc != null) {
            BasePropertyWriter pTgt = p.getChildElement(e.getTargetNode().getUUID());
            pTgt.setParent(pSrc);
        }
    });
    context.dockEdges().forEach(e -> {
        ActivityPropertyWriter pSrc = (ActivityPropertyWriter) p.getChildElement(e.getSourceNode().getUUID());
        BoundaryEventPropertyWriter pTgt = (BoundaryEventPropertyWriter) p.getChildElement(e.getTargetNode().getUUID());
        pTgt.setParentActivity(pSrc);
    });
    context.edges().map(e -> converterFactory.sequenceFlowConverter().toFlowElement(e, p)).forEach(p::addChildElement);
}
Also used : Result(org.kie.workbench.common.stunner.bpmn.backend.converters.Result) ConverterFactory(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory) BoundaryEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter) ActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ActivityPropertyWriter) LanePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter) Collectors(java.util.stream.Collectors) View(org.kie.workbench.common.stunner.core.graph.content.view.View) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) List(java.util.List) Stream(java.util.stream.Stream) DefinitionsBuildingContext(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext) BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) ElementContainer(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ElementContainer) Node(org.kie.workbench.common.stunner.core.graph.Node) BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) ActivityPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ActivityPropertyWriter) BoundaryEventPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter)

Example 2 with BasePropertyWriter

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

the class SequenceFlowConverter method toFlowElement.

public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) {
    ViewConnector<SequenceFlow> connector = (ViewConnector<SequenceFlow>) edge.getContent();
    SequenceFlow definition = connector.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());
    if (pSrc == null || pTgt == null) {
        String msg = String.format("pSrc = %s, pTgt = %s", pSrc, pTgt);
        LOG.debug(msg);
        return Result.failure(msg);
    }
    p.setSource(pSrc);
    p.setTarget(pTgt);
    p.setConnection(connector);
    BPMNGeneralSet general = definition.getGeneral();
    p.setName(general.getName().getValue());
    p.setDocumentation(general.getDocumentation().getValue());
    SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
    p.setPriority(executionSet.getPriority().getValue());
    p.setConditionExpression(executionSet.getConditionExpression().getValue());
    return Result.of(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) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) SequenceFlowPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter) SequenceFlowExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet)

Example 3 with BasePropertyWriter

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

the class AssociationConverter method toFlowElement.

public Result<BasePropertyWriter> toFlowElement(Edge<?, ?> edge, ElementContainer process) {
    ViewConnector<Association> connector = (ViewConnector<Association>) edge.getContent();
    Association definition = connector.getDefinition();
    org.eclipse.bpmn2.Association association = bpmn2.createAssociation();
    AssociationPropertyWriter p = propertyWriterFactory.of(association);
    association.setId(edge.getUUID());
    BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
    BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
    if (pSrc == null || pTgt == null) {
        String msg = String.format("BasePropertyWriter was not found for source node or target node at edge: %s, pSrc = %s, pTgt = %s", edge.getUUID(), pSrc, pTgt);
        LOG.debug(msg);
        return Result.failure(msg);
    }
    p.setSource(pSrc);
    p.setTarget(pTgt);
    p.setConnection(connector);
    BPMNGeneralSet general = definition.getGeneral();
    p.setDocumentation(general.getDocumentation().getValue());
    p.setDirectionAssociation(definition);
    return Result.of(p);
}
Also used : BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) Association(org.kie.workbench.common.stunner.bpmn.definition.Association) ViewConnector(org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector) Factories.bpmn2(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) AssociationPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AssociationPropertyWriter)

Example 4 with BasePropertyWriter

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

the class AssociationConverterTest method testToFlowElementSuccess.

@Test
public void testToFlowElementSuccess() {
    org.kie.workbench.common.stunner.bpmn.definition.Association association = new org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation();
    association.setGeneral(new BPMNGeneralSet("nameValue", "documentationValue"));
    when(connector.getDefinition()).thenReturn(association);
    Result<BasePropertyWriter> result = converter.toFlowElement(edge, process);
    assertTrue(result.isSuccess());
    verify(propertyWriterFactory).of(argumentCaptor.capture());
    assertEquals(EDGE_ID, argumentCaptor.getValue().getId());
    verify(associationPropertyWriter).setSource(pSrc);
    verify(associationPropertyWriter).setTarget(pTgt);
    verify(associationPropertyWriter).setConnection(connector);
    verify(associationPropertyWriter).setDocumentation("documentationValue");
    verify(associationPropertyWriter).setDirectionAssociation(association);
}
Also used : BasePropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) Test(org.junit.Test)

Aggregations

BasePropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BasePropertyWriter)4 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)3 Factories.bpmn2 (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2)2 ViewConnector (org.kie.workbench.common.stunner.core.graph.content.view.ViewConnector)2 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Test (org.junit.Test)1 Result (org.kie.workbench.common.stunner.bpmn.backend.converters.Result)1 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)1 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)1 ElementContainer (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ElementContainer)1 ActivityPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ActivityPropertyWriter)1 AssociationPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AssociationPropertyWriter)1 BoundaryEventPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.BoundaryEventPropertyWriter)1 LanePropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.LanePropertyWriter)1 SequenceFlowPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SequenceFlowPropertyWriter)1 Association (org.kie.workbench.common.stunner.bpmn.definition.Association)1 BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)1 SequenceFlow (org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow)1