Class PostgresTabularDataSetConnector
java.lang.Object
org.odpi.openmetadata.frameworks.connectors.Connector
org.odpi.openmetadata.frameworks.connectors.ConnectorBase
org.odpi.openmetadata.adapters.connectors.postgres.tabulardatasource.PostgresTabularDataSetConnector
- All Implemented Interfaces:
SecureConnectorExtension,ReadableTabularDataSource,WritableTabularDataSource,VirtualConnectorExtension
- Direct Known Subclasses:
PostgresTabularDataSetCollectionConnector
public class PostgresTabularDataSetConnector
extends ConnectorBase
implements ReadableTabularDataSource, WritableTabularDataSource
PostgresTabularDataSetConnector presents one PostgreSQL table as a simple table of data that can be both read and
written. As a source, it describes the table's columns from the database's own catalog and reads its records in
a stable order; as a destination, it creates the table from the column descriptions it is given and writes
records into it. Column names cross the boundary in canonical form - capitalised words with spaces between them -
and are held in the database in snake case, which is the naming convention PostgreSQL uses.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
ConnectorBase.ProtectedConnection -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PropertyHelperprotected Stringprotected StringFields inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
auditLog, connectionBean, connectorInstanceId, embeddedConnectors, messageFormatter, secretsStoreConnectorMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidappendRecord(List<String> dataValues) Write the requested data record to the end of the data source.voiddeleteRecord(long rowNumber) Remove the requested data record.voidClose the fileReturn the list of columns in this table, named in canonical form so that a destination can translate them into its own naming convention.intgetColumnNumber(String columnName) Locate the named column.longReturn the number of records in the table.Return the description for this data source.Return the name of the table in canonical form - capitalised words with spaces between them - so that a destination can translate it into its own naming convention.readRecord(long rowNumber) Return the requested data record.voidsetColumnDescriptions(List<TabularColumnDescription> columnDescriptions) Set up the columns associated with this tabular data source, creating the schema and table to hold them if they do not already exist.voidstart()Indicates that the connector is completely configured and can begin processing.voidwriteRecord(long requestedRowNumber, List<String> dataValues) Write the requested data record.Methods inherited from class org.odpi.openmetadata.frameworks.connectors.ConnectorBase
combineConfigurationProperties, disconnectConnectors, equals, fromCamelToCanonicalCase, fromCanonicalToCamelCase, fromCanonicalToKebabCase, fromCanonicalToSnakeCase, fromKebabToCanonicalCase, fromSnakeToCanonicalCase, getArrayConfigurationProperty, getArrayConfigurationProperty, getArrayConfigurationProperty, getBooleanConfigurationProperty, getConnection, getConnectorInstanceId, getDateConfigurationProperty, getIntConfigurationProperty, getLongConfigurationProperty, getSecretsCollectionName, getSecretsLocation, getSecretsProvider, getStringConfigurationProperty, getStringConfigurationProperty, getSuppliedPlaceholderProperties, hashCode, initialize, initializeEmbeddedConnectors, initializeSecretsStoreConnector, isActive, logExceptionRecord, logExceptionRecord, logRecord, logRecord, throwMissingConfigurationProperty, throwMissingElement, throwMissingEndpointAddress, throwMissingResource, throwNoAsset, throwWrongTypeOfAsset, throwWrongTypeOfResource, throwWrongTypeOfRootSchema, toStringMethods inherited from class org.odpi.openmetadata.frameworks.connectors.Connector
clearStatisticProperty, clearStatisticTimestamp, getConnectorStatistics, getStatisticCounter, getStatisticProperty, getStatisticTimestamp, incrementStatisticCounter, initializeStatisticCounter, refreshStatistics, setStatisticProperty, setStatisticTimestamp
-
Field Details
-
tableName
-
tableDescription
-
propertyHelper
-
-
Constructor Details
-
PostgresTabularDataSetConnector
public PostgresTabularDataSetConnector()
-
-
Method Details
-
start
Indicates that the connector is completely configured and can begin processing.- Overrides:
startin classConnectorBase- Throws:
ConnectorCheckedException- the connector detected a problem.UserNotAuthorizedException- the connector was disconnected before/during start
-
getRecordCount
Return the number of records in the table.- Specified by:
getRecordCountin interfaceReadableTabularDataSource- Specified by:
getRecordCountin interfaceWritableTabularDataSource- Returns:
- count
- Throws:
ConnectorCheckedException- problem accessing the data
-
getTableName
Return the name of the table in canonical form - capitalised words with spaces between them - so that a destination can translate it into its own naming convention. The table is held in the database in snake case.- Specified by:
getTableNamein interfaceReadableTabularDataSource- Returns:
- table name
- Throws:
ConnectorCheckedException- data access problem
-
getTableDescription
Return the description for this data source.- Specified by:
getTableDescriptionin interfaceReadableTabularDataSource- Returns:
- string
- Throws:
ConnectorCheckedException- data access problem
-
getColumnDescriptions
Return the list of columns in this table, named in canonical form so that a destination can translate them into its own naming convention. The column order is the table's own, which is also the order that the values of a record are returned in byreadRecord(long).- Specified by:
getColumnDescriptionsin interfaceReadableTabularDataSource- Returns:
- a list of column descriptions or null if not available.
- Throws:
ConnectorCheckedException- data access problem
-
getColumnNumber
Locate the named column. The name may be given in canonical form or as the database names it. A negative number means the column is not present.- Specified by:
getColumnNumberin interfaceReadableTabularDataSource- Parameters:
columnName- name of the column- Returns:
- column number, starting at 0
- Throws:
ConnectorCheckedException- problem extracting the column descriptions
-
readRecord
Return the requested data record. The first record is record 0.
A table has no row numbers of its own, so the record at a position is the one at that offset when the rows are put in the same repeatable order thatdeleteRecord(long)uses - by the columns that identify a record where the table has them, and by physical position where it does not. The values are returned in the table's column order, as text: PostgreSQL renders each value in its own type's text form, which is what a destination casts back on the way in.- Specified by:
readRecordin interfaceReadableTabularDataSource- Parameters:
rowNumber- long- Returns:
- List of strings, each string is the value from the column; a null value stays null.
- Throws:
ConnectorCheckedException- a problem occurred accessing the data, or there is no such record.
-
setColumnDescriptions
public void setColumnDescriptions(List<TabularColumnDescription> columnDescriptions) throws ConnectorCheckedException Set up the columns associated with this tabular data source, creating the schema and table to hold them if they do not already exist.- Specified by:
setColumnDescriptionsin interfaceWritableTabularDataSource- Parameters:
columnDescriptions- a list of column descriptions- Throws:
ConnectorCheckedException- data access problem
-
writeRecord
public void writeRecord(long requestedRowNumber, List<String> dataValues) throws ConnectorCheckedException Write the requested data record. The first data record is record 0.
A relational table has no row order to insert into, so the row number is not used; the record is written the same way asappendRecord(java.util.List<java.lang.String>): as an upsert keyed on the identifier columns when the column descriptions have been set and mark some, and as a plain insert otherwise. A plain insert was used here before, and it meant a data set delivered a second time to the same table - which is what a refresh subscription does - failed on every row already there.- Specified by:
writeRecordin interfaceWritableTabularDataSource- Parameters:
requestedRowNumber- longdataValues- Map of column descriptions to strings, each string is the value for the column.- Throws:
ConnectorCheckedException- a problem occurred accessing the data.
-
appendRecord
Write the requested data record to the end of the data source.- Specified by:
appendRecordin interfaceWritableTabularDataSource- Parameters:
dataValues- Map of column descriptions to strings, each string is the value for the column.- Throws:
ConnectorCheckedException- a problem occurred accessing the data.
-
deleteRecord
Remove the requested data record. The first data record is record 0.
A table has no row numbers of its own, so the record at a position is the one at that offset when the rows are put in a repeatable order - by the columns that identify a record where the table has them, and by physical position where it does not. That is the same order every other operation on this connector sees, which is what makes "the record at position n" mean the same thing to all of them.- Specified by:
deleteRecordin interfaceWritableTabularDataSource- Parameters:
rowNumber- long- Throws:
ConnectorCheckedException- a problem occurred accessing the data.
-
disconnect
public void disconnect()Close the file- Overrides:
disconnectin classConnectorBase
-