public class MongoReader extends IntegrationReader
DataEndpoint.State
fieldLineage, recordLineage
lastRecord, PRODUCT, PRODUCT_VERSION, VENDOR, XML_INPUT_FACTORY_KEY
BUFFER_SIZE, captureElapsedTime, DEFAULT_READ_BUFFER_SIZE
id, log, name, TIMESTAMP_FORMAT
Constructor and Description |
---|
MongoReader(MongoClient client,
String database,
String collection)
Connects to the MongoDB server as specified in MongoClient.
|
MongoReader(String database,
String collection)
Connects to the MongoDB server in localhost on the default port 27017.
|
Modifier and Type | Method and Description |
---|---|
DataException |
addExceptionProperties(DataException exception)
Adds this endpoint's current state to a
DataException . |
void |
close()
Indicates that this endpoint has finished reading or writing.
|
String |
getQuery()
Gets the JSON style query string.
Output format: (e.g. |
boolean |
isAutoCloseConnection()
Indicates if the MongoDB client should be closed when this reader closes (defaults to false).
|
boolean |
isRemoveDocumentId()
Indicates if the document "_id" property should be removed from the resulting records (defaults to true).
|
void |
open()
Makes this endpoint ready for reading or writing.
|
protected Record |
readImpl()
Overridden by subclasses to read the next record from this
DataReader . |
MongoReader |
setAutoCloseConnection(boolean closeConnection)
Indicates if the MongoDB client should be closed when this reader closes (defaults to false).
|
MongoReader |
setQuery(Record query)
Set the JSON style query.
(e.g. |
MongoReader |
setQuery(String query)
Set the JSON style query.
(e.g. |
MongoReader |
setRemoveDocumentId(boolean removeDocumentId)
Indicates if the document "_id" property should be removed from the resulting records (defaults to true).
|
addLineage, available, getBufferSize, getNestedEndpoint, getNestedReader, getRootEndpoint, getRootReader, isExhausted, isLineageSupported, isSaveLineage, peek, pop, push, read, setSaveLineage, skip
decrementRecordCount, enableJmx, getLastRecord, getRecordCount, getRecordCountAsBigInteger, getRecordCountAsString, incrementRecordCount, isRecordCountBigInteger, resetRecordCount, toString
addElapsedtime, assertClosed, assertNotOpened, assertOpened, finalize, getClosedOn, getDescription, getElapsedTime, getElapsedTimeAsString, getOpenedOn, getOpenElapsedTime, getOpenElapsedTimeAsString, getSelfTime, getSelfTimeAsString, getState, isCaptureElapsedTime, isClosed, isOpen, setCaptureElapsedTime, setDescription
public MongoReader(String database, String collection)
database
- name of the database to be used.collection
- name of the collection to be used.public MongoReader(MongoClient client, String database, String collection)
client
- the MongoClient instance.database
- name of the database to be used.collection
- name of the collection to be used.public MongoReader setQuery(String query)
query
- the JSON style query string.public MongoReader setQuery(Record query)
query
- the JSON query as a Record.Record.toJson()
,
setQuery(String)
public String getQuery()
public boolean isAutoCloseConnection()
public MongoReader setAutoCloseConnection(boolean closeConnection)
public boolean isRemoveDocumentId()
public MongoReader setRemoveDocumentId(boolean removeDocumentId)
protected Record readImpl() throws Throwable
DataReader
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.
readImpl
in class DataReader
Throwable
public void open() throws DataException
DataEndpoint
open
in class IntegrationReader
DataException
public void close() throws DataException
DataEndpoint
close
in class DataEndpoint
DataException
public DataException addExceptionProperties(DataException exception)
Endpoint
DataException
. Since this method is called whenever an
exception is thrown, subclasses should override it to add their specific information.addExceptionProperties
in class DataReader
Copyright (c) 2006-2024 North Concepts Inc. All Rights Reserved.