Class TwitterUserLookupReader


public class TwitterUserLookupReader extends TwitterProxyReader
Adds Twitter user details to records from a nested reader by looking up the user ID or screen name in a source field.
  • Field Details

  • Constructor Details

    • TwitterUserLookupReader

      public TwitterUserLookupReader(String consumerKey, String consumerSecret, DataReader nestedDataReader, String sourceIdFieldName)
      Creates a reader that looks up users by the ID or screen name at the sourceIdFieldName field path.
    • TwitterUserLookupReader

      public TwitterUserLookupReader(String consumerKey, String consumerSecret, String accessToken, String accessTokenSecret, DataReader nestedDataReader, String sourceIdFieldName)
      Creates a reader that looks up users by the ID or screen name at the sourceIdFieldName field path.
    • TwitterUserLookupReader

      public TwitterUserLookupReader(TwitterProvider provider, DataReader nestedDataReader, String sourceIdFieldName)
      Creates a reader that looks up users by the ID or screen name at the sourceIdFieldName field path.
  • Method Details

    • isLookupByScreenName

      public boolean isLookupByScreenName()
      Indicates if users are looked up by the screen name in the source field instead of by ID (default is false).
    • isLookupById

      public boolean isLookupById()
      Indicates if users are looked up by ID (the default); the source field must then hold Long values.
    • setLookupByScreenName

      public TwitterUserLookupReader setLookupByScreenName(boolean lookupByScreenName)
      Indicates if users are looked up by the screen name in the source field instead of by ID (default is false).
    • getDiscardWriter

      public DataWriter getDiscardWriter()
      Returns the discard sink for records where the lookup failed or null if one was not assigned.
    • setDiscardWriter

      public TwitterUserLookupReader setDiscardWriter(DataWriter writer)
      Assign a discard sink for records where the lookup failed.
      Parameters:
      writer - the discard sink
    • isReturnOrphans

      public boolean isReturnOrphans()
      Indicates if records failing the lookup should be returned — instead of being deleted (default is false).
    • setReturnOrphans

      public TwitterUserLookupReader setReturnOrphans(boolean returnOrphans)
      Indicates if records failing the lookup should be returned — instead of being deleted (default is false).
    • getBatchSize

      public int getBatchSize()
      Returns the number of records looked up per API request (default is 100).
    • setBatchSize

      public TwitterUserLookupReader setBatchSize(int batchSize)
      Sets the number of records looked up per API request, from 1 to MAX_BATCH_SIZE (default is 100).
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class TwitterProxyReader
      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
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

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

      Overrides:
      readImpl in class ProxyReader
      Throws:
      Throwable
    • onUserFound

      protected void onUserFound(Long userId, String screenName, Record record)
      Called for each user found.
      Parameters:
      userId -
    • onUserNotFound

      protected void onUserNotFound(Long userId, String screenName, Record record)
      Called for each user not found.
    • 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 TwitterProxyReader