use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByCommand.
@Override
public List<RequestInfoInstance> getRequestsByCommand(String command, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(JOB_CMD_NAME, command);
String queryString = getPagingQueryString("", page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_CMD_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByCommand", new Object[] { command, page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByCommand.
@Override
public List<RequestInfoInstance> getRequestsByCommand(String command, List<String> statuses, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(JOB_CMD_NAME, command);
String statusQuery = getAdditionalParams("", "status", statuses);
String queryString = getPagingQueryString(statusQuery, page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_CMD_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByCommand", new Object[] { command, safeList(statuses), page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByContainer.
@Override
public List<RequestInfoInstance> getRequestsByContainer(String containerId, List<String> statuses, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
String statusQuery = getAdditionalParams("", "status", statuses);
String queryString = getPagingQueryString(statusQuery, page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_CONTAINER_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByContainer", new Object[] { containerId, safeList(statuses), page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method getRequestsByBusinessKey.
@Override
public List<RequestInfoInstance> getRequestsByBusinessKey(String businessKey, Integer page, Integer pageSize) {
RequestInfoInstanceList list = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(JOB_KEY, businessKey);
String queryString = getPagingQueryString("", page, pageSize);
list = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI + "/" + JOB_INSTANCES_BY_KEY_GET_URI, valuesMap) + queryString, RequestInfoInstanceList.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "getRequestsByBusinessKey", new Object[] { businessKey, page, pageSize })));
ServiceResponse<RequestInfoInstanceList> response = (ServiceResponse<RequestInfoInstanceList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
list = response.getResult();
}
if (list != null && list.getRequestInfoInstances() != null) {
return Arrays.asList(list.getRequestInfoInstances());
}
return Collections.emptyList();
}
use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.
the class JobServicesClientImpl method scheduleRequest.
@Override
public Long scheduleRequest(String containerId, JobRequestInstance jobRequest) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
String queryString = "";
if (containerId != null && !containerId.isEmpty()) {
queryString = "?containerId=" + containerId;
}
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), JOB_URI, valuesMap) + queryString, jobRequest, Object.class);
} else {
if (containerId == null) {
containerId = "";
}
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("JobService", "scheduleRequest", serialize(jobRequest), marshaller.getFormat().getType(), new Object[] { containerId })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
throwExceptionOnFailure(response);
if (shouldReturnWithNullResponse(response)) {
return null;
}
result = deserialize(response.getResult(), Object.class);
}
if (result instanceof Wrapped) {
return (Long) ((Wrapped) result).unwrap();
}
return ((Number) result).longValue();
}
Aggregations