Search in sources :

Example 11 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class XMLEncoderDiagramMetadataMarshallerTest method testDecodeTest1.

@Test
public void testDecodeTest1() throws Exception {
    InputStream is = loadStream(TEST1);
    Metadata metadata = tested.unmarshall(is);
    assertNotNull(metadata);
    assertEquals("defSet1", metadata.getDefinitionSetId());
    assertEquals("ss1", metadata.getShapeSetId());
    assertEquals("thumbData1", metadata.getThumbData());
    assertEquals("title1", metadata.getTitle());
    assertEquals("root1", metadata.getCanvasRootUUID());
}
Also used : InputStream(java.io.InputStream) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Test(org.junit.Test)

Example 12 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class DiagramServiceImpl method obtainMetadata.

@SuppressWarnings("unchecked")
@Override
protected Metadata obtainMetadata(DefinitionSetService services, final org.uberfire.backend.vfs.Path diagramFilePath, final String defSetId, final String fileName) {
    Metadata metadata = null;
    final InputStream metaDataStream = loadMetadataForPath(diagramFilePath);
    if (null != metaDataStream) {
        try {
            metadata = services.getDiagramMarshaller().getMetadataMarshaller().unmarshall(metaDataStream);
            if (null == metadata.getRoot() || null == metadata.getRoot().toURI()) {
                metadata.setRoot(getRoot());
            }
        } catch (java.io.IOException e) {
            LOG.error("Cannot unmarshall metadata for diagram's path [" + diagramFilePath + "]", e);
        }
    }
    return metadata;
}
Also used : InputStream(java.io.InputStream) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata)

Example 13 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class SessionDiagramEditorScreen method newDiagram.

private void newDiagram(final String uuid, final String title, final String definitionSetId, final String shapeSetId, final Command callback) {
    BusyPopup.showMessage("Loading");
    final Metadata metadata = buildMetadata(definitionSetId, shapeSetId, title);
    clientFactoryServices.newDiagram(uuid, definitionSetId, metadata, new ServiceCallback<Diagram>() {

        @Override
        public void onSuccess(final Diagram diagram) {
            final Metadata metadata = diagram.getMetadata();
            metadata.setShapeSetId(shapeSetId);
            metadata.setTitle(title);
            openDiagram(diagram, callback);
        }

        @Override
        public void onError(final ClientRuntimeError error) {
            showError(error);
            callback.execute();
        }
    });
}
Also used : Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) ClientRuntimeError(org.kie.workbench.common.stunner.core.client.service.ClientRuntimeError) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram)

Example 14 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testMarshallProcessVariables.

@Test
public void testMarshallProcessVariables() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_PROCESSVARIABLES);
    JBPMBpmn2ResourceImpl resource = tested.marshallToBpmn2Resource(diagram);
    String result = tested.marshall(diagram);
    assertDiagram(result, 1, 7, 7);
    Definitions definitions = (Definitions) resource.getContents().get(0);
    assertNotNull(definitions);
    List<RootElement> rootElements = definitions.getRootElements();
    assertNotNull(rootElements);
    assertNotNull(getItemDefinition(rootElements, "_employeeItem", "java.lang.String"));
    assertNotNull(getItemDefinition(rootElements, "_reasonItem", "java.lang.String"));
    assertNotNull(getItemDefinition(rootElements, "_performanceItem", "java.lang.String"));
    Process process = getProcess(definitions);
    assertNotNull(process);
    List<Property> properties = process.getProperties();
    assertNotNull(properties);
    assertNotNull(getProcessProperty(properties, "employee", "_employeeItem"));
    assertNotNull(getProcessProperty(properties, "reason", "_reasonItem"));
    assertNotNull(getProcessProperty(properties, "performance", "_performanceItem"));
}
Also used : Graph(org.kie.workbench.common.stunner.core.graph.Graph) RootElement(org.eclipse.bpmn2.RootElement) JBPMBpmn2ResourceImpl(org.kie.workbench.common.stunner.bpmn.backend.legacy.resource.JBPMBpmn2ResourceImpl) Definitions(org.eclipse.bpmn2.Definitions) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Process(org.eclipse.bpmn2.Process) Matchers.anyString(org.mockito.Matchers.anyString) Property(org.eclipse.bpmn2.Property) Test(org.junit.Test)

Example 15 with Metadata

use of org.kie.workbench.common.stunner.core.diagram.Metadata in project kie-wb-common by kiegroup.

the class BPMNDiagramMarshallerTest method testUnmarshallBusinessRuleTaskAssignments.

@Test
@SuppressWarnings("unchecked")
public void testUnmarshallBusinessRuleTaskAssignments() throws Exception {
    Diagram<Graph, Metadata> diagram = unmarshall(BPMN_BUSINESSRULETASKASSIGNMENTS);
    assertDiagram(diagram, 4);
    assertEquals("BusinessRuleTaskAssignments", diagram.getMetadata().getTitle());
    Node<? extends Definition, ?> businessRuleNode = diagram.getGraph().getNode("_45C2C340-D1D0-4D63-8419-EF38F9E73507");
    BusinessRuleTask businessRuleTask = (BusinessRuleTask) businessRuleNode.getContent().getDefinition();
    assertEquals(businessRuleTask.getTaskType().getValue(), TaskTypes.BUSINESS_RULE);
    DataIOSet dataIOSet = businessRuleTask.getDataIOSet();
    AssignmentsInfo assignmentsinfo = dataIOSet.getAssignmentsinfo();
    assertEquals(assignmentsinfo.getValue(), "|input1:String,input2:String||output1:String,output2:String|[din]pv1->input1,[din]pv2->input2,[dout]output1->pv2,[dout]output2->pv2");
}
Also used : DataIOSet(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet) Graph(org.kie.workbench.common.stunner.core.graph.Graph) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) Test(org.junit.Test)

Aggregations

Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)175 Graph (org.kie.workbench.common.stunner.core.graph.Graph)158 Test (org.junit.Test)156 Matchers.anyString (org.mockito.Matchers.anyString)53 View (org.kie.workbench.common.stunner.core.graph.content.view.View)32 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)30 ItemAwareElement (org.eclipse.bpmn2.ItemAwareElement)28 RootElement (org.eclipse.bpmn2.RootElement)28 DataIOSet (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.DataIOSet)28 Element (org.kie.workbench.common.stunner.core.graph.Element)27 FlowElement (org.eclipse.bpmn2.FlowElement)26 Diagram (org.kie.workbench.common.stunner.core.diagram.Diagram)16 UserTask (org.kie.workbench.common.stunner.bpmn.definition.UserTask)14 Edge (org.kie.workbench.common.stunner.core.graph.Edge)14 BPMNGeneralSet (org.kie.workbench.common.stunner.bpmn.definition.property.general.BPMNGeneralSet)11 StartErrorEvent (org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent)10 MessageRef (org.kie.workbench.common.stunner.bpmn.definition.property.event.message.MessageRef)10 StartSignalEvent (org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent)9 StartTimerEvent (org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent)9 Node (org.kie.workbench.common.stunner.core.graph.Node)9