use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method addComment.
@Override
public String addComment(String containerId, String caseId, String author, String text, List<String> restrictions) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
String queryString = "?author=" + author;
queryString = getAdditionalParams(queryString, "restrictedTo", restrictions);
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_COMMENTS_POST_URI, valuesMap) + queryString, text, String.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "addCommentToCase", serialize(text), marshaller.getFormat().getType(), new Object[] { containerId, caseId, author, safeList(restrictions) })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = deserialize(response.getResult(), Object.class);
}
if (result instanceof Wrapped) {
return (String) ((Wrapped) result).unwrap();
}
return (String) result;
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method updateComment.
@Override
public void updateComment(String containerId, String caseId, String commentId, String author, String text, List<String> restrictions) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
valuesMap.put(CASE_COMMENT_ID, commentId);
String queryString = "?author=" + author;
queryString = getAdditionalParams(queryString, "restrictedTo", restrictions);
makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_COMMENTS_PUT_URI, valuesMap) + queryString, serialize(text), null, new HashMap<String, String>());
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "updateCommentInCase", serialize(text), marshaller.getFormat().getType(), new Object[] { containerId, caseId, commentId, author, safeList(restrictions) })));
ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCaseInstancesByDefinition.
@Override
public List<CaseInstance> getCaseInstancesByDefinition(String containerId, String caseDefinitionId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder, boolean withData) {
CaseInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_DEF_ID, caseDefinitionId);
String queryString = getPagingQueryString("", page, pageSize);
queryString = getAdditionalParams(queryString, "status", status);
queryString = getSortingQueryString(queryString, sort, sortOrder);
queryString = getAdditionalParams(queryString, "withData", Collections.singletonList(withData));
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_INSTANCES_BY_DEF_GET_URI, valuesMap) + queryString, CaseInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstancesByDefinition", new Object[] { containerId, caseDefinitionId, safeList(status), page, pageSize, sort, sortOrder, withData })));
ServiceResponse<CaseInstanceList> response = (ServiceResponse<CaseInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getMilestones.
@Override
public List<CaseMilestone> getMilestones(String containerId, String caseId, boolean achievedOnly, Integer page, Integer pageSize) {
CaseMilestoneList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
String queryString = getPagingQueryString("?achievedOnly=" + achievedOnly, page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_MILESTONES_GET_URI, valuesMap) + queryString, CaseMilestoneList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getMilestones", new Object[] { containerId, caseId, achievedOnly, page, pageSize })));
ServiceResponse<CaseMilestoneList> response = (ServiceResponse<CaseMilestoneList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.DescriptorCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method internalGetCaseInstanceDataItems.
/*
* internal methods
*/
protected List<CaseFileDataItem> internalGetCaseInstanceDataItems(String caseId, List<String> names, List<String> types, Integer page, Integer pageSize) {
CaseFileDataItemList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CASE_ID, caseId);
String queryString = getPagingQueryString("", page, pageSize);
if (names != null && !names.isEmpty()) {
queryString = getAdditionalParams(queryString, "name", names);
} else if (types != null && !types.isEmpty()) {
queryString = getAdditionalParams(queryString, "type", types);
}
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_QUERY_URI + "/" + CASE_FILE_GET_URI, valuesMap) + queryString, CaseFileDataItemList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCaseInstanceDataItems", new Object[] { caseId, safeList(names), safeList(types), page, pageSize })));
ServiceResponse<CaseFileDataItemList> response = (ServiceResponse<CaseFileDataItemList>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null) {
return list.getItems();
}
return Collections.emptyList();
}
Aggregations