use of org.kie.server.api.model.Wrapped 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();
}
use of org.kie.server.api.model.Wrapped 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.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class DMNServicesClientImpl method evaluateDecisions.
/**
* Please notice this method is NOT exposed to the API interface.
*/
// DO NOT ADD @Override
public ServiceResponse<DMNResult> evaluateDecisions(String containerId, DMNContextKS payload) {
ServiceResponse<DMNResult> result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
result = (ServiceResponse<DMNResult>) (ServiceResponse<?>) makeHttpPostRequestAndCreateServiceResponse(build(loadBalancer.getUrl(), DMN_URI, valuesMap), payload, DMNResultKS.class);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("DMNService", "evaluateDecisions", serialize(payload), marshaller.getFormat().getType(), new Object[] { containerId })));
result = (ServiceResponse<DMNResult>) executeJmsCommand(script, DescriptorCommand.class.getName(), KieServerConstants.CAPABILITY_DMN, containerId).getResponses().get(0);
throwExceptionOnFailure(result);
if (shouldReturnWithNullResponse(result)) {
return null;
}
}
if (result instanceof Wrapped) {
return (ServiceResponse<DMNResult>) ((Wrapped) result).unwrap();
}
ServiceResponse<DMNResult> result2 = (ServiceResponse<DMNResult>) result;
// to manage scalar values when deserializing from JSON always as a BigDecimal instead of default Jackson NumberDeserializers
if (config.getMarshallingFormat() == MarshallingFormat.JSON) {
recurseAndModifyByCoercingNumbers(result2.getResult().getContext());
for (DMNDecisionResult dr : result2.getResult().getDecisionResults()) {
DMNDecisionResultKS drKS = (DMNDecisionResultKS) dr;
drKS.setResult(recurseAndModifyByCoercingNumbers(dr.getResult()));
}
}
return result2;
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminServicesClientImpl method notifyWhenNotStarted.
@Override
public Long notifyWhenNotStarted(String containerId, Long taskId, String expiresAt, EmailNotification emailNotification) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
Map<String, String> headers = new HashMap<String, String>();
String queryString = "?expiresAt=" + expiresAt + "&whenNotStarted=true";
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_NOTIFICATIONS_URI, valuesMap) + queryString, emailNotification, Object.class, headers);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskAdminService", "notifyWhenNotStarted", serialize(emailNotification), marshaller.getFormat().getType(), new Object[] { containerId, taskId, expiresAt })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).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();
}
use of org.kie.server.api.model.Wrapped in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminServicesClientImpl method notifyWhenNotCompleted.
@Override
public Long notifyWhenNotCompleted(String containerId, Long taskId, String expiresAt, EmailNotification emailNotification) {
Object result = null;
if (config.isRest()) {
Map<String, Object> valuesMap = new HashMap<String, Object>();
valuesMap.put(CONTAINER_ID, containerId);
valuesMap.put(TASK_INSTANCE_ID, taskId);
Map<String, String> headers = new HashMap<String, String>();
String queryString = "?expiresAt=" + expiresAt + "&whenNotCompleted=true";
result = makeHttpPostRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_NOTIFICATIONS_URI, valuesMap) + queryString, emailNotification, Object.class, headers);
} else {
CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskAdminService", "notifyWhenNotCompleted", serialize(emailNotification), marshaller.getFormat().getType(), new Object[] { containerId, taskId, expiresAt })));
ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).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