use of org.activiti.bpmn.model.EventSubProcess in project Activiti by Activiti.
the class SubProcessParser method parse.
public void parse(XMLStreamReader xtr, List<SubProcess> activeSubProcessList, Process activeProcess) {
SubProcess subProcess = null;
if (ELEMENT_TRANSACTION.equalsIgnoreCase(xtr.getLocalName())) {
subProcess = new Transaction();
} else if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(xtr.getAttributeValue(null, ATTRIBUTE_TRIGGERED_BY))) {
subProcess = new EventSubProcess();
} else {
subProcess = new SubProcess();
}
BpmnXMLUtil.addXMLLocation(subProcess, xtr);
activeSubProcessList.add(subProcess);
subProcess.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
subProcess.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
boolean async = false;
String asyncString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_ASYNCHRONOUS);
if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(asyncString)) {
async = true;
}
boolean notExclusive = false;
String exclusiveString = xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_ACTIVITY_EXCLUSIVE);
if (ATTRIBUTE_VALUE_FALSE.equalsIgnoreCase(exclusiveString)) {
notExclusive = true;
}
boolean forCompensation = false;
String compensationString = xtr.getAttributeValue(null, ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION);
if (ATTRIBUTE_VALUE_TRUE.equalsIgnoreCase(compensationString)) {
forCompensation = true;
}
subProcess.setAsynchronous(async);
subProcess.setNotExclusive(notExclusive);
subProcess.setForCompensation(forCompensation);
if (StringUtils.isNotEmpty(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT))) {
subProcess.setDefaultFlow(xtr.getAttributeValue(null, ATTRIBUTE_DEFAULT));
}
if (activeSubProcessList.size() > 1) {
activeSubProcessList.get(activeSubProcessList.size() - 2).addFlowElement(subProcess);
} else {
activeProcess.addFlowElement(subProcess);
}
}
use of org.activiti.bpmn.model.EventSubProcess in project Activiti by Activiti.
the class EventSubProcessJsonConverter method convertJsonToElement.
protected FlowElement convertJsonToElement(JsonNode elementNode, JsonNode modelNode, Map<String, JsonNode> shapeMap) {
EventSubProcess subProcess = new EventSubProcess();
JsonNode childShapesArray = elementNode.get(EDITOR_CHILD_SHAPES);
processor.processJsonElements(childShapesArray, modelNode, subProcess, shapeMap, model);
return subProcess;
}
use of org.activiti.bpmn.model.EventSubProcess in project Activiti by Activiti.
the class SubProcessParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, SubProcess subProcess) {
ActivityImpl activity = createActivityOnScope(bpmnParse, subProcess, BpmnXMLConstants.ELEMENT_SUBPROCESS, bpmnParse.getCurrentScope());
activity.setAsync(subProcess.isAsynchronous());
activity.setExclusive(!subProcess.isNotExclusive());
boolean triggeredByEvent = false;
if (subProcess instanceof EventSubProcess) {
triggeredByEvent = true;
}
activity.setProperty("triggeredByEvent", triggeredByEvent);
// event subprocesses are not scopes
activity.setScope(!triggeredByEvent);
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createSubprocActivityBehavior(subProcess));
bpmnParse.setCurrentScope(activity);
bpmnParse.setCurrentSubProcess(subProcess);
bpmnParse.processFlowElements(subProcess.getFlowElements());
processArtifacts(bpmnParse, subProcess.getArtifacts(), activity);
// no data objects for event subprocesses
if (!(subProcess instanceof EventSubProcess)) {
// parse out any data objects from the template in order to set up the necessary process variables
Map<String, Object> variables = processDataObjects(bpmnParse, subProcess.getDataObjects(), activity);
activity.setVariables(variables);
}
bpmnParse.removeCurrentScope();
bpmnParse.removeCurrentSubProcess();
if (subProcess.getIoSpecification() != null) {
IOSpecification ioSpecification = createIOSpecification(bpmnParse, subProcess.getIoSpecification());
activity.setIoSpecification(ioSpecification);
}
}
use of org.activiti.bpmn.model.EventSubProcess in project Activiti by Activiti.
the class BpmnXMLConverter method createXML.
private void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception {
if (flowElement instanceof SubProcess) {
SubProcess subProcess = (SubProcess) flowElement;
if (flowElement instanceof Transaction) {
xtw.writeStartElement(ELEMENT_TRANSACTION);
} else {
xtw.writeStartElement(ELEMENT_SUBPROCESS);
}
xtw.writeAttribute(ATTRIBUTE_ID, subProcess.getId());
if (StringUtils.isNotEmpty(subProcess.getName())) {
xtw.writeAttribute(ATTRIBUTE_NAME, subProcess.getName());
} else {
xtw.writeAttribute(ATTRIBUTE_NAME, "subProcess");
}
if (subProcess instanceof EventSubProcess) {
xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE);
} else if (subProcess instanceof Transaction == false) {
if (subProcess.isAsynchronous()) {
BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
if (subProcess.isNotExclusive()) {
BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
}
}
}
if (StringUtils.isNotEmpty(subProcess.getDocumentation())) {
xtw.writeStartElement(ELEMENT_DOCUMENTATION);
xtw.writeCharacters(subProcess.getDocumentation());
xtw.writeEndElement();
}
boolean didWriteExtensionStartElement = ActivitiListenerExport.writeListeners(subProcess, false, xtw);
didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(subProcess, didWriteExtensionStartElement, model.getNamespaces(), xtw);
if (didWriteExtensionStartElement) {
// closing extensions element
xtw.writeEndElement();
}
MultiInstanceExport.writeMultiInstance(subProcess, xtw);
for (FlowElement subElement : subProcess.getFlowElements()) {
createXML(subElement, model, xtw);
}
for (Artifact artifact : subProcess.getArtifacts()) {
createXML(artifact, model, xtw);
}
xtw.writeEndElement();
} else {
BaseBpmnXMLConverter converter = convertersToXMLMap.get(flowElement.getClass());
if (converter == null) {
throw new XMLException("No converter for " + flowElement.getClass() + " found");
}
converter.convertToXML(xtw, flowElement, model);
}
}
Aggregations