Class BaseEDIOutboundGenerator
java.lang.Object
com.onenetwork.platform.integ.edi.BaseEDIOutboundGenerator
- All Implemented Interfaces:
ModelOutboundGenerator
- Direct Known Subclasses:
BaseNetChangeEDIOutboundGenerator
public abstract class BaseEDIOutboundGenerator extends java.lang.Object implements ModelOutboundGenerator
Base class for Outbound Interfaces which generate EDI.
By default, this supports only Model-based outbound generation.
If this is all that's required, the only thing the subclass needs to do is
to provide a no-args constructor which internally provides all params to this
class' constructor, and implement the
derivePartners(ModelOutboundProcessingContext)
to identify the Partner to be used for EDIOutboundRouting of each transaction set.
If the caller wants to support NetChange-based outbound, they should
extend BaseNetChangeEDIOutboundGenerator
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
ediFormat
protected java.lang.String
ediTransactionSetNo
protected com.onenetwork.platform.data.model.impl.ModelType
modelType
protected QueueRef
outboundQueueRef
protected static int
TRANSACTION_CHUNK_SIZE
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseEDIOutboundGenerator(com.onenetwork.platform.data.model.impl.ModelType modelType, java.lang.String ediTransactionSetNo, java.lang.String ediFormat)
Construct BaseEDIOutboundGenerator generator for the specified model type -
Method Summary
Modifier and Type Method Description protected EDIMessage
createAndSendEnvelope(java.util.List<com.americancoders.edi.TransactionSet> txnSetsToSend, EDIMessagingContext ediMsgCtx, EDIEnvelopeInfo ediEnvelopeInfo, boolean createEdiMqEntries)
This method creates and envelope and usesEDIUtil.send
to send the envelope.protected abstract java.util.Map<Partner,java.util.List<? extends Model>>
derivePartners(ModelOutboundProcessingContext processingContext)
Implementing class should map incoming models to a Partner record for purposes of matching to EDIOutboundRoutes.void
generate(ModelOutboundProcessingContext processingContext)
Callback from the Outbound framework to generate the outbound message.protected void
generateEDI(Partner partner, java.util.List<? extends Model> models, PlatformUserContext pltUserContext)
Generates the EDI transaction sets for the models, sends it using EDIUtil.send (also updating the EDI MQ in the process)protected EDIDelimiters
getEDIDelimitersFromPartnerConfig(EDIMessagingContext ediMsgCtx, EDIEnvelopeInfo ediEnvelopeInfo)
Method to get the EDIDelimiters as specified in EDIPartnerConfig model.protected EDIEnvelopeInfo
getEDIEnvelopeInfoToBuildEnvelope(EDIMessagingContext ediMsgContext, EDIDelimiters ediDelimiters)
Method to buildEDIEnvelopeInfo
object to capture delimiters and other control number related data used for EDIUtil.send processprotected EDIMessagingContext
getEDIMessagingContext(Partner partner, PlatformUserContext pltUserContext)
Build EDIMessagingContext that will be used to get the outbound mapper.protected InterchangeInfo
getInterchangeInfoToBuildEnvelope(EDIMessagingContext ediMsgContext)
Method to buildInterchangeInfo
object to capture sender/receiver EDI data used for EDIUtil.send process.protected EDIMapper
getOutboundMapper(EDIMessagingContext ediMessagingContext)
Method to get the outbound mapper using which the EDI transaction set will be formedprotected java.util.List<java.util.List<com.americancoders.edi.TransactionSet>>
partitionTransactionsPerEnvelope(java.util.List<com.americancoders.edi.TransactionSet> transactionSets)
Method to partition the transaction set list based on how many transaction sets need to be sent in one envelope.protected EDIMessage
send(com.americancoders.edi.Envelope envelope, EDIEnvelopeInfo ediEnvelopeInfo, EDIMessagingContext messagingContext, boolean createEdiMqEntries)
"Sends" the EDI data by enqueuing it to the outbound queue referred by the IntegSubs.protected EDIMessage
send(com.americancoders.edi.Envelope envelope, EDIMessagingContext messagingContext)
Deprecated.protected EDIMessage
send(com.americancoders.edi.Envelope envelope, EDIMessagingContext messagingContext, boolean createEdiMqEntries)
Deprecated.
-
Field Details
-
TRANSACTION_CHUNK_SIZE
protected static final int TRANSACTION_CHUNK_SIZE- See Also:
- Constant Field Values
-
modelType
protected com.onenetwork.platform.data.model.impl.ModelType modelType -
ediTransactionSetNo
protected java.lang.String ediTransactionSetNo -
ediFormat
protected java.lang.String ediFormat -
outboundQueueRef
-
-
Constructor Details
-
BaseEDIOutboundGenerator
protected BaseEDIOutboundGenerator(com.onenetwork.platform.data.model.impl.ModelType modelType, java.lang.String ediTransactionSetNo, java.lang.String ediFormat)Construct BaseEDIOutboundGenerator generator for the specified model typeEx. If you want to generate EDI file for order then, model type will be Order, transactionSet number will be 850and EDI format will be X-12.
- Parameters:
modelType
- model type for which edi needs to be generatedediTransactionSetNo
- transaction set number for the model type
-
-
Method Details
-
generate
Description copied from interface:ModelOutboundGenerator
Callback from the Outbound framework to generate the outbound message. Developer can read the data using models available in the ModelOutboundProcessingContext and write the data to the given OutputStream.- Specified by:
generate
in interfaceModelOutboundGenerator
- Parameters:
processingContext
-ModelOutboundProcessingContext
context to generate outbound data- See Also:
ModelOutboundGenerator.generate(com.onenetwork.platform.integ.msg.ModelOutboundProcessingContext)
-
generateEDI
protected void generateEDI(Partner partner, java.util.List<? extends Model> models, PlatformUserContext pltUserContext)Generates the EDI transaction sets for the models, sends it using EDIUtil.send (also updating the EDI MQ in the process)- Parameters:
partner
-models
-- Throws:
java.lang.RuntimeException
- when EDI cannot be formed or if there is an exception in the whole process.
-
createAndSendEnvelope
protected EDIMessage createAndSendEnvelope(java.util.List<com.americancoders.edi.TransactionSet> txnSetsToSend, EDIMessagingContext ediMsgCtx, EDIEnvelopeInfo ediEnvelopeInfo, boolean createEdiMqEntries) throws java.lang.ExceptionThis method creates and envelope and usesEDIUtil.send
to send the envelope.- Parameters:
txnSetsToSend
-ediMsgCtx
-ediEnvelopeInfo
-createEdiMqEntries
-- Returns:
- EDIMessage that was sent
- Throws:
java.lang.Exception
-
send
protected EDIMessage send(com.americancoders.edi.Envelope envelope, EDIEnvelopeInfo ediEnvelopeInfo, EDIMessagingContext messagingContext, boolean createEdiMqEntries) throws java.lang.Exception"Sends" the EDI data by enqueuing it to the outbound queue referred by the IntegSubs. Creates the EDI MQ entries for outbound if the createEdiMqEntries flag is set to true.- Parameters:
envelope
-ediEnvelopeInfo
-messagingContext
-createEdiMqEntries
-- Returns:
- EDIMessage
- Throws:
java.lang.Exception
-
send
@Deprecated protected EDIMessage send(com.americancoders.edi.Envelope envelope, EDIMessagingContext messagingContext, boolean createEdiMqEntries) throws java.lang.ExceptionDeprecated.Deprecated. Please usesend(Envelope, EDIEnvelopeInfo, EDIMessagingContext, boolean)
- Parameters:
envelope
-messagingContext
-createEdiMqEntries
-- Returns:
- EDIMessage
- Throws:
java.lang.Exception
-
send
@Deprecated protected EDIMessage send(com.americancoders.edi.Envelope envelope, EDIMessagingContext messagingContext) throws java.lang.ExceptionDeprecated.Deprecated. Please usesend(Envelope, EDIEnvelopeInfo, EDIMessagingContext, boolean)
- Parameters:
envelope
-messagingContext
-- Returns:
- Throws:
java.lang.Exception
-
derivePartners
protected abstract java.util.Map<Partner,java.util.List<? extends Model>> derivePartners(ModelOutboundProcessingContext processingContext)Implementing class should map incoming models to a Partner record for purposes of matching to EDIOutboundRoutes. -
getEDIMessagingContext
protected EDIMessagingContext getEDIMessagingContext(Partner partner, PlatformUserContext pltUserContext)Build EDIMessagingContext that will be used to get the outbound mapper.- Returns:
- EDIMessagingContext
-
getOutboundMapper
Method to get the outbound mapper using which the EDI transaction set will be formed- Parameters:
ediMessagingContext
-- Returns:
- outbound EDIMapper
-
getEDIDelimitersFromPartnerConfig
protected EDIDelimiters getEDIDelimitersFromPartnerConfig(EDIMessagingContext ediMsgCtx, EDIEnvelopeInfo ediEnvelopeInfo)Method to get the EDIDelimiters as specified in EDIPartnerConfig model. If this config is not available for a partner, then default delimiters are used- Parameters:
ediMsgCtx
-- Returns:
- EDIDelimiters
-
getInterchangeInfoToBuildEnvelope
Method to buildInterchangeInfo
object to capture sender/receiver EDI data used for EDIUtil.send process.- Parameters:
ediMsgContext
-- Returns:
InterchangeInfo
object
-
getEDIEnvelopeInfoToBuildEnvelope
protected EDIEnvelopeInfo getEDIEnvelopeInfoToBuildEnvelope(EDIMessagingContext ediMsgContext, EDIDelimiters ediDelimiters)Method to buildEDIEnvelopeInfo
object to capture delimiters and other control number related data used for EDIUtil.send process- Parameters:
ediMsgContext
-ediDelimiters
-- Returns:
EDIEnvelopeInfo
object
-
partitionTransactionsPerEnvelope
protected java.util.List<java.util.List<com.americancoders.edi.TransactionSet>> partitionTransactionsPerEnvelope(java.util.List<com.americancoders.edi.TransactionSet> transactionSets)Method to partition the transaction set list based on how many transaction sets need to be sent in one envelope. Default behavior is to split it into 100- Parameters:
transactionSets
-- Returns:
- List
- >
-