Please enable JavaScript to view this site.

The manual for the JobRouter developer

Navigation: System activities

The status model

Scroll Prev Top Next More

General

The execution logic of the system activity is exclusively controlled through the so called step status (or in error cases triggered through exceptions, through which the step status is set automatically and the execution is cancelled). The application programming interfaces (API) offer methods to easily query and change the status, so it is not necessary to know the internal status codes from memory. Nevertheless it can be helpful for debugging. The following table contains the predefined status codes:

Step status

Description

0

First execution / unchanged

1-98

In progress (per default there is no distinction made between 1 to 98)

99

System activity completed / No rules executed yet

Exceptions

In case an error occurs, the system activity can be informed by triggering an exception. The error output occurs in form of a message, which is passed to the exception and the status of the step is automatically set to -1 (error).

Example

The following example shows how the API methods are used to check and edit the step status within the system activity.

Implemented status change in the basic class (getDialogXml shortened for space reasons)

<?php

class csvSystemActivity extends AbstractSystemActivityAPI

{

...

    // functionId='exportCsv'

    protected function exportCsv()

    {

        if ($this->isCompleted()) {

            // This position should never be reached

            throw new Exception('The system activity cannot be executed since it was already completed');

        }

 

        // check the status "first execution"

        if ($this->isFirstExecution()) {

            // set the status to "in progress"

            $this->markActivityAsPending();

        }

 

        // check the status "in progress"

        if ($this->isPending()) {

            // set the status to "completed"

            $this->markActivityAsCompleted();

        }

    }

}

Please pay attention to the correct order the methods are used in. In the example the status is first set from 0 (first execution) to 1 (in progress). Directly afterwards the status is changed to 99 (completed). This causes the system activity to be executed once. In the next example the importance of this order is further explained:

Implemented status change in the basic class with changed order (getDialogXml shortened for space reasons)

<?php

class csvSystemActivity extends AbstractSystemActivityAPI

{

...

    // functionId='exportCsv'

    protected function exportCsv()

    {

        if ($this->isCompleted()) {

            // This position should never be reached

            throw new Exception('The system activity cannot be executed since it was already completed');

        }

 

        // check the status "in progress"

        if ($this->isPending()) {

            // set the status to "completed"

            $this->markActivityAsCompleted();

        }

 

        // check the status "first execution"

        if ($this->isFirstExecution()) {

            // set the status to "in progress"

            $this->markActivityAsPending();

        }

    }

}

In the second example the status is only set from 0 (first execution) to 1 (in progress) at the very end and the system activity reaches the end of execution without having reached the status completed. Is it now executed for the second time, the in progress check is executed and completed will be set. So only after the system activity was executed twice, it will be successfully completed (In the simulator the step has therefore to be sent twice).