use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method setAdHocSubProcessProperties.
private void setAdHocSubProcessProperties(final AdHocSubProcess subProcess, final Map<String, Object> properties) {
if (subProcess.getOrdering().equals(AdHocOrdering.PARALLEL)) {
properties.put(ADHOCORDERING, "Parallel");
} else if (subProcess.getOrdering().equals(AdHocOrdering.SEQUENTIAL)) {
properties.put(ADHOCORDERING, "Sequential");
} else {
// default to parallel
properties.put(ADHOCORDERING, "Parallel");
}
if (subProcess.getCompletionCondition() != null) {
final FormalExpression expression = (FormalExpression) subProcess.getCompletionCondition();
final String language = Utils.getScriptLanguage(expression.getLanguage());
final String script = expression.getBody().replaceAll("\n", "\\\\n");
final ScriptTypeValue value = new ScriptTypeValue(language, script);
properties.put(ADHOCCOMPLETIONCONDITION, new ScriptTypeTypeSerializer().serialize(value));
}
}
use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.
the class SubProcessConverter method convertEventSubprocessNode.
private SubProcessPropertyWriter convertEventSubprocessNode(Node<View<EventSubprocess>, ?> n) {
SubProcess process = bpmn2.createSubProcess();
process.setId(n.getUUID());
SubProcessPropertyWriter p = propertyWriterFactory.of(process);
EventSubprocess definition = n.getContent().getDefinition();
process.setTriggeredByEvent(true);
BPMNGeneralSet general = definition.getGeneral();
p.setName(general.getName().getValue());
p.setDocumentation(general.getDocumentation().getValue());
ProcessData processData = definition.getProcessData();
p.setProcessVariables(processData.getProcessVariables());
p.setSimulationSet(definition.getSimulationSet());
p.setBounds(n.getContent().getBounds());
return p;
}
use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method linkSequenceFlows.
private void linkSequenceFlows(List<FlowElement> flowElements) {
Map<String, FlowNode> nodes = new HashMap<String, FlowNode>();
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof FlowNode) {
nodes.put(flowElement.getId(), (FlowNode) flowElement);
if (flowElement instanceof SubProcess) {
linkSequenceFlows(((SubProcess) flowElement).getFlowElements());
}
}
}
for (FlowElement flowElement : flowElements) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
if (sequenceFlow.getSourceRef() == null && sequenceFlow.getTargetRef() == null) {
String id = sequenceFlow.getId();
try {
String[] subids = id.split("-_");
String id1 = subids[0];
String id2 = "_" + subids[1];
FlowNode source = nodes.get(id1);
if (source != null) {
sequenceFlow.setSourceRef(source);
}
FlowNode target = nodes.get(id2);
if (target != null) {
sequenceFlow.setTargetRef(target);
}
} catch (Throwable t) {
// Do nothing
}
}
}
}
}
use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallItemAwareElements.
private void marshallItemAwareElements(Activity activity, List<? extends ItemAwareElement> elements, StringBuilder buffer, List<String> disallowedNames) {
for (ItemAwareElement element : elements) {
String name = null;
if (element instanceof DataInput) {
name = ((DataInput) element).getName();
}
if (element instanceof DataOutput) {
name = ((DataOutput) element).getName();
}
if (name != null && !name.isEmpty() && !disallowedNames.contains(name)) {
buffer.append(name);
if (element.getItemSubjectRef() != null && element.getItemSubjectRef().getStructureRef() != null && !element.getItemSubjectRef().getStructureRef().isEmpty()) {
buffer.append(":").append(element.getItemSubjectRef().getStructureRef());
} else if (activity.eContainer() instanceof SubProcess) {
// BZ1247105: for Outputs on Tasks inside sub-processes
String dtype = getAnyAttributeValue(element, "dtype");
if (dtype != null && !dtype.isEmpty()) {
buffer.append(":").append(dtype);
}
}
buffer.append(",");
}
}
}
use of org.eclipse.bpmn2.SubProcess in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method updateShapeBoundsInSubprocess.
public void updateShapeBoundsInSubprocess(BPMNPlane plane, BaseElement ele, SubProcess sub, float parentX, float parentY) {
boolean foundInSubprocess = false;
for (FlowElement subEle : sub.getFlowElements()) {
if (subEle.getId().equals(ele.getId())) {
foundInSubprocess = true;
Bounds subEleBounds = getBoundsForElement(subEle, plane);
if (subEleBounds != null) {
subEleBounds.setX(subEleBounds.getX() + parentX);
subEleBounds.setY(subEleBounds.getY() + parentY);
}
}
}
if (!foundInSubprocess) {
for (FlowElement subEle : sub.getFlowElements()) {
if (subEle instanceof SubProcess) {
Bounds subEleBounds = getBoundsForElement(subEle, plane);
updateShapeBoundsInSubprocess(plane, ele, (SubProcess) subEle, subEleBounds.getX(), subEleBounds.getY());
}
}
}
}
Aggregations