Class LookupTransformer

java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
com.northconcepts.datapipeline.transform.lookup.LookupTransformer

public class LookupTransformer extends Transformer
A Transformer that merges into each record the fields of the record a Lookup returns for the values of the key fields. It throws if there is no match (unless allowed) or more than one.
  • Constructor Details

  • Method Details

    • getFields

      public FieldList getFields()
      Returns the fields whose values form the lookup key.
    • getLookup

      public Lookup getLookup()
    • getDuplicateFieldAction

      public Node.DuplicateNodeAction getDuplicateFieldAction()
      Returns how looked-up fields that clash with existing field names are merged (default is APPEND).
    • setDuplicateFieldAction

      public LookupTransformer setDuplicateFieldAction(Node.DuplicateNodeAction duplicateFieldAction)
      Sets how looked-up fields that clash with existing field names are merged (default is APPEND).
    • isOverwriteFields

      public boolean isOverwriteFields()
      Returns true if the duplicate field action is Node.DuplicateNodeAction.OVERWRITE.
    • isAllowNoResults

      public boolean isAllowNoResults()
      Indicates if no exception should be thrown if no results are found (default false, exceptions are thrown).
    • setAllowNoResults

      public LookupTransformer setAllowNoResults(boolean allowNoResults)
      Indicates if no exception should be thrown if no results are found (default false, exceptions are thrown).
    • open

      protected void open()
      Description copied from class: Transformer
      Called by TransformingReader or TransformingWriter when their open() method is called (before reading or writing starts).
      Overrides:
      open in class Transformer
    • close

      protected void close()
      Description copied from class: Transformer
      Called by TransformingReader or TransformingWriter when their close() method is called (after reading or writing ends).
      Overrides:
      close in class Transformer
    • transform

      public boolean transform(Record record) throws Throwable
      Description copied from class: Transformer
      Applies this transformer to a record on its way through a TransformingReader or TransformingWriter.

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

      • Mutate record in place as needed.
      • Return true to keep the record in the pipeline.
      • Return false to drop the record (the host routes it to a discard writer if one is configured, otherwise it disappears).
      • Throw to fail (or route to a discard writer, depending on host configuration).
      • Do not call incrementRecordCount() on the host endpoint; the host handles it.
      Specified by:
      transform in class Transformer
      Throws:
      Throwable
    • join

      protected void join(Record originalRecord, RecordList lookupResult, List<?> lookupArguments)
      Merges the first lookup result into the record, after passing an empty result to noResults(Record, List) or a multi-record one to tooManyResults(Record, List, RecordList).
    • noResults

      protected RecordList noResults(Record originalRecord, List<?> arguments)
      Called when the lookup finds no records; returns null if that is allowed, otherwise throws. Subclasses may return a fallback result instead.
    • tooManyResults

      protected RecordList tooManyResults(Record originalRecord, List<?> arguments, RecordList lookupResult)
      Called when the lookup returns more than one record; throws by default. Subclasses may return a list whose first record is used instead.
    • toString

      public String toString()
      Overrides:
      toString in class Object