The datastore class is used to access the BPS databases. More...
Public Member Functions | |
void | checkin () |
Check in the user by creating a record in table t_actors. More... | |
void | checkout () |
Check out the user by dropping the record in table t_actors. More... | |
void | commit () |
Commit an open transaction. More... | |
void | connect () |
Connect to database server using the current settings in the properties username, password, driver, database, host and port. | |
void | disconnect () |
Disconnect from database server if currently connected. | |
void | dropConnection (Number aScopes=bps::Settings::LocalUserScope) |
Drop connection. More... | |
Number | fieldLength (String aTable, String aColumn) |
Get the maximum length of a certain field in the default schema. More... | |
Boolean | hasDivisionAccess (Number aDivisionKey) |
Checks if the current user is authorized for the division. More... | |
Boolean | hasPermission (String aPermission) |
Checks if the current user is authorized for the named permission. More... | |
Boolean | hasZoneAccess (Number aZoneKey) |
Checks if the current user is authorized for the zone. More... | |
Boolean | indexExists (String aName, String aSchema="") |
Check if a certain index exists. More... | |
String | indexTablespace () |
Get the tablespace name used for indexes. More... | |
Boolean | isCheckedIn () |
Test if similar actor already checked in. More... | |
Boolean | loadConnection (Number aScopes=bps::Settings::LocalScopes) |
Load connection settings. More... | |
Number | nextIdent (String aSeqenceName) |
Get the next sequence value. More... | |
Number | nextKey (String aName) |
Get the next unused key for a table. More... | |
void | purgeActors () |
Purge actors which are no longer connected. More... | |
String | quote (String aText) |
Quote a literal text in single quotes to include it in a sql statement. More... | |
void | renameConnection (QString aConnection, Number aScopes=bps::Settings::LocalUserScope) |
Rename the connection. More... | |
bps::Access | reportAccess (Number aReportKey) |
Check access to a certain report. More... | |
void | rollback () |
Roll back an open transaction. More... | |
void | saveConnection (Number aScopes=bps::Settings::LocalUserScope) |
Save the connection settings. More... | |
Boolean | sequenceExists (String aName, String aSchema="") |
Check if a certain sequence exists. More... | |
Boolean | tableExists (String aName, String aSchema="") |
Check if a certain table exists. More... | |
String | tableTablespace () |
Get the tablespace name used for tables. More... | |
void | touchActor () |
Update the actors timestamp. More... | |
void | transaction () |
Begin a new transaction. More... | |
Boolean | viewExists (String aName, String aSchema="") |
Check if a certain view exists. More... | |
Properties | |
Number | actorKey |
Returns the actor's identifier (the primary key c_key in the t_actors table). More... | |
Boolean | connected |
Current connection status. More... | |
String | connection |
Name of the current connection. More... | |
Array | connections |
A list of all connections that have been declared in the BPS configuration program. More... | |
Date | currentTimestamp |
The current timestamp from the datastore. | |
String | database |
Database name for PostgreSQL, or TNS service name or SID for Oracle. More... | |
String | driver |
The database driver name as BPSPG for PostgreSQL, or BPSORA for Oracle. | |
String | host |
Either the database servers host name, or it's numeric IP address. More... | |
Boolean | inTransaction |
True when the connection is currently in an uncommitted transaction. More... | |
Boolean | oracle |
Current driver is Oracle (BPSORA). More... | |
Boolean | owner |
True when current user is the BPS schema owner. More... | |
String | password |
The database user's password. More... | |
Number | port |
Get host IP port number. More... | |
Boolean | postgres |
Current driver is PostgreSQL (BPSPG). More... | |
Array | roles |
All database roles. More... | |
String | schema |
The BPS schema name. More... | |
Number | sessionId |
Returns the session ID (the database internal identifier of the current session). More... | |
Array | tablespaces |
All tablespace names. More... | |
Array | tnsnames |
List of all Oracle TNS names. More... | |
Number | userid |
The userid, or -1 if not available. More... | |
Number | userKey |
Returns the user's identifier (the primary key c_key in the t_users table). More... | |
String | username |
The database user's name. More... | |
Array | users |
All database user names. More... | |
The datastore class is used to access the BPS databases.
It supports connections to PostgreSQL and to Oracle and encapsulates a Qt database connection, adding generic methods for both database types supported by BPS.
void bps::Datastore::checkin | ( | ) |
Check in the user by creating a record in table t_actors.
Checking in is required for active users, because all permanent locks will be referencing the entry in t_actors. In case the current connection was already checked in, it will be checked out before attempting to do the new check in.
Error | thrown when not connected, no valid userid or general sql error. |
void bps::Datastore::checkout | ( | ) |
Check out the user by dropping the record in table t_actors.
Error | thrown when not connected or general sql error. |
void bps::Datastore::commit | ( | ) |
Commit an open transaction.
Error | thrown when not connected or commit fails. |
void bps::Datastore::dropConnection | ( | Number | aScopes = bps::Settings::LocalUserScope | ) |
Drop connection.
The database properties are removed from the settings.
[in] | aScopes | Scopes at which the settings are removed. Valid scopes include BpsSettings::LocalUserSettings, BpsSettings::LocalSystemSettings and BpsSettings::LocalInstallSettings. |
Get the maximum length of a certain field in the default schema.
[in] | aTable | Name of the table. |
[in] | aColumn | Name of the column. |
Boolean bps::Datastore::hasDivisionAccess | ( | Number | aDivisionKey | ) |
Checks if the current user is authorized for the division.
[in] | aDivisionKey | The key within table t_divisions. |
Boolean bps::Datastore::hasPermission | ( | String | aPermission | ) |
Checks if the current user is authorized for the named permission.
[in] | aPermission | The permission name, for example settings.view |
Boolean bps::Datastore::hasZoneAccess | ( | Number | aZoneKey | ) |
Checks if the current user is authorized for the zone.
[in] | aZoneKey | The key within table t_zones. |
Check if a certain index exists.
[in] | aName | Name of the index. |
[in] | aSchema | Schema name. Default schema is used when omitted. |
Error | thrown when the query fails. |
String bps::Datastore::indexTablespace | ( | ) |
Get the tablespace name used for indexes.
Note that this is only working for a existing BPS schema because it queries table t_users to get the information.
Boolean bps::Datastore::isCheckedIn | ( | ) |
Boolean bps::Datastore::loadConnection | ( | Number | aScopes = bps::Settings::LocalScopes | ) |
Load connection settings.
When loading a connection that has been previously saved, the properties for node, schema, database, driver, host and port are searched and loaded from the locations defined in aScopes.
[in] | aScopes | Scopes at which the settings are searched. Valid scopes include BpsSettings::LocalUserSettings, BpsSettings::LocalSystemSettings and BpsSettings::LocalInstallSettings. |
Number bps::Datastore::nextIdent | ( | String | aSeqenceName | ) |
Get the next sequence value.
[in] | aSeqenceName | The name of the sequence. |
Number bps::Datastore::nextKey | ( | String | aName | ) |
Get the next unused key for a table.
[in] | aName | The base name of the sequence and table, where the prefix s_ and t_ is added. Example: aName = users , sequence = s_users and table = t_users . |
void bps::Datastore::purgeActors | ( | ) |
Purge actors which are no longer connected.
Such records can be present in case of crashed sessions. Removing them will release all permanent locks that still may be held.
Error | thrown when not connected or general sql error. |
Quote a literal text in single quotes to include it in a sql statement.
Takes care of any single quotes within the literal.
[in] | aText | Literal text to be quoted. |
void bps::Datastore::renameConnection | ( | QString | aConnection, |
Number | aScopes = bps::Settings::LocalUserScope |
||
) |
Rename the connection.
[in] | aConnection | New name of the connection. |
[in] | aScopes | Scopes at which the settings are renamed. Valid scopes include BpsSettings::LocalUserSettings, BpsSettings::LocalSystemSettings and BpsSettings::LocalInstallSettings. |
bps::Access bps::Datastore::reportAccess | ( | Number | aReportKey | ) |
Check access to a certain report.
The connection must be established and checked in.
aReportKey | The key within table t_reports. |
void bps::Datastore::rollback | ( | ) |
Roll back an open transaction.
Error | thrown when not connected or rollback fails. |
void bps::Datastore::saveConnection | ( | Number | aScopes = bps::Settings::LocalUserScope | ) |
Save the connection settings.
The database properties are saved for subsequent availability by setConnection().
[in] | aScopes | Scopes at which the settings are saved. Valid scopes include BpsSettings::LocalUserSettings, BpsSettings::LocalSystemSettings and BpsSettings::LocalInstallSettings. |
Check if a certain sequence exists.
[in] | aName | Name of the sequence. |
[in] | aSchema | Schema name. Default schema is used when omitted. |
Error | thrown when the query fails. |
Check if a certain table exists.
[in] | aName | Name of the table. |
[in] | aSchema | Schema name. Default schema is used when omitted. |
Error | thrown when the query fails. |
String bps::Datastore::tableTablespace | ( | ) |
Get the tablespace name used for tables.
Note that this is only working for a existing BPS schema because it queries table t_users to get the information.
void bps::Datastore::touchActor | ( | ) |
Update the actors timestamp.
Will usually be called by license check routines.
Error | thrown when not connected, actor token lost or invalid, or general sql error. |
void bps::Datastore::transaction | ( | ) |
Begin a new transaction.
The transaction will be closed either by a call to commit, or a call to rollback.
Error | thrown when not connected or transaction cannot be started. |
Check if a certain view exists.
[in] | aName | Name of the view. |
[in] | aSchema | Schema name. Default schema is used when omitted. |
Error | thrown when the query fails. |
|
read |
Returns the actor's identifier (the primary key c_key in the t_actors table).
A valid actorKey is only returned when checked in, otherwise Undefined is returned.
|
read |
Current connection status.
|
readwrite |
Name of the current connection.
The database connection name is used to identify a certain connection within the application.
|
read |
A list of all connections that have been declared in the BPS configuration program.
|
readwrite |
Database name for PostgreSQL, or TNS service name or SID for Oracle.
|
readwrite |
Either the database servers host name, or it's numeric IP address.
|
read |
True when the connection is currently in an uncommitted transaction.
|
read |
Current driver is Oracle (BPSORA).
|
read |
True when current user is the BPS schema owner.
|
readwrite |
The database user's password.
|
readwrite |
Get host IP port number.
The default is -1 which will assume 5432 for PostgreSQL and 1531 for Oracle (in case not using TNS).
|
read |
Current driver is PostgreSQL (BPSPG).
|
read |
All database roles.
Only available when connected as user with sufficient privileges (for example DBA or Superuser) to query the respective objects, otherwise nothing may be returned or an Error thrown.
|
readwrite |
The BPS schema name.
|
read |
Returns the session ID (the database internal identifier of the current session).
A valid session ID is only returned when connected, otherwise Undefined is returned.
|
read |
All tablespace names.
Only available when connected as user with sufficient privileges (for example DBA or Superuser) to query the respective objects, otherwise nothing may be returned or an Error thrown.
|
read |
List of all Oracle TNS names.
|
read |
The userid, or -1 if not available.
A valid userid is only present when the username is made up by {schema {userid}. The userid of the BPS owner is 0.
|
read |
Returns the user's identifier (the primary key c_key in the t_users table).
A valid userKey is only returned when checked in, otherwise Undefined is returned.
|
readwrite |
The database user's name.
|
read |
All database user names.
Only available when connected as user with sufficient privileges (for example DBA or Superuser) to query the respective objects, otherwise nothing may be returned or an Error thrown.