Initiate a process

I would like to start a process using webservice call. Is it possible in Bonita Soft. Appreciate if anyone can help with some example.

Also is there anyway a Message Event can start a process without depending on any other process. Is there any example of how to do it.

I have seen this video but the message event (Pool 2) is derived from the first pool. 

Here is the video link: https://www.youtube.com/watch?v=Sbi_BrRWBY0

Would be grateful if someone can help with these.

Thanks in Advance

To start a process from a webservice, in my case, i have create one in my own WS API, the code look lioke that:

public ProcessInstance startProcessByName(String processName, Map<String, Serializable> initailContractValue, String initiator, APISession session) {
    ProcessAPI processAPI;
    try {
        IdentityAPI identityAPI = TenantAPIAccessor.getIdentityAPI(session);
        log.info("-- Recherche de l'utilisateur bonita [" + initiator + "]");
        User user = identityAPI.getUserByUserName(initiator);
        log.info("-- lancement du processus bonita [" + processName + "]");

        processAPI = TenantAPIAccessor.getProcessAPI(session);
        ProcessInstance processInstance;
        long processDefinitionId = processAPI.getLatestProcessDefinitionId(processName);
        ProcessDeploymentInfo infos = processAPI.getProcessDeploymentInfo(processDefinitionId);
        log.info("-- process [" + processName + "], processDefinition ID :[" + processDefinitionId + "]");
        if (initailContractValue != null && !initailContractValue.isEmpty()) {
            if (initailContractValue != null) {
                String result = initailContractValue.entrySet().stream()
                        .map(entry -> entry.getKey() + " - " + entry.getValue()).collect(Collectors.joining(", "));
                log.info("-- param du processus :[" + result + "]");
            }
            processInstance = processAPI.startProcessWithInputs(user.getId(), infos.getProcessId(), initailContractValue);
        } else {
            processInstance = processAPI.startProcess(user.getId(), infos.getProcessId());
        }
        log.info("-- lancement du processus bonita [" + processName + "] -- DONE");
        return processInstance;
    } catch (BonitaHomeNotSetException | ServerAPIException | UnknownAPITypeException
            | ProcessDefinitionNotFoundException | ProcessActivationException | ProcessExecutionException
            | UserNotFoundException | ContractViolationException ex) {
        log.error("Impossible de lancer le process avec pour id : " + processName, ex);
    }
    log.info("-- lancement du processus bonita [" + processName + "] -- FAIL");
    return null;
}

Hope it's will help,

Regards,

 

Hi bastien,

Thanks a lot for the code.

I will have a look and let you know how I get on.

Regards

Muhammad

 

So this is what I am trying now but can't move forward due to some error. Any idea what's happening.

I used Maven based project using Bonita 7.10.0

LoginAPI loginAPI  = TenantAPIAccessor.getLoginAPI();        
APISession session = loginAPI.login("walter.bates", "bpm");
ProcessAPI processapi = TenantAPIAccessor.getProcessAPI(session);        

//When the application has finished processing, log out to delete the session:
loginAPI.logout(session);

---------------------------------Here is the error------------------------------------------------

The error is pointing at "TenantAPIAccessor.getLoginAPI(); " 

java.lang.ClassNotFoundException: org.bonitasoft.engine.api.impl.ServerAPIFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.bonitasoft.engine.api.impl.LocalServerAPIFactory.<clinit>(LocalServerAPIFactory.java:34)
    at org.bonitasoft.engine.api.PlatformAPIAccessor.getServerAPI(PlatformAPIAccessor.java:50)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getServerAPI(TenantAPIAccessor.java:41)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getAPI(TenantAPIAccessor.java:61)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getLoginAPI(TenantAPIAccessor.java:67)
    at bonitaSoftTest.Main.main(Main.java:37)
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.bonitasoft.engine.api.impl.LocalServerAPIFactory.<clinit>(LocalServerAPIFactory.java:37)
    at org.bonitasoft.engine.api.PlatformAPIAccessor.getServerAPI(PlatformAPIAccessor.java:50)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getServerAPI(TenantAPIAccessor.java:41)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getAPI(TenantAPIAccessor.java:61)
    at org.bonitasoft.engine.api.TenantAPIAccessor.getLoginAPI(TenantAPIAccessor.java:67)
    at bonitaSoftTest.Main.main(Main.java:37)
Caused by: java.lang.ClassNotFoundException: org.bonitasoft.engine.api.impl.ServerAPIFactory
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at org.bonitasoft.engine.api.impl.LocalServerAPIFactory.<clinit>(LocalServerAPIFactory.java:34)
    ... 5 more