Is there a possibility to start a Xpert.ivy process from a Java bean in my ivy project? Either by calling a request start or a sub process...

Something like:

String signature = "myProcess()";
Set<IProcessStart> processes = ivy.wf.findProcessStartsBySignature(signature);
if(!processes.isEmpty()){
    IProcessStart process = processes.iterator().next();
    IProcessRequest request = RequestFactory.createProcessRequest(
        ivy.request.getProcessModelVersion(), process.getRequestPath(), 
        new HashMap<String, Object>()
    );
    try{
        // somehow send the request...
    }catch(Exception e){
        // do some exception handling if process fails...
    }
}

The main purpose is to be able to catch exceptions which may be thrown from the process.

asked 06.12.2013 at 14:38

Lars%20Tuchel's gravatar image

Lars Tuchel
(suspended)
accept rate: 60%


Since Axon.ivy 4.3 you can start sub processes like this:

ISubProcessStart object;
if (className != null) {
    object = getSubProcess(className);
    if (object == null) {
        setProcessDataField(context, STATUS_MESSAGE_PROPERTY, StatusMessage.MESSAGE_TYPE_ERROR);
        return in;
    }
    results= SubProcessRunner.exec(object, param);
}



private ISubProcessStart getSubProcess(String className){

    //Create filter.
    SubProcessSearchFilter filter = SubProcessSearchFilter.create()
            .setProcessPathPattern(className) 
            .toFilter();

    //Result list of processes. picking first only.

    List<ISubProcessStart> foundSubProcesses = SubProcessRunner.findSubProcessStarts(filter);
    if (foundSubProcesses.isEmpty()) {
        return null;
    }
    return foundSubProcesses.get(0);
}

You need to handle the exceptions within the subprocesses. You can't handle it to the parent class.

link

answered 06.12.2013 at 14:41

Daniel%20Oechslin's gravatar image

Daniel Oechslin
(suspended)
accept rate: 39%

edited 03.03.2017 at 09:44

SupportIvyTeam's gravatar image

SupportIvyTeam ♦♦
1.4k102118122

SubProcessRunner.exec(object, param) throws an error (null pointer ex) if it is run from ManagedBean. If i run it from BussinessProcess it is OK.

Is this 'by design' ?

(11.05.2017 at 08:09) Stelt0 Stelt0's gravatar image

Try the new API above: SubProcessCall.... Does it work better?

(11.05.2017 at 08:13) SupportIvyTeam ♦♦ SupportIvyTeam's gravatar image

I really want, but I`m on version 6.0

Do I have alternative ?

(11.05.2017 at 08:25) Stelt0 Stelt0's gravatar image

You can invoke methods from the HD logic by using the EL expression factory. Within the called method you could run the sub proces...

package test;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.MethodExpression;
import javax.el.MethodInfo;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;

@ManagedBean
public class MyBean {

    public void doIt()
    {
        FacesContext context = FacesContext.getCurrentInstance();
        ExpressionFactory elFactory = context.getApplication().getExpressionFactory();
        ELContext elContext = context.getELContext();
        MethodExpression methodExpression = elFactory
                .createMethodExpression(elContext, "#{logic.fromBean2()}", String.class, new Class[0]);
        MethodInfo info = methodExpression.getMethodInfo(elContext);
        methodExpression.invoke(elContext, new Object[0]);
    }

}
(12.05.2017 at 04:18) SupportIvyTeam ♦♦ SupportIvyTeam's gravatar image

Alternative (with System Events)

I do not like the search of the correct process.
To jump from plain Java in a Ivy process, I recommend an alternative way with System Events.

You have to change your process a little. Add a "event start" element instead the normal "request start" element. Or you can put it also next to the process start.

Write your one event bean like this:

public class SystemEventSubscriber extends AbstractProcessStartEventBean {...

Or you could use the example from ivyhacker

The java code to jump in the process looks nicer:

IApplication app = Ivy.wf().getApplication();
SystemEvent<E> event = 
  new SystemEvent<E>(SystemEventCategory.THIRD_PARTY, [identifier-string], [object of type E]);
app.sendSystemEvent(event);

Like this, you are able to jump to any start event with an identifier string, and you could hand out a parameter as an object type of your choice. For further information read this entry ivyhacker.

Conclusion:

  • (-) Small process changes
  • (+) Posibility to jump to any process step (activity)
link

answered 28.07.2014 at 13:54

Adrian%20Imfeld's gravatar image

Adrian Imfeld
(suspended)
accept rate: 77%

edited 28.07.2014 at 13:57

But you can't add parameters to the call.

(06.08.2014 at 12:18) HaraldWeber HaraldWeber's gravatar image

Yes, you can. But it is just one parameter object of class E. This could also be a parameter-list-object, a JSON string or a ivy dataclass. (Be careful about ivy dataclasses, they are not compatible by diffrent ProcessModelVersions PMV.)

(07.08.2014 at 09:15) Adrian Imfeld Adrian%20Imfeld's gravatar image

Calling a Sub-Process from plain Java has become much simpler since Axon.ivy 6.3. There is now a nice fluent API to invoke a process and get back the the resulting data. The entry point is here: ch.ivyteam.ivy.process.call.SubProcessCall

You can find an example in the ConnectivityDemos where a Java REST-Service implementation starts a Process in the engine. See ConnectivityDemos -> com.axonivy.connectivity.rest.provider.ApprovalService.create(String, String, String)

ITask task = SubProcessCall.withPath("rest/createApproval")
                .withParam("title", title)
                .withParam("description", description)
                .call()
                .get("approvalTask", ITask.class);
link

answered 03.03.2017 at 09:42

Reguel%20Wermelinger's gravatar image

Reguel Werme... ♦♦
9.4k31958
accept rate: 70%

edited 30.08.2021 at 08:21

Christian%20Strebel's gravatar image

Christian St... ♦
3.2k31338

Hello, is that possible to call a sub process which call another html dialog inside. E.g

SubProcessCall.withPath("Functional Processes/callAnotherDialog").call();

I tried it and got exception with number 1 ClassCastException: java.lang.Object cannot be cast to ch.ivyteam.ivy.scripting.objects.util.IIvyDataObject. Number 2 solution work well alt text

link

answered 18.06.2018 at 00:35

hungnam's gravatar image

hungnam
(suspended)
accept rate: 0%

edited 18.06.2018 at 00:44

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×52

Asked: 06.12.2013 at 14:38

Seen: 10,581 times

Last updated: 30.08.2021 at 08:21