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, QueryFilterSpec filterSpec, 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, page, pageSize);
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, filterSpec, resultTypeList);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFiltered", serialize(filterSpec), marshaller.getFormat().getType(), new Object[] { queryName, mapper, 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 Collections.emptyList();
}
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 builder, Map<String, Object> parameters, 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 + "&builder=" + builder, page, pageSize);
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_DEF_URI + "/" + RUN_FILTERED_QUERY_DEF_POST_URI, valuesMap) + queryString, parameters, resultTypeList);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryDataService", "queryFilteredWithBuilder", serialize(safeMap(parameters)), marshaller.getFormat().getType(), new Object[] { queryName, mapper, builder, 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 Collections.emptyList();
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method getTaskOutputContentByTaskId.
@Override
public Map<String, Object> getTaskOutputContentByTaskId(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_OUTPUT_DATA_GET_URI, valuesMap), Object.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getTaskOutputContentByTaskId", 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 addTaskComment.
@Override
public Long addTaskComment(String containerId, Long taskId, String text, String addedBy, Date addedOn) {
Object commentId = null;
TaskComment taskComment = TaskComment.builder().text(text).addedBy(addedBy).addedAt(addedOn).build();
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
commentId = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_COMMENT_ADD_POST_URI, valuesMap), taskComment, Object.class, getHeaders(taskComment));
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "addComment", serialize(taskComment), 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;
}
commentId = deserialize(response.getResult(), Object.class);
}
if (commentId instanceof Wrapped) {
return (Long) ((Wrapped) commentId).unwrap();
}
return ((Number) commentId).longValue();
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskServicesClientImpl method addTaskAttachment.
@Override
public Long addTaskAttachment(String containerId, Long taskId, String userId, String name, Object attachment) {
Object attachmentId = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
attachmentId = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_ATTACHMENT_ADD_POST_URI, valuesMap) + getUserAndAdditionalParam(userId, "name", name), attachment, Object.class, getHeaders(null));
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "addAttachment", serialize(attachment), marshaller.getFormat().getType(), new Object[] { containerId, taskId, userId, name })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
attachmentId = deserialize(response.getResult(), Object.class);
}
if (attachmentId instanceof Wrapped) {
return (Long) ((Wrapped) attachmentId).unwrap();
}
return ((Number) attachmentId).longValue();
}
Aggregations