Class IDocMapper

java.lang.Object
com.onenetwork.platform.integ.sap.IDocMapper

public abstract class IDocMapper
extends java.lang.Object
Abstract class for an IDoc integration mapper. Provides various methods for processing and creating IDoc messages.

Implement this class to process an inbound IDoc file or generate an outbound IDoc file.

Methods used for inbound (listed in order of necessity)

  1. (Required) process(IDoc) - to process the inbound IDoc file and generate a ModelList

Outbound methods

  1. (Required) generate(List) - to generate a list of IDoc files for the list of models

Common methods needed for both inbound and outbound flow

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected EDIMessagingContext ediMsgContext  
    protected IDocDef idocDefObj  
  • Constructor Summary

    Constructors 
    Constructor Description
    IDocMapper​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, EDIMessagingContext ediMsgContext)
    This method is used to create and load the IDocDef object from the metadata XML file within the module or EPT.
  • Method Summary

    Modifier and Type Method Description
    void addTransactionReferences​(java.util.List<EdiMQTransRef> emqTransRefs, IDoc iDoc)
    This method can be overridden by subclass mappers to provide the implementation for adding one or more EdiMQTransRef entries into the List present in the method parameter with related transaction ref number and it model level type.
    abstract java.util.List<IDoc> generate​(java.util.List<? extends Model> modelList)
    Your implementation should convert the given Models into IDocs and return the result.
    EDIMessagingContext getEDIMessagingContext()
    EDIMessagingContext which captures information about the current IDoc.
    IDocDef getIDocDef()
    Returns the IDocDef object that contains the metadata from the XML specified during instantiation.
    abstract void populateRefTransDetailsInEdiMsgQueue​(EdiMessageQueue ediMessageQueue, IDoc iDoc)
    This method must be overridden by subclass mappers to provide the implementation for updating the edi message queue with transaction ref numbers (primary, secondary, tertiary) where applicable.
    abstract ModelList process​(IDoc iDoc)
    Your implementation should convert the given IDoc to models, write them (e.g.
    void setEDIMessagingContext​(EDIMessagingContext ediMsgContext)
    EDIMessagingContext which captures information about the current IDoc.
    void setIDocDef​(IDocDef idocDefObj)
    Sets the IDocDef object that defines how the IDocs are structured for this mapper
    abstract void setSenderReceiverOrgsOnEMQ​(EdiMessageQueue ediMessageQueue, IDoc idoc)
    Implement this method to populate sender and receiver information on EDIMessageQueue by 1)Use the IDoc param to derive the senderOrg and receiverOrg based on the sender and receiver of the IDoc respectively.
    void validateIDoc​(IDoc iDoc)
    Override this method when you want to skip validation or customize the validation process that determine how to validate the IDoc The default implementation will attempt to validate the IDoc object against its IDocDef object derived from the metadata XML file.
    protected ModelList writeModelList​(ModelList modelList)
    Provided as a convenience, as the best practice is for your implementation of process(IDoc) 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

    • IDocMapper

      public IDocMapper​(java.lang.String moduleOrEptPrefix, java.lang.String metadataFileName, EDIMessagingContext ediMsgContext)
      This method is used to create and load the IDocDef object from the metadata XML file within the module or EPT.
      • When overriding from a module: If we need to use a metadata file called ORDERS05.xml within PlatformTestModule, place the file within the "com.onenetwork.platformtestmodule.idoc" package and call this method from the implementing mapper's constructor as super("PTA","ORDERS05.xml", ediMsgContext);
      • When overriding from an EPT: Pass the EPT name for moduleOrEptName. For example, if you have an ept named "MyEnt" then place the metadata XML in package "com.onenetwork.myent.idoc" and call this method from the implementing mapper's constructor as - super("EPT.MyEnt","ORDERS05.xml", ediMsgContext);
      • to get the IdocDef object from the XML file within the ept "EPT.MyEnt"
      Parameters:
      moduleOrEptPrefix - module prefix (e.g. ZBKS or EPT.MyEnt)
      metadataFileName - this xml file should be in the "idoc" subpackage of your module or EPT's base java package
      ediMsgContext - message context for the IDoc
  • Method Details

    • writeModelList

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

      public abstract void setSenderReceiverOrgsOnEMQ​(EdiMessageQueue ediMessageQueue, IDoc idoc)
      Implement this method to populate sender and receiver information on EDIMessageQueue by 1)Use the IDoc param to derive the senderOrg and receiverOrg based on the sender and receiver of the IDoc respectively. 2)Use any custom lookup OR external reference to get the OrgName~EntName of the sender and populate the same on EMQ 3)Use ant custom lookup OR external reference to get the OrgName~EntName of the receiver and populate the same on EMQ
      Parameters:
      EdiMessageQueue -
      IDoc -
    • process

      public abstract ModelList process​(IDoc iDoc) throws java.lang.Exception
      Your implementation should convert the given IDoc to models, write them (e.g. using writeModelList(ModelList), and return back the error response as another ModelList.
      Parameters:
      IDoc - IDoc to be written
      Returns:
      ModelList errors
      Throws:
      java.lang.Exception
    • generate

      public abstract java.util.List<IDoc> generate​(java.util.List<? extends Model> modelList)
      Your implementation should convert the given Models into IDocs and return the result.
      Parameters:
      modelList - Models to be converted to IDocs
      Returns:
      List IDocs derived from the given models
    • populateRefTransDetailsInEdiMsgQueue

      public abstract void populateRefTransDetailsInEdiMsgQueue​(EdiMessageQueue ediMessageQueue, IDoc iDoc)
      This method must be overridden by subclass mappers to provide the implementation for updating the edi message queue with transaction ref numbers (primary, secondary, tertiary) where applicable. Populating these values it not required, but highly recommended as it facilitiates searching of IDocs by transaction reference numbers from the EDI Message Queue page.
      Parameters:
      ediMessageQueue - message
      iDoc - IDoc
    • addTransactionReferences

      public void addTransactionReferences​(java.util.List<EdiMQTransRef> emqTransRefs, IDoc iDoc)
      This method can be overridden by subclass mappers to provide the implementation for adding one or more EdiMQTransRef entries into the List present in the method parameter with related transaction ref number and it model level type. All the entries in the list of EdiMQTransRef will be related to the EdiMessageQueue for the transaction set in picture. If the implementation is not available in the child mapper, the default behavior is to not create any EdiMQTransRef entries for the edi message queue.
      Parameters:
      emqTransRefs -
      transactionSet -
    • getIDocDef

      public IDocDef getIDocDef()
      Returns the IDocDef object that contains the metadata from the XML specified during instantiation.
    • setIDocDef

      public void setIDocDef​(IDocDef idocDefObj)
      Sets the IDocDef object that defines how the IDocs are structured for this mapper
      Parameters:
      idocDefObj - IDocDef object that defines how the IDocs are structured for this mapper
    • getEDIMessagingContext

      public EDIMessagingContext getEDIMessagingContext()
      EDIMessagingContext which captures information about the current IDoc.
    • setEDIMessagingContext

      public void setEDIMessagingContext​(EDIMessagingContext ediMsgContext)
      EDIMessagingContext which captures information about the current IDoc.
      Parameters:
      ediMsgContext - EDIMessagingContext which captures information about the current IDoc
    • validateIDoc

      public void validateIDoc​(IDoc iDoc)
      Override this method when you want to skip validation or customize the validation process that determine how to validate the IDoc The default implementation will attempt to validate the IDoc object against its IDocDef object derived from the metadata XML file.
      Parameters:
      iDoc -
      Throws:
      RunTimeException - when the IDoc is invalid along with detailed message indicating cause of validation failure.