use of org.activiti.bpmn.model.DataAssociation in project Activiti by Activiti.
the class SendTaskParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, SendTask sendTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, sendTask, BpmnXMLConstants.ELEMENT_TASK_SEND);
activity.setAsync(sendTask.isAsynchronous());
activity.setExclusive(!sendTask.isNotExclusive());
if (StringUtils.isNotEmpty(sendTask.getType())) {
if (sendTask.getType().equalsIgnoreCase("mail")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(sendTask));
} else if (sendTask.getType().equalsIgnoreCase("mule")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
} else if (sendTask.getType().equalsIgnoreCase("camel")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(sendTask, bpmnParse.getBpmnModel()));
}
// for web service
} else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(sendTask.getImplementationType()) && StringUtils.isNotEmpty(sendTask.getOperationRef())) {
if (!bpmnParse.getOperations().containsKey(sendTask.getOperationRef())) {
logger.warn(sendTask.getOperationRef() + " does not exist for sendTask " + sendTask.getId());
} else {
WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(sendTask);
Operation operation = bpmnParse.getOperations().get(sendTask.getOperationRef());
webServiceActivityBehavior.setOperation(operation);
if (sendTask.getIoSpecification() != null) {
IOSpecification ioSpecification = createIOSpecification(bpmnParse, sendTask.getIoSpecification());
webServiceActivityBehavior.setIoSpecification(ioSpecification);
}
for (DataAssociation dataAssociationElement : sendTask.getDataInputAssociations()) {
AbstractDataAssociation dataAssociation = createDataInputAssociation(bpmnParse, dataAssociationElement);
webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
}
for (DataAssociation dataAssociationElement : sendTask.getDataOutputAssociations()) {
AbstractDataAssociation dataAssociation = createDataOutputAssociation(bpmnParse, dataAssociationElement);
webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
}
activity.setActivityBehavior(webServiceActivityBehavior);
}
} else {
logger.warn("One of the attributes 'type' or 'operation' is mandatory on sendTask " + sendTask.getId());
}
}
use of org.activiti.bpmn.model.DataAssociation in project Activiti by Activiti.
the class DataOutputAssociationParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof Activity)) {
return;
}
DataAssociation dataAssociation = new DataAssociation();
BpmnXMLUtil.addXMLLocation(dataAssociation, xtr);
DataAssociationParser.parseDataAssociation(dataAssociation, getElementName(), xtr);
((Activity) parentElement).getDataOutputAssociations().add(dataAssociation);
}
use of org.activiti.bpmn.model.DataAssociation in project Activiti by Activiti.
the class DataInputAssociationParser method parseChildElement.
public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement, BpmnModel model) throws Exception {
if (!(parentElement instanceof Activity)) {
return;
}
DataAssociation dataAssociation = new DataAssociation();
BpmnXMLUtil.addXMLLocation(dataAssociation, xtr);
DataAssociationParser.parseDataAssociation(dataAssociation, getElementName(), xtr);
((Activity) parentElement).getDataInputAssociations().add(dataAssociation);
}
use of org.activiti.bpmn.model.DataAssociation in project Activiti by Activiti.
the class WebServiceActivityBehavior method execute.
public void execute(DelegateExecution execution) {
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(execution.getProcessDefinitionId());
FlowElement flowElement = execution.getCurrentFlowElement();
IOSpecification ioSpecification = null;
String operationRef = null;
List<DataAssociation> dataInputAssociations = null;
List<DataAssociation> dataOutputAssociations = null;
if (flowElement instanceof SendTask) {
SendTask sendTask = (SendTask) flowElement;
ioSpecification = sendTask.getIoSpecification();
operationRef = sendTask.getOperationRef();
dataInputAssociations = sendTask.getDataInputAssociations();
dataOutputAssociations = sendTask.getDataOutputAssociations();
} else if (flowElement instanceof ServiceTask) {
ServiceTask serviceTask = (ServiceTask) flowElement;
ioSpecification = serviceTask.getIoSpecification();
operationRef = serviceTask.getOperationRef();
dataInputAssociations = serviceTask.getDataInputAssociations();
dataOutputAssociations = serviceTask.getDataOutputAssociations();
} else {
throw new ActivitiException("Unsupported flow element type " + flowElement);
}
MessageInstance message = null;
fillDefinitionMaps(bpmnModel);
Operation operation = operationMap.get(operationRef);
try {
if (ioSpecification != null) {
initializeIoSpecification(ioSpecification, execution, bpmnModel);
if (ioSpecification.getDataInputRefs().size() > 0) {
String firstDataInputName = ioSpecification.getDataInputRefs().get(0);
ItemInstance inputItem = (ItemInstance) execution.getVariable(firstDataInputName);
message = new MessageInstance(operation.getInMessage(), inputItem);
}
} else {
message = operation.getInMessage().createInstance();
}
execution.setVariable(CURRENT_MESSAGE, message);
fillMessage(dataInputAssociations, execution);
ProcessEngineConfigurationImpl processEngineConfig = Context.getProcessEngineConfiguration();
MessageInstance receivedMessage = operation.sendMessage(message, processEngineConfig.getWsOverridenEndpointAddresses());
execution.setVariable(CURRENT_MESSAGE, receivedMessage);
if (ioSpecification != null && ioSpecification.getDataOutputRefs().size() > 0) {
String firstDataOutputName = ioSpecification.getDataOutputRefs().get(0);
if (firstDataOutputName != null) {
ItemInstance outputItem = (ItemInstance) execution.getVariable(firstDataOutputName);
outputItem.getStructureInstance().loadFrom(receivedMessage.getStructureInstance().toArray());
}
}
returnMessage(dataOutputAssociations, execution);
execution.setVariable(CURRENT_MESSAGE, null);
leave(execution);
} catch (Exception exc) {
Throwable cause = exc;
BpmnError error = null;
while (cause != null) {
if (cause instanceof BpmnError) {
error = (BpmnError) cause;
break;
}
cause = cause.getCause();
}
if (error != null) {
ErrorPropagation.propagateError(error, execution);
} else if (exc instanceof RuntimeException) {
throw (RuntimeException) exc;
}
}
}
use of org.activiti.bpmn.model.DataAssociation in project Activiti by Activiti.
the class ServiceTaskParseHandler method executeParse.
protected void executeParse(BpmnParse bpmnParse, ServiceTask serviceTask) {
ActivityImpl activity = createActivityOnCurrentScope(bpmnParse, serviceTask, BpmnXMLConstants.ELEMENT_TASK_SERVICE);
activity.setAsync(serviceTask.isAsynchronous());
activity.setFailedJobRetryTimeCycleValue(serviceTask.getFailedJobRetryTimeCycleValue());
activity.setExclusive(!serviceTask.isNotExclusive());
// Email, Mule and Shell service tasks
if (StringUtils.isNotEmpty(serviceTask.getType())) {
if (serviceTask.getType().equalsIgnoreCase("mail")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMailActivityBehavior(serviceTask));
} else if (serviceTask.getType().equalsIgnoreCase("mule")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createMuleActivityBehavior(serviceTask, bpmnParse.getBpmnModel()));
} else if (serviceTask.getType().equalsIgnoreCase("camel")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createCamelActivityBehavior(serviceTask, bpmnParse.getBpmnModel()));
} else if (serviceTask.getType().equalsIgnoreCase("shell")) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createShellActivityBehavior(serviceTask));
} else {
logger.warn("Invalid service task type: '" + serviceTask.getType() + "' " + " for service task " + serviceTask.getId());
}
// activiti:class
} else if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createClassDelegateServiceTask(serviceTask));
// activiti:delegateExpression
} else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskDelegateExpressionActivityBehavior(serviceTask));
// activiti:expression
} else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equalsIgnoreCase(serviceTask.getImplementationType())) {
activity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createServiceTaskExpressionActivityBehavior(serviceTask));
// Webservice
} else if (ImplementationType.IMPLEMENTATION_TYPE_WEBSERVICE.equalsIgnoreCase(serviceTask.getImplementationType()) && StringUtils.isNotEmpty(serviceTask.getOperationRef())) {
if (!bpmnParse.getOperations().containsKey(serviceTask.getOperationRef())) {
logger.warn(serviceTask.getOperationRef() + " does not exist for service task " + serviceTask.getId());
} else {
WebServiceActivityBehavior webServiceActivityBehavior = bpmnParse.getActivityBehaviorFactory().createWebServiceActivityBehavior(serviceTask);
webServiceActivityBehavior.setOperation(bpmnParse.getOperations().get(serviceTask.getOperationRef()));
if (serviceTask.getIoSpecification() != null) {
IOSpecification ioSpecification = createIOSpecification(bpmnParse, serviceTask.getIoSpecification());
webServiceActivityBehavior.setIoSpecification(ioSpecification);
}
for (DataAssociation dataAssociationElement : serviceTask.getDataInputAssociations()) {
AbstractDataAssociation dataAssociation = createDataInputAssociation(bpmnParse, dataAssociationElement);
webServiceActivityBehavior.addDataInputAssociation(dataAssociation);
}
for (DataAssociation dataAssociationElement : serviceTask.getDataOutputAssociations()) {
AbstractDataAssociation dataAssociation = createDataOutputAssociation(bpmnParse, dataAssociationElement);
webServiceActivityBehavior.addDataOutputAssociation(dataAssociation);
}
activity.setActivityBehavior(webServiceActivityBehavior);
}
} else {
logger.warn("One of the attributes 'class', 'delegateExpression', 'type', 'operation', or 'expression' is mandatory on serviceTask " + serviceTask.getId());
}
}
Aggregations