Class LookupTransformer
java.lang.Object
com.northconcepts.datapipeline.transform.Transformer
com.northconcepts.datapipeline.transform.lookup.LookupTransformer
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 Summary
ConstructorsConstructorDescriptionLookupTransformer(FieldList fields, Lookup lookup) Creates a transformer that looks up the values offieldsand resolves clashes with existing field names usingNode.DuplicateNodeAction.APPEND.LookupTransformer(FieldList fields, Lookup lookup, boolean overwriteFields) Deprecated.LookupTransformer(FieldList fields, Lookup lookup, Node.DuplicateNodeAction duplicateFieldAction) Creates a transformer that looks up the values offieldsand resolves clashes with existing field names usingduplicateFieldAction. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclose()Called byTransformingReaderorTransformingWriterwhen theirclose()method is called (after reading or writing ends).Returns how looked-up fields that clash with existing field names are merged (default is APPEND).Returns the fields whose values form the lookup key.booleanIndicates if no exception should be thrown if no results are found (default false, exceptions are thrown).booleanReturns true if the duplicate field action isNode.DuplicateNodeAction.OVERWRITE.protected voidjoin(Record originalRecord, RecordList lookupResult, List<?> lookupArguments) Merges the first lookup result into the record, after passing an empty result tonoResults(Record, List)or a multi-record one totooManyResults(Record, List, RecordList).protected RecordListCalled when the lookup finds no records; returnsnullif that is allowed, otherwise throws.protected voidopen()Called byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts).setAllowNoResults(boolean allowNoResults) Indicates if no exception should be thrown if no results are found (default false, exceptions are thrown).setDuplicateFieldAction(Node.DuplicateNodeAction duplicateFieldAction) Sets how looked-up fields that clash with existing field names are merged (default is APPEND).protected RecordListtooManyResults(Record originalRecord, List<?> arguments, RecordList lookupResult) Called when the lookup returns more than one record; throws by default.toString()booleanApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Methods inherited from class com.northconcepts.datapipeline.transform.Transformer
addExceptionProperties, geEndpoint, getEndpoint, getReader, getWriter, of, setWriter
-
Constructor Details
-
LookupTransformer
public LookupTransformer(FieldList fields, Lookup lookup, Node.DuplicateNodeAction duplicateFieldAction) Creates a transformer that looks up the values offieldsand resolves clashes with existing field names usingduplicateFieldAction. -
LookupTransformer
Deprecated.UseLookupTransformer(FieldList, Lookup, DuplicateNodeAction)instead; true maps to OVERWRITE and false to APPEND. -
LookupTransformer
Creates a transformer that looks up the values offieldsand resolves clashes with existing field names usingNode.DuplicateNodeAction.APPEND.
-
-
Method Details
-
getFields
Returns the fields whose values form the lookup key. -
getLookup
-
getDuplicateFieldAction
Returns how looked-up fields that clash with existing field names are merged (default is APPEND). -
setDuplicateFieldAction
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 isNode.DuplicateNodeAction.OVERWRITE. -
isAllowNoResults
public boolean isAllowNoResults()Indicates if no exception should be thrown if no results are found (default false, exceptions are thrown). -
setAllowNoResults
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:TransformerCalled byTransformingReaderorTransformingWriterwhen theiropen()method is called (before reading or writing starts).- Overrides:
openin classTransformer
-
close
protected void close()Description copied from class:TransformerCalled byTransformingReaderorTransformingWriterwhen theirclose()method is called (after reading or writing ends).- Overrides:
closein classTransformer
-
transform
Description copied from class:TransformerApplies this transformer to a record on its way through aTransformingReaderorTransformingWriter.Contract for subclasses (see also
docs/authoring/Transformer.md):- Mutate
recordin place as needed. - Return
trueto keep the record in the pipeline. - Return
falseto 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:
transformin classTransformer- Throws:
Throwable
- Mutate
-
join
Merges the first lookup result into the record, after passing an empty result tonoResults(Record, List)or a multi-record one totooManyResults(Record, List, RecordList). -
noResults
Called when the lookup finds no records; returnsnullif 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
-