use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method getWorkItemByProcessInstance.
@Override
public List<WorkItemInstance> getWorkItemByProcessInstance(String containerId, Long processInstanceId) {
WorkItemInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_WORK_ITEMS_BY_PROC_INST_ID_GET_URI, valuesMap), WorkItemInstanceList.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("ProcessService", "getWorkItemByProcessInstance", marshaller.getFormat().getType(), new Object[] { containerId, processInstanceId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = deserialize(response.getResult(), WorkItemInstanceList.class);
}
if (list != null && list.getWorkItems() != null) {
return Arrays.asList(list.getWorkItems());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method signal.
@Override
public void signal(String containerId, String signalName, Object event) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(SIGNAL_NAME, signalName);
Map<String, String> headers = new HashMap<String, String>();
makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + SIGNAL_PROCESS_INSTANCES_PORT_URI, valuesMap), event, String.class, headers);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("ProcessService", "signal", serialize(event), marshaller.getFormat().getType(), new Object[] { containerId, signalName })));
ServiceResponse<?> response = (ServiceResponse<?>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
}
}
use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method getProcessInstance.
@Override
public ProcessInstance getProcessInstance(String containerId, Long processInstanceId) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
return makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_GET_URI, valuesMap), ProcessInstance.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("ProcessService", "getProcessInstance", marshaller.getFormat().getType(), new Object[] { containerId, processInstanceId, false })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
return deserialize(response.getResult(), ProcessInstance.class);
}
}
use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method findNodeInstancesByType.
@Override
public List<NodeInstance> findNodeInstancesByType(String containerId, Long processInstanceId, String entryType, Integer page, Integer pageSize) {
NodeInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
String queryString = getPagingQueryString("?" + RestURI.PROCESS_INST_HISTORY_TYPE + "=" + entryType, page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCES_NODE_INSTANCES_GET_URI, valuesMap) + queryString, NodeInstanceList.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getProcessInstanceFullHistoryByType", processInstanceId, entryType, page, pageSize)));
ServiceResponse<NodeInstanceList> response = (ServiceResponse<NodeInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getNodeInstances() != null) {
return Arrays.asList(result.getNodeInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.ServiceResponse in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method getAssociatedEntityDefinitions.
@Override
public AssociatedEntitiesDefinition getAssociatedEntityDefinitions(String containerId, String processId) {
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_ID, processId);
return makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_DEF_URI + "/" + PROCESS_DEF_ASSOCIATED_ENTITIES_GET_URI, valuesMap), AssociatedEntitiesDefinition.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("DefinitionService", "getAssociatedEntities", new Object[] { containerId, processId })));
ServiceResponse<AssociatedEntitiesDefinition> response = (ServiceResponse<AssociatedEntitiesDefinition>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
return response.getResult();
}
}
Aggregations