Search in sources :

Example 11 with Wrapped

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();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) Wrapped(org.kie.server.api.model.Wrapped) CommandScript(org.kie.server.api.commands.CommandScript)

Example 12 with Wrapped

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;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) Wrapped(org.kie.server.api.model.Wrapped) CommandScript(org.kie.server.api.commands.CommandScript)

Example 13 with Wrapped

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;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) DMNResult(org.kie.dmn.api.core.DMNResult) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) DMNResultKS(org.kie.server.api.model.dmn.DMNResultKS) DMNDecisionResultKS(org.kie.server.api.model.dmn.DMNDecisionResultKS) ServiceResponse(org.kie.server.api.model.ServiceResponse) Wrapped(org.kie.server.api.model.Wrapped) DMNDecisionResult(org.kie.dmn.api.core.DMNDecisionResult)

Example 14 with Wrapped

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();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ServiceResponse(org.kie.server.api.model.ServiceResponse) Wrapped(org.kie.server.api.model.Wrapped)

Example 15 with Wrapped

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();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript) ServiceResponse(org.kie.server.api.model.ServiceResponse) Wrapped(org.kie.server.api.model.Wrapped)

Aggregations

Wrapped (org.kie.server.api.model.Wrapped)36 ServiceResponse (org.kie.server.api.model.ServiceResponse)32 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)31 KieServerCommand (org.kie.server.api.model.KieServerCommand)31 HashMap (java.util.HashMap)27 CommandScript (org.kie.server.api.commands.CommandScript)27 ArrayList (java.util.ArrayList)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)5 List (java.util.List)4 Map (java.util.Map)4 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)4 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)4 VariableInstanceList (org.kie.server.api.model.instance.VariableInstanceList)4 Marshaller (org.kie.server.api.marshalling.Marshaller)3 MarshallingFormat (org.kie.server.api.marshalling.MarshallingFormat)3 ItemList (org.kie.server.api.model.ItemList)3 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)3 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)3 QueryDefinitionList (org.kie.server.api.model.definition.QueryDefinitionList)3