SEND_TRUCK_CALLUP_MSG_INTERCEPTOR

Description: Limited to code that overrides the message Content and delivery of the SendCallupMessage business task. A code extension of this type can send a customized message to a built-in destination, a built-in message to a custom destination, or a customized message to a custom destination.

Abstract Base Class: AbstractSendTruckCallupMsgInterceptor

Method: sendMessage() and getMessageContent()

Interface: ESendTruckCallupMsgInterceptor

Module: Road

Version Added: 2.5

Requires Code Extension Name or Name Pattern: Yes

Code Extension Name or Name Pattern: SendTruckCallupMsgInterceptor

Where to specify code extensions of this type: N/A. Code extension is called by name only.

 

Code example

The following sample code implements a code extension of type SEND_TRUCK_CALLUP_MSG_INTERCEPTOR.

/*

* Copyright (c) 2012 Navis LLC. All Rights Reserved.

*

*/

 

package com.navis.external.road;

import org.jdom.Element;

import java.util.ArrayList;

import java.util.List;

import java.util.Set;

import com.navis.argo.ContextHelper;

import com.navis.external.framework.AbstractExtensionCallback;

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

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

import com.navis.road.RoadConfig;

import com.navis.road.business.adaptor.thirdparty.gos.GosAdaptor;

import com.navis.road.business.apihandler.GateApiXmlUtil;

import com.navis.road.business.model.TruckTransaction;

import com.navis.road.business.model.TruckVisitDetails;

import com.navis.road.business.util.RoadCallupUtil;

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

import com.navis.road.extension.callup.SendTruckCallupMsgExtensionContext;

import com.navis.road.extension.callup.SendTruckCallupMsgExtensionResponse;

import com.navis.road.portal.configuration.CachedGateConfiguration;

import com.navis.road.portal.configuration.CachedGateStage;

import com.navis.argo.util.XmlUtil;

 

public class SendTruckCallupMsgInterceptor extends AbstractSendTruckCallupMsgInterceptor implements ESendTruckCallupMsgInterceptor {

 

   public void sendMessage(SendTruckCallupMsgExtensionContext inContext, SendTruckCallupMsgExtensionResponse inResponse) {

 

         this.log("Overriding sendCallupMsg");

        TransactionAndVisitHolder  dao = inContext.getDao();

        if (dao == null || !gosIsEnabled()) {

            return;

        }

 

        Element eCallup = getMessageContent(dao);

 

        this.log("Callup Msg " + XmlUtil.toString(eCallup, true));

        String response = GosAdaptor.callGos(eCallup);

        this.log("Callup Message Sent");

    }

 

    public Element  getMessageContent(TransactionAndVisitHolder inDao) {

        this.log("Overriding getMessageContent");

        Element eCallup = RoadCallupUtil.getMessageContent(inDao);

        return eCallup;

    }

 

    private static boolean gosIsEnabled() {

        return RoadConfig.GOS_OUTBOUND_ENABLED.isOn(ContextHelper.getThreadUserContext());

    }

 

    public void addMessages(List<UserMessage> inMessages) {

        _messages.addAll(inMessages);

        for (int i = 0; i < inMessages.size() && !_hasError; i++) {

            _hasError = MessageLevel.SEVERE.equals(inMessages.get(i).getSeverity());

        }

    }

 

    List<UserMessage> _messages = new ArrayList<UserMessage>();

    boolean _hasError = false;

 

}