GATE_WORKFLOW_INTERCEPTOR

Description: Limited to code that overrides or customizes gate business tasks.

Abstract Base Class: AbstractGateWorkflowInterceptor

Method: void preWorkflow(TransactionAndVisitHolder inWfCtx, List<CachedGateTask> inTasks), executed immediately prior to the list of gate tasks. The tasks to be executed are passed as inTasks. You may modify this list.

vvoid postWorkflow(TransactionAndVisitHolder inWfCtx), executed immediately following the list of gate tasks.

Interface: EGateWorkflowInterceptor

Module: Road

Version Added: 2.5

Requires Code Extension Name or Name Pattern: Yes

Code Extension Name or Name Pattern: To override workflows:

GateWorkflow<gateID><stageID><timingID>

For example, to override the truck arrival workflow at the ingate stage of gate MAIN, the code extension would be called GateWorkflowMAINingateOnArrival.

GateWorkflow<gateID><stageID<transactionTypeID>

For example, to override a receive export transaction submitted at the ingate stage of a gate MAIN, the code extension would be called GateWorkflowMAINingateRE

Where to specify code extensions of this type: By naming convention only. When N4 executes a gate workflow, it searches for a code extension with a name that follows the described name pattern.

 

Code Example

The following code extension shows an example of workflow pre- and post-processing with a Gate Workflow Interceptor. N4 automatically searches the code extension of type GATE_WORKFLOW_INTERCEPTOR by name. The class is named GateWorkflowTESTinRM, which indicates that it is executed in the workflow for the gate called TEST, at the stage called "in," and for the transaction type RM.

This example gives special processing to trucks whose ID starts with "XX." Containers on XX trucks are not require inspection and any errors in processing the transaction are only logged as warnings.

In the preWorkflow() method, the list of business tasks to be executed is searched, and the task RejectInspectionNotFound is excluded.

In the postWorkflow() method, the message collector is checked for errors, and if found, they are demoted to warnings.

import com.navis.external.road.AbstractGateWorkflowInterceptor

import com.navis.external.road.EGateWorkflowInterceptor

import com.navis.framework.util.TransactionParms

import com.navis.framework.util.internationalization.UserMessage

import com.navis.framework.util.message.MessageCollector

import com.navis.framework.util.message.MessageLevel

import com.navis.road.business.workflow.TransactionAndVisitHolder

import com.navis.road.portal.configuration.CachedGateTask

public class GateWorkflowTESTinRM extends AbstractGateWorkflowInterceptor implements EGateWorkflowInterceptor {

 

  public void preWorkflow(TransactionAndVisitHolder inWfCtx, List<CachedGateTask> inTasks) {

    if (inWfCtx.getTv().getTvdtlsTruckId().startsWith("XX")) {

      CachedGateTask rejectInspectionNotFound = null;

      for (CachedGateTask task : inTasks) {

        if ("RejectInspectionNotFound".equalsIgnoreCase(task.getId())) {

          rejectInspectionNotFound = task;

        }

      }

      if (rejectInspectionNotFound != null) {

        inTasks.remove(rejectInspectionNotFound);

      }

    }

  }

   public void postWorkflow(TransactionAndVisitHolder inWfCtx) {

    if (inWfCtx.getTv().getTvdtlsTruckId().startsWith("XX")) {

      MessageCollector mc = TransactionParms.getBoundParms().getMessageCollector();

      if (mc.hasError()) {

        for (UserMessage um : mc.getMessages()) {

          if (MessageLevel.SEVERE.equals(um.getSeverity())) {

            um.setSeverity(MessageLevel.WARNING);

          }

        }

      }

    }

  }

}