Search in sources :

Example 1 with ProcessDefinitionResponse

use of org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse in project camel by apache.

the class BonitaStartProducer method process.

public void process(Exchange exchange) throws Exception {
    // Setup access type (HTTP on local host)
    String hostname = this.configuration.getHostname();
    String port = this.configuration.getPort();
    String processName = this.configuration.getProcessName();
    String username = this.configuration.getUsername();
    String password = this.configuration.getPassword();
    BonitaAPIConfig bonitaAPIConfig = new BonitaAPIConfig(hostname, port, username, password);
    BonitaAPI bonitaApi = BonitaAPIBuilder.build(bonitaAPIConfig);
    ProcessDefinitionResponse processDefinition = bonitaApi.getProcessDefinition(processName);
    bonitaApi.startCase(processDefinition, exchange.getIn().getBody(Map.class));
}
Also used : ProcessDefinitionResponse(org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse) BonitaAPIConfig(org.apache.camel.component.bonita.api.util.BonitaAPIConfig) BonitaAPI(org.apache.camel.component.bonita.api.BonitaAPI) Map(java.util.Map)

Example 2 with ProcessDefinitionResponse

use of org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse in project camel by apache.

the class BonitaAPI method getProcessDefinition.

public ProcessDefinitionResponse getProcessDefinition(String processName) {
    if (ObjectHelper.isEmpty(processName)) {
        throw new IllegalArgumentException("processName is empty.");
    }
    WebTarget resource = getBaseResource().path("process").queryParam("s", processName);
    List<ProcessDefinitionResponse> listProcess = resource.request().accept(MediaType.APPLICATION_JSON).get(new GenericType<List<ProcessDefinitionResponse>>() {
    });
    if (listProcess.size() > 0) {
        return listProcess.get(0);
    } else {
        throw new RuntimeException("The process with name " + processName + " has not been retrieved");
    }
}
Also used : ProcessDefinitionResponse(org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse) List(java.util.List) WebTarget(javax.ws.rs.client.WebTarget)

Example 3 with ProcessDefinitionResponse

use of org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse in project camel by apache.

the class BonitaAPITest method testStartCaseNUllContractInput.

@Test(expected = IllegalArgumentException.class)
public void testStartCaseNUllContractInput() throws Exception {
    BonitaAPI bonitaApi = BonitaAPIBuilder.build(new BonitaAPIConfig("hostname", "port", "username", "password"));
    ProcessDefinitionResponse processDefinition = new ProcessDefinitionResponse();
    bonitaApi.startCase(processDefinition, null);
}
Also used : ProcessDefinitionResponse(org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse) BonitaAPIConfig(org.apache.camel.component.bonita.api.util.BonitaAPIConfig) Test(org.junit.Test)

Aggregations

ProcessDefinitionResponse (org.apache.camel.component.bonita.api.model.ProcessDefinitionResponse)3 BonitaAPIConfig (org.apache.camel.component.bonita.api.util.BonitaAPIConfig)2 List (java.util.List)1 Map (java.util.Map)1 WebTarget (javax.ws.rs.client.WebTarget)1 BonitaAPI (org.apache.camel.component.bonita.api.BonitaAPI)1 Test (org.junit.Test)1