Update only data and remain at the same task

1
0
-1

Hi everybody I'm Daniele,
I have a question that is surely simple but i can't find a solution.

When the previous task finished it update the data of the two parallel task, but when the first of the the two parallel task is completed the comment or other data fullfilled in the closure of the task is not visible on the second parallel task.

Is there a way to refresh/update the data of the second parallel task inserted in the other task?

Thaks in advance ;-)

Daniele

3 answers

1
0
-1

it is possible.

One way to achieve this is set a Timer in your form, using AJAX to call REST API to get BDM data instance of this case. Of course, you have to use a List to keep comments.

This approach is calling long-polling, which introduce additional cost on network and server, but this is compatible with all browsers.

We also can use another 2 new methods: Server-Event or WebSocket instead of long-polling.

Server-Event relies on a new JavaScript object "EventSource". Refer to below sample, EventSource object will request to given URL for every 3 seconds and get response to update your form. However, we must set header "Cache-Control" to "no-cache" and content type with "text/event-stream" to given URL. So you might need add your own servlet into Bonita which implements backend logic using Bonita Java API.
</p>

 
  <head>  
    <meta charset="UTF-8">  
    <title>Basic SSE Example</title>  
  </head>  
  <body>  
    <pre id="x">Page Loaded...</pre>
    <script>  
    var es = new EventSource("http://localhost/testServerEvent?listner");
    es.addEventListener("message", function(e){  
      document.getElementById("x").innerHTML += "\n" + e.data;
      },false);  
    </script>
  </body>  

Server-Event approach is easy to implement, but its downside is IE does not support EventSource object, while other browsers including Edge support this object.

The 3rd option WebSocket will be a little bit complex. But it costs lest network traffic and lest server, because it only send messages whenever necessary. Usually I use Talend ESB which has Jetty component to implement this approach. A sample code of front-end will be similar to this:

<script type="text/javascript" src="http://localhost:8080/Origami/websocket/sockjs-0.3.min.js"></script>
        <script>
            var websocket;
            if ('WebSocket' in window) {
                websocket = new WebSocket("ws://localhost:8080/Origami/webSocketServer");
            } else if ('MozWebSocket' in window) {
                websocket = new MozWebSocket("ws://localhost:8080/Origami/webSocketServer");
            } else {
                websocket = new SockJS("http://localhost:8080/Origami/sockjs/webSocketServer");
            }
            websocket.onopen = function (evnt) {
            };
            websocket.onmessage = function (evnt) {
                $("#msgcount").html("(<font color='red'>"+evnt.data+"</font>)")
            };
            websocket.onerror = function (evnt) {
            };
            websocket.onclose = function (evnt) {
            }

        </script>

WebSocket approach needs to use a second port,which could introduce some effort on firewall setup and others.

All 3 approaches above eventually call Bonita APIs, either REST API "http://../API/bdm/businessDataReference/{caseId}/{businessDataName}" (here is the document: http://documentation.bonitasoft.com/bdm-api-0#businessdatareference) or Engine API "BusinessDataReference" (here is the document: http://documentation.bonitasoft.com/javadoc/api/7.2/index.html).

You could choose which is more suitable based on your circumstance.

1
0
-1

If my understanding is correct what you want is two parallel tasks that share a data.

This is possible in Bonita BPM with business or process variables. Each task form will display the data and let the user input a new value. If user submit step 3 first, reloading form of step 2 will display the newly updated value. The opposite scenario work as well.

I create a very basic process to illustrate that and have a video of the process running as well.

1
0
-1

So what you want is to

finish task 1
Start task 2 in parallel with 3
Start task 3 in parallel with 2
Update task 2 and show the updates in task 3

Trouble is as parallel tasks 2 can be completed before 3 (as above) and 3 can be completed before 2 (not shown).

I suppose if 3 completes before 2 then you want the comments to be shown in 2 as well? :)

The question depending on your answers to the above is simple, are these parallel tasks or are they really sequential tasks?

If the data changes between the two and either steps is dependent on that data I think you need to redesign you process as it doesn't sound parallel.

regards
Seán

Comments

Submitted by dovemipare on Thu, 04/28/2016 - 16:19

The Task are parallel,
because i don't know when they complete 2 after 3 or 3 after 2.
And when the task are 5 or more and are each other indipendent this refresh are very important.

So the question are, this refresh is possible or not, otherwise i'll go to another system.

Thanks a lot.

Warm regards

Daniele

Notifications