use of org.activiti.bpmn.model.Activity in project Activiti by Activiti.
the class BaseBpmnXMLConverter method convertToXML.
public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) throws Exception {
xtw.writeStartElement(getXMLElementName());
boolean didWriteExtensionStartElement = false;
writeDefaultAttribute(ATTRIBUTE_ID, baseElement.getId(), xtw);
if (baseElement instanceof FlowElement) {
writeDefaultAttribute(ATTRIBUTE_NAME, ((FlowElement) baseElement).getName(), xtw);
}
if (baseElement instanceof FlowNode) {
final FlowNode flowNode = (FlowNode) baseElement;
if (flowNode.isAsynchronous()) {
writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
if (flowNode.isNotExclusive()) {
writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
}
}
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
if (activity.isForCompensation()) {
writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw);
}
if (StringUtils.isNotEmpty(activity.getDefaultFlow())) {
FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow());
if (defaultFlowElement instanceof SequenceFlow) {
writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw);
}
}
}
if (baseElement instanceof Gateway) {
final Gateway gateway = (Gateway) baseElement;
if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
if (defaultFlowElement instanceof SequenceFlow) {
writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
}
}
}
}
writeAdditionalAttributes(baseElement, model, xtw);
if (baseElement instanceof FlowElement) {
final FlowElement flowElement = (FlowElement) baseElement;
if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {
xtw.writeStartElement(ELEMENT_DOCUMENTATION);
xtw.writeCharacters(flowElement.getDocumentation());
xtw.writeEndElement();
}
}
didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement, didWriteExtensionStartElement, model.getNamespaces(), xtw);
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
FailedJobRetryCountExport.writeFailedJobRetryCount(activity, xtw);
}
if (didWriteExtensionStartElement) {
xtw.writeEndElement();
}
if (baseElement instanceof Activity) {
final Activity activity = (Activity) baseElement;
MultiInstanceExport.writeMultiInstance(activity, xtw);
}
writeAdditionalChildElements(baseElement, model, xtw);
xtw.writeEndElement();
}
use of org.activiti.bpmn.model.Activity in project Activiti by Activiti.
the class BpmnXMLConverter method processFlowElements.
private void processFlowElements(Collection<FlowElement> flowElementList, BaseElement parentScope) {
for (FlowElement flowElement : flowElementList) {
if (flowElement instanceof SequenceFlow) {
SequenceFlow sequenceFlow = (SequenceFlow) flowElement;
FlowNode sourceNode = getFlowNodeFromScope(sequenceFlow.getSourceRef(), parentScope);
if (sourceNode != null) {
sourceNode.getOutgoingFlows().add(sequenceFlow);
}
FlowNode targetNode = getFlowNodeFromScope(sequenceFlow.getTargetRef(), parentScope);
if (targetNode != null) {
targetNode.getIncomingFlows().add(sequenceFlow);
}
} else if (flowElement instanceof BoundaryEvent) {
BoundaryEvent boundaryEvent = (BoundaryEvent) flowElement;
FlowElement attachedToElement = getFlowNodeFromScope(boundaryEvent.getAttachedToRefId(), parentScope);
if (attachedToElement != null) {
boundaryEvent.setAttachedToRef((Activity) attachedToElement);
((Activity) attachedToElement).getBoundaryEvents().add(boundaryEvent);
}
} else if (flowElement instanceof SubProcess) {
SubProcess subProcess = (SubProcess) flowElement;
processFlowElements(subProcess.getFlowElements(), subProcess);
}
}
}
use of org.activiti.bpmn.model.Activity in project Activiti by Activiti.
the class IOSpecificationParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (parentElement instanceof Activity == false && parentElement instanceof Process == false)
return;
IOSpecification ioSpecification = new IOSpecification();
BpmnXMLUtil.addXMLLocation(ioSpecification, xtr);
boolean readyWithIOSpecification = false;
try {
while (readyWithIOSpecification == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement() && ELEMENT_DATA_INPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataInputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT.equalsIgnoreCase(xtr.getLocalName())) {
DataSpec dataSpec = new DataSpec();
BpmnXMLUtil.addXMLLocation(dataSpec, xtr);
dataSpec.setId(xtr.getAttributeValue(null, ATTRIBUTE_ID));
dataSpec.setName(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
dataSpec.setItemSubjectRef(parseItemSubjectRef(xtr.getAttributeValue(null, ATTRIBUTE_ITEM_SUBJECT_REF), model));
ioSpecification.getDataOutputs().add(dataSpec);
} else if (xtr.isStartElement() && ELEMENT_DATA_INPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataInputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataInputRefs)) {
ioSpecification.getDataInputRefs().add(dataInputRefs.trim());
}
} else if (xtr.isStartElement() && ELEMENT_DATA_OUTPUT_REFS.equalsIgnoreCase(xtr.getLocalName())) {
String dataOutputRefs = xtr.getElementText();
if (StringUtils.isNotEmpty(dataOutputRefs)) {
ioSpecification.getDataOutputRefs().add(dataOutputRefs.trim());
}
} else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithIOSpecification = true;
}
}
} catch (Exception e) {
LOGGER.warn("Error parsing ioSpecification child elements", e);
}
if (parentElement instanceof Process) {
((Process) parentElement).setIoSpecification(ioSpecification);
} else {
((Activity) parentElement).setIoSpecification(ioSpecification);
}
}
use of org.activiti.bpmn.model.Activity in project Activiti by Activiti.
the class MultiInstanceParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (parentElement instanceof Activity == false)
return;
MultiInstanceLoopCharacteristics multiInstanceDef = new MultiInstanceLoopCharacteristics();
BpmnXMLUtil.addXMLLocation(multiInstanceDef, xtr);
if (xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL) != null) {
multiInstanceDef.setSequential(Boolean.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL)));
}
multiInstanceDef.setInputDataItem(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MULTIINSTANCE_COLLECTION));
multiInstanceDef.setElementVariable(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MULTIINSTANCE_VARIABLE));
multiInstanceDef.setElementIndexVariable(xtr.getAttributeValue(ACTIVITI_EXTENSIONS_NAMESPACE, ATTRIBUTE_MULTIINSTANCE_INDEX_VARIABLE));
boolean readyWithMultiInstance = false;
try {
while (readyWithMultiInstance == false && xtr.hasNext()) {
xtr.next();
if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_CARDINALITY.equalsIgnoreCase(xtr.getLocalName())) {
multiInstanceDef.setLoopCardinality(xtr.getElementText());
} else if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_DATAINPUT.equalsIgnoreCase(xtr.getLocalName())) {
multiInstanceDef.setInputDataItem(xtr.getElementText());
} else if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_DATAITEM.equalsIgnoreCase(xtr.getLocalName())) {
if (xtr.getAttributeValue(null, ATTRIBUTE_NAME) != null) {
multiInstanceDef.setElementVariable(xtr.getAttributeValue(null, ATTRIBUTE_NAME));
}
} else if (xtr.isStartElement() && ELEMENT_MULTIINSTANCE_CONDITION.equalsIgnoreCase(xtr.getLocalName())) {
multiInstanceDef.setCompletionCondition(xtr.getElementText());
} else if (xtr.isEndElement() && getElementName().equalsIgnoreCase(xtr.getLocalName())) {
readyWithMultiInstance = true;
}
}
} catch (Exception e) {
LOGGER.warn("Error parsing multi instance definition", e);
}
((Activity) parentElement).setLoopCharacteristics(multiInstanceDef);
}
use of org.activiti.bpmn.model.Activity in project Activiti by Activiti.
the class FlowElementValidator method executeValidation.
@Override
protected void executeValidation(BpmnModel bpmnModel, Process process, List<ValidationError> errors) {
for (FlowElement flowElement : process.getFlowElements()) {
if (flowElement instanceof Activity) {
Activity activity = (Activity) flowElement;
handleConstraints(process, activity, errors);
handleMultiInstanceLoopCharacteristics(process, activity, errors);
handleDataAssociations(process, activity, errors);
}
}
}
Aggregations