This discussion is archived
3 Replies Latest reply: Jul 24, 2013 6:56 AM by 1005285 RSS

API call to alter the flow (11g)

JaseerAbubakar Newbie
Currently Being Moderated
I am doing a POC to figure out if i can alter the flow of a bpm process instance programmatically using the API. I found the API methods to alter a flow by calling setTargetActivity(IActivityInfo targetActivity) on the IFlowChangeItem

However, mostly when we alter the flow, we will also need to set the data object values manually to reflect the instance state that would have been if the instance was in that state. But after sifting through the API methods here http://docs.oracle.com/cd/E23943_01/apirefs.1111/e25378/toc.htm , I couldn't find anything to do this.

Could anyone please help me with any pointers to do this ? [Googling didn't help]

thanks,
Jaseer
  • 1. Re: API call to alter the flow (11g)
    BillWallen Explorer
    Currently Being Moderated
    Download the example from http://java.net/projects/oraclebpmsuite11g/downloads/directory/Samples/bpm-api-101-instance-query

    oracle.bpm.sample.query.ProcessQueryExamples will show you how to find your instance.

    oracle.bpm.sample.instance.InitiateCreditIncreaseRequest shows how to manipulate payload data once you have a handle on the task.
  • 2. Re: API call to alter the flow (11g)
    810583 Newbie
    Currently Being Moderated
    I was doing the same POC, I used queryTask to get a instance but when I tried to use grab it returns an error. I didn't find examples or documentation about how to use the API to implement this feature.

    My code is:

    cf = ProcessUtils.getServiceClientFactory(CLIENT_CONFIG);

    ProcessUtils processUtils = new ProcessUtils(cf);


    try {
    ctx =
    (IBPMContext)processUtils.getHwfServiceClient().getTaskQueryService().authenticate(null,
    null,
    null);
    } catch (WorkflowException e) {
    }
    IBPMServiceClient bPMServiceClient = cf.getBPMServiceClient();
    IInstanceManagementService instManSer = bPMServiceClient.getInstanceManagementService();

    GrabInstanceRequest grab = new GrabInstanceRequest();
    //id and name for acitivities in bpmn file
    IFlowChangeItem change = FlowChangeItem.create(ActivityInfo.create("ABSTRACT_ACTIVITY3688569746588", "Cadastrar Briefing"), ActivityInfo.create("ABSTRACT_ACTIVITY3690017028690","Validar Briefing"));

    IProcessInstance instance = null;
    IInstanceQueryService query = bPMServiceClient.getInstanceQueryService();

    try {
    instance = query.getProcessInstance(ctx, "760001");
    } catch (BPMException e) {
    e.printStackTrace();
    }

    grab.setProcessInstance(instance);

    change.setTargetActivity(ActivityInfo.create("ABSTRACT_ACTIVITY3690017028690","Validar Briefing"));
    IGrabInstanceRequest igrab = grab;

    ArrayList<IFlowChangeItem> list = new ArrayList<IFlowChangeItem>();
    list.add(change);
    igrab.setRequestedFlowChanges(list);

    try {
    instManSer.grabInstance(ctx, igrab);
    } catch (BPMException e) {
    e.printStackTrace();
    }

    The error is:

    Exception in thread "main" java.lang.ClassCastException: cannot assign instance of oracle.bpm.services.instancemanagement.model.impl.alterflow.ActivityInfo to field oracle.bpm.services.instancemanagement.model.impl.alterflow.FlowChangeItem.sourceActivity of type oracle.bpm.services.instancemanagement.model.IOpenActivityInfo in instance of oracle.bpm.services.instancemanagement.model.impl.alterflow.FlowChangeItem
         at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl_1036_WLStub.grabInstance(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
         at $Proxy15.grabInstance(Unknown Source)
         at br.com.grupomult.bpm11g.services.grab.Grab.<init>(Grab.java:98)
         at br.com.grupomult.bpm11g.services.grab.Grab.main(Grab.java:50)
    Caused by: java.lang.ClassCastException: cannot assign instance of oracle.bpm.services.instancemanagement.model.impl.alterflow.ActivityInfo to field oracle.bpm.services.instancemanagement.model.impl.alterflow.FlowChangeItem.sourceActivity of type oracle.bpm.services.instancemanagement.model.IOpenActivityInfo in instance of oracle.bpm.services.instancemanagement.model.impl.alterflow.FlowChangeItem
         at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:2039)
         at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1212)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1952)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
         at java.util.ArrayList.readObject(ArrayList.java:593)
         at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1848)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
         at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:599)
         at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:204)
         at oracle.bpm.services.instancemanagement.ejb.InstanceManagementServiceBean_sqa2w0_IInstanceManagementServiceRemoteImpl_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:668)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)


    I can't even find the IOpenActivityInfo in the path mentioned.

    Anyone can help?
    Jaseer, can you send your code?

    Thanks.
  • 3. Re: API call to alter the flow (11g)
    1005285 Newbie
    Currently Being Moderated

    i also have a similar requirement , where you able to implement it ?

     

    InitiateCreditIncreaseRequest is meant for moving to next activity by completing the user task. What i am looking for is the ability to move any activity within the given process.


    I am using   IGrabMultipleInstancesRequest request = new GrabMultipleInstancesRequest(); to grab instances.


    I see the project variable is getting updated for the selected instance , but the instance is not moving to target activity. Below message is what display in the console.


    Weblogic Console message:

    =====================

    >>>>VARIABLE UPDATE->com.collaxa.cube.engine.core.CubeInstanceImpl@62e37f5a ;

    [oldValue-><address_PC xmlns:def="http://www.w3.org/2001/XMLSchema" ns0:type="def:string" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance">address32</address_PC>,newValue-><address_PC xmlns:def="http://www.w3.org/2001/XMLSchema" ns0:type="def:string" xmlns:ns0="http://www.w3.org/2001/XMLSchema-instance">Modified by me</address_PC>] ;

    null

     

    Java Console ExceptionMessage from response:

    =================================

    "Internal error while grabbing."


    Any idea what could be the issue ?

     

    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points