How to Create a Custom Virtualization Library
From Business Process Management, BPM and Workflow Automation Wiki | BizAgi BPMS
<keywords content="keywords"> virtual library, entity library </keywords>
Applies to ENTERPRISE .NET EDITION |
Contents |
How to Create a Custom Virtualization Library
To virtualize data sources other than MSSQL or Oracle, it is necessary to write an assembly that implements the IProviderVirtualDA and IEntityVirtualDA interfaces. Bizagi separates the operations for connection, disconnection and transactional management from the operations to insert, update and query the data sources in the Provider and Entity interfaces.
Provider Interface IProviderVirtualDA
The class that implements this interface must contain the following methods:
void Init (HybridDictionary htMetadata): In charge of taking the data supplied in the system configuration, such as server name, database name, user, password, etc. It receives a HybridDictionary object that contains the data configured as system metadata.
void OpenConnection(): This method is used to make the connection with the external system. In the case of a database, this is where you build the connection links and open a connection with the repository.
void CloseConnection(): In charge of closing the connection with the external system.
void BeginTransaction(): In charge of initiating a new transaction for the current operation in the system.
void Commit(): Commits the current transaction in the reference system.
void Rollback(): Carries out rollback of the current transaction in the reference system.
Entity Interface IEntityVirtualDA
The class that implements this interface must contain the logic necessary to manipulate the virtualized data, such as inserting a new record, consulting within a group of records and updating and deleting a registry. The methods that the class must contain are listed below:
void Init(IProviderVirtualDA objProvider, HybridDictionary htMetadata): Initializes the connection with the system. The parameters required to establish the connection with the system are carried on in this method.
PARAMETERS
objProvider: Allows the conversion toward the object that implements the IProviderVirtualDA interface.
htMetadata: Contains the information required as metadata to establish the connection with the configured system.
DataSet GetEntityInstance(string sEntSource, string[] arrsKeyColumns, object[] arroKeyValues, string[] arrsColList): Takes data from entity instances (values) from the corresponding table for a specific ID.
PARAMETERS
sEntSource: Table where the entity is implemented
arrsKeyColumns: An array that contains the names of the columns used to filter the record.
arroKeyValues: Array that contains the values to be used as a filter for a search of the record.
arrsColList: Array that contains the name of the columns to be consulted.
RETURNS - DataSet with the values of the entity.
DataSet GetEntityInstancesTable(string sEntSource, string[] arrsKeyColumns, string[] arrsColList, string sFilterText, bool bFillSchema, int iTopReturnRows)
PARAMETERS
sEntSource: Table where the entity is located.
arrsKeyColumns: Array of columns used as keys.
arrsColList: Columns to be included on the list.
sFilterText: Filter to be applied in search of entities in the WHERE clause.
bFillSchema: True if the information from the schema is to be returned from the database, False otherwise.
iTopReturnRows: Number of registers to be returned.
RETURNS - DataSet with the values of the entity.
object GetAttributeValue(string sEntSource, string[] arrsKeyColumns, object[] arroKeyValues, string sAttrSource)
PARAMETERS
sEntSource: Table where the entity is implemented.
arrsKeyColumns: Array of columns used as keys.
arroKeyValues: Values of the columns used as keys.
sAttrSource: Column of values to return.
RETURNS - Value of the attribute.
bool ExistsEntityInstance(string sEntSource, string[] arrsKeyColumns, object[] arroKeyValues)
PARAMETERS
sEntSource: Table where the entity is implemented.
arrsKeyColumns: Array of columns used as key.
arroKeyValues: Value of columns used as key.
RETURNS - True if the instance was found, False otherwise.
int ExistsEntityInstance(string sEntSource, string sColumn, object oValue, string[] arrsKeyColumns, object[] arroKeyValues)
PARAMETERS
sEntSource: Table where the entity is implemented.
sColumn: Column used to find the instance.
oValue: Value used to find the instance.
arrsKeyColumns: Array of columns used as key.
arroKeyValues: Array of values used as key.
RETURNS - 1 if the instance was found, 0 if not.
Hashtable AddEntity(string sEntSource, Hashtable htAddCols, string[] arrsKeyColumns, object[] arroKeyValues, string[] arrsAutoColumns): Adds a new instance (values) to the database
PARAMETERS
sEntSource: Table where the entity is implemented.
htAddCols: List of columns to add to values.
arrsKeyColumns: Array of columns used as keys.
arroKeyValues: Array of values used as keys.
arrsAutoColumns: Array of auto-numeric columns.
RETURNS - a HashTable that contains the name of the column and the value that was inserted.
Hashtable UpdateEntity(string sEntSource, string[] arrsKeyColumns, object[] arroKeyValues, Hashtable htUpdateCols, string[] arrsAutoColumns): Updates the data of an instance of the entity (values) in the database and records the update.
PARAMETERS
sEntSource: Table where the entity is implemented.
arrsKeyColumns: Array of columns used as key.
arroKeyValues: Value of columns used as key.
htUpdateCols: List of columns to be updated, with values.
arrsAutoColumns: Array of auto-numeric columns.
RETURNS - HashTable that contains the name of the column and the value that was inserted.
bool DeleteEntity(string sEntSource, string[] arrsKeyColumns, object[] arroKeyValues): Deletes a record from the database.
PARAMETERS
sEntSource: Table where the entity is implemented.
arrsKeyColumns: Array of columns used as key.
arroKeyValues: Value of columns used as key.
RETURNS - True if the record was deleted, False otherwise.
Examples
- Class Interface IProviderVirtualDA implementation example
- Class Interface IEntityVirtualDA implementation example
<comments />