use of org.kie.server.api.model.instance.VariableInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessServiceRestOnlyIntegrationTest method testProcessVariablesWhichBelongsToAContainer.
@Test
public void testProcessVariablesWhichBelongsToAContainer() {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
valuesMap.put(RestURI.PROCESS_ID, PROCESS_ID_USERTASK);
Response response = null;
try {
// start process instance
WebTarget clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + START_PROCESS_POST_URI, valuesMap));
logger.debug("[POST] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).post(createEntity(""));
assertThat(response.getStatus()).isEqualTo(Response.Status.CREATED.getStatusCode());
Long pid = response.readEntity(JaxbLong.class).unwrap();
assertThat(pid).isNotNull();
response.close();
// find process instance variables which belong to a process in a deployed container
valuesMap.clear();
valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
valuesMap.put(PROCESS_INST_ID, pid);
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_VAR_INSTANCES_GET_URI, valuesMap));
logger.debug("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
Marshaller marshaller = MarshallerFactory.getMarshaller(marshallingFormat, Thread.currentThread().getContextClassLoader());
VariableInstanceList variableInstanceList = marshaller.unmarshall(response.readEntity(String.class), VariableInstanceList.class);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(variableInstanceList.getItems()).hasSize(1);
response.close();
// find process instance variables of non-existing process instance
valuesMap.clear();
valuesMap.put(RestURI.CONTAINER_ID, CONTAINER_ID);
valuesMap.put(PROCESS_INST_ID, "-1");
clientRequest = newRequest(build(TestConfig.getKieServerHttpUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_VAR_INSTANCES_GET_URI, valuesMap));
logger.debug("[GET] " + clientRequest.getUri());
response = clientRequest.request(getMediaType()).get();
variableInstanceList = marshaller.unmarshall(response.readEntity(String.class), VariableInstanceList.class);
assertThat(response.getStatus()).isEqualTo(Response.Status.OK.getStatusCode());
assertThat(variableInstanceList.getItems()).isEmpty();
} finally {
if (response != null) {
response.close();
}
}
}
use of org.kie.server.api.model.instance.VariableInstanceList in project droolsjbpm-integration by kiegroup.
the class QueryServicesClientImpl method findVariableHistory.
@Override
public List<VariableInstance> findVariableHistory(Long processInstanceId, String variableName, Integer page, Integer pageSize) {
VariableInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(PROCESS_INST_ID, processInstanceId);
valuesMap.put(VAR_NAME, variableName);
String queryString = getPagingQueryString("", page, pageSize);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), QUERY_URI + "/" + VAR_INSTANCES_BY_VAR_INSTANCE_ID_GET_URI, valuesMap) + queryString, VariableInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getVariableHistory", new Object[] { processInstanceId, variableName, page, pageSize })));
ServiceResponse<VariableInstanceList> response = (ServiceResponse<VariableInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getVariableInstances() != null) {
return Arrays.asList(result.getVariableInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.model.instance.VariableInstanceList in project droolsjbpm-integration by kiegroup.
the class ProcessServicesClientImpl method findVariablesCurrentState.
@Override
public List<VariableInstance> findVariablesCurrentState(String containerId, Long processInstanceId) {
VariableInstanceList result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(PROCESS_INST_ID, processInstanceId);
result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), PROCESS_URI + "/" + PROCESS_INSTANCE_VAR_INSTANCES_GET_URI, valuesMap), VariableInstanceList.class);
} else {
CommandScript script = new CommandScript(singletonList((KieServerCommand) new DescriptorCommand("QueryService", "getVariablesCurrentState", new Object[] { processInstanceId })));
ServiceResponse<VariableInstanceList> response = (ServiceResponse<VariableInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = response.getResult();
}
if (result != null && result.getVariableInstances() != null) {
return Arrays.asList(result.getVariableInstances());
}
return Collections.emptyList();
}
Aggregations