Package com.faircom.jsonaction
Class DbApi
- Object
-
- DbApi
-
public class DbApi extends Object
Executes actions in FairCom's JSON DB API, such as querying data, managing records, and creating data objects, such as databases, tables, and indexes.- Simplifies using FairCom's JSON DB API.
- Provides a method for each JSON action.
- Provides the most common parameters for each method.
- Depends on the
Session
class to send requests to the server and receive responses.
- The methods in this class do not provide parameters for all possible JSON properties. When you need to pass additional JSON properties to a request, add them to Jackson ObjectNode and pass it into requestOverride. You can do this to override most JSON property values.
- This class is optional. You may directly send JSON requests to the server using
Session.post()
.
Example:
ServerConnection serverConnection = new ServerConnection() .endpoint( "https://localhost:8443/api" ) .caCertificatePath( "/FairCom/ca.crt" ) .build(); Session session = new Session() .serverConnection( serverConnection ) .username( USER ) .password( PASS ) .databaseName( "ctreeSQL" ) .numberFormat( Session.NumberFormat.NUMBER ) .dataFormat( Session.DataFormat.OBJECTS ) .build(); DbApi dbApi = new DbApi( session ); ObjectNode listDatabasesResult = dbApi.listDatabases( null, null ).get( "result" ).get( "data" ); // Process the list of databases...
To create a Jackson ObjectNode and set it to override properties for a unique request (in this case, return arrays instead of objects):ObjectMapper objectMapper = new ObjectMapper(); ObjectNode override = objectMapper.createObjectNode().set( "responseOptions", objectMapper.createObjectNode().put( "dataFormat", "ARRAYS" ) ); ObjectNode listTablesResponse = dbApiUnderTest.listTables( "ctreeSQL", null, override ); // Process the list of tables...
- See Also:
- FairCom DB API
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DbApi.AtEnd
Defines how the action commits or rolls back the statements it runs.static class
DbApi.OnError
Determines when to stop or continue the execution of SQL statements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectNode
alterTable(String databaseName, String tableName, ArrayNode addFields, ArrayNode alterFields, ArrayNode deleteFields, String transactionId, ObjectNode requestOverride)
Alters a table by adding, renaming or removing fields and settings.ObjectNode
commitTransaction(String transactionId, String transactionSavepointId, ObjectNode requestOverride)
Commits a transaction.ObjectNode
createDatabase(String databaseName, String transactionId, ObjectNode requestOverride)
Creates a new database with the specified name.ObjectNode
createIndex(String databaseName, String tableName, String indexName, List<String> fieldNames, String transactionId, ObjectNode requestOverride)
Creates an index for the specified fields in the specified table.ObjectNode
createTable(String databaseName, String tableName, Fields fields, String transactionId, ObjectNode requestOverride)
Creates a table using the provided fields and properties.ObjectNode
createTransaction(ObjectNode requestOverride)
Generates a new "transactionId" value and returns it in the "result.transactionId" property.ObjectNode
createTransactionSavepoint(String transactionId, ObjectNode requestOverride)
Creates a transaction savepoint and returns a unique identifier for the savepoint in the "result.transactionSavepointId" property.ObjectNode
deleteDatabase(String databaseName, ObjectNode transactionId, ObjectNode requestOverride)
Deletes a database with the specified name.ObjectNode
deleteIndexes(String databaseName, String tableName, List<String> indexNames, String transactionId, ObjectNode requestOverride)
Deletes the specified indexes in the specified table.ObjectNode
deleteRecordsUsingIds(String databaseName, String tableName, List<Long> ids, String transactionId, ObjectNode requestOverride)
Deletes one or more records in a table.ObjectNode
deleteRecordsUsingKeys(String databaseName, String tableName, ArrayNode primaryKeys, String transactionId, ObjectNode requestOverride)
Deletes one or more records in a table.ObjectNode
deleteTables(String databaseName, List<String> tableNames, String transactionId, ObjectNode requestOverride)
Deletes one or more tables from the designated database with options.ObjectNode
describeTables(String databaseName, List<String> tableNames, ObjectNode requestOverride)
Describes specific tables in the designated database.ObjectNode
getAllRecordsFromIndex(String databaseName, String tableName, String indexName, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns all records that are included in an index.ObjectNode
getAllRecordsFromKeyRange(String databaseName, String tableName, String indexName, ArrayNode indexFieldFilters, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns all records within a range of keys in an index.ObjectNode
getAllRecordsFromPartialKeyRange(String databaseName, String tableName, String indexName, String partialKey, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns all records matching a partial key value.ObjectNode
getAllRecordsFromSQL(String databaseName, String sql, ArrayNode sqlParams, String transactionId, ObjectNode requestOverride)
Runs a SQL query and returns the resulting records.ObjectNode
getAllRecordsFromTable(String databaseName, String tableName, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns all records from a table in table order.Cursor
getCursorFromIndex(String databaseName, String tableName, String indexName, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns a cursor object that you can use to retrieve a table's records in index order.Cursor
getCursorFromKeyRange(String databaseName, String tableName, String indexName, ArrayNode indexFieldFilters, String tableFilter, String transactionId, ObjectNode requestOverride)
Defines a key range in an index and returns a cursor object that you can use to retrieve a table's records within that range.Cursor
getCursorFromPartialKeyRange(String databaseName, String tableName, String indexName, String partialKey, String tableFilter, String transactionId, ObjectNode requestOverride)
Defines a partial key range and returns a cursor object that you can use to retrieve a table's records within that range.Cursor
getCursorFromSQL(String databaseName, String sql, ArrayNode sqlParams, String transactionId, ObjectNode requestOverride)
Runs a SQL query and returns a cursor object that you can use to retrieve the resulting records.Cursor
getCursorFromTable(String databaseName, String tableName, String tableFilter, String transactionId, ObjectNode requestOverride)
Returns a forward-only cursor object that retrieves a table's records.Cursor
getCursorStartingAtKey(String databaseName, String tableName, String indexName, String operator, ArrayNode indexFields, String tableFilter, String transactionId, ObjectNode requestOverride)
Finds the closest matching record and returns a cursor object that you can use to retrieve a table's records starting from that point.ObjectNode
getRecordsFromIds(String databaseName, String tableName, List<Long> ids, String transactionId, ObjectNode requestOverride)
Returns all records that match the long IDs in a list of record IDs.ObjectNode
insertRecords(String databaseName, String tableName, JsonNode sourceData, List<String> fieldNames, String transactionId, ObjectNode requestOverride)
Inserts one or more records into a table.ObjectNode
listDatabases(String partialDatabaseName, ObjectNode requestOverride)
Lists all databases on the FairCom JSON Action API server that match a partial name.ObjectNode
listIndexes(String databaseName, String tableName, ObjectNode requestOverride)
Lists the indexes for a specified table.ObjectNode
listTables(String databaseName, String partialTableName, ObjectNode requestOverride)
Lists all table names in the designated database that start with the specified String.ObjectNode
listTransactions(ObjectNode requestOverride)
Lists all transactions that the session has permission to view.ObjectNode
rebuildIndexes(String databaseName, String tableName, ObjectNode requestOverride)
Rebuilds a table's indexes.ObjectNode
rebuildTables(String databaseName, List<String> tableNames, ObjectNode requestOverride)
Rebuilds the indexes for one or more tables.ObjectNode
revertToTransactionSavepoint(String transactionId, String transactionSavepointId, ObjectNode requestOverride)
Reverts a transaction to a savepoint.ObjectNode
rollbackTransaction(String transactionId, ObjectNode requestOverride)
Rolls back a transaction.ObjectNode
runSQLStatements(String databaseName, List<String> sqlStatements, DbApi.OnError onError, DbApi.AtEnd atEnd, List<ObjectNode> inParams, ObjectNode requestOverride)
Runs one or more SQL statements such as drop, create, alter, call, insert, update, and delete statements.ObjectNode
truncateRecords(String databaseName, String tableName, String transactionId, ObjectNode requestOverride)
Deletes all records in a table, quickly and efficiently by removing its data file.ObjectNode
updateRecords(String databaseName, String tableName, JsonNode sourceData, List<String> fieldNames, String transactionId, ObjectNode requestOverride)
Updates one or more records in a table.
-
-
-
Constructor Detail
-
DbApi
public DbApi(Session session) throws ConnectionException
Use this constructor to use an existing session with a FairCom server to send JSON DB API actions to the server.- Parameters:
session
- an instance of the Session class.- Throws:
ConnectionException
- when a new session cannot be created.- Since:
- 1.0
-
-
Method Detail
-
listDatabases
public ObjectNode listDatabases(String partialDatabaseName, ObjectNode requestOverride) throws ApiException
Lists all databases on the FairCom JSON Action API server that match a partial name. To return all databases, pass null or an empty String in partialDatabaseName.- Parameters:
partialDatabaseName
- an optional String which must be in a database name for it to be returned.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom listDatabases documentation
-
createDatabase
public ObjectNode createDatabase(String databaseName, String transactionId, ObjectNode requestOverride) throws ApiException
Creates a new database with the specified name.- Parameters:
databaseName
- the name of the new database.transactionId
- an optional transactionId for this operation. If present, this action will be committed or rolled back as part of the specified transaction. Set to null or an empty String to run this action in a private transaction that automatically commits when the action finishes.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom createDatabase documentation
-
deleteDatabase
public ObjectNode deleteDatabase(String databaseName, ObjectNode transactionId, ObjectNode requestOverride) throws ApiException
Deletes a database with the specified name.- Parameters:
databaseName
- the name of the database to delete.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom deleteDatabase documentation
-
listTables
public ObjectNode listTables(String databaseName, String partialTableName, ObjectNode requestOverride) throws ApiException
Lists all table names in the designated database that start with the specified String. To return all table names, pass null or an empty String in partialTableName.- Parameters:
databaseName
- the database containing the tables.partialTableName
- a table name is returned when it starts with this string.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom listTables documentation
-
describeTables
public ObjectNode describeTables(String databaseName, List<String> tableNames, ObjectNode requestOverride) throws ApiException
Describes specific tables in the designated database. The description contains all table properties, fields, and indexes.- Parameters:
databaseName
- the database containing the tables.tableNames
- list of strings where each string is the name of a table that the server will describe.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom describeTables documentation
-
createTable
public ObjectNode createTable(String databaseName, String tableName, Fields fields, String transactionId, ObjectNode requestOverride) throws ApiException
Creates a table using the provided fields and properties.- Parameters:
databaseName
- the database that will contain the table.tableName
- the name of the new table.fields
- a Jackson ArrayNode containing the fields to add to this table.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the POST returns an HTTP code outside the 200 range.- Since:
- 1.0
- See Also:
- FairCom createTable documentation
-
alterTable
public ObjectNode alterTable(String databaseName, String tableName, ArrayNode addFields, ArrayNode alterFields, ArrayNode deleteFields, String transactionId, ObjectNode requestOverride) throws ApiException
Alters a table by adding, renaming or removing fields and settings.- Parameters:
databaseName
- the database containing the table to alter.tableName
- the name of the table to alter.addFields
- an optional array of unique objects. Each object is the definition of how to add a field in a table. The name property in each field object must be unique and cannot be the name of an existing field in the table. A field name is a string with a length from 1 to 64 bytes.alterFields
- an optional array of field objects. Each object specifies how to alter a field in a table. The name property in each object must be unique and be the name of an existing field in the table. Change a field's properties to modify the field. Changing the data type or shortening its length may destroy data in the field.deleteFields
- an optional array of unique strings. Each string is the name of a field to remove from a table. Removing a field destroys the data in that field.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom alterTable documentation
-
deleteTables
public ObjectNode deleteTables(String databaseName, List<String> tableNames, String transactionId, ObjectNode requestOverride) throws ApiException
Deletes one or more tables from the designated database with options.- Parameters:
databaseName
- the database containing the tables to delete.tableNames
- the names of the tables to delete.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom deleteTables documentation
-
rebuildTables
public ObjectNode rebuildTables(String databaseName, List<String> tableNames, ObjectNode requestOverride) throws ApiException
Rebuilds the indexes for one or more tables.- Parameters:
databaseName
- the database containing the tables to rebuild.tableNames
- the names of the tables to rebuild.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom rebuildTables documentation
-
listIndexes
public ObjectNode listIndexes(String databaseName, String tableName, ObjectNode requestOverride) throws ApiException
Lists the indexes for a specified table.- Parameters:
databaseName
- the database containing the table.tableName
- the name of the table.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom listIndexes documentation
-
createIndex
public ObjectNode createIndex(String databaseName, String tableName, String indexName, List<String> fieldNames, String transactionId, ObjectNode requestOverride) throws ApiException
Creates an index for the specified fields in the specified table. An index has many additional properties. Use requestOverride to set these properties.- Parameters:
databaseName
- the database containing the table.tableName
- the table on which to create the index.indexName
- the name of the new index.fieldNames
- an array of one or more field names to index.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom createIndex documentation
-
deleteIndexes
public ObjectNode deleteIndexes(String databaseName, String tableName, List<String> indexNames, String transactionId, ObjectNode requestOverride) throws ApiException
Deletes the specified indexes in the specified table.- Parameters:
databaseName
- the database containing the table and its indexes.tableName
- the table from which to delete indexes.indexNames
- the names of the indexes to delete.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom deleteIndexes documentation
-
rebuildIndexes
public ObjectNode rebuildIndexes(String databaseName, String tableName, ObjectNode requestOverride) throws ApiException
Rebuilds a table's indexes. This optimizes each index and fixes any index corruption.- Parameters:
databaseName
- the database containing the table with the indexes to rebuild.tableName
- the table containing the index to rebuild.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom rebuildIndexes documentation
-
insertRecords
public ObjectNode insertRecords(String databaseName, String tableName, JsonNode sourceData, List<String> fieldNames, String transactionId, ObjectNode requestOverride) throws ApiException
Inserts one or more records into a table.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records.fieldNames
- the fields containing each record's data.sourceData
- a required array containing one or more records. It either contains an array of objects or an array of arrays. Each object or nested array contains the source data for the record. When sourceData contains an array of objects, you may omit optional fields from each object and the server will set their values to null. You may also set the fieldNames parameter to null. When sourceData contains an array of arrays, you must include the fieldNames parameter to define which fields are included in the operation, and you must assign a field value to each item in the array; thus, you must set null fields to null. Use an array of arrays to minimize the size of the JSON sent to the server.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom insertRecords documentation
-
updateRecords
public ObjectNode updateRecords(String databaseName, String tableName, JsonNode sourceData, List<String> fieldNames, String transactionId, ObjectNode requestOverride) throws ApiException
Updates one or more records in a table.- Parameters:
databaseName
- the database containing the table to update.tableName
- the table containing the records to update.fieldNames
- the fields to update.sourceData
- a required array containing one or more records. It either contains an array of objects or an array of arrays. Each object or nested array contains the source data for the record. When sourceData contains an array of objects, you may omit optional fields from each object and the server will set their values to null. You may also set the fieldNames parameter to null. When sourceData contains an array of arrays, you must include the fieldNames parameter to define which fields are included in the operation, and you must assign a field value to each item in the array; thus, you must set null fields to null. Use an array of arrays to minimize the size of the JSON sent to the server.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom updateRecords documentation
-
deleteRecordsUsingIds
public ObjectNode deleteRecordsUsingIds(String databaseName, String tableName, List<Long> ids, String transactionId, ObjectNode requestOverride) throws ApiException
Deletes one or more records in a table. The records to delete are determined by their IDs.- Parameters:
databaseName
- the database containing the table.tableName
- the table to delete records from.ids
- an array containing at least one string or one integer number. It is a record ID that uniquely identifies a row in a table. A zero-length string is an invalid id. It can be an integer number or an integer number embedded in a string. In the database, the identifier is stored in "id" field of each table.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom deleteRecords documentation
-
deleteRecordsUsingKeys
public ObjectNode deleteRecordsUsingKeys(String databaseName, String tableName, ArrayNode primaryKeys, String transactionId, ObjectNode requestOverride) throws ApiException
Deletes one or more records in a table. The records to delete are determined by an array of primaryKeys.- Parameters:
databaseName
- the database containing the table.tableName
- the table to delete records from.primaryKeys
- The "primaryKeys" property is an array of arrays. The outer array contains one or more primary key definitions. Each inner array is a primary key definition that specifies the values the server needs to find and return one matching record.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom deleteRecords documentation
-
truncateRecords
public ObjectNode truncateRecords(String databaseName, String tableName, String transactionId, ObjectNode requestOverride) throws ApiException
Deletes all records in a table, quickly and efficiently by removing its data file. It returns an error when the data file is in use. It either removes all records or removes none.- Parameters:
databaseName
- the database containing the table.tableName
- the table to delete records from.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom truncateRecords documentation
-
getAllRecordsFromTable
public ObjectNode getAllRecordsFromTable(String databaseName, String tableName, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns all records from a table in table order. WARNING: use this method thoughtfully because it can return large amounts of data that overwhelm server, network, and application resources.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByTable documentation
-
getCursorFromTable
public Cursor getCursorFromTable(String databaseName, String tableName, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns a forward-only cursor object that retrieves a table's records.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByTable documentation
-
getAllRecordsFromIndex
public ObjectNode getAllRecordsFromIndex(String databaseName, String tableName, String indexName, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns all records that are included in an index. Records are returned in index order. WARNING: use this method thoughtfully because it can return large amounts of data that overwhelm server, network, and application resources.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index to retrieve records from.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByIndex documentation
-
getCursorFromIndex
public Cursor getCursorFromIndex(String databaseName, String tableName, String indexName, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns a cursor object that you can use to retrieve a table's records in index order. You can retrieve and skip records forward and backward.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index to retrieve records from.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByIndex documentation
-
getRecordsFromIds
public ObjectNode getRecordsFromIds(String databaseName, String tableName, List<Long> ids, String transactionId, ObjectNode requestOverride) throws ApiException
Returns all records that match the long IDs in a list of record IDs. The server does not return records for IDs that it cannot find.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.ids
- the IDs of records to return.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByIds documentation
-
getAllRecordsFromSQL
public ObjectNode getAllRecordsFromSQL(String databaseName, String sql, ArrayNode sqlParams, String transactionId, ObjectNode requestOverride) throws ApiException
Runs a SQL query and returns the resulting records.- Parameters:
databaseName
- the database containing the table.sql
- the SQL query.sqlParams
- the SQL parameters to apply to this query.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsUsingSQL documentation
-
getCursorFromSQL
public Cursor getCursorFromSQL(String databaseName, String sql, ArrayNode sqlParams, String transactionId, ObjectNode requestOverride) throws ApiException
Runs a SQL query and returns a cursor object that you can use to retrieve the resulting records. You can retrieve and skip records forward and backward.- Parameters:
databaseName
- the database containing the table.sql
- the SQL query.sqlParams
- the SQL parameters to apply to this query.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsUsingSQL documentation
-
getAllRecordsFromKeyRange
public ObjectNode getAllRecordsFromKeyRange(String databaseName, String tableName, String indexName, ArrayNode indexFieldFilters, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns all records within a range of keys in an index. Records are returned in index order.Example:
ArrayNode indexFilters = objectMapper.createArrayNode(); ObjectNode firstFilter = objectMapper.createObjectNode(); ObjectNode secondFilter = objectMapper.createObjectNode(); firstFilter.put( "fieldName", fieldName ); firstFilter.put( "operator", ">=" ); firstFilter.put( "value", 20 ); secondFilter.put( "fieldName", fieldName ); secondFilter.put( "operator", "<" ); secondFilter.put( "value", 40 ); indexFilters.add( firstFilter ); indexFilters.add( secondFilter ); ObjectNode getRecordsInKeyRangeResponse = dbApiUnderTest.getRecordsInKeyRange( "ctreeSQL", "myTableName", fieldName, indexFilters, null, null );
- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index containing the keys to check for.indexFieldFilters
- the filter to apply to fields.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsInKeyRange documentation
-
getCursorFromKeyRange
public Cursor getCursorFromKeyRange(String databaseName, String tableName, String indexName, ArrayNode indexFieldFilters, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Defines a key range in an index and returns a cursor object that you can use to retrieve a table's records within that range. Records are returned in index order. You can retrieve and skip records forward and backward.Example:
ArrayNode indexFilters = objectMapper.createArrayNode(); ObjectNode firstFilter = objectMapper.createObjectNode(); ObjectNode secondFilter = objectMapper.createObjectNode(); firstFilter.put( "fieldName", fieldName ); firstFilter.put( "operator", ">=" ); firstFilter.put( "value", 20 ); secondFilter.put( "fieldName", fieldName ); secondFilter.put( "operator", "<" ); secondFilter.put( "value", 40 ); indexFilters.add( firstFilter ); indexFilters.add( secondFilter ); ObjectNode getRecordsInKeyRangeResponse = dbApiUnderTest.getRecordsInKeyRange( "ctreeSQL", "myTableName", fieldName, indexFilters, null, null );
- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index containing the keys to check for.indexFieldFilters
- the filter to apply to fields.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsInKeyRange documentation
-
getAllRecordsFromPartialKeyRange
public ObjectNode getAllRecordsFromPartialKeyRange(String databaseName, String tableName, String indexName, String partialKey, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Returns all records matching a partial key value. Records are returned in index order.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index to use to find records.partialKey
- a partial key used to designate records.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByPartialKeyRange documentation
-
getCursorFromPartialKeyRange
public Cursor getCursorFromPartialKeyRange(String databaseName, String tableName, String indexName, String partialKey, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Defines a partial key range and returns a cursor object that you can use to retrieve a table's records within that range. Records are returned in index order. You can retrieve and skip records forward and backward.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index to use to find records.partialKey
- a partial key used to designate records.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsByPartialKeyRange documentation
-
getCursorStartingAtKey
public Cursor getCursorStartingAtKey(String databaseName, String tableName, String indexName, String operator, ArrayNode indexFields, String tableFilter, String transactionId, ObjectNode requestOverride) throws ApiException
Finds the closest matching record and returns a cursor object that you can use to retrieve a table's records starting from that point. Records are returned in index order. You can retrieve and skip records forward and backward.- Parameters:
databaseName
- the database containing the table.tableName
- the table containing the records to return.indexName
- the index containing the keys to check for.operator
- the relational operators to apply to this operation.indexFields
- the index to use for this operation.tableFilter
- optional filter that removes records from the results.transactionId
- an optional transactionId for this operation. If null or an empty String, this property will be ignored. If present, this action will be part of the specified transaction.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom getRecordsStartingAtKey documentation
-
runSQLStatements
public ObjectNode runSQLStatements(String databaseName, List<String> sqlStatements, DbApi.OnError onError, DbApi.AtEnd atEnd, List<ObjectNode> inParams, ObjectNode requestOverride) throws ApiException
Runs one or more SQL statements such as drop, create, alter, call, insert, update, and delete statements.- Parameters:
databaseName
- the database containing the table.sqlStatements
- a list of SQL statements the server will execute in sequential order.onError
- an optional string that determines when to stop or continue the execution of all SQL statements. It defaults to "continue". onErroratEnd
- an optional string that defines how the action commits or rolls back the statement it runs. It defaults to "rollbackOnError". atEndinParams
- both an optional and required array of objects that specifies the values of input parameters. When optional it defaults to an empty array. inParamsrequestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom runSqlStatements documentation
-
listTransactions
public ObjectNode listTransactions(ObjectNode requestOverride) throws ApiException
Lists all transactions that the session has permission to view.- Parameters:
requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom listTransactions documentation
-
createTransaction
public ObjectNode createTransaction(ObjectNode requestOverride) throws ApiException
Generates a new "transactionId" value and returns it in the "result.transactionId" property. When you want to run multiple actions under control of one transaction, create a transactionId and add it to each action that you want to put under the transaction's control. A transactionId can be applied to many actions until it is committed or rolled back using commitTransaction or rollbackTransaction methods. A zero-length string is always an invalid "transactionId" value. When you run an action without specifying a transactionId, the action runs in its own transaction and automatically commits when successful and rolls back when unsuccessful.- Parameters:
requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom createTransaction documentation
-
createTransactionSavepoint
public ObjectNode createTransactionSavepoint(String transactionId, ObjectNode requestOverride) throws ApiException
Creates a transaction savepoint and returns a unique identifier for the savepoint in the "result.transactionSavepointId" property. A transaction savepoint represents the current point in the transaction process specified by the "transactionId" property. A client can revert a transaction to any savepoint by calling the revertToTransactionSavepoint action with the desired transactionSavepointId. Reverting a transaction does not close, roll back or commit it. Reverting a transaction keeps a transaction open and undoes actions back to the specified point in time. A client can partially commit a transaction to any savepoint by calling the commitTransaction action with the desired transactionSavepointId.- Parameters:
transactionId
- the transactionId to create a savepoint for.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom createTransactionSavepoint documentation
-
rollbackTransaction
public ObjectNode rollbackTransaction(String transactionId, ObjectNode requestOverride) throws ApiException
Rolls back a transaction. All actions performed in the transaction are permanently undone.- Parameters:
transactionId
- the transactionId to roll back.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom rollbackTransaction documentation
-
commitTransaction
public ObjectNode commitTransaction(String transactionId, String transactionSavepointId, ObjectNode requestOverride) throws ApiException
Commits a transaction. All actions performed in the transaction are permanently committed to the database.- Parameters:
transactionId
- the transactionId to commit.transactionSavepointId
- an optional transactionSavepointId to commit.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom commitTransaction documentation
-
revertToTransactionSavepoint
public ObjectNode revertToTransactionSavepoint(String transactionId, String transactionSavepointId, ObjectNode requestOverride) throws ApiException
Reverts a transaction to a savepoint. It undoes all actions in the transaction that occur after the savepoint. The transaction remains active. It does not close, roll back, or commit a transaction.- Parameters:
transactionId
- the transactionId containing a savepoint.transactionSavepointId
- a savepoint to revert back to.requestOverride
- Add new JSON properties and/or override any property value being sent to the FairCom server. See the FairCom documentation for all options. Set to null when you do not want to override anything.- Returns:
- Jackson ObjectNode containing the JSON response from the FairCom server.
- Throws:
ApiException
- when the input object cannot be read or when a class member cannot be serialized.- Since:
- 1.0
- See Also:
- FairCom revertToTransactionSavepoint documentation
-
-