use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method getProcessInstanceVariable.
@Override
public <T> T getProcessInstanceVariable(String containerId, Long processInstanceId, String variableName, Class<T> type) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
valuesMap.put(VAR_NAME, variableName);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_VAR_GET_URI, valuesMap), type);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("ProcessService", "getProcessInstanceVariable", marshaller.getFormat().getType(), new Object[] { containerId, processInstanceId, variableName })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = deserialize(response.getResult(), type);
}
if (result instanceof Wrapped) {
return (T) ((Wrapped) result).unwrap();
}
return (T) result;
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method query.
@Override
public <T> List<T> query(String queryName, String mapper, String orderBy, Integer page, Integer pageSize, Class<T> resultType) {
Object result = null;
Class<?> resultTypeList = getResultTypeList(resultType);
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(QUERY_NAME, queryName);
String queryString = getPagingQueryString("?mapper=" + mapper + "&orderBy=" + orderBy, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_QUERY_DEF_GET_URI, valuesMap) + queryString, resultTypeList);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "query", new Object[] { queryName, mapper, orderBy, page, pageSize })));
ServiceResponse<Object> response = (ServiceResponse<Object>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null) {
if (result instanceof ItemList) {
return ((ItemList<T>) result).getItems();
} else if (result instanceof List) {
return (List) result;
} else if (result instanceof Wrapped) {
return (List) ((Wrapped) result).unwrap();
}
}
return null;
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method saveTaskContent.
@Override
public Long saveTaskContent(String containerId, Long taskId, String userId, Map<String, Object> values) {
Object contentId = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
contentId = makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_OUTPUT_DATA_PUT_URI, valuesMap) + getUserQueryStr(userId), values, Object.class, getHeaders(null));
} else {
Object[] params = null;
if (userId != null) {
params = new Object[] { containerId, userId, taskId };
} else {
params = new Object[] { containerId, taskId };
}
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "saveContent", serialize(values), marshaller.getFormat().getType(), params)));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
contentId = deserialize(response.getResult(), Object.class);
}
if (contentId instanceof Wrapped) {
return (Long) ((Wrapped) contentId).unwrap();
}
return ((Number) contentId).longValue();
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method getTaskInputContentByTaskId.
@Override
public Map<String, Object> getTaskInputContentByTaskId(String containerId, Long taskId) {
Object variables = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
variables = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_INPUT_DATA_GET_URI, valuesMap), Object.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getTaskInputContentByTaskId", marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
variables = deserialize(response.getResult(), Object.class);
}
if (variables instanceof Wrapped) {
return (Map) ((Wrapped) variables).unwrap();
}
return (Map) variables;
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method getTaskAttachmentContentById.
@Override
public Object getTaskAttachmentContentById(String containerId, Long taskId, Long attachmentId) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
valuesMap.put(ATTACHMENT_ID, attachmentId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_ATTACHMENT_CONTENT_GET_URI, valuesMap), Object.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getAttachmentContentById", marshaller.getFormat().getType(), new Object[] { containerId, taskId, attachmentId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = deserialize(response.getResult(), Object.class);
}
if (result instanceof Wrapped) {
return ((Wrapped) result).unwrap();
}
return result;
}
Aggregations