use of org.wso2.carbon.bpmn.rest.common.CorrelationProcess in project carbon-business-process by wso2.
the class CorrelationService method recieveMessage.
@POST
@Path("/")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response recieveMessage(CorrelationActionRequest correlationActionRequest) {
if (correlationActionRequest.getProcessDefinitionId() == null && correlationActionRequest.getProcessDefinitionKey() == null && (correlationActionRequest.getMessageName() == null && correlationActionRequest.getSignalName() == null)) {
throw new ActivitiIllegalArgumentException("Either processDefinitionId, processDefinitionKey, signal or " + "message is required.");
}
int paramsSet = ((correlationActionRequest.getProcessDefinitionId() != null) ? 1 : 0) + ((correlationActionRequest.getProcessDefinitionKey() != null) ? 1 : 0);
if (paramsSet > 1) {
throw new ActivitiIllegalArgumentException("Only one of processDefinitionId or processDefinitionKey should be set.");
}
paramsSet = ((correlationActionRequest.getMessageName() != null) ? 1 : 0) + ((correlationActionRequest.getSignalName() != null) ? 1 : 0);
if (paramsSet > 1) {
throw new ActivitiIllegalArgumentException("Only one of message name or signal should be " + "set.");
}
CorrelationProcess correlationProcess = new CorrelationProcess();
return correlationProcess.getQueryResponse(correlationActionRequest, uriInfo);
}
use of org.wso2.carbon.bpmn.rest.common.CorrelationProcess in project carbon-business-process by wso2.
the class ProcessInstanceService method performCorrelation.
private Response performCorrelation(ProcessInstanceCreateRequest processInstanceCreateRequest) {
CorrelationActionRequest correlationActionRequest = new CorrelationActionRequest();
String requestValue = processInstanceCreateRequest.getProcessDefinitionId();
if (requestValue != null) {
correlationActionRequest.setProcessDefinitionId(processInstanceCreateRequest.getProcessDefinitionId());
}
requestValue = processInstanceCreateRequest.getProcessDefinitionKey();
if (requestValue != null) {
correlationActionRequest.setProcessDefinitionKey(requestValue);
}
if (processInstanceCreateRequest.isCustomTenantSet()) {
correlationActionRequest.setTenantId(processInstanceCreateRequest.getTenantId());
}
requestValue = processInstanceCreateRequest.getMessageName();
if (requestValue != null) {
correlationActionRequest.setMessageName(requestValue);
}
List<RestVariable> variables = processInstanceCreateRequest.getVariables();
if (variables != null) {
RestResponseFactory restResponseFactory = new RestResponseFactory();
List<QueryVariable> correlationVariableList = new ArrayList<>();
for (RestVariable variable : variables) {
QueryVariable correlationVariable = new QueryVariable();
correlationVariable.setName(variable.getName());
correlationVariable.setOperation("equals");
correlationVariable.setType(variable.getType());
correlationVariable.setValue(restResponseFactory.getVariableValue(variable));
correlationVariableList.add(correlationVariable);
}
correlationActionRequest.setCorrelationVariables(correlationVariableList);
}
variables = processInstanceCreateRequest.getAdditionalVariables();
if (variables != null) {
correlationActionRequest.setVariables(variables);
}
correlationActionRequest.setAction(CorrelationActionRequest.ACTION_MESSAGE_EVENT_RECEIVED);
return new CorrelationProcess().getQueryResponse(correlationActionRequest, uriInfo);
}
Aggregations