Search in sources :

Example 81 with CommandScript

use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method disposeContainer.

@Override
public ServiceResponse<Void> disposeContainer(String id) {
    if (config.isRest()) {
        return makeHttpDeleteRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/" + id, Void.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DisposeContainerCommand(id)));
        ServiceResponse<Void> response = (ServiceResponse<Void>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript) DisposeContainerCommand(org.kie.server.api.commands.DisposeContainerCommand)

Example 82 with CommandScript

use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method updateReleaseId.

@Override
public ServiceResponse<ReleaseId> updateReleaseId(String id, ReleaseId releaseId, boolean resetBeforeUpdate) {
    if (config.isRest()) {
        return makeHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/" + id + "/release-id?" + KieServerConstants.RESET_CONTAINER_BEFORE_UPDATE + "=" + resetBeforeUpdate, releaseId, ReleaseId.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList(new UpdateReleaseIdCommand(id, releaseId, resetBeforeUpdate)));
        ServiceResponse<ReleaseId> response = (ServiceResponse<ReleaseId>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : UpdateReleaseIdCommand(org.kie.server.api.commands.UpdateReleaseIdCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript) ReleaseId(org.kie.server.api.model.ReleaseId)

Example 83 with CommandScript

use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method getContainerInfo.

@Override
public ServiceResponse<KieContainerResource> getContainerInfo(String id) {
    if (config.isRest()) {
        return makeHttpGetRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/" + id, KieContainerResource.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new GetContainerInfoCommand(id)));
        ServiceResponse<KieContainerResource> response = (ServiceResponse<KieContainerResource>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript) GetContainerInfoCommand(org.kie.server.api.commands.GetContainerInfoCommand) KieContainerResource(org.kie.server.api.model.KieContainerResource)

Example 84 with CommandScript

use of org.kie.server.api.commands.CommandScript in project droolsjbpm-integration by kiegroup.

the class KieServicesClientImpl method executeCommands.

// for backward compatibility reason
/**
 * This method is deprecated on KieServicesClient as it was moved to RuleServicesClient
 *
 * @see RuleServicesClient#executeCommands(String, String)
 * @deprecated
 */
@Deprecated
@Override
public ServiceResponse<String> executeCommands(String id, String payload) {
    if (config.isRest()) {
        return makeBackwardCompatibleHttpPostRequestAndCreateServiceResponse(loadBalancer.getUrl() + "/containers/instances/" + id, payload, String.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new CallContainerCommand(id, payload)));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, null, null, id).getResponses().get(0);
        return getResponseOrNullIfNoResponse(response);
    }
}
Also used : CallContainerCommand(org.kie.server.api.commands.CallContainerCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) CommandScript(org.kie.server.api.commands.CommandScript)

Example 85 with CommandScript

use of org.kie.server.api.commands.CommandScript 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)

Aggregations

CommandScript (org.kie.server.api.commands.CommandScript)275 ServiceResponse (org.kie.server.api.model.ServiceResponse)269 KieServerCommand (org.kie.server.api.model.KieServerCommand)256 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)232 HashMap (java.util.HashMap)218 Wrapped (org.kie.server.api.model.Wrapped)27 ArrayList (java.util.ArrayList)22 ProcessInstanceList (org.kie.server.api.model.instance.ProcessInstanceList)18 ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)17 TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)16 NodeInstanceList (org.kie.server.api.model.instance.NodeInstanceList)14 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)12 KieContainerResource (org.kie.server.api.model.KieContainerResource)9 ExecutionErrorInstanceList (org.kie.server.api.model.admin.ExecutionErrorInstanceList)8 ProcessDefinitionList (org.kie.server.api.model.definition.ProcessDefinitionList)8 VariableInstanceList (org.kie.server.api.model.instance.VariableInstanceList)8 RequestInfoInstanceList (org.kie.server.api.model.instance.RequestInfoInstanceList)7 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)6 Map (java.util.Map)5 CallContainerCommand (org.kie.server.api.commands.CallContainerCommand)5