Class EDIMapper
java.lang.Object
com.onenetwork.platform.integ.edi.EDIMapper
public abstract class EDIMapper
extends java.lang.Object
Abstract class for EDIMapper providing various methods for processing and creating EDI messages.
Implement this class to process an inbound EDI transaction set or generate an outbound EDI transaction set for the models.
Methods used for inbound (listed in order of necessity)
- (Required)
parse(TransactionSet)
- to parse the inbound transaction set and generate a ModelList - (Optional)
customize997(TransactionSet, FunctionalGroup)
- Override this method only if the 997 generated for an inbound transaction set needs to be customized. - (Optional)
generateOutbound824(ModelList, EDIMessagingContext)
- override this method to generate an outbound 824 for the workflow error response. Platform by default provides an implementation for this method to create a generic 824 for the workflow error. - (Optional)
generateOutbound824(EDI824ErrorDef)
- Override this method only if the 824 generated for the errors captured EDI824ErrorDef needs to be customized. Platform provides default implementation to build an 824 using the error def. - (Optional)
receive997(TransactionSet)
- When an inbound 997 transaction set is received by Platform, it passed it on to the mapper for any business process updates. NOTE: Platform handles the updates to EDIMessageQueue and the mapper does not need to handle that. - (Optional)
postWrite(ModelList, TransactionSet)
- for any additional callbacks after the ModelWrite
Outbound methods
- (Required)
convertToEDI(List)
- to generate a list of EDI transaction set for the list of models - (Required)
convertToEDI(List, Map)
- to generate a list of EDI transaction set for the list of models. The Map provides additional data derived fromfetchAdditionalData(List)
- (Optional)
convertToEDI(Model)
- to generate a single EDI transaction set for the model - (Optional)
convertToEDI(Model, Map)
- to generate a single EDI transaction set for the model. The Map provides additional data derived fromfetchAdditionalData(List)
- (Optional)
chooseOutboundQueue(Envelope, EDIMessagingContext)
- implement this method to specify the outbound Queue that needs to be used. Platform uses generic outbox/EDI queue when none is specified otherwise. - (Optional)
preprocessOutboundEnvelope(Envelope, EDIMessagingContext)
- When an outbound envelope needs to be massaged to update any value and is called as part of send()
Common methods needed for both inbound and outbound flow
getPartner()
- Platform invokes this method when it cannot find the Partner record to be used for processing the EDI.populateRefTransDetailsInEdiMsgQueue(EdiMessageQueue, TransactionSet)
- Must implement as Platform uses this method to populate the RefTransInfo onEdiMessageQueue
setEDIMessagingContext(EDIMessagingContext)
- Set the EDIMessagingContext to be used for this mapper's EDI processing.getEDIMessagingContext()
- Get the current EDI messaging context
-
Constructor Summary
Constructors Constructor Description EDIMapper()
-
Method Summary
Modifier and Type Method Description void
addTransactionReferences(java.util.List<EdiMQTransRef> emqTransRefs, com.americancoders.edi.TransactionSet transactionSet)
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.QueueRef
chooseOutboundQueue(com.americancoders.edi.Envelope envelope, EDIMessagingContext ctx)
Override this method to choose the outbound queue for the given Envelope to be placed in.java.util.List<com.americancoders.edi.TransactionSet>
convertToEDI(java.util.List<? extends Model> modelList)
Public method which is invoked to convert model/list of models to list of TransactionSetprotected java.util.List<com.americancoders.edi.TransactionSet>
convertToEDI(java.util.List<? extends Model> modelList, java.util.Map<java.lang.String,java.lang.Object> additionalData)
Implementing mappers are responsible for creation and population of TransactionSet (with all the required segments) from model list<T extends Model>
java.util.List<com.americancoders.edi.TransactionSet>convertToEDI(T model)
Public method which is invoked to convert a model to list of TransactionSetprotected <T extends Model>
java.util.List<com.americancoders.edi.TransactionSet>convertToEDI(T model, java.util.Map<java.lang.String,java.lang.Object> additionalData)
Implement this method when a single model object needs to be converted into a list of transaction sets.java.util.List<com.americancoders.edi.TransactionSet>
customize997(com.americancoders.edi.TransactionSet txnSetsOf997, com.americancoders.edi.FunctionalGroup funcGrpOfParentTxn)
Override this method only when the outbound 997 payload needs to be customized for module/partner specific requirements.protected java.util.Map<java.lang.String,java.lang.Object>
fetchAdditionalData(java.util.List<? extends Model> modelList)
Fetches any data not on the given list of Model objects and puts into a Map.com.americancoders.edi.Envelope
generateOutbound824(ModelList wfResponse, EDIMessagingContext ediMessagingContext)
Method which should be overridden by the module mappers to create outbound 824 envelope based on the workflow response which will be sent by the platform.com.americancoders.edi.TransactionSet
generateOutbound824(EDI824ErrorDef edi824ErrorDef)
Method to create outbound EDI 824 transaction set for the EDI824ErrorDef parameter.EDIMessagingContext
getEDIMessagingContext()
QueueRef
getInboundQueueToEnqueueTransactionSet(com.americancoders.edi.TransactionSet transactionSet)
Override this method when a specific queue needs to be used to process the inbound transaction set on the param.java.lang.String
getOutboundFilename(com.americancoders.edi.Envelope envelope)
Override this method to provide outbound file name.Partner
getPartner()
Override this method to get the partner and populate it on EDIMessagingContextabstract ModelList
parse(com.americancoders.edi.TransactionSet transactionSet)
Implement this method to parse the inbound transaction set and generate a ModelList along with the action to be used.void
populateRefTransDetailsInEdiMsgQueue(EdiMessageQueue ediMessageQueue, com.americancoders.edi.TransactionSet transactionSet)
This method can be overridden by subclass mappers to provide the implementation for updating the edi message queue with transaction ref numbers ( primary , secondary , tertiary ) whichever applicable for the transaction set in picture.void
populateRefTransNumberOn824(com.americancoders.edi.Envelope envelope824, EDIMessagingContext ediMsgContext)
Override this method when the reference transaction number on the 824 transaction set needs to be populated on a segment other than OTI.REF.void
postWrite(ModelList resp, com.americancoders.edi.TransactionSet transactionSet)
Post processing of the transaction set writing.boolean
preprocessOutboundEnvelope(com.americancoders.edi.Envelope envelope, EDIMessagingContext ctx)
Override this method to update the content of an outbound generated envelope just before sending.void
receive997(com.americancoders.edi.TransactionSet transactionSet)
Override this method ONLY when module needs to perform any additional logic.void
setEDIMessagingContext(EDIMessagingContext messagingContext)
-
Constructor Details
-
EDIMapper
public EDIMapper()
-
-
Method Details
-
parse
Implement this method to parse the inbound transaction set and generate a ModelList along with the action to be used.- Parameters:
transactionSet
-- Returns:
- ModelList
-
convertToEDI
protected java.util.List<com.americancoders.edi.TransactionSet> convertToEDI(java.util.List<? extends Model> modelList, java.util.Map<java.lang.String,java.lang.Object> additionalData)Implementing mappers are responsible for creation and population of TransactionSet (with all the required segments) from model list- Parameters:
modelList
-additionalData
- - derived fromfetchAdditionalData(List)
- Returns:
- List
-
convertToEDI
protected <T extends Model> java.util.List<com.americancoders.edi.TransactionSet> convertToEDI(T model, java.util.Map<java.lang.String,java.lang.Object> additionalData)Implement this method when a single model object needs to be converted into a list of transaction sets.- Parameters:
model
-additionalData
-- Returns:
- List
-
convertToEDI
public java.util.List<com.americancoders.edi.TransactionSet> convertToEDI(java.util.List<? extends Model> modelList)Public method which is invoked to convert model/list of models to list of TransactionSet- Parameters:
modelList
-- Returns:
- List
-
convertToEDI
public <T extends Model> java.util.List<com.americancoders.edi.TransactionSet> convertToEDI(T model)Public method which is invoked to convert a model to list of TransactionSet- Parameters:
model
-- Returns:
- List
-
fetchAdditionalData
protected java.util.Map<java.lang.String,java.lang.Object> fetchAdditionalData(java.util.List<? extends Model> modelList)Fetches any data not on the given list of Model objects and puts into a Map. Separated from transform so that it can be reused by subclasses (o/w subclass may end up re-fetching same data) Note - Not an abstract method (as it should've been) to retain backward compatibility for existing mappers.- Parameters:
List
- extends Model> modelList- Returns:
- Map
with additionalData (if any)
-
receive997
public void receive997(com.americancoders.edi.TransactionSet transactionSet)Override this method ONLY when module needs to perform any additional logic. PLT handles all updates to EdiMessageQueue whenever an inbound 997 is received. Hence modules NEED NOT do any bookkeeping.- Parameters:
TransactionSet
-
-
getEDIMessagingContext
- Returns:
- the messagingContext
-
setEDIMessagingContext
- Parameters:
messagingContext
- the messagingContext to set
-
postWrite
Post processing of the transaction set writing.- Parameters:
resp
-transactionSet
-
-
generateOutbound824
public com.americancoders.edi.TransactionSet generateOutbound824(EDI824ErrorDef edi824ErrorDef) throws java.lang.ExceptionMethod to create outbound EDI 824 transaction set for the EDI824ErrorDef parameter.- Parameters:
edi824ErrorDef
-- Returns:
- EDI 824 TransactionSet
- Throws:
java.lang.Exception
-
generateOutbound824
public com.americancoders.edi.Envelope generateOutbound824(ModelList wfResponse, EDIMessagingContext ediMessagingContext) throws java.lang.ExceptionMethod which should be overridden by the module mappers to create outbound 824 envelope based on the workflow response which will be sent by the platform. If mapper decides that 824 is not required for a particular scenario, return null.- Parameters:
wfResponse
-ediMessagingContext
-- Returns:
- the EDI 824 envelope created
- Throws:
java.lang.Exception
-
customize997
public java.util.List<com.americancoders.edi.TransactionSet> customize997(com.americancoders.edi.TransactionSet txnSetsOf997, com.americancoders.edi.FunctionalGroup funcGrpOfParentTxn)Override this method only when the outbound 997 payload needs to be customized for module/partner specific requirements. The default payload is the one that is created by PLT as part of parse/validation.- Parameters:
txnSetOf997
- - the transactionSet of 997 created by PLTfuncGrpOfParentTxn
- - the functional group of the parent transaction that is being validated/parsed.ediMessagingContext
-- Returns:
- List of 997 transaction sets
-
populateRefTransDetailsInEdiMsgQueue
public void populateRefTransDetailsInEdiMsgQueue(EdiMessageQueue ediMessageQueue, com.americancoders.edi.TransactionSet transactionSet)This method can be overridden by subclass mappers to provide the implementation for updating the edi message queue with transaction ref numbers ( primary , secondary , tertiary ) whichever applicable for the transaction set in picture. If the implementation is not available in the child mapper, the default behavior is not to update the edi message queue with the ref nos.- Parameters:
ediMessageQueue
-transactionSet
-
-
addTransactionReferences
public void addTransactionReferences(java.util.List<EdiMQTransRef> emqTransRefs, com.americancoders.edi.TransactionSet transactionSet)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
-
-
getPartner
Override this method to get the partner and populate it on EDIMessagingContext- Returns:
- Partner using sender/receiver Ids on inbound EDI.
-
preprocessOutboundEnvelope
public boolean preprocessOutboundEnvelope(com.americancoders.edi.Envelope envelope, EDIMessagingContext ctx)Override this method to update the content of an outbound generated envelope just before sending. Should return "true" if you want the EDIMapperFactory's populateEnvelope to be skipped, "false" if it should still be called. By default, this method does nothing and returns "false". -
chooseOutboundQueue
public QueueRef chooseOutboundQueue(com.americancoders.edi.Envelope envelope, EDIMessagingContext ctx)Override this method to choose the outbound queue for the given Envelope to be placed in. Return null to fall back on the outbound queue selection of the factory. -
populateRefTransNumberOn824
public void populateRefTransNumberOn824(com.americancoders.edi.Envelope envelope824, EDIMessagingContext ediMsgContext)Override this method when the reference transaction number on the 824 transaction set needs to be populated on a segment other than OTI.REF. Default behavior is to populate the ref trans number on the REG segment within OTI.- Parameters:
envelope824
- - envelope of the EDI 824ediMsgContext
-
-
getInboundQueueToEnqueueTransactionSet
public QueueRef getInboundQueueToEnqueueTransactionSet(com.americancoders.edi.TransactionSet transactionSet)Override this method when a specific queue needs to be used to process the inbound transaction set on the param. If no such config is required, then return null. PLT will use the queue returned to enqueue the individual transaction set. If this method returns null, PLT proceeds to use the same queue as the original payload was received.- Parameters:
transactionSet
-- Returns:
- QueueRef to be used to enqueue the transactionSet
-
getOutboundFilename
public java.lang.String getOutboundFilename(com.americancoders.edi.Envelope envelope)Override this method to provide outbound file name. Also refer the config in MessageDestination which control the actual outbound file name.- Parameters:
envelope
-- Returns:
- outbound file name
-