Search in sources :

Example 91 with View

use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.

the class SubProcessConverter method convertEventSubprocessNode.

private BpmnNode convertEventSubprocessNode(SubProcess subProcess) {
    Node<View<EventSubprocess>, Edge> node = factoryManager.newNode(subProcess.getId(), EventSubprocess.class);
    EventSubprocess definition = node.getContent().getDefinition();
    SubProcessPropertyReader p = propertyReaderFactory.of(subProcess);
    definition.setGeneral(new BPMNGeneralSet(new Name(subProcess.getName()), new Documentation(p.getDocumentation())));
    definition.getIsAsync().setValue(p.isAsync());
    definition.setProcessData(new ProcessData(new ProcessVariables(p.getProcessVariables())));
    definition.setSimulationSet(p.getSimulationSet());
    definition.setDimensionsSet(p.getRectangleDimensionsSet());
    definition.setFontSet(p.getFontSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    node.getContent().setBounds(p.getBounds());
    return BpmnNode.of(node);
}
Also used : SubProcessPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.SubProcessPropertyReader) AdHocSubProcessPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.AdHocSubProcessPropertyReader) ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) BPMNGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 92 with View

use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.

the class ScriptTaskConverter method convert.

public Node<? extends View<? extends BPMNViewDefinition>, ?> convert(org.eclipse.bpmn2.ScriptTask task) {
    Node<View<ScriptTask>, Edge> node = factoryManager.newNode(task.getId(), ScriptTask.class);
    ScriptTask definition = node.getContent().getDefinition();
    ScriptTaskPropertyReader p = propertyReaderFactory.of(task);
    definition.setGeneral(new TaskGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new ScriptTaskExecutionSet(new Script(p.getScript()), new IsAsync(p.isAsync())));
    node.getContent().setBounds(p.getBounds());
    definition.setDimensionsSet(p.getRectangleDimensionsSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    definition.setFontSet(p.getFontSet());
    definition.setSimulationSet(p.getSimulationSet());
    return node;
}
Also used : Script(org.kie.workbench.common.stunner.bpmn.definition.property.task.Script) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) TaskGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet) IsAsync(org.kie.workbench.common.stunner.bpmn.definition.property.task.IsAsync) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) ScriptTaskPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ScriptTaskPropertyReader) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) ScriptTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.ScriptTaskExecutionSet)

Example 93 with View

use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.

the class TaskConverter method noneTask.

private BpmnNode noneTask(Task task) {
    Node<View<NoneTask>, Edge> node = factoryManager.newNode(task.getId(), NoneTask.class);
    TaskPropertyReader p = propertyReaderFactory.of(task);
    NoneTask definition = node.getContent().getDefinition();
    definition.setGeneral(new TaskGeneralSet(new Name(p.getName()), new Documentation(p.getDocumentation())));
    definition.setExecutionSet(new EmptyTaskExecutionSet());
    definition.setSimulationSet(p.getSimulationSet());
    node.getContent().setBounds(p.getBounds());
    definition.setDimensionsSet(p.getRectangleDimensionsSet());
    definition.setBackgroundSet(p.getBackgroundSet());
    definition.setFontSet(p.getFontSet());
    return BpmnNode.of(node);
}
Also used : UserTaskPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.UserTaskPropertyReader) TaskPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.TaskPropertyReader) BusinessRuleTaskPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.BusinessRuleTaskPropertyReader) ScriptTaskPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ScriptTaskPropertyReader) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) TaskGeneralSet(org.kie.workbench.common.stunner.bpmn.definition.property.general.TaskGeneralSet) EmptyTaskExecutionSet(org.kie.workbench.common.stunner.bpmn.definition.property.task.EmptyTaskExecutionSet) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) TaskName(org.kie.workbench.common.stunner.bpmn.definition.property.task.TaskName)

Example 94 with View

use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallSequenceFlow.

@Test
public void testUnmarshallSequenceFlow() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_SEQUENCEFLOW);
    SequenceFlow sequenceFlow1 = null;
    SequenceFlow sequenceFlow2 = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof ExclusiveGateway) {
                List<Edge> outEdges = ((NodeImpl) element).getOutEdges();
                for (Edge edge : outEdges) {
                    SequenceFlow flow = (SequenceFlow) ((ViewConnectorImpl) edge.getContent()).getDefinition();
                    if ("route1".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow1 = flow;
                    }
                    if ("route2".equals(flow.getGeneral().getName().getValue())) {
                        sequenceFlow2 = flow;
                    }
                }
            }
        }
    }
    assertNotNull(sequenceFlow1);
    assertNotNull(sequenceFlow1.getExecutionSet());
    assertNotNull(sequenceFlow1.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow1.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow1.getGeneral());
    assertNotNull(sequenceFlow1.getGeneral().getName());
    assertEquals("route1", sequenceFlow1.getGeneral().getName().getValue());
    assertEquals("age >= 10;", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("javascript", sequenceFlow1.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("2", sequenceFlow1.getExecutionSet().getPriority().getValue());
    assertNotNull(sequenceFlow2);
    assertNotNull(sequenceFlow2.getExecutionSet());
    assertNotNull(sequenceFlow2.getExecutionSet().getConditionExpression());
    assertNotNull(sequenceFlow2.getExecutionSet().getPriority());
    assertNotNull(sequenceFlow2.getGeneral());
    assertNotNull(sequenceFlow2.getGeneral().getName());
    assertEquals("route2", sequenceFlow2.getGeneral().getName().getValue());
    assertEquals("age\n" + "<\n" + "10;", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getScript());
    assertEquals("java", sequenceFlow2.getExecutionSet().getConditionExpression().getValue().getLanguage());
    assertEquals("1", sequenceFlow2.getExecutionSet().getPriority().getValue());
}
Also used : ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) Graph(org.kie.workbench.common.stunner.core.graph.Graph) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Test(org.junit.Test)

Example 95 with View

use of org.kie.workbench.common.stunner.core.graph.content.view.View in project kie-wb-common by kiegroup.

the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessVariables.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    assertDiagram(diagram, 8);
    assertEquals("ProcessVariables", diagram.getMetadata().getTitle());
    ProcessVariables variables = null;
    Iterator<Element> it = nodesIterator(diagram);
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View) {
            Object oDefinition = ((View) element.getContent()).getDefinition();
            if (oDefinition instanceof BPMNDiagram) {
                BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) oDefinition;
                variables = bpmnDiagram.getProcessData().getProcessVariables();
                break;
            }
        }
    }
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
    Node<? extends Definition, ?> diagramNode = diagram.getGraph().getNode("_luRBMdEjEeWXpsZ1tNStKQ");
    assertTrue(diagramNode.getContent().getDefinition() instanceof BPMNDiagram);
    BPMNDiagramImpl bpmnDiagram = (BPMNDiagramImpl) diagramNode.getContent().getDefinition();
    assertTrue(bpmnDiagram.getProcessData() != null);
    assertTrue(bpmnDiagram.getProcessData().getProcessVariables() != null);
    variables = bpmnDiagram.getProcessData().getProcessVariables();
    assertEquals(variables.getValue(), "employee:java.lang.String,reason:java.lang.String,performance:java.lang.String");
}
Also used : ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) ItemAwareElement(org.eclipse.bpmn2.ItemAwareElement) FlowElement(org.eclipse.bpmn2.FlowElement) RootElement(org.eclipse.bpmn2.RootElement) Element(org.kie.workbench.common.stunner.core.graph.Element) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Test(org.junit.Test)

Aggregations

View (org.kie.workbench.common.stunner.core.graph.content.view.View)144 Edge (org.kie.workbench.common.stunner.core.graph.Edge)100 Node (org.kie.workbench.common.stunner.core.graph.Node)57 Test (org.junit.Test)49 Graph (org.kie.workbench.common.stunner.core.graph.Graph)45 Element (org.kie.workbench.common.stunner.core.graph.Element)36 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)32 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)31 Documentation (org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation)31 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)31 FlowElement (org.eclipse.bpmn2.FlowElement)26 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)26 RootElement (org.eclipse.bpmn2.RootElement)26 Bounds (org.kie.workbench.common.stunner.core.graph.content.Bounds)21 EventPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.EventPropertyReader)16 Point2D (org.kie.workbench.common.stunner.core.graph.content.view.Point2D)16 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)14 BoundImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundImpl)12 BoundsImpl (org.kie.workbench.common.stunner.core.graph.content.view.BoundsImpl)12 ProcessVariables (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables)10