use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class BaseRuntimeService method addLocalVariables.
protected void addLocalVariables(Execution execution, int variableType, Map<String, RestVariable> variableMap) {
Map<String, Object> rawLocalvariables = runtimeService.getVariablesLocal(execution.getId());
List<RestVariable> localVariables = new RestResponseFactory().createRestVariables(rawLocalvariables, execution.getId(), variableType, RestVariable.RestVariableScope.LOCAL, uriInfo.getBaseUri().toString());
for (RestVariable var : localVariables) {
variableMap.put(var.getName(), var);
}
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class CorrelationProcess method getVariablesToSet.
protected Map<String, Object> getVariablesToSet(CorrelationActionRequest correlationActionRequest) {
Map<String, Object> variablesToSet = new HashMap<String, Object>();
for (RestVariable var : correlationActionRequest.getVariables()) {
if (var.getName() == null) {
throw new ActivitiIllegalArgumentException("Variable name is required");
}
Object actualVariableValue = new RestResponseFactory().getVariableValue(var);
variablesToSet.put(var.getName(), actualVariableValue);
}
return variablesToSet;
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class CorrelationProcess method addVariables.
protected void addVariables(ExecutionQuery processInstanceQuery, List<QueryVariable> variables, boolean process) {
for (QueryVariable variable : variables) {
if (variable.getVariableOperation() == null) {
throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
}
if (variable.getValue() == null) {
throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
}
boolean nameLess = variable.getName() == null;
Object actualValue = new RestResponseFactory().getVariableValue(variable);
// A value-only query is only possible using equals-operator
if (nameLess && variable.getVariableOperation() != QueryVariable.QueryVariableOperation.EQUALS) {
throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation.");
}
switch(variable.getVariableOperation()) {
case EQUALS:
if (nameLess) {
if (process) {
processInstanceQuery.processVariableValueEquals(actualValue);
} else {
processInstanceQuery.variableValueEquals(actualValue);
}
} else {
if (process) {
processInstanceQuery.processVariableValueEquals(variable.getName(), actualValue);
} else {
processInstanceQuery.variableValueEquals(variable.getName(), actualValue);
}
}
break;
case EQUALS_IGNORE_CASE:
if (actualValue instanceof String) {
if (process) {
processInstanceQuery.processVariableValueEqualsIgnoreCase(variable.getName(), (String) actualValue);
} else {
processInstanceQuery.variableValueEqualsIgnoreCase(variable.getName(), (String) actualValue);
}
} else {
throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
}
break;
case NOT_EQUALS:
if (process) {
processInstanceQuery.processVariableValueNotEquals(variable.getName(), actualValue);
} else {
processInstanceQuery.variableValueNotEquals(variable.getName(), actualValue);
}
break;
case NOT_EQUALS_IGNORE_CASE:
if (actualValue instanceof String) {
if (process) {
processInstanceQuery.processVariableValueNotEqualsIgnoreCase(variable.getName(), (String) actualValue);
} else {
processInstanceQuery.variableValueNotEqualsIgnoreCase(variable.getName(), (String) actualValue);
}
} else {
throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
}
break;
default:
throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
}
}
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class BaseExecutionService method getVariablesToSet.
protected Map<String, Object> getVariablesToSet(ExecutionActionRequest actionRequest) {
Map<String, Object> variablesToSet = new HashMap<String, Object>();
for (RestVariable var : actionRequest.getVariables()) {
if (var.getName() == null) {
throw new ActivitiIllegalArgumentException("Variable name is required");
}
Object actualVariableValue = new RestResponseFactory().getVariableValue(var);
variablesToSet.put(var.getName(), actualVariableValue);
}
return variablesToSet;
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class BaseExecutionService method setSimpleVariable.
protected RestVariable setSimpleVariable(RestVariable restVariable, Execution execution, boolean isNew, UriInfo uriInfo) {
if (restVariable.getName() == null) {
throw new ActivitiIllegalArgumentException("Variable name is required");
}
// Figure out scope, revert to local is omitted
RestVariable.RestVariableScope scope = restVariable.getVariableScope();
if (scope == null) {
scope = RestVariable.RestVariableScope.LOCAL;
}
Object actualVariableValue = new RestResponseFactory().getVariableValue(restVariable);
setVariable(execution, restVariable.getName(), actualVariableValue, scope, isNew);
return constructRestVariable(restVariable.getName(), restVariable.getValue(), scope, execution.getId(), false, uriInfo);
}
Aggregations