Description: Allows interception of gate tasks. The code extension is called in place of the gate task by specifying the code extension name in the custom code. The base class provides default implementations for the specified methods. With no methods overridden, a code extension of this type will have no effect other than to execute the internal definition of the gate task, that is the same as if it were not present.
Abstract Base Class: AbstractGateTaskInterceptor
Methods: preProcess(), execute(), postProcess(), postProcessSuccess(), postProcessError()
Interface: com.navis.external.road.EGateTaskInterceptor
Module: Road
Version Added: 2.5
Requires Code Extension Name or Name Pattern: No
Code Extension Name or Name Pattern: N/A
Where to Specify Code Extensions of this Type: Customize field of the respective business task.
System-Seeded Code Extensions Using this Type: None
Code Example
The following code extension shows an example of an override for the business task RejectDriverCardExpired. The code extension is of type GATE_TASK_INTERCEPTOR and named GateTaskRejectDriverCardExpired. N4 calls the code extension because its name is referenced in the Customize field of the RejectDriverCardExpired task.
In this example, the preProcess(), execute(), and two of the postProcess() methods have been overridden for illustrative purposes, but it is possible to override fewer methods:
The first preProcess() method first checks if the driver card was an internal card and if so, it clears the truck driver details because for the purposes of this example, the internal cards are not driver-specific and hence the driver is not recorded and no further checks are performed.
The execute() method is first checking if the card ID starts with X. X is an old series of cards that are no longer valid regardless of their original expiry date. For all other cards, the regular RejectDriverCardExpired functionality is called via executeInternal().
The method postProcessError() is called if the card failed the expiry check. This method adds an info message to instruct the driver to make an appointment to receive a new card.
The method postProcessSuccess() is called if the card expiry check passed. This method checks if the card will expire soon (within 60 days) and adds a warning message to the driver to renew the card at the help desk.
The message codes starting with CUSTOM_ have been added here for the example and will need translation added to the application.
import com.navis.argo.business.api.ArgoUtils
import com.navis.external.road.AbstractGateTaskInterceptor
import com.navis.external.road.EGateTaskInterceptor
import com.navis.framework.util.DateUtil
import com.navis.framework.util.internationalization.PropertyKey
import com.navis.framework.util.internationalization.PropertyKeyFactory
import com.navis.framework.util.message.MessageLevel
import com.navis.road.business.model.TruckDriver
import com.navis.road.business.model.TruckTransaction
import com.navis.road.business.model.TruckVisitDetails
import com.navis.road.business.util.RoadBizUtil
import com.navis.road.business.workflow.TransactionAndVisitHolder
public class GateTaskRejectDriverCardExpired extends AbstractGateTaskInterceptor implements EGateTaskInterceptor {
// Internal cards aren't driver specific so erase the driver
public void preProcess(TransactionAndVisitHolder inWfCtx) {
TruckVisitDetails tvdtls = inWfCtx.getTv();
TruckDriver driver = tvdtls.getTvdtlsDriver();
if (driver != null && driver.getDriverIsInternal()) {
tvdtls.setTvdtlsDriver(null);
}
}
// Old-series cards with X prefix have been withdrawn
public void execute(TransactionAndVisitHolder inWfCtx) {
TruckVisitDetails tvdtls = inWfCtx.getTv();
TruckTransaction tran = inWfCtx.getTran();
TruckDriver driver = tvdtls.getTvdtlsDriver();
if (driver != null) {
if (driver.getDriverCardId().startsWith("X")) {
// error message for X cards
PropertyKey CUSTOM__CARD_OLD_SERIES = PropertyKeyFactory.valueOf("CUSTOM__CARD_OLD_SERIES");
RoadBizUtil.getMessageCollector().appendMessage(MessageLevel.SEVERE, CUSTOM__CARD_OLD_SERIES, null, null);
}
else {
// otherwise the execute the regular RejectDriverCardExpired check
executeInternal(inWfCtx);
}
}
}
// If it's already expired they need to make an appointment to renew
public void postProcessError(TransactionAndVisitHolder inWfCtx) {
PropertyKey CUSTOM__RENEW_BY_APPOINTMENT = PropertyKeyFactory.valueOf("CUSTOM__RENEW_BY_APPOINTMENT");
RoadBizUtil.getMessageCollector().appendMessage(MessageLevel.INFO, CUSTOM__RENEW_BY_APPOINTMENT, null, null);
}
// If it's OK but < 60 days to go then give them a warning
public void postProcessSuccess(TransactionAndVisitHolder inWfCtx) {
TruckVisitDetails tvdtls = inWfCtx.getTv();
TruckDriver driver = tvdtls.getTvdtlsDriver();
if (driver != null && driver.getDriverCardExpiration() != null) {
if (ArgoUtils.timeNowMillis() + DateUtil.MILLIS_PER_DAY * 60 > driver.getDriverCardExpiration().getTime()) {
PropertyKey CUSTOM__RENEW_AT_HELPDESK = PropertyKeyFactory.valueOf("CUSTOM__RENEW_AT_HELPDESK");
RoadBizUtil.getMessageCollector().appendMessage(MessageLevel.WARNING, CUSTOM__RENEW_AT_HELPDESK, null, null);
}
}
}
}