use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet in project kie-wb-common by kiegroup.
the class SequenceFlowConverter method toFlowElement.
public SequenceFlowPropertyWriter toFlowElement(Edge<?, ?> edge, ElementContainer process) {
ViewConnector<SequenceFlow> content = (ViewConnector<SequenceFlow>) edge.getContent();
SequenceFlow definition = content.getDefinition();
org.eclipse.bpmn2.SequenceFlow seq = bpmn2.createSequenceFlow();
SequenceFlowPropertyWriter p = propertyWriterFactory.of(seq);
seq.setId(edge.getUUID());
BasePropertyWriter pSrc = process.getChildElement(edge.getSourceNode().getUUID());
BasePropertyWriter pTgt = process.getChildElement(edge.getTargetNode().getUUID());
p.setSource(pSrc);
p.setTarget(pTgt);
seq.setId(edge.getUUID());
seq.setName(definition.getGeneral().getName().getValue());
p.setConnection(content);
SequenceFlowExecutionSet executionSet = definition.getExecutionSet();
ScriptTypeValue scriptTypeValue = executionSet.getConditionExpression().getValue();
String language = scriptTypeValue.getLanguage();
String script = scriptTypeValue.getScript();
if (script != null) {
FormalExpression formalExpression = bpmn2.createFormalExpression();
String uri = Scripts.scriptLanguageToUri(language);
formalExpression.setLanguage(uri);
formalExpression.setBody(asCData(script));
seq.setConditionExpression(formalExpression);
}
process.addChildElement(p);
process.addChildEdge(p.getEdge());
return p;
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet in project kie-wb-common by kiegroup.
the class SequenceFlowConverter method convertEdge.
public BpmnEdge convertEdge(org.eclipse.bpmn2.SequenceFlow seq, Map<String, BpmnNode> nodes) {
Edge<View<SequenceFlow>, Node> edge = factoryManager.newEdge(seq.getId(), SequenceFlow.class);
SequenceFlow definition = edge.getContent().getDefinition();
SequenceFlowPropertyReader p = propertyReaderFactory.of(seq);
definition.setGeneral(new BPMNGeneralSet(new Name(seq.getName()), new Documentation(p.getDocumentation())));
definition.setExecutionSet(new SequenceFlowExecutionSet(new Priority(p.getPriority()), new ConditionExpression(p.getConditionExpression())));
return BpmnEdge.of(edge, nodes.get(p.getSourceId()), p.getSourceConnection(), nodes.get(p.getTargetId()), p.getTargetConnection());
}
use of org.kie.workbench.common.stunner.bpmn.definition.property.connectors.SequenceFlowExecutionSet in project kie-wb-common by kiegroup.
the class ConditionalComboBoxFieldRendererTest method initWithDefinitionSet.
@Test
public void initWithDefinitionSet() throws Exception {
resetMocks();
SequenceFlow sequenceFlow = new SequenceFlow.SequenceFlowBuilder().build();
SequenceFlowExecutionSet sequenceFlowExecutionSet = sequenceFlow.getExecutionSet();
ConditionExpression conditionExpression = sequenceFlowExecutionSet.getConditionExpression();
// static mock
PowerMockito.mockStatic(ClientBindingUtils.class);
BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlow, "executionSet")).willReturn(sequenceFlowExecutionSet);
BDDMockito.given(ClientBindingUtils.getProxiedValue(sequenceFlowExecutionSet, "conditionExpression")).willReturn(conditionExpression);
// instances mock
when(conditionalComboBoxFieldDefinition.getRelatedField()).thenReturn("executionSet.conditionExpression");
when(renderingContext.getModel()).thenReturn(null);
when(renderingContext.getParentContext()).thenReturn(renderingContextParent);
when(renderingContextParent.getModel()).thenReturn(sequenceFlow);
when(adapterManager.forProperty()).thenReturn(Mockito.mock(PropertyAdapter.class));
when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("value");
conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
verify(conditionalComboBoxFieldRenderer, never()).setReadOnly(true);
verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(false);
when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn("");
conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
verify(conditionalComboBoxFieldRenderer, times(1)).setReadOnly(true);
when(adapterManager.forProperty().getValue(conditionExpression)).thenReturn(null);
conditionalComboBoxFieldRenderer.init(renderingContext, conditionalComboBoxFieldDefinition);
verify(conditionalComboBoxFieldRenderer, atLeastOnce()).setReadOnly(true);
}
Aggregations