use of org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition in project kie-wb-common by kiegroup.
the class CaseManagementShapeDefFactory method newStageShape.
@SuppressWarnings("unchecked")
private Shape newStageShape(final Object instance, final ShapeDef shapeDef) {
final BPMNViewDefinition bpmnDefinition = (BPMNViewDefinition) instance;
final StageShapeDef cmShapeDef = (StageShapeDef) shapeDef;
final double width = cmShapeDef.getWidth(bpmnDefinition);
final double height = cmShapeDef.getHeight(bpmnDefinition);
final double dropWidth = cmShapeDef.getDropAreaWidth(bpmnDefinition);
final double dropHeight = cmShapeDef.getDropAreaHeight(bpmnDefinition);
final double voffset = cmShapeDef.getVOffset(bpmnDefinition);
final StageView view = cmShapeViewFactory.newStageView(dropWidth, dropHeight, voffset).setWidth(width).setHeight(height);
return new CMContainerShape(cmShapeDef, view);
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition in project kie-wb-common by kiegroup.
the class CaseManagementShapeDefFactory method newActivityShape.
@SuppressWarnings("unchecked")
private Shape newActivityShape(final Object instance, final ShapeDef shapeDef) {
final BPMNViewDefinition bpmnDefinition = (BPMNViewDefinition) instance;
final CaseManagementActivityShapeDef cmShapeDef = (CaseManagementActivityShapeDef) shapeDef;
final double width = cmShapeDef.getWidth(bpmnDefinition);
final double height = cmShapeDef.getHeight(bpmnDefinition);
final ActivityView view = cmShapeViewFactory.newActivityView(width, height);
final SafeUri iconUri = cmShapeDef.getIconUri(instance.getClass());
final PictureShapeView iconView = basicShapeViewFactory.pictureFromUri(iconUri, 15d, 15d);
return new ActivityShape(cmShapeDef, iconView, view);
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition in project kie-wb-common by kiegroup.
the class ProcessConverterDelegateTest method testPostConvertNodes.
@Test
@SuppressWarnings("unchecked")
public void testPostConvertNodes() {
TestingGraphMockHandler graphTestHandler = new TestingGraphMockHandler();
BPMNDiagramImpl bpmnDiagram = new BPMNDiagramImpl();
StartNoneEvent level0StartNode = new StartNoneEvent();
EndNoneEvent level0EndNode = new EndNoneEvent();
UserTask level0Node1 = new UserTask();
UserTask level0Node2 = new UserTask();
EmbeddedSubprocess level1SubProcess1 = new EmbeddedSubprocess();
ScriptTask level1Node1 = new ScriptTask();
IntermediateSignalEventThrowing level1Node2 = new IntermediateSignalEventThrowing();
AdHocSubprocess level2SubProcess1 = new AdHocSubprocess();
BusinessRuleTask level2Node1 = new BusinessRuleTask();
EndCompensationEvent level2Node2 = new EndCompensationEvent();
TestingGraphInstanceBuilder2.Level2Graph level2Graph = TestingGraphInstanceBuilder2.buildLevel2Graph(graphTestHandler, bpmnDiagram, level0StartNode, level0Node1, level0Node2, level0EndNode, level1SubProcess1, level1Node1, level1Node2, level2SubProcess1, level2Node1, level2Node2);
DefinitionsBuildingContext ctx = new DefinitionsBuildingContext(level2Graph.graph);
PropertyWriterFactory writerFactory = new PropertyWriterFactory();
ConverterFactory factory = spy(new ConverterFactory(ctx, writerFactory));
FlowElementPostConverter flowElementPostConverter = mock(FlowElementPostConverter.class);
when(factory.flowElementPostConverter()).thenReturn(flowElementPostConverter);
MyProcessConverter abstractProcessConverter = new MyProcessConverter(factory);
ProcessPropertyWriter processWriter = writerFactory.of(bpmn2.createProcess());
abstractProcessConverter.postConvertChildNodes(processWriter, ctx);
verify(flowElementPostConverter, times(10)).postConvert(anyObject(), anyObject(), nodeCaptor.capture());
Map<String, BPMNViewDefinition> nodes = new HashMap<>();
nodes.put(LEVEL0_START_NODE.uuid(), level0StartNode);
nodes.put(LEVEL0_NODE1.uuid(), level0Node1);
nodes.put(LEVEL0_NODE2.uuid(), level0Node2);
nodes.put(LEVEL0_END_NODE.uuid(), level0EndNode);
nodes.put(LEVEL1_SUB_PROCESS1.uuid(), level1SubProcess1);
nodes.put(LEVEL1_NODE1.uuid(), level1Node1);
nodes.put(LEVEL1_NODE2.uuid(), level1Node2);
nodes.put(LEVEL2_SUB_PROCESS1.uuid(), level2SubProcess1);
nodes.put(LEVEL2_NODE1.uuid(), level2Node1);
nodes.put(LEVEL2_NODE2.uuid(), level2Node2);
assertEquals(nodes.size(), nodeCaptor.getAllValues().size());
nodes.entrySet().forEach(entry -> {
Optional<Node<View<? extends BPMNViewDefinition>, ?>> processed = nodeCaptor.getAllValues().stream().filter(captured -> entry.getKey().equals(captured.getUUID())).findFirst();
assertTrue("Node: " + entry.getKey() + " was not present in result", processed.isPresent());
assertEquals(entry.getValue(), processed.get().getContent().getDefinition());
});
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition in project kie-wb-common by kiegroup.
the class SubProcessConverterTest method JBPM_7525_eventSubProcessShouldStoreIsAsync.
@Test
public void JBPM_7525_eventSubProcessShouldStoreIsAsync() {
ConverterFactory f = new ConverterFactory(new DefinitionsBuildingContext(new GraphImpl("x", new GraphNodeStoreImpl())), new PropertyWriterFactory());
SubProcessConverter c = f.subProcessConverter();
NodeImpl<View<? extends BPMNViewDefinition>> n = new NodeImpl<>("n");
EventSubprocess subProcessNode = new EventSubprocess();
subProcessNode.getExecutionSet().setIsAsync(new IsAsync(true));
n.setContent(new ViewImpl<>(subProcessNode, Bounds.create()));
Activity activity = c.convertSubProcess(n).value().getFlowElement();
Boolean value = CustomElement.async.of(activity).get();
assertThat(value).isEqualTo(true);
}
use of org.kie.workbench.common.stunner.bpmn.definition.BPMNViewDefinition in project kie-wb-common by kiegroup.
the class LaneConverter method toElement.
public Result<LanePropertyWriter> toElement(Node<View<? extends BPMNViewDefinition>, ?> node) {
return NodeMatch.fromNode(BPMNViewDefinition.class, LanePropertyWriter.class).when(Lane.class, n -> {
org.eclipse.bpmn2.Lane lane = bpmn2.createLane();
lane.setId(n.getUUID());
LanePropertyWriter p = propertyWriterFactory.of(lane);
Lane definition = n.getContent().getDefinition();
BPMNGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
p.setMetaData(definition.getAdvancedData().getMetaDataAttributes());
p.setAbsoluteBounds(n);
return p;
}).ignore(Object.class).apply(node);
}
Aggregations