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)
- (Required)
process(IDoc)
- to process the inbound IDoc file and generate a ModelList
Outbound methods
- (Required)
generate(List)
- to generate a list of IDoc files for the list of models
Common methods needed for both inbound and outbound flow
- (Required)
setSenderReceiverOrgsOnEMQ(EdiMessageQueue, IDoc)
- to set the senderOrg and receiverOrg on EdiMessageQueue #populateRefTransDetailsInEdiMsgQueue(EdiMessageQueue, TransactionSet)
- Must implement as Platform uses this method to populate the RefTransInfo onEdiMessageQueue
-
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 mapperabstract 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 ofprocess(IDoc)
to use this method internally.
-
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 packageediMsgContext
- message context for the IDoc
-
-
Method Details
-
writeModelList
Provided as a convenience, as the best practice is for your implementation ofprocess(IDoc)
to use this method internally.- Parameters:
ModelList
- models to write- Returns:
- ModelList response, including any errors
- Throws:
java.lang.Exception
-
setSenderReceiverOrgsOnEMQ
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
Your implementation should convert the given IDoc to models, write them (e.g. usingwriteModelList(ModelList)
, and return back the error response as another ModelList.- Parameters:
IDoc
- IDoc to be written- Returns:
- ModelList errors
- Throws:
java.lang.Exception
-
generate
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
- messageiDoc
- IDoc
-
addTransactionReferences
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
Returns the IDocDef object that contains the metadata from the XML specified during instantiation. -
setIDocDef
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
EDIMessagingContext which captures information about the current IDoc. -
setEDIMessagingContext
EDIMessagingContext which captures information about the current IDoc.- Parameters:
ediMsgContext
- EDIMessagingContext which captures information about the current IDoc
-
validateIDoc
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.
-