public class DatabaseCollectionReader extends BaseDatabaseCollectionReader
Modifier and Type | Field and Description |
---|---|
protected String |
idColumn
Zero based index of the ID column in the query.
|
protected String |
noteColumn
Zero based index of the note column in the query.
|
protected String |
query
Query to be used to get the data.
|
dataManager, driver, mRecordList, mRowIndex, password, url, username
filters, textFilters
Constructor and Description |
---|
DatabaseCollectionReader()
Default constructor used during UIMA initialization.
|
DatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
DataQueryInformation dataQueryInformation)
Initialize with the database connection and query information.
|
DatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation,
String query,
String idColumn,
String noteColumn)
Initialize with the database connection and query information.
|
DatabaseCollectionReader(String driver,
String url,
String username,
String password,
String query,
String idColumn,
String noteColumn)
Initialize with the database connection and query information.
|
Modifier and Type | Method and Description |
---|---|
protected void |
getData(String query)
Executes the query and saves the results internally to a
List of Object[] to be retrieved when
getNext() is called. |
String |
getIdColumn()
Get the ID Column name.
|
void |
getNext(org.apache.uima.cas.CAS aCAS) |
String |
getNoteColumn()
Get the note column name.
|
org.apache.uima.util.Progress[] |
getProgress()
Gets information about the number of entities and/or amount of data that has been read from
this
CollectionReader , and the total amount that remains (if that information
is available). |
String |
getQuery()
Get the database query used to pull data.
|
boolean |
hasNext() |
<T extends DatabaseCollectionReader> |
setIdColumn(String idColumn)
Set the ID column to be used.
|
<T extends DatabaseCollectionReader> |
setNoteColumn(String noteColumn)
Set the note column name.
|
<T extends DatabaseCollectionReader> |
setQuery(String query)
Set the database query used to pull data.
|
protected void |
validateParams(String query,
String idColumn,
String noteColumn)
Validate the parameters for the DatabaseCollectionReader to ensure that none of the required arguments are
missing or invalid.
|
getDataManager, getDriver, getPassword, getURL, getUsername, setDriver, setPassword, setURL, setUsername
addFilters, addFilters, close, generateCollectionReaderDescription, getFilters, initialize, produceCollectionReader
destroy, getCasInitializer, getProcessingResourceMetaData, initialize, isConsuming, reconfigure, setCasInitializer, typeSystemInit
getConfigParameterValue, getConfigParameterValue, setConfigParameterValue, setConfigParameterValue
getCasManager, getLogger, getMetaData, getResourceManager, getUimaContext, getUimaContextAdmin, setLogger, setMetaData
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
@LeoConfigurationParameter(mandatory=true) protected String query
@LeoConfigurationParameter(mandatory=true) protected String idColumn
@LeoConfigurationParameter(mandatory=true) protected String noteColumn
public DatabaseCollectionReader()
public DatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation, DataQueryInformation dataQueryInformation)
databaseConnectionInformation
- database connection information to use.dataQueryInformation
- database query for retrieving results, assumes one record per row.public DatabaseCollectionReader(DatabaseConnectionInformation databaseConnectionInformation, String query, String idColumn, String noteColumn)
databaseConnectionInformation
- database connection information to use.query
- SQL query used to retrieve the data, one record per row of results.idColumn
- name of the ID column in the SQL query. Assumes only one column to use as the record ID.
Additional ID fields are propagated through the row results String array of the CSI annotation.noteColumn
- name of the note column in the SQL query. Assumes only one note column.public DatabaseCollectionReader(String driver, String url, String username, String password, String query, String idColumn, String noteColumn)
driver
- JDBC driver classurl
- JDBC connection URLusername
- database user name.password
- database user password.query
- SQL query used to retrieve the data, one record per row of results.idColumn
- name of the ID column in the SQL query. Assumes only one column to use as the record ID.
Additional ID fields are propagated through the row results String array of the CSI annotation.noteColumn
- name of the note column in the SQL query. Assumes only one note column.public String getQuery()
public <T extends DatabaseCollectionReader> T setQuery(String query)
query
- database querypublic String getIdColumn()
public <T extends DatabaseCollectionReader> T setIdColumn(String idColumn)
idColumn
- ID column namepublic String getNoteColumn()
public <T extends DatabaseCollectionReader> T setNoteColumn(String noteColumn)
noteColumn
- note column nameprotected void validateParams(String query, String idColumn, String noteColumn)
query
- SQL query to execute to retrieve the data.idColumn
- Name of the column from which the record ID will be maintained.noteColumn
- Name of the column which contains the note.public void getNext(org.apache.uima.cas.CAS aCAS) throws org.apache.uima.collection.CollectionException, IOException
getNext
in interface org.apache.uima.collection.CollectionReader
getNext
in class BaseDatabaseCollectionReader
aCAS
- the CAS to populate with the next document;org.apache.uima.collection.CollectionException
- if there is a problem getting the next and populating the CAS.IOException
public boolean hasNext() throws org.apache.uima.collection.CollectionException
hasNext
in interface org.apache.uima.collection.base_cpm.BaseCollectionReader
hasNext
in class BaseDatabaseCollectionReader
org.apache.uima.collection.CollectionException
protected void getData(String query) throws org.apache.uima.collection.CollectionException
List of Object[]
to be retrieved when
getNext()
is called. Validates the id and note column field names.getData
in class BaseDatabaseCollectionReader
query
- the sql query to run.org.apache.uima.collection.CollectionException
- if there is an error in the query or with the id or column namespublic org.apache.uima.util.Progress[] getProgress()
CollectionReader
, and the total amount that remains (if that information
is available).
This method returns an array of Progress
objects so that results can be reported
using different units. For example, the CollectionReader could report progress in terms of the
number of documents that have been read and also in terms of the number of bytes that have been
read. In many cases, it will be sufficient to return just one Progress
object.getProgress
in interface org.apache.uima.collection.base_cpm.BaseCollectionReader
getProgress
in class BaseDatabaseCollectionReader
Progress
objects. Each object may have different units (for
example number of entities or bytes).Copyright © 2018 Department of Veterans Affairs. All Rights Reserved.