Class BaseInboundFixLenProcessor

java.lang.Object
com.onenetwork.platform.integ.fixlen.BaseInboundFixLenProcessor
All Implemented Interfaces:
InboundProcessor

public abstract class BaseInboundFixLenProcessor
extends java.lang.Object
implements InboundProcessor
Implement this class to process an inbound fixed-length format file.

Methods which must be implemented are:

  1. (Required) #processFixLenRows(FixLenRow, PlatformUserContext) - to process the inbound FixedLength file and generate a ModelList
  2. (Required)#setPrimaryRefTransNo(fileRow,context) - to set the primaryRefTransNo for the fixLenRow
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected boolean allowParseWithErrorRecords  
    protected boolean defaultMessageDetailEnabled  
    protected java.lang.String metadataFileName  
    protected java.lang.String moduleOrEptPrefix  
  • Constructor Summary

    Constructors 
    Constructor Description
    BaseInboundFixLenProcessor​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName)
    This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file.
    BaseInboundFixLenProcessor​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, boolean allowParseWithErrorRecords, boolean defaultMessageDetailEnabled)
    This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file, as well as the field allowParseWithErrorRecords and defaultMessageDetailEnabled.
  • Method Summary

    Modifier and Type Method Description
    MessageDetail createMessageDetailEntry​(java.lang.String recordIdentifier, java.lang.String error, java.lang.String primaryRefTransNo, java.lang.String modelType, java.lang.String rawData, Message message, java.util.List<MessageDetail> messageDetails, PlatformUserContext context)
    This method creates a messageDetail JAXB for the parameters passed.
    void handleResults​(TaskResult taskResult, Message message, PlatformUserContext context)
    After processing, handles success and error cases, typically by enqueueing a response message.
    TaskResult process​(Message message, GridTaskContext gridTaskContext, PlatformUserContext context)
    Callback from the message queue framework to process an inbound message.
    abstract ModelList processFixLenRows​(java.util.List<FixLenRow> fixLenRows, Message message, PlatformUserContext context)
    Your implementation should convert the given List to models, write them (e.g.
    abstract java.lang.String setPrimaryRefTransNo​(FixLenRow fileRow, PlatformUserContext context)
    This method must be overridden by subclass processor to provide the implementation for setting the primary transaction reference number.
    protected ModelList writeModelList​(ModelList modelList, PlatformUserContext userContext)
    Provided as a convenience, as the best practice is for your implementation of #processFixLenRows(fixLenRows) to use this method internally.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • BaseInboundFixLenProcessor

      public BaseInboundFixLenProcessor​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName)
      This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file.
      • When overriding from a module: If we need to use a metadata file called Order.xml within PlatformTestModule, place the file within the "com.onenetwork.platformtestmodule.integ.fixlen.rules" package and call this constructor from the implementing processor's constructor as super("PTA","Order.xml");
      • When overriding from an EPT: Pass the EPT name for moduleOrEptName. For example, if you have an ept named "MyEnt" then place the XML rule file in package "com.onenetwork.myent.integ.fixlen.rules" and call this constructor from the implementing processor's constructor as - super("EPT.MyEnt","Order.xml");
      • to get the FixLenDef object from the XML rule file within the ept "EPT.MyEnt"
      Parameters:
      moduleOrEptPrefix - module prefix (e.g. ZBKS or EPT.MyEnt)
      metadataFileName - this xml file should be in the "integ.fixlen.rules" subpackage of your module or EPT's base java package
    • BaseInboundFixLenProcessor

      public BaseInboundFixLenProcessor​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, boolean allowParseWithErrorRecords, boolean defaultMessageDetailEnabled)
      This constructor is used to set moduleOrEptPrefix and metadataFileName fields which are used for loading the XML rule file, as well as the field allowParseWithErrorRecords and defaultMessageDetailEnabled.
      • The field allowParseWithErrorRecords is by default set as true which means that if some rows have parsing errors, other rows are processed and parsing errors for the error rows are captured in the messageDetail. If allowParseWithErrorRecords value is set to false, then if any one row has parsing error, other rows are also not parsed and processed. The error will be thrown by the Processor.
      • The field defaultMessageDetailEnabled is by default set as false which means that messageDetail implementation is to be done by the implementing Processor for the FixLenRow processing. This base processor doesn't provide any implementation for messageDetail for processing FixLenRows in this case. If defaultMessageDetailEnabled value is set to true, then this base processor will be providing a default message detail implementation for processing. If there are any errors thrown from the implementing processor/modelLists, then the base processor sets error message for all the FixLenRows as the returned error message in messageDetail. This is because the base processor does not have any way to determine the error/success case for each FixLenRow. In case there are no error thrown by implementing processor or if modelList has no errors, then messageDetail entries are created for all the FixLenRows without any errors (success)
      • Any parsing errors that occurs are still stored in MessageDetail if allowParseWithErrorRecords flag is set to true.
      Parameters:
      moduleOrEptPrefix - module prefix (e.g. ZBKS or EPT.MyEnt)
      metadataFileName - this xml file should be in the "integ.fixlen.rules" subpackage of your module or EPT's base java package
      allowParseWithErrorRecords - boolean flag to determine if parsing should continue for other rows if some rows have errors.
      defaultMessageDetailEnabled - boolean flag which determines if messageDetail implementation for processing rows will be done by the base processor, or the implementing processor.
  • Method Details

    • process

      public TaskResult process​(Message message, GridTaskContext gridTaskContext, PlatformUserContext context) throws java.lang.Exception
      Description copied from interface: InboundProcessor
      Callback from the message queue framework to process an inbound message.
      Specified by:
      process in interface InboundProcessor
      Parameters:
      message - Message which needs to be processed
      gridTaskContext - GridTaskContext provides information about the grid task associated with the message
      context - value chain admin context for the queue's parent value chain
      Returns:
      TaskResult indicates whether processing succeeded or failed, and whether to retry
      Throws:
      java.lang.Exception
    • processFixLenRows

      public abstract ModelList processFixLenRows​(java.util.List<FixLenRow> fixLenRows, Message message, PlatformUserContext context) throws java.lang.Exception
      Your implementation should convert the given List to models, write them (e.g. using #writeModelList(ModelList), and return back the error response as another ModelList.
      Parameters:
      fixLenRows - List to be processed
      message - Message
      context - PlatformUserContext
      Returns:
      ModelList errors
      Throws:
      java.lang.Exception
    • setPrimaryRefTransNo

      public abstract java.lang.String setPrimaryRefTransNo​(FixLenRow fileRow, PlatformUserContext context)
      This method must be overridden by subclass processor to provide the implementation for setting the primary transaction reference number. This facilitates searching of FixLenRows by transaction reference numbers from the Message detail report page.
      Parameters:
      fileRow - FixLenRow
      context - PlatformUserContext
    • writeModelList

      protected ModelList writeModelList​(ModelList modelList, PlatformUserContext userContext) throws java.lang.Exception
      Provided as a convenience, as the best practice is for your implementation of #processFixLenRows(fixLenRows) to use this method internally.
      Parameters:
      ModelList - models to write
      Returns:
      ModelList response, including any errors
      Throws:
      java.lang.Exception
    • createMessageDetailEntry

      public MessageDetail createMessageDetailEntry​(java.lang.String recordIdentifier, java.lang.String error, java.lang.String primaryRefTransNo, java.lang.String modelType, java.lang.String rawData, Message message, java.util.List<MessageDetail> messageDetails, PlatformUserContext context) throws java.lang.Exception
      This method creates a messageDetail JAXB for the parameters passed. This can be overrriden by the implementing processor if needed
      Parameters:
      recordIdentifier - RecordIdentifier for MessageDetail
      error - ErrorMessage if present
      primaryRefTransNo - primaryIdentificationNumber for MessageDetail
      modelType - modelType
      rawData - rawData for the record
      message - inputMessage
      messageDetails - List
      context - userContext
      Returns:
      MessageDetail
      Throws:
      java.lang.Exception
    • handleResults

      public void handleResults​(TaskResult taskResult, Message message, PlatformUserContext context) throws java.lang.Exception
      Description copied from interface: InboundProcessor
      After processing, handles success and error cases, typically by enqueueing a response message.

      The general contract for Platform's supported processors is:
      If TaskResult is SUCCEED and there are no upload errors, empty success message will be enqueued to success queue If TaskResult is SUCCEED or FAILD and there are upload errors (.results file is not empty), error message will be enqueued to error queue with payloadRef pointing to error file For scenarios where extra handling is required on errors before enqueueing, override this method in the implementation class

      Specified by:
      handleResults in interface InboundProcessor
      Parameters:
      taskResult - TaskResult task result from InboundProcessor.process(Message, GridTaskContext, PlatformUserContext)
      message - Processed Message
      context - value chain admin context for the queue's parent value chain
      Throws:
      java.lang.Exception