Search in sources :

Example 1 with DiagramSet

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

the class RootProcessConverter method convertProcessNode.

private ProcessPropertyWriter convertProcessNode(Node<Definition<BPMNDiagramImpl>, ?> node) {
    Process process = bpmn2.createProcess();
    ProcessPropertyWriter p = propertyWriterFactory.of(process);
    BPMNDiagramImpl definition = node.getContent().getDefinition();
    DiagramSet diagramSet = definition.getDiagramSet();
    p.setName(diagramSet.getName().getValue());
    p.setDocumentation(diagramSet.getDocumentation().getValue());
    process.setId(diagramSet.getId().getValue());
    p.setPackage(diagramSet.getPackageProperty().getValue());
    p.setVersion(diagramSet.getVersion().getValue());
    p.setAdHoc(diagramSet.getAdHoc().getValue());
    p.setDescription(diagramSet.getProcessInstanceDescription().getValue());
    p.setExecutable(diagramSet.getExecutable().getValue());
    ProcessData processData = definition.getProcessData();
    p.setProcessVariables(processData.getProcessVariables());
    return p;
}
Also used : DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) Process(org.eclipse.bpmn2.Process) ProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)

Example 2 with DiagramSet

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

the class RootProcessConverter method convertProcessNode.

private BpmnNode convertProcessNode(String id, Process process) {
    Node<View<BPMNDiagramImpl>, Edge> diagramNode = factoryManager.newNode(id, BPMNDiagramImpl.class);
    BPMNDiagramImpl definition = diagramNode.getContent().getDefinition();
    ProcessPropertyReader e = propertyReaderFactory.of(process);
    definition.setDiagramSet(new DiagramSet(new Name(process.getName()), new Documentation(e.getDocumentation()), new Id(process.getId()), new Package(e.getPackage()), new Version(e.getVersion()), new AdHoc(e.isAdHoc()), new ProcessInstanceDescription(e.getDescription()), new Executable(process.isIsExecutable())));
    definition.setProcessData(new ProcessData(new ProcessVariables(e.getProcessVariables())));
    diagramNode.getContent().setBounds(e.getBounds());
    definition.setFontSet(e.getFontSet());
    definition.setBackgroundSet(e.getBackgroundSet());
    return BpmnNode.of(diagramNode);
}
Also used : Documentation(org.kie.workbench.common.stunner.bpmn.definition.property.general.Documentation) ProcessInstanceDescription(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.ProcessInstanceDescription) View(org.kie.workbench.common.stunner.core.graph.content.view.View) ProcessData(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) ProcessVariables(org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessVariables) Version(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Version) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) Id(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Id) Package(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package) AdHoc(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.AdHoc) Executable(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Executable) Edge(org.kie.workbench.common.stunner.core.graph.Edge) ProcessPropertyReader(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ProcessPropertyReader)

Example 3 with DiagramSet

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

the class BPMNDirectDiagramMarshallerTest method testUnmarshallProcessProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("BPSimple", diagram.getMetadata().getTitle());
    DiagramSet diagramProperties = 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;
                diagramProperties = bpmnDiagram.getDiagramSet();
                break;
            }
        }
    }
    assertEquals("BPSimple", diagramProperties.getName().getValue());
    assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
    assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
    assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
    assertEquals(Boolean.TRUE, diagramProperties.getExecutable().getValue());
    assertEquals(Boolean.TRUE, diagramProperties.getAdHoc().getValue());
    assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
Also used : BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) 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)

Example 4 with DiagramSet

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

the class BPMNProjectDiagramFactoryImpl method updateDiagramProperties.

@Override
protected void updateDiagramProperties(final String name, final Node<Definition<BPMNDiagram>, ?> diagramNode, final ProjectMetadata metadata) {
    super.updateDiagramProperties(name, diagramNode, metadata);
    // Set kie related properties for the current project.
    final BPMNDiagram diagram = diagramNode.getContent().getDefinition();
    final DiagramSet diagramSet = diagram.getDiagramSet();
    final String id = diagramSet.getId().getValue();
    if (id == null || id.isEmpty()) {
        final String projectName = null != metadata.getModuleName() ? metadata.getModuleName() + "." : "";
        diagramSet.getId().setValue(projectName + name);
    }
    final String p = diagramSet.getPackageProperty().getValue();
    if (p == null || p.isEmpty()) {
        final Package metadataPackage = metadata.getProjectPackage();
        final String value = metadataPackage == null ? org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package.DEFAULT_PACKAGE : metadata.getProjectPackage().getPackageName();
        diagramSet.getPackageProperty().setValue(value);
    }
    final String diagramName = diagramSet.getName().getValue();
    if (null == diagramName || diagramName.isEmpty()) {
        diagramSet.getName().setValue(name);
    }
}
Also used : BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) Package(org.guvnor.common.services.project.model.Package)

Example 5 with DiagramSet

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

the class BPMNDiagramMarshallerTest method testUnmarshallProcessProperties.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallProcessProperties() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSPROPERTIES);
    assertDiagram(diagram, 4);
    assertEquals("BPSimple", diagram.getMetadata().getTitle());
    DiagramSet diagramProperties = 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;
                diagramProperties = bpmnDiagram.getDiagramSet();
                break;
            }
        }
    }
    assertEquals("BPSimple", diagramProperties.getName().getValue());
    assertEquals("This is a\n" + "simple\n" + "process", diagramProperties.getDocumentation().getValue());
    assertEquals("JDLProj.BPSimple", diagramProperties.getId().getValue());
    assertEquals("org.jbpm", diagramProperties.getPackageProperty().getValue());
    assertEquals(Boolean.valueOf(true), diagramProperties.getExecutable().getValue());
    assertEquals(Boolean.valueOf(true), diagramProperties.getAdHoc().getValue());
    assertEquals("This is the\n" + "Process\n" + "Instance\n" + "Description", diagramProperties.getProcessInstanceDescription().getValue());
}
Also used : BPMNDiagram(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram) Graph(org.kie.workbench.common.stunner.core.graph.Graph) DiagramSet(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet) 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

DiagramSet (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.DiagramSet)6 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)5 BPMNDiagram (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagram)3 View (org.kie.workbench.common.stunner.core.graph.content.view.View)3 FlowElement (org.eclipse.bpmn2.FlowElement)2 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)2 RootElement (org.eclipse.bpmn2.RootElement)2 Test (org.junit.Test)2 Id (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Id)2 Package (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Package)2 Version (org.kie.workbench.common.stunner.bpmn.definition.property.diagram.Version)2 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)2 ProcessData (org.kie.workbench.common.stunner.bpmn.definition.property.variables.ProcessData)2 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)2 Element (org.kie.workbench.common.stunner.core.graph.Element)2 Graph (org.kie.workbench.common.stunner.core.graph.Graph)2 Process (org.eclipse.bpmn2.Process)1 Package (org.guvnor.common.services.project.model.Package)1 ProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.ProcessPropertyWriter)1 ProcessPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.ProcessPropertyReader)1