public class DataMappingWriter extends IntegrationProxyWriter
Maps each record with a DataMapping and writes the target record to a nested writer instead; records failing a mapping condition are not written.
  • Constructor Details

    • DataMappingWriter

      public DataMappingWriter(DataWriter nestedDataWriter, DataMapping dataMapping)
      Creates a writer that throws an exception for the first record whose mapping throws or fails validation; records failing a mapping condition are skipped.
    • DataMappingWriter

      public DataMappingWriter(DataWriter nestedDataWriter, DataMapping dataMapping, DataWriter discardWriter, String discardReasonFieldName)
      Creates a writer that sends records whose mapping throws or fails validation to discardWriter (throwing instead if it is null), with the reason in the discardReasonFieldName field when that is not null. Records failing a mapping condition are only skipped unless setSendSkippedToDiscardWriter(boolean) is enabled.
  • Method Details

    • getExpressionContext

      public RecordExpressionContext getExpressionContext()
    • getDataMapping

      public DataMapping getDataMapping()
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class IntegrationProxyWriter
      Throws:
      DataException
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class ProxyWriter
      Throws:
      DataException
    • interceptRecord

      protected Record interceptRecord(Record record) throws Throwable
      Description copied from class: ProxyWriter
      Overridden by subclasses to transform, drop, or observe a record on its way through this proxy.

      Contract for subclasses (see also docs/authoring/ProxyWriter.md):

      • Return the record (possibly modified) to forward it to the nested DataWriter.
      • Return null to drop the record; the framework will not write it downstream.
      • Throw to fail the pipeline; the framework wraps the throwable in a DataException with .setRecord(record).
      • The nested DataWriter is opened and closed for you; do not write to it here.
      • Do not call DataEndpoint.incrementRecordCount() here.
      Overrides:
      interceptRecord in class ProxyWriter
      Throws:
      Throwable
    • onFailure

      protected Record onFailure(Record record, DataException exception, DataMappingResult result)
      Handles a record whose mapping threw exceptions or failed validation: writes it to the discard writer and returns null to skip it, or throws exception if there is no discard writer. Overrides may return a record to write.
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class ProxyWriter
    • isSendSkippedToDiscardWriter

      public boolean isSendSkippedToDiscardWriter()
      Indicates if records skipped by a failed mapping condition are also written to the discard writer (default false).
    • setSendSkippedToDiscardWriter

      public DataMappingWriter setSendSkippedToDiscardWriter(boolean sendSkippedToDiscardWriter)
      Indicates if records skipped by a failed mapping condition are also written to the discard writer (default false).