public class DataMappingReader extends IntegrationProxyReader
Maps each record read from a nested reader with a DataMapping and returns the target record instead; records failing a mapping condition are skipped.
  • Constructor Details

    • DataMappingReader

      public DataMappingReader(DataReader nestedDataReader, DataMapping dataMapping, DataWriter discardWriter, String discardReasonFieldName)
      Creates a reader 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.
    • DataMappingReader

      public DataMappingReader(DataReader nestedDataReader, DataMapping dataMapping)
      Creates a reader that throws an exception for the first record whose mapping throws or fails validation; records failing a mapping condition are skipped.
  • 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 IntegrationProxyReader
      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 ProxyReader
      Throws:
      DataException
    • isLineageSupported

      public boolean isLineageSupported()
      Description copied from class: DataReader
      Indicates if this reader can capture record and field lineage (false unless overridden by a reader that supports it).
      Overrides:
      isLineageSupported in class DataReader
    • interceptRecord

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

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

      • Return the record (possibly modified) to pass it downstream.
      • Return null to drop the record; the framework reads the next one.
      • Throw to fail the pipeline; the framework wraps the throwable in a DataException with .setRecord(record).
      • The nested DataReader is opened and closed for you; do not read from it here.
      • Do not call DataEndpoint.incrementRecordCount() here.
      Overrides:
      interceptRecord in class ProxyReader
      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 pass on.
    • 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 ProxyReader
    • isSendSkippedToDiscardWriter

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

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