Class ConfigureableDataprocessor<T extends ConfigureableField>

java.lang.Object
de.cxp.ocs.preprocessor.ConfigureableDataprocessor<T>
Type Parameters:
T - ConfigureableField implementation to which the DocumentPreProcessor gets mapped.
All Implemented Interfaces:
DocumentPreProcessor
Direct Known Subclasses:
RemoveValuesDataProcessor, ReplacePatternInValuesDataProcessor, SplitValueDataProcessor

public abstract class ConfigureableDataprocessor<T extends ConfigureableField> extends Object implements DocumentPreProcessor
Abstract class which handles reading and initializing DocumentPreProcessor implementations which need further configuration.
Author:
hjk
  • Field Details

  • Constructor Details

    • ConfigureableDataprocessor

      public ConfigureableDataprocessor()
  • Method Details

    • initialize

      public void initialize(FieldConfigAccess fieldConfig, Map<String,String> confMap)
      Description copied from interface: DocumentPreProcessor
      DataPreProcessor MUST have a no-args constructor. To configure it afterwards, this method will be used.
      Specified by:
      initialize in interface DocumentPreProcessor
      Parameters:
      fieldConfig - field config access
      confMap - custom string-to-string map that can be configured per DocumentPreProcessor.
    • getPatternConfiguration

      protected abstract T getPatternConfiguration(String key, String value, Map<String,String> confMap)
      Returns the ConfigureableField holding the parsed configuration for every configured key.
      Parameters:
      key - a key from the data processor configuration for this data processor.
      value - the value of that key.
      confMap - the complete data processor configuration map.
      Returns:
      the parsed configurable field for the key.
    • process

      public boolean process(Document sourceDocument, boolean visible)
      Description copied from interface: DocumentPreProcessor
      Called for each source document.
      Specified by:
      process in interface DocumentPreProcessor
      Parameters:
      sourceDocument - source document
      visible - weather or not the record is currently marked for indexing.
      Returns:
      true if the record should be indexed, false otherwise.
    • getProcessConsumer

      protected abstract BiConsumer<T,Object> getProcessConsumer(Document sourceDocument, boolean visible)
      Returns a BiConsumer whose input is the configured ConfigureableField with the value of the currently processed record. The consumer gets called in the DocumentPreProcessor.process(Document, boolean) method for each configured key.
      Parameters:
      sourceDocument - the record data
      visible - the current visibility of the record
      Returns:
      a BiConsumer whose accept method should handle every PatternConfiguration with the corresponding value.
    • isRecordVisible

      protected boolean isRecordVisible(Document sourceDocument, boolean visible)
      Called at the end of each process(Document, boolean) run after getProcessConsumer(Document, boolean) is has run for every ConfigureableField, to determine weather the record should be visible or not.
      Parameters:
      sourceDocument - the record data
      visible - the current visibility of the record
      Returns:
      true if the record should be indexed, false otherwise.