Search in sources :

Example 1 with BPMNViewDefinition

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

the class SubProcessConverterTest method testConvertAdhocSubprocess.

@Test
public void testConvertAdhocSubprocess() {
    AdHocSubprocess definition = new AdHocSubprocess();
    String adHocOrdering = "Parallel";
    boolean adHocAutostart = true;
    String processVariables = "processVar1:Object,processVar2:Integer";
    definition.getGeneral().getName().setValue(NAME);
    definition.getGeneral().getDocumentation().setValue(DOCUMENTATION);
    definition.getProcessData().getProcessVariables().setValue(processVariables);
    definition.getExecutionSet().getAdHocOrdering().setValue(adHocOrdering);
    definition.getExecutionSet().getAdHocAutostart().setValue(adHocAutostart);
    definition.getExecutionSet().getAdHocActivationCondition().setValue(ACTIVATION_CONDITION);
    definition.getExecutionSet().getAdHocCompletionCondition().setValue(COMPLETION_CONDITION);
    definition.getExecutionSet().getOnEntryAction().getValue().addValue(ON_ENTRY_ACTION);
    definition.getExecutionSet().getOnExitAction().getValue().addValue(ON_EXIT_ACTION);
    setBaseSubprocessExecutionSetValues(definition.getExecutionSet());
    double nodeX1 = 10;
    double nodeY1 = 20;
    double nodeX2 = 40;
    double nodeY2 = 60;
    View<BaseAdHocSubprocess> view = new ViewImpl<>(definition, Bounds.create(nodeX1, nodeY1, nodeX2, nodeY2));
    Node<View<? extends BPMNViewDefinition>, Edge> node = new NodeImpl<>(ELEMENT_ID);
    node.setContent(view);
    double parentX1 = 30;
    double parentY1 = 40;
    double parentX2 = 60;
    double parentY2 = 100;
    Node<View<? extends BPMNViewDefinition>, ?> parent = new NodeImpl<>("parentId");
    View<? extends BPMNViewDefinition> parentView = new ViewImpl<>(null, Bounds.create(parentX1, parentY1, parentX2, parentY2));
    parent.setContent(parentView);
    Edge<Child, Node> edge = new EdgeImpl("edgeId");
    edge.setContent(mock(Child.class));
    node.getInEdges().add(edge);
    edge.setSourceNode(parent);
    edge.setTargetNode(node);
    Result<SubProcessPropertyWriter> result = tested.convertSubProcess(node);
    assertTrue(result.isSuccess());
    AdHocSubProcess adHocSubProcess = (AdHocSubProcess) result.value().getElement();
    assertEquals(ELEMENT_ID, adHocSubProcess.getId());
    assertEquals(NAME, adHocSubProcess.getName());
    assertEquals(asCData(NAME), CustomElement.name.of(adHocSubProcess).get());
    assertEquals(asCData(DOCUMENTATION), adHocSubProcess.getDocumentation().get(0).getText());
    assertEquals(adHocOrdering, adHocSubProcess.getOrdering().getName());
    assertEquals(adHocAutostart, CustomElement.autoStart.of(adHocSubProcess).get());
    assertEquals(asCData(ACTIVATION_CONDITION), CustomElement.customActivationCondition.of(adHocSubProcess).get());
    assertEquals(Scripts.LANGUAGE.valueOf(COMPLETION_CONDITION.getLanguage().toUpperCase()).format(), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getLanguage());
    assertEquals(asCData(COMPLETION_CONDITION.getScript()), ((FormalExpression) adHocSubProcess.getCompletionCondition()).getBody());
    assertEquals(ON_ENTRY_ACTION.getLanguage(), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_ENTRY_ACTION.getScript()), Scripts.onEntry(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertEquals(ON_EXIT_ACTION.getLanguage(), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getLanguage());
    assertEquals(asCData(ON_EXIT_ACTION.getScript()), Scripts.onExit(adHocSubProcess.getExtensionValues()).getValues().get(0).getScript());
    assertVariables(Arrays.asList(new Pair<>("processVar1", "Object"), new Pair<>("processVar2", "Integer")), adHocSubProcess.getProperties());
    BPMNShape shape = result.value().getShape();
    assertEquals(parentX1 + nodeX1, shape.getBounds().getX(), 0);
    assertEquals(parentY1 + nodeY1, shape.getBounds().getY(), 0);
    assertEquals(nodeX2 - nodeX1, shape.getBounds().getWidth(), 0);
    assertEquals(nodeY2 - nodeY1, shape.getBounds().getHeight(), 0);
    assertBaseSubprocessExecutionSet(result.value());
}
Also used : NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) Node(org.kie.workbench.common.stunner.core.graph.Node) EdgeImpl(org.kie.workbench.common.stunner.core.graph.impl.EdgeImpl) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) BaseAdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) BPMNShape(org.eclipse.bpmn2.di.BPMNShape) View(org.kie.workbench.common.stunner.core.graph.content.view.View) SubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter) AdHocSubProcessPropertyWriter(org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter) AdHocSubProcess(org.eclipse.bpmn2.AdHocSubProcess) ViewImpl(org.kie.workbench.common.stunner.core.graph.content.view.ViewImpl) Edge(org.kie.workbench.common.stunner.core.graph.Edge) Child(org.kie.workbench.common.stunner.core.graph.content.relationship.Child) Pair(org.uberfire.commons.data.Pair) Test(org.junit.Test)

Example 2 with BPMNViewDefinition

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

the class BPMNElementDecoratorsTest method mockBpmnNode.

private BpmnNode mockBpmnNode() {
    BpmnNode element = mock(BpmnNode.class);
    Node node = mock(Node.class);
    when(element.value()).thenReturn(node);
    View content = mock(View.class);
    when(node.getContent()).thenReturn(content);
    BPMNViewDefinition viewDefinition = mock(BPMNViewDefinition.class);
    when(content.getDefinition()).thenReturn(viewDefinition);
    BPMNBaseInfo general = mock(BPMNBaseInfo.class);
    when(viewDefinition.getGeneral()).thenReturn(general);
    Name name = mock(Name.class);
    when(general.getName()).thenReturn(name);
    when(name.getValue()).thenReturn(NAME);
    return element;
}
Also used : BPMNBaseInfo(org.kie.workbench.common.stunner.bpmn.definition.BPMNBaseInfo) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) Node(org.kie.workbench.common.stunner.core.graph.Node) BpmnNode(org.kie.workbench.common.stunner.bpmn.backend.converters.tostunner.BpmnNode) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) View(org.kie.workbench.common.stunner.core.graph.content.view.View) Name(org.kie.workbench.common.stunner.bpmn.definition.property.general.Name)

Example 3 with BPMNViewDefinition

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

the class BPMNViewHandlersTest method testFontHandler.

@Test
@SuppressWarnings("unchecked")
public void testFontHandler() {
    final FontHandler<BPMNViewDefinition, ShapeView> fontHandler = new BPMNShapeViewHandlers.FontHandlerBuilder<>().build();
    final StartNoneEvent bean = new StartNoneEvent();
    bean.getFontSet().getFontColor().setValue("fontColor");
    bean.getFontSet().getFontFamily().setValue("fontFamily");
    bean.getFontSet().getFontSize().setValue(12d);
    bean.getFontSet().getFontBorderColor().setValue("borderColor");
    bean.getFontSet().getFontBorderSize().setValue(8d);
    fontHandler.handle(bean, view);
    verify(view, times(1)).setTitleFontColor(eq("fontColor"));
    verify(view, times(1)).setTitleFontFamily(eq("fontFamily"));
    verify(view, times(1)).setTitleFontSize(eq(12d));
    verify(view, times(1)).setTitleStrokeColor(eq("borderColor"));
    verify(view, times(1)).setTitleStrokeWidth(eq(8d));
}
Also used : ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) Test(org.junit.Test)

Example 4 with BPMNViewDefinition

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

the class BPMNViewHandlersTest method testViewHandler.

@Test
@SuppressWarnings("unchecked")
public void testViewHandler() {
    final ViewAttributesHandler<BPMNViewDefinition, ShapeView> fontHandler = new BPMNShapeViewHandlers.ViewAttributesHandlerBuilder<>().build();
    final StartNoneEvent bean = new StartNoneEvent();
    bean.getBackgroundSet().getBgColor().setValue("bgColor");
    bean.getBackgroundSet().getBorderColor().setValue("borderColor");
    bean.getBackgroundSet().getBorderSize().setValue(5d);
    fontHandler.handle(bean, view);
    verify(view, times(1)).setFillGradient(any(HasFillGradient.Type.class), eq("bgColor"), anyString());
    verify(view, times(1)).setStrokeColor(eq("borderColor"));
    verify(view, times(1)).setStrokeWidth(eq(5d));
}
Also used : ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) Test(org.junit.Test)

Example 5 with BPMNViewDefinition

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

the class BPMNShapeFactory method getFontHandler.

private <W extends BPMNViewDefinition, V extends ShapeView> FontHandler.Builder<W, V> getFontHandler() {
    final String definitionSetId = definitionUtils.getDefinitionSetId(BPMNDefinitionSet.class);
    final StunnerTextPreferences preferences = preferencesRegistries.get(definitionSetId, StunnerTextPreferences.class);
    return new BPMNShapeViewHandlers.FontHandlerBuilder<W, V>().alpha(c -> preferences.getTextAlpha()).fontFamily(c -> preferences.getTextFontFamily()).fontSize(c -> preferences.getTextFontSize()).fontColor(c -> preferences.getTextFillColor()).strokeColor(c -> preferences.getTextStrokeColor()).strokeSize(c -> preferences.getTextStrokeWidth()).strokeAlpha(c -> getStrokeAlpha(preferences.getTextStrokeWidth()));
}
Also used : EventGateway(org.kie.workbench.common.stunner.bpmn.definition.EventGateway) DefinitionUtils(org.kie.workbench.common.stunner.core.util.DefinitionUtils) BPMNDiagramShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.BPMNDiagramShapeDef) SequenceFlow(org.kie.workbench.common.stunner.bpmn.definition.SequenceFlow) DirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.DirectionalAssociation) IntermediateCompensationEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEventThrowing) TextAnnotationShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.TextAnnotationShapeDef) IntermediateLinkEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateLinkEventCatching) IntermediateErrorEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateErrorEventCatching) ManagedInstance(org.jboss.errai.ioc.client.api.ManagedInstance) EndErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.EndErrorEvent) StartSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartSignalEvent) GatewayShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.GatewayShapeDef) StartTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.StartTimerEvent) UserTask(org.kie.workbench.common.stunner.bpmn.definition.UserTask) BPMNViewDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition) IntermediateCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateCompensationEvent) CustomTask(org.kie.workbench.common.stunner.bpmn.workitem.CustomTask) Lane(org.kie.workbench.common.stunner.bpmn.definition.Lane) GenericServiceTask(org.kie.workbench.common.stunner.bpmn.definition.GenericServiceTask) TextAnnotation(org.kie.workbench.common.stunner.bpmn.definition.TextAnnotation) NonDirectionalAssociation(org.kie.workbench.common.stunner.bpmn.definition.NonDirectionalAssociation) FontHandlerBuilder.getStrokeAlpha(org.kie.workbench.common.stunner.bpmn.client.shape.view.handler.BPMNShapeViewHandlers.FontHandlerBuilder.getStrokeAlpha) EndTerminateEvent(org.kie.workbench.common.stunner.bpmn.definition.EndTerminateEvent) BasicShapesFactory(org.kie.workbench.common.stunner.shapes.client.factory.BasicShapesFactory) StartConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.StartConditionalEvent) DelegateShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.DelegateShapeFactory) StartErrorEvent(org.kie.workbench.common.stunner.bpmn.definition.StartErrorEvent) ExclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.ExclusiveGateway) ScriptTask(org.kie.workbench.common.stunner.bpmn.definition.ScriptTask) SequenceFlowConnectorDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.SequenceFlowConnectorDef) TaskShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.TaskShapeDef) ThrowingIntermediateEventShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.ThrowingIntermediateEventShapeDef) EmbeddedSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess) CustomTaskShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.CustomTaskShapeDef) PostConstruct(javax.annotation.PostConstruct) BPMNDefinitionSet(org.kie.workbench.common.stunner.bpmn.BPMNDefinitionSet) EndEventShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.EndEventShapeDef) IntermediateTimerEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateTimerEvent) NoneTask(org.kie.workbench.common.stunner.bpmn.definition.NoneTask) StartMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.StartMessageEvent) IntermediateLinkEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateLinkEventThrowing) AssociationConnectorDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.AssociationConnectorDef) StartCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.StartCompensationEvent) StartNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent) EndEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndEscalationEvent) BusinessRuleTask(org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask) BPMNShapeViewHandlers(org.kie.workbench.common.stunner.bpmn.client.shape.view.handler.BPMNShapeViewHandlers) SVGShapeFactory(org.kie.workbench.common.stunner.svg.client.shape.factory.SVGShapeFactory) ParallelGateway(org.kie.workbench.common.stunner.bpmn.definition.ParallelGateway) Supplier(java.util.function.Supplier) IntermediateConditionalEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateConditionalEvent) Shape(org.kie.workbench.common.stunner.core.client.shape.Shape) AdHocSubprocess(org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess) Inject(javax.inject.Inject) DataObject(org.kie.workbench.common.stunner.bpmn.definition.DataObject) IntermediateEscalationEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEventThrowing) Glyph(org.kie.workbench.common.stunner.core.definition.shape.Glyph) EndCompensationEvent(org.kie.workbench.common.stunner.bpmn.definition.EndCompensationEvent) IntermediateSignalEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventThrowing) ReusableSubprocess(org.kie.workbench.common.stunner.bpmn.definition.ReusableSubprocess) StunnerTextPreferences(org.kie.workbench.common.stunner.core.client.preferences.StunnerTextPreferences) FontHandler(org.kie.workbench.common.stunner.core.client.shape.view.handler.FontHandler) IntermediateSignalEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateSignalEventCatching) DataObjectShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.DataObjectShapeDef) StunnerPreferencesRegistries(org.kie.workbench.common.stunner.core.client.preferences.StunnerPreferencesRegistries) EndMessageEvent(org.kie.workbench.common.stunner.bpmn.definition.EndMessageEvent) CatchingIntermediateEventShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.CatchingIntermediateEventShapeDef) BPMNDefinition(org.kie.workbench.common.stunner.bpmn.definition.BPMNDefinition) EndSignalEvent(org.kie.workbench.common.stunner.bpmn.definition.EndSignalEvent) StartEventShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.StartEventShapeDef) BPMNDiagramImpl(org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl) IntermediateEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.IntermediateEscalationEvent) InclusiveGateway(org.kie.workbench.common.stunner.bpmn.definition.InclusiveGateway) SubprocessShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.SubprocessShapeDef) ShapeView(org.kie.workbench.common.stunner.core.client.shape.view.ShapeView) EventSubprocess(org.kie.workbench.common.stunner.bpmn.definition.EventSubprocess) IntermediateMessageEventThrowing(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventThrowing) Dependent(javax.enterprise.context.Dependent) LaneShapeDef(org.kie.workbench.common.stunner.bpmn.client.shape.def.LaneShapeDef) StartEscalationEvent(org.kie.workbench.common.stunner.bpmn.definition.StartEscalationEvent) ShapeFactory(org.kie.workbench.common.stunner.core.client.shape.factory.ShapeFactory) WorkItemDefinitionRegistry(org.kie.workbench.common.stunner.bpmn.workitem.WorkItemDefinitionRegistry) MultipleInstanceSubprocess(org.kie.workbench.common.stunner.bpmn.definition.MultipleInstanceSubprocess) IntermediateMessageEventCatching(org.kie.workbench.common.stunner.bpmn.definition.IntermediateMessageEventCatching) EndNoneEvent(org.kie.workbench.common.stunner.bpmn.definition.EndNoneEvent) StunnerTextPreferences(org.kie.workbench.common.stunner.core.client.preferences.StunnerTextPreferences) BPMNShapeViewHandlers(org.kie.workbench.common.stunner.bpmn.client.shape.view.handler.BPMNShapeViewHandlers)

Aggregations

BPMNViewDefinition (org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition)11 Test (org.junit.Test)5 StartNoneEvent (org.kie.workbench.common.stunner.bpmn.definition.StartNoneEvent)4 View (org.kie.workbench.common.stunner.core.graph.content.view.View)4 DefinitionsBuildingContext (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.DefinitionsBuildingContext)3 AdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.AdHocSubprocess)3 ShapeView (org.kie.workbench.common.stunner.core.client.shape.view.ShapeView)3 ConverterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.ConverterFactory)2 Factories.bpmn2 (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.Factories.bpmn2)2 AdHocSubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.AdHocSubProcessPropertyWriter)2 PropertyWriterFactory (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.PropertyWriterFactory)2 SubProcessPropertyWriter (org.kie.workbench.common.stunner.bpmn.backend.converters.fromstunner.properties.SubProcessPropertyWriter)2 BPMNDiagramImpl (org.kie.workbench.common.stunner.bpmn.definition.BPMNDiagramImpl)2 BaseAdHocSubprocess (org.kie.workbench.common.stunner.bpmn.definition.BaseAdHocSubprocess)2 BusinessRuleTask (org.kie.workbench.common.stunner.bpmn.definition.BusinessRuleTask)2 EmbeddedSubprocess (org.kie.workbench.common.stunner.bpmn.definition.EmbeddedSubprocess)2 Node (org.kie.workbench.common.stunner.core.graph.Node)2 GraphImpl (org.kie.workbench.common.stunner.core.graph.impl.GraphImpl)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 GraphNodeStoreImpl (org.kie.workbench.common.stunner.core.graph.store.GraphNodeStoreImpl)2