use of org.kie.server.api.model.KieServerCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCaseInstance.
@Override
public CaseInstance getCaseInstance(String containerId, String caseId, boolean withData, boolean withRoles, boolean withMilestones, boolean withStages) {
CaseInstance caseInstance = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
String queryString = "?withData=" + withData + "&withRoles=" + withRoles + "&withMilestones=" + withMilestones + "&withStages=" + withStages;
caseInstance = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_INSTANCE_GET_URI, valuesMap) + queryString, CaseInstance.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "getCaseInstance", marshaller.getFormat().getType(), new Object[] { containerId, caseId, withData, withRoles, withMilestones, withStages })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
caseInstance = deserialize(response.getResult(), CaseInstance.class);
}
return caseInstance;
}
use of org.kie.server.api.model.KieServerCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method putCaseInstanceData.
@Override
public void putCaseInstanceData(String containerId, String caseId, String name, Object data, 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_FILE_ITEM, name);
String queryString = getAdditionalParams("", "restrictedTo", restrictions);
makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_FILE_BY_NAME_POST_URI, valuesMap) + queryString, data, null);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "putCaseFileDataByName", serialize(data), marshaller.getFormat().getType(), new Object[] { containerId, caseId, name, safeList(restrictions) })));
ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
use of org.kie.server.api.model.KieServerCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method internalAddDynamicTask.
protected void internalAddDynamicTask(String containerId, String caseId, String stageId, Map<String, Object> taskSpecMap) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
if (stageId != null) {
valuesMap.put(CASE_STAGE_ID, stageId);
makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_IN_STAGE_POST_URI, valuesMap), taskSpecMap, null);
} else {
makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_DYNAMIC_TASK_POST_URI, valuesMap), taskSpecMap, null);
}
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "addDynamicTask", serialize(taskSpecMap), marshaller.getFormat().getType(), new Object[] { containerId, caseId, emptyIfNull(stageId) })));
ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
use of org.kie.server.api.model.KieServerCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method getCompletedNodes.
@Override
public List<NodeInstance> getCompletedNodes(String containerId, String caseId, Integer page, Integer pageSize) {
NodeInstanceList 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("?completed=true", page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_NODE_INSTANCES_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseQueryService", "getCompletedNodes", new Object[] { containerId, caseId, page, pageSize })));
ServiceResponse<NodeInstanceList> response = (ServiceResponse<NodeInstanceList>) 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.model.KieServerCommand in project droolsjbpm-integration by kiegroup.
the class CaseServicesClientImpl method internalAddRoleAssignment.
protected void internalAddRoleAssignment(String containerId, String caseId, String roleName, String user, String group) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(CASE_ID, caseId);
valuesMap.put(CASE_ROLE_NAME, roleName);
String queryString = "?user=" + emptyIfNull(user) + "&group=" + emptyIfNull(group);
makeHttpPutRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), CASE_URI + "/" + CASE_ROLES_PUT_URI, valuesMap) + queryString, null, null, new HashMap<String, String>());
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("CaseService", "assignToRole", new Object[] { containerId, caseId, roleName, emptyIfNull(user), emptyIfNull(group) })));
ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_CASE).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
Aggregations