Issue Computation Code

An issue computation consists Java code which may be run programmatically or as part of a workflow. Before you can add an issue computation to a workflow, you must first create the code.


Procedure 4.15. To create the code for an issue computation:

  1. Click the issue computation within the list on the issues tab.

  2. Select the Code tab.
    images/download/attachments/144835123/modeling_23-version-1-modificationdate-1645041979000-api-v2.png

  3. A code skeleton is generated for you. Select the edit button to edit the skeleton code. This will open the class in a normal editing window.

  4. Edit the code to contain the logic you require.

  5. When you have completed your edits, save the file as you would any other by clicking the save button on the toolbar.

  6. Click the refresh button to refresh the display on the code tab so the tab displays the contents of the code file. Clicking refresh is not required for the issue to work correctly, it simply updates what is displayed.

    The following listing is an example of a functional issue computation.

    public void execute(Book input, Book current, ActionBasedWorkflowContext<Book>
    if (isInBadCondition(input)){
    input.issueOn("ZBKS.NotInGoodCondition", IssueSeverity.MEDIUM);
    }
    else {
    input.issueOff("ZBKS.NotInGoodCondition");
    }
    }

In this case a book model with an attribute InBadCondition has been sent into an action which defines a write transaction. The action is associated with a workflow containing this issue computation. The three arguments on the execute method, which is generated as part of the skeleton you got when you created the action, allow you access to the full model as it was passed in as input , the current working copy as current , and the ActionBasedWorkflowContext. If there is no currently persisted copy of the model, current will be null. Since the book model has been configured to support issues, it has the issueOn and issueOff methods available. This is a toggle. Invoking issueOn will "turn on" this issue for this model record as it persisted. The issueOff method "turns off" the issue for the record. Note the use of issueOn in the above example. This method as shown takes two arguments. You specify the issue to raise in the first argument. Note you must pass in the string-based name of the issue exactly as you defined it. Further note the issue computation's name is always preceded by your modules module ID to differentiate it from issues with the same name that may exist in other modules. The second argument allows you to specify the severity of the issue.