Class CSVTabularDataSetConnector
java.lang.Object
org.odpi.openmetadata.frameworks.connectors.Connector
org.odpi.openmetadata.frameworks.connectors.ConnectorBase
org.odpi.openmetadata.adapters.connectors.datastore.csvfile.CSVTabularDataSetConnector
- All Implemented Interfaces:
SecureConnectorExtension
,ReadableTabularDataSource
,WritableTabularDataSource
,VirtualConnectorExtension
- Direct Known Subclasses:
CSVTabularDataSetCollectionConnector
public class CSVTabularDataSetConnector
extends ConnectorBase
implements ReadableTabularDataSource, WritableTabularDataSource
CSVFileStoreConnector works with structured files to retrieve simple tables of data.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
ConnectorBase.ProtectedConnection
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected CSVFileStoreConnector
protected String
protected String
Fields inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
auditLog, connectionBean, connectorInstanceId, embeddedConnectors, messageFormatter, secretsStoreConnectorMap
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendRecord
(List<String> dataValues) Write the requested data record to the end of the data source.void
deleteRecord
(long rowNumber) Remove the requested data record.void
Close the fileReturn the list of column names associated with this data source.int
getColumnNumber
(String columnName) Locate the named column.long
Return the number of records in the file.Return the description for this data source.Return the canonical table name for this data source.readRecord
(long dataRecordNumber) Return the requested data record.void
setColumnDescriptions
(List<TabularColumnDescription> columnDescriptions) Set up the columns associated with this tabular data source.protected void
setFileStoreName
(String tableName) Set up the file name to use for this tabular data set.void
start()
Indicates that the connector is completely configured and can begin processing.void
writeRecord
(long requestedRowNumber, List<String> dataValues) Write the requested data record.Methods inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
combineConfigurationProperties, disconnectConnectors, equals, fromCanonicalToKebabCase, fromCanonicalToSnakeCase, fromKebabToCanonicalCase, fromSnakeToCanonicalCase, getArrayConfigurationProperty, getArrayConfigurationProperty, getArrayConfigurationProperty, getBooleanConfigurationProperty, getConnection, getConnectorInstanceId, getDateConfigurationProperty, getIntConfigurationProperty, getLongConfigurationProperty, getStringConfigurationProperty, getStringConfigurationProperty, getSuppliedPlaceholderProperties, hashCode, initialize, initializeEmbeddedConnectors, initializeSecretsStoreConnector, isActive, logExceptionRecord, logRecord, logRecord, throwMissingConfigurationProperty, throwMissingEndpointAddress, throwMissingResource, throwNoAsset, throwWrongTypeOfAsset, throwWrongTypeOfResource, throwWrongTypeOfRootSchema, toString
Methods inherited from class org.odpi.openmetadata.frameworks.connectors.Connector
clearStatisticProperty, clearStatisticTimestamp, getConnectorStatistics, getStatisticCounter, getStatisticProperty, getStatisticTimestamp, incrementStatisticCounter, initializeStatisticCounter, refreshStatistics, setStatisticProperty, setStatisticTimestamp
-
Field Details
-
tableName
-
tableDescription
-
fileStoreConnector
-
-
Constructor Details
-
CSVTabularDataSetConnector
public CSVTabularDataSetConnector()
-
-
Method Details
-
start
Indicates that the connector is completely configured and can begin processing.- Overrides:
start
in classConnectorBase
- Throws:
ConnectorCheckedException
- there is a problem within the connector.UserNotAuthorizedException
- the connector was disconnected before/during start
-
setFileStoreName
Set up the file name to use for this tabular data set.- Parameters:
tableName
- name of table- Throws:
FileException
- problem using the name as a file name.
-
getColumnNumber
Locate the named column. A negative number means the column is not present.- Specified by:
getColumnNumber
in interfaceReadableTabularDataSource
- Parameters:
columnName
- name of the column to return- Returns:
- column
- Throws:
ConnectorCheckedException
- problem extracting the column descriptions
-
getRecordCount
Return the number of records in the file. This is achieved by scanning the file and counting the records - not recommended for very large files.- Specified by:
getRecordCount
in interfaceReadableTabularDataSource
- Specified by:
getRecordCount
in interfaceWritableTabularDataSource
- Returns:
- count
- Throws:
FileException
- problem accessing the fileFileReadException
- unable to find, open or scan the file.
-
getTableName
Return the canonical table name for this data source. Each word in the name should be capitalized, with spaces between the words to allow translation between different naming conventions.- Specified by:
getTableName
in interfaceReadableTabularDataSource
- Returns:
- string
- Throws:
ConnectorCheckedException
- there is a problem accessing the data
-
getTableDescription
Return the description for this data source.- Specified by:
getTableDescription
in interfaceReadableTabularDataSource
- Returns:
- string
- Throws:
ConnectorCheckedException
- there is a problem accessing the data
-
getColumnDescriptions
Return the list of column names associated with this data source.- Specified by:
getColumnDescriptions
in interfaceReadableTabularDataSource
- Returns:
- a list of column descriptions or null if not available.
- Throws:
ConnectorCheckedException
- there is a problem accessing the data
-
readRecord
Return the requested data record. The first record is record 0. If the first line of the file is the column names then record 0 is the line following the column names.- Specified by:
readRecord
in interfaceReadableTabularDataSource
- Parameters:
dataRecordNumber
- long- Returns:
- List of strings, each string is the value from the column.
- Throws:
FileException
- problem accessing the fileFileReadException
- unable to find, open or read the file, or the file does not include the requested record.
-
writeRecord
public void writeRecord(long requestedRowNumber, List<String> dataValues) throws ConnectorCheckedException Write the requested data record. The first data record is record 0. This process reads the entire file, inserts the record in the right place and writes it out again.- Specified by:
writeRecord
in interfaceWritableTabularDataSource
- Parameters:
requestedRowNumber
- longdataValues
- Map of column descriptions to strings, each string is the value for the column.- Throws:
ConnectorCheckedException
- there is a problem accessing the data.
-
setColumnDescriptions
public void setColumnDescriptions(List<TabularColumnDescription> columnDescriptions) throws ConnectorCheckedException Set up the columns associated with this tabular data source. These are stored in the first record of the file. The rest of the file is cleared.- Specified by:
setColumnDescriptions
in interfaceWritableTabularDataSource
- Parameters:
columnDescriptions
- a list of column descriptions- Throws:
ConnectorCheckedException
- there is a problem accessing the data
-
appendRecord
Write the requested data record to the end of the data source.- Specified by:
appendRecord
in interfaceWritableTabularDataSource
- Parameters:
dataValues
- Map of column descriptions to strings, each string is the value for the column.- Throws:
ConnectorCheckedException
- there is a problem accessing the data.
-
deleteRecord
Remove the requested data record. The first data record is record 0.- Specified by:
deleteRecord
in interfaceWritableTabularDataSource
- Parameters:
rowNumber
- long- Throws:
ConnectorCheckedException
- there is a problem accessing the data.
-
disconnect
public void disconnect()Close the file- Overrides:
disconnect
in classConnectorBase
-