Search in sources :

Example 1 with DataObject

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

the class AbstractDataTypeCacheTest method testExtractDataObject.

@Test
public void testExtractDataObject() {
    DataObject object = new DataObject();
    DataObject object2 = new DataObject();
    when(firstView.getDefinition()).thenReturn(object);
    when(lastView.getDefinition()).thenReturn(object2);
    dataTypeCache.extractFromItem(firstView);
    dataTypeCache.extractFromItem(lastView);
    assertTrue(dataTypeCache.allDataTypes.contains(object.getType().getValue().getType()));
    assertTrue(dataTypeCache.allDataTypes.contains(object2.getType().getValue().getType()));
}
Also used : DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) Test(org.junit.Test)

Example 2 with DataObject

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

the class AssignmentsEditorWidgetProcessVariablesTest method testGetProcessVariableFromDataObjects.

@Test
public void testGetProcessVariableFromDataObjects() {
    DataObject dataObject = new DataObject();
    dataObject.getGeneral().getDocumentation().setValue("doc");
    dataObject.setName(new Name("name"));
    dataObject.setType(new DataObjectType(new DataObjectTypeValue("com.myType.dataObject")));
    final String uuid = UUID.uuid();
    when(dataObjectNode.getUUID()).thenReturn("uuid");
    when(dataObjectNode.getContent()).thenReturn(dataObjectView);
    when(dataObjectView.getDefinition()).thenReturn(dataObject);
    graphNodes.clear();
    graphNodes.add(dataObjectNode);
    graphNodes.add(parentNode);
    when(parentNodeView.getDefinition()).thenReturn(dataObjectNode);
    when(dataObjectNode.getUUID()).thenReturn("rootId");
    createWidget();
    assertEquals(dataObject.getName().getValue() + ":" + dataObject.getType().getValue().getType(), widget.getProcessVariables());
}
Also used : DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) DataObjectTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectTypeValue) DataObjectType(org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectType) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) Test(org.junit.Test)

Example 3 with DataObject

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

the class ArtifactsConverterTest method toDataObjectElement.

@Test
public void toDataObjectElement() {
    DataObject dataObject = new DataObject();
    dataObject.getGeneral().getDocumentation().setValue(DOC);
    dataObject.setName(new Name(NAME));
    dataObject.setType(new DataObjectType(new DataObjectTypeValue(NAME)));
    dataObjectNode = new NodeImpl<>(UUID.uuid());
    dataObjectNode.setContent(dataObjectView);
    when(dataObjectView.getDefinition()).thenReturn(dataObject);
    when(propertyWriterFactory.of(any(org.eclipse.bpmn2.DataObjectReference.class))).thenReturn(dataObjectWriter);
    artifactsConverter = new ArtifactsConverter(propertyWriterFactory);
    PropertyWriter propertyWriter = artifactsConverter.toElement(((NodeImpl) dataObjectNode));
    verify(dataObjectWriter).setName(NAME);
    verify(dataObjectWriter).setType(NAME);
    verify(dataObjectWriter).setAbsoluteBounds(dataObjectNode);
    assertEquals(dataObjectWriter, propertyWriter);
}
Also used : DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) DataObjectTypeValue(org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectTypeValue) DataObjectType(org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectType) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name) TextAnnotationPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.TextAnnotationPropertyWriter) PropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter) DataObjectPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.DataObjectPropertyWriter) Test(org.junit.Test)

Example 4 with DataObject

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

the class AbstractDataTypeCache method extractFromItem.

public void extractFromItem(View view) {
    Object definition = view.getDefinition();
    if (definition instanceof DataObject) {
        DataObject dataObject = (DataObject) definition;
        allDataTypes.add(dataObject.getType().getValue().getType());
    } else if (definition instanceof AdHocSubprocess) {
        AdHocSubprocess adhoc = (AdHocSubprocess) definition;
        allDataTypes.addAll(getDataTypes(adhoc.getProcessData().getProcessVariables().getValue()));
    } else if (definition instanceof BPMNDiagramImpl) {
        BPMNDiagramImpl diagram = (BPMNDiagramImpl) definition;
        allDataTypes.addAll(getDataTypes(diagram.getProcessData().getProcessVariables().getValue()));
    } else if (definition instanceof EmbeddedSubprocess) {
        EmbeddedSubprocess embeddedSubprocess = (EmbeddedSubprocess) definition;
        allDataTypes.addAll(getDataTypes(embeddedSubprocess.getProcessData().getProcessVariables().getValue()));
    } else if (definition instanceof EventSubprocess) {
        EventSubprocess eventSubprocess = (EventSubprocess) definition;
        allDataTypes.addAll(getDataTypes(eventSubprocess.getProcessData().getProcessVariables().getValue()));
    } else if (definition instanceof MultipleInstanceSubprocess) {
        MultipleInstanceSubprocess multipleInstanceSubprocess = (MultipleInstanceSubprocess) definition;
        allDataTypes.addAll(getDataTypes(multipleInstanceSubprocess.getProcessData().getProcessVariables().getValue()));
        allDataTypes.addAll(getDataTypes(multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataInput().getValue()));
        allDataTypes.addAll(getDataTypes(multipleInstanceSubprocess.getExecutionSet().getMultipleInstanceDataOutput().getValue()));
    } else if (definition instanceof UserTask) {
        UserTask userTask = (UserTask) definition;
        allDataTypes.addAll(processAssignments(userTask.getExecutionSet().getAssignmentsinfo()));
    } else if (definition instanceof GenericServiceTask) {
        GenericServiceTask genericServiceTask = (GenericServiceTask) definition;
        allDataTypes.addAll(processAssignments(genericServiceTask.getExecutionSet().getAssignmentsinfo()));
    } else if (definition instanceof BusinessRuleTask) {
        BusinessRuleTask businessRuleTask = (BusinessRuleTask) definition;
        allDataTypes.addAll(processAssignments(businessRuleTask.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof EndErrorEvent) {
        EndErrorEvent endErrorEvent = (EndErrorEvent) definition;
        allDataTypes.addAll(processAssignments(endErrorEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof EndEscalationEvent) {
        EndEscalationEvent endEscalationEvent = (EndEscalationEvent) definition;
        allDataTypes.addAll(processAssignments(endEscalationEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof EndMessageEvent) {
        EndMessageEvent endMessageEvent = (EndMessageEvent) definition;
        allDataTypes.addAll(processAssignments(endMessageEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof EndSignalEvent) {
        EndSignalEvent endSignalEvent = (EndSignalEvent) definition;
        allDataTypes.addAll(processAssignments(endSignalEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateLinkEventCatching) {
        IntermediateLinkEventCatching intermediateLinkEventCatching = (IntermediateLinkEventCatching) definition;
        allDataTypes.addAll(processAssignments(intermediateLinkEventCatching.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateLinkEventThrowing) {
        IntermediateLinkEventThrowing intermediateLinkEventThrowing = (IntermediateLinkEventThrowing) definition;
        allDataTypes.addAll(processAssignments(intermediateLinkEventThrowing.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateErrorEventCatching) {
        IntermediateErrorEventCatching intermediateErrorEventCatching = (IntermediateErrorEventCatching) definition;
        allDataTypes.addAll(processAssignments(intermediateErrorEventCatching.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateEscalationEvent) {
        IntermediateEscalationEvent intermediateEscalationEvent = (IntermediateEscalationEvent) definition;
        allDataTypes.addAll(processAssignments(intermediateEscalationEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateEscalationEventThrowing) {
        IntermediateEscalationEventThrowing intermediateEscalationEventThrowing = (IntermediateEscalationEventThrowing) definition;
        allDataTypes.addAll(processAssignments(intermediateEscalationEventThrowing.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateMessageEventCatching) {
        IntermediateMessageEventCatching intermediateMessageEventCatching = (IntermediateMessageEventCatching) definition;
        allDataTypes.addAll(processAssignments(intermediateMessageEventCatching.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateMessageEventThrowing) {
        IntermediateMessageEventThrowing intermediateMessageEventThrowing = (IntermediateMessageEventThrowing) definition;
        allDataTypes.addAll(processAssignments(intermediateMessageEventThrowing.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateSignalEventCatching) {
        IntermediateSignalEventCatching intermediateSignalEventCatching = (IntermediateSignalEventCatching) definition;
        allDataTypes.addAll(processAssignments(intermediateSignalEventCatching.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof IntermediateSignalEventThrowing) {
        IntermediateSignalEventThrowing intermediateSignalEventThrowing = (IntermediateSignalEventThrowing) definition;
        allDataTypes.addAll(processAssignments(intermediateSignalEventThrowing.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof ReusableSubprocess) {
        ReusableSubprocess reusableSubprocess = (ReusableSubprocess) definition;
        allDataTypes.addAll(processAssignments(reusableSubprocess.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof StartErrorEvent) {
        StartErrorEvent startErrorEvent = (StartErrorEvent) definition;
        allDataTypes.addAll(processAssignments(startErrorEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof StartEscalationEvent) {
        StartEscalationEvent startEscalationEvent = (StartEscalationEvent) definition;
        allDataTypes.addAll(processAssignments(startEscalationEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof StartMessageEvent) {
        StartMessageEvent startMessageEvent = (StartMessageEvent) definition;
        allDataTypes.addAll(processAssignments(startMessageEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof StartSignalEvent) {
        StartSignalEvent startSignalEvent = (StartSignalEvent) definition;
        allDataTypes.addAll(processAssignments(startSignalEvent.getDataIOSet().getAssignmentsinfo()));
    } else if (definition instanceof CustomTask) {
        CustomTask customTask = (CustomTask) definition;
        allDataTypes.addAll(processAssignments(customTask.getDataIOSet().getAssignmentsinfo()));
    }
}
Also used : StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) GenericServiceTask(org.kie.workbench.common.stunner.bpmn.definition.GenericServiceTask) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) EndEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndEscalationEvent) StartEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.StartEscalationEvent) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) IntermediateEscalationEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEventThrowing) IntermediateEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEvent) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) IntermediateLinkEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateLinkEventCatching) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) IntermediateMessageEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventThrowing) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) IntermediateLinkEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateLinkEventThrowing) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) EndErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.EndErrorEvent) DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask)

Example 5 with DataObject

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

the class BPMNDataObjectValidator method validate.

@Override
public void validate(Diagram diagram, Consumer<Collection<DomainViolation>> resultConsumer) {
    Iterator<Element> it = diagram.getGraph().nodes().iterator();
    Map<String, String> dataObjectsMap = new HashMap<>();
    List<DomainViolation> violations = new ArrayList<>();
    while (it.hasNext()) {
        Element element = it.next();
        if (element.getContent() instanceof View && ((View) element.getContent()).getDefinition() instanceof DataObject) {
            DataObject dataObject = (DataObject) ((View) element.getContent()).getDefinition();
            String name = dataObject.getName().getValue();
            String type = dataObject.getType().getValue().getType();
            String containedType = dataObjectsMap.get(name);
            if (containedType != null && !type.equals(containedType)) {
                // If already defined with different type
                BPMNViolation bpmnViolation = new BPMNViolation(getMessageDataObjectWithTypeSameName() + " : " + name, Violation.Type.WARNING, element.getUUID());
                violations.add(bpmnViolation);
            } else {
                dataObjectsMap.put(name, type);
            }
            if (!name.matches(ALLOWED_CHARS)) {
                BPMNViolation bpmnViolation = new BPMNViolation(getMessageDataObjectIllegalName() + " : " + name, Violation.Type.WARNING, element.getUUID());
                violations.add(bpmnViolation);
            }
        }
    }
    resultConsumer.accept(violations);
}
Also used : DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) HashMap(java.util.HashMap) Element(org.kie.workbench.common.stunner.core.graph.Element) ArrayList(java.util.ArrayList) DomainViolation(org.kie.workbench.common.stunner.core.validation.DomainViolation) View(org.kie.workbench.common.stunner.core.graph.content.view.View)

Aggregations

DataObject (org.kie.workbench.common.stunner.bpmn.definition.DataObject)12 Test (org.junit.Test)6 DataObjectType (org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectType)6 DataObjectTypeValue (org.kie.workbench.common.stunner.bpmn.definition.property.artifacts.DataObjectTypeValue)6 Name (org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)6 View (org.kie.workbench.common.stunner.core.graph.content.view.View)5 Element (org.kie.workbench.common.stunner.core.graph.Element)4 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)3 ArrayList (java.util.ArrayList)2 DataObjectPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.DataObjectPropertyWriter)2 HashMap (java.util.HashMap)1 Factories.bpmn2 (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2)1 PropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriter)1 TextAnnotationPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.TextAnnotationPropertyWriter)1 DataObjectPropertyReader (org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.properties.DataObjectPropertyReader)1 AssignmentBaseTest (org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentBaseTest)1 AdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess)1 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)1 BusinessRuleTask (org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)1 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)1