com.archibus.datasource
Interface DataSource

All Known Subinterfaces:
ObjectDataSource
All Known Implementing Classes:
DataSourceGroupingImpl, DataSourceImpl, ObjectDataSourceImpl

public interface DataSource

The DataSource is a programming interface to Web Central data access layer. Web Central data access layer implements declarative object-relational mapping, secure data access, and transparent data localization using metadata defined in the ARCHIBUS data dictionary.

When the DataSource is used to read or write data, it transparently performs ARCHIBUS-specific processing:


Nested Class Summary
static interface DataSource.RecordHandler
          Callback interface that can be passed as a parameter to getRecords() and getAllRecords().
 
Field Summary
static java.lang.String DATA_TYPE_DATE
          Constant for date field/parameter type.
static java.lang.String DATA_TYPE_INTEGER
          Constant for integer field/parameter type.
static java.lang.String DATA_TYPE_MEMO
          Constant for memo field/parameter type.
static java.lang.String DATA_TYPE_NUMBER
          Constant for numeric field/parameter type.
static java.lang.String DATA_TYPE_TEXT
          Constant for text field/parameter type.
static java.lang.String DATA_TYPE_TIME
          Constant for time field/parameter type.
static java.lang.String DATA_TYPE_VERBATIM
          Constant for unformatted (verbatim) parameter type.
static java.lang.String DB_ROLE_DATA
          Constant for "data" database role.
static java.lang.String DB_ROLE_SCHEMA
          Constant for "schema" database role.
static java.lang.String DB_ROLE_SECURITY
          Constant for "security" database role.
static java.lang.String ROLE_MAIN
          Constant for "main" table role.
static java.lang.String ROLE_STANDARD
          Constant for "standard" table role.
static java.lang.String SORT_ASC
          Constant for ascending sort order.
static java.lang.String SORT_DESC
          Constant for descending sort order.
 
Method Summary
 DataSource addCalculatedField(com.archibus.datasource.VirtualFieldDef calculatedField)
          Adds a calculated field to the data source.
 DataSource addField(java.lang.String name)
          Adds specified main table field to the data source query.
 DataSource addField(java.lang.String[] names)
          Adds specified main table fields to the data source query.
 DataSource addField(java.lang.String table, java.lang.String name)
          Adds specified field to the data source query.
 DataSource addField(java.lang.String table, java.lang.String[] names)
          Adds specified fields to the data source query.
 DataSource addParameter(java.lang.String name, double value, java.lang.String dataType)
           
 DataSource addParameter(java.lang.String name, int value, java.lang.String dataType)
           
 DataSource addParameter(java.lang.String name, java.lang.Object value, java.lang.String dataType)
           
 DataSource addParameter(java.lang.String name, java.lang.String value, java.lang.String dataType)
          Adds a query parameter.
 DataSource addQuery(java.lang.String sql)
          Adds a generic dialect SQL query to the data source.
 DataSource addQuery(java.lang.String sql, java.lang.String dialect)
          Adds an SQL query to the data source.
 DataSource addRestriction(Restrictions.Restriction.Clause c)
          Adds a restriction clause.
 DataSource addRestriction(Restrictions.Restriction r)
          Adds a restriction.
 DataSource addSort(java.lang.String name)
          Adds a main table sort field to the data source query, in SORT_ASC mode.
 DataSource addSort(java.lang.String table, java.lang.String name)
          Adds a sort field to the data source query, in SORT_ASC mode.
 DataSource addSort(java.lang.String table, java.lang.String name, java.lang.String order)
          Adds a sort field to the data source query.
 DataSource addTable(java.lang.String name)
          Adds specified table to the data source query, as a "main" table.
 DataSource addTable(java.lang.String name, java.lang.String role)
          Adds specified table in specified role to the data source query.
 DataSource addVirtualField(java.lang.String table, java.lang.String name, java.lang.String dataType)
          Adds a virtual field to the data source.
 DataSource addVirtualField(java.lang.String table, java.lang.String name, java.lang.String dataType, int size, int decimals)
          Adds a virtual field to the data source.
 DataSource addVirtualField(java.lang.String table, java.lang.String name, java.lang.String dataType, int size, int decimals, java.lang.String title)
           
 DataSource clearRestrictions()
          Clears all restrictions defined in AXVW.
 void commit()
          Commit current database transaction.
 DataRecord createNewRecord()
          Creates new DataRecord with default values for all fields defined in the data source.
 org.json.JSONArray createPrimaryKeyIds()
          Creates primary key column definitions in JSON format from the data source.
 DataRecord createRecord()
          Creates new DataRecord with default values for all fields defined in the data source.
 DataRecord createRecordFromContext()
          Creates new DataRecord with default values for all fields defined in the data source.
 com.archibus.db.ViewField.Immutable createVirtualViewField(java.lang.String table, java.lang.String name, java.lang.String fieldJavaType, java.text.NumberFormat format)
          Creates and returns virtual view field for specified Java field type.
 void deleteRecord(DataRecord record)
          Deletes existing record.
 void deleteRecord(java.util.Map fieldValues)
          Deletes record specified by field values.
 void executeUpdate()
          Executes SQL update query, set using addQuery().
 com.archibus.db.ViewField.Immutable findField(java.lang.String fullName)
          Returns a field definition for specified full field name.
 com.archibus.db.ViewField.Immutable findVirtualField(java.lang.String fullName)
          Loop through the virtual fields for the current data source and Returns a field definition for specified full field name.
 java.lang.String formatSqlForPersistentRestrictions()
          Formats SQL expression that includes VPA and hierarchical security restrictions.
 java.lang.String formatSqlQuery(java.lang.String restriction, boolean doNotWrap)
          Formats and returns an SQL query based on: previously added tables, fields, sort fields, restrictions, and custom SQL queries; current user VPA restriction; client-side restriction.
 java.lang.String formatSqlQuery(java.lang.String restriction, java.util.List sortValues, java.util.List filterValues, boolean isOrderbyAllowed, boolean doNotWrap)
          Formats and returns an SQL query based on: previously added tables, fields, sort fields, restrictions, and custom SQL queries; current user VPA restriction; client-side restriction.
 java.util.List<com.archibus.db.ViewField.Immutable> getAllFields()
          Returns a list of field definitions for visible and/or virtual fields.
 java.util.List<DataRecord> getAllRecords()
          Retrieves records that contains values for all fields defined in the data source, using no record limit.
 com.archibus.datasource.VirtualFieldDef getCalculatedFieldDef(java.lang.String tableName, java.lang.String fieldName)
          Returns specified virtual field definition.
 java.util.List<EventHandlerBase.DbField> getDbFieldsForNewRecord()
          Returns a list of DB field definitions for default new record.
 java.util.Map<java.lang.String,EventHandlerBase.DbField> getDbFieldsForPrimaryKeysAsMap()
          Returns a map of DB field definitions for key fields.
 java.util.List<EventHandlerBase.DbField> getDbFieldsForVisibleFields()
          Returns a list of DB field definitions for all fields defined in the data source.
 DataRecord getDefaultRecord(java.lang.String restriction)
          Returns DataRecord with default values for all fields defined in the data source.
 java.util.List<java.lang.String> getFieldNames()
           
 java.lang.String getId()
           
 com.archibus.schema.TableDef.ThreadSafe getMainTableDef()
          Returns main table definition.
 java.lang.String getMainTableName()
          Returns main table name.
 java.util.Map<java.lang.String,DataSourceImpl.Parameter> getParameters()
          Returns all parameters.
 java.util.List<java.lang.String> getPrimaryKeyFieldNamesForTable(java.lang.String tableName)
          Returns a collection of the main table's primary key field names.
 java.util.List<com.archibus.db.ViewField.Immutable> getPrimaryKeyFields()
          Returns a list of primary key fields.
 com.archibus.datasource.SqlExpressions getQueries()
          Returns al custom queries.
 DataRecord getRecord()
          Retrieves a single record that contains values for all fields defined in the data source.
 DataRecord getRecord(java.lang.String restriction)
          Retrieves a single record that contains values for all fields defined in the data source.
 java.util.List<DataRecord> getRecords()
          Retrieves records that contains values for all fields defined in the data source.
 java.util.List<DataRecord> getRecords(java.lang.String restriction)
          Retrieves records that contains values for all fields defined in the data source.
 java.util.List<Restrictions.Restriction> getRestrictions()
          Returns a list of restriction definitions.
 java.util.Map<java.lang.String,java.lang.Object> getRestrictionValues()
          Returns restrictions values passed in from the client.
 java.util.List<DataSourceImpl.SortField> getSortFields()
          Returns a list of sort field definitions.
 java.util.List<DataSourceImpl.TableAndRole> getTablesAndRoles()
          Returns a list of table names and roles.
 java.lang.String getTitle()
           
 com.archibus.datasource.VirtualFieldDef getVirtualFieldDef(java.lang.String tableName, java.lang.String fieldName)
          Returns specified virtual field definition.
 java.util.List<com.archibus.db.ViewField.Immutable> getVirtualFields()
          Returns a list of virtual fields.
 java.util.List<com.archibus.db.ViewField.Immutable> getVisibleFields()
          Returns a list of visible fields.
 java.util.Map<java.lang.String,com.archibus.db.ViewField.Immutable> getVisibleFieldsByName()
          Returns a map of visible fields.
 boolean hasCustomQuery()
          Returns true if the data source uses custom SQL qeury.
 boolean hasMoreRecords()
          Returns true if preceding call to retrieveRecords() did not read all records due to record limit.
 boolean hasVirtualFields()
          Returns true if the data source defines virtual fields for custom SQL qeury.
 boolean isOracle()
          Returns true if the current database server is Oracle.
 boolean isSqlServer()
          Returns true if the current database server is SQL Server.
 boolean isSybase()
          Returns true if the current database server is Sybase.
 java.util.List<com.archibus.db.RestrictionBase.Immutable> parseClientRestrictions(java.lang.String restrictionString)
          Creates parsed or SQL restriction from the string input parameter.
 void queryRecords(DataSource.RecordHandler recordHandler)
          Executes SQL query and calls specified callback for each retrieved record.
 void queryRecords(java.lang.String restriction, DataSource.RecordHandler recordHandler)
          Executes SQL query and calls specified callback for each retrieved record.
 void rollback()
          Rollback current database transaction.
 DataRecord saveRecord(DataRecord record)
          Saves new or updates existing record.
 DataSource setAutoCommit(boolean autoCommit)
          Sets the autoCommit flag.
 DataSource setContext()
          Sets data source context and initializes context-dependent data source state based on the current thread context.
 DataSource setContext(com.archibus.config.ContextCacheable.Immutable context)
          Sets data source context and initializes context-dependent data source state.
 DataSource setContext(EventHandlerContext eventHandlerContext)
          Sets data source context and initializes context-dependent data source state.
 DataSource setDatabaseRole(java.lang.String role)
          Set database role for this DataSource to access.
 DataSource setDistinct(boolean isDistinct)
          Sets isDistinct flag.
 void setId(java.lang.String id)
           
 DataSource setMaxRecords(int maxRecords)
          Sets the max number of records that can be retrieved by consequent calls to retrieveRecords().
 DataSource setParameter(java.lang.String name, java.lang.Object value)
          Sets new value for specified parameter.
 void setTitle(java.lang.String title)
           
 DataSource setUseHierarchicalSecurityRestriction(boolean useHierarchicalSecurityRestriction)
          Sets the useHierarchicalSecurityRestriction property.
 

Field Detail

DB_ROLE_DATA

static final java.lang.String DB_ROLE_DATA
Constant for "data" database role. Can be used as an argument for setDatabaseRole() method. The "data" is the default database role that should be used to access most ARCHIBUS data.

See Also:
Constant Field Values

DB_ROLE_SCHEMA

static final java.lang.String DB_ROLE_SCHEMA
Constant for "schema" database role. Can be used as an argument for setDatabaseRole() method.

See Also:
Constant Field Values

DB_ROLE_SECURITY

static final java.lang.String DB_ROLE_SECURITY
Constant for "security" database role. Can be used as an argument for setDatabaseRole() method.

See Also:
Constant Field Values

ROLE_MAIN

static final java.lang.String ROLE_MAIN
Constant for "main" table role. Can be used as a "role" argument for addTable() method.

See Also:
Constant Field Values

ROLE_STANDARD

static final java.lang.String ROLE_STANDARD
Constant for "standard" table role. Can be used as a "role" argument for addTable() method.

See Also:
Constant Field Values

SORT_ASC

static final java.lang.String SORT_ASC
Constant for ascending sort order. Can be used as an "order" argument for addSort() method.

See Also:
Constant Field Values

SORT_DESC

static final java.lang.String SORT_DESC
Constant for descending sort order. Can be used as an "order" argument for addSort() method.

See Also:
Constant Field Values

DATA_TYPE_TEXT

static final java.lang.String DATA_TYPE_TEXT
Constant for text field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_NUMBER

static final java.lang.String DATA_TYPE_NUMBER
Constant for numeric field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_INTEGER

static final java.lang.String DATA_TYPE_INTEGER
Constant for integer field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_DATE

static final java.lang.String DATA_TYPE_DATE
Constant for date field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_TIME

static final java.lang.String DATA_TYPE_TIME
Constant for time field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_MEMO

static final java.lang.String DATA_TYPE_MEMO
Constant for memo field/parameter type.

See Also:
Constant Field Values

DATA_TYPE_VERBATIM

static final java.lang.String DATA_TYPE_VERBATIM
Constant for unformatted (verbatim) parameter type.

See Also:
Constant Field Values
Method Detail

setDatabaseRole

DataSource setDatabaseRole(java.lang.String role)
Set database role for this DataSource to access. If this method is not called, the "data" role is used. This is appropriate for most workflow rules.

Parameters:
role -

getFieldNames

java.util.List<java.lang.String> getFieldNames()
Returns:
the fieldNames

getTitle

java.lang.String getTitle()
Returns:
the title

setTitle

void setTitle(java.lang.String title)
Parameters:
title - the title to set

getId

java.lang.String getId()
Returns:
the id

setId

void setId(java.lang.String id)
Parameters:
id - the id to set

addTable

DataSource addTable(java.lang.String name)
Adds specified table to the data source query, as a "main" table.

Parameters:
name - Table name, i.e. "wr".

addTable

DataSource addTable(java.lang.String name,
                    java.lang.String role)
Adds specified table in specified role to the data source query.

Parameters:
name - Table name, i.e. "wr".
role - Table role, i.e. "standard".

addField

DataSource addField(java.lang.String name)
Adds specified main table field to the data source query.

Parameters:
name - Field name, i.e. "status".

addField

DataSource addField(java.lang.String[] names)
Adds specified main table fields to the data source query.

Parameters:
names - Array of field names.

addField

DataSource addField(java.lang.String table,
                    java.lang.String name)
Adds specified field to the data source query.

Parameters:
table - Table name, i.e. "wr".
name - Field name, i.e. "status".

addField

DataSource addField(java.lang.String table,
                    java.lang.String[] names)
Adds specified fields to the data source query.

Parameters:
table - Table name, i.e. "wr".
names - Array of field names.

addSort

DataSource addSort(java.lang.String name)
Adds a main table sort field to the data source query, in SORT_ASC mode.

Parameters:
name - Field name, i.e. "status".

addSort

DataSource addSort(java.lang.String table,
                   java.lang.String name)
Adds a sort field to the data source query, in SORT_ASC mode.

Parameters:
table - Table name, i.e. "wr".
name - Field name, i.e. "status".

addSort

DataSource addSort(java.lang.String table,
                   java.lang.String name,
                   java.lang.String order)
Adds a sort field to the data source query.

Parameters:
table - Table name, i.e. "wr".
name - Field name, i.e. "status".
order - Sort order: asc|desc.

addVirtualField

DataSource addVirtualField(java.lang.String table,
                           java.lang.String name,
                           java.lang.String dataType)
Adds a virtual field to the data source. Virtual fields are used to provide formatting for calculated columns in custom SQL queries.

Parameters:
table - Table name, matching the SQL query table alias.
name - Virtual field name, matching the calculated SQL column name.
dataType - Virtual field type: text|number|date|time|memo|verbatim.

addVirtualField

DataSource addVirtualField(java.lang.String table,
                           java.lang.String name,
                           java.lang.String dataType,
                           int size,
                           int decimals)
Adds a virtual field to the data source. Virtual fields are used to provide formatting for calculated columns in custom SQL queries.

Parameters:
table - Table name, matching the SQL query table alias.
name - Virtual field name, matching the calculated SQL column name.
dataType - Virtual field type: text|number|date|time|memo|verbatim.
size - For numeric field, the number of integer digits.
decimals - For numeric field, the number of fraction digits.

addVirtualField

DataSource addVirtualField(java.lang.String table,
                           java.lang.String name,
                           java.lang.String dataType,
                           int size,
                           int decimals,
                           java.lang.String title)

addCalculatedField

DataSource addCalculatedField(com.archibus.datasource.VirtualFieldDef calculatedField)
Adds a calculated field to the data source. Calculated fields are virtual fields that are based on SQL expressions.

Parameters:
calculatedField -
Returns:

addQuery

DataSource addQuery(java.lang.String sql)
Adds a generic dialect SQL query to the data source.

Parameters:
sql -

addQuery

DataSource addQuery(java.lang.String sql,
                    java.lang.String dialect)
Adds an SQL query to the data source.

Parameters:
sql -
dialect - SQL dialect: generic|sybase|oracle|sqlserver

getQueries

com.archibus.datasource.SqlExpressions getQueries()
Returns al custom queries.


addParameter

DataSource addParameter(java.lang.String name,
                        java.lang.String value,
                        java.lang.String dataType)
Adds a query parameter.

Parameters:
name - Parameter name.
value - Parameter value.
dataType - Parameter type, used to parse the value into an object.

addParameter

DataSource addParameter(java.lang.String name,
                        java.lang.Object value,
                        java.lang.String dataType)

addParameter

DataSource addParameter(java.lang.String name,
                        int value,
                        java.lang.String dataType)

addParameter

DataSource addParameter(java.lang.String name,
                        double value,
                        java.lang.String dataType)

getParameters

java.util.Map<java.lang.String,DataSourceImpl.Parameter> getParameters()
Returns all parameters.


addRestriction

DataSource addRestriction(Restrictions.Restriction r)
Adds a restriction.

Parameters:
r - Restriction.

addRestriction

DataSource addRestriction(Restrictions.Restriction.Clause c)
Adds a restriction clause.

Parameters:
c - Restriction clause.

clearRestrictions

DataSource clearRestrictions()
Clears all restrictions defined in AXVW.


setDistinct

DataSource setDistinct(boolean isDistinct)
Sets isDistinct flag.

Parameters:
isDistinct -

setUseHierarchicalSecurityRestriction

DataSource setUseHierarchicalSecurityRestriction(boolean useHierarchicalSecurityRestriction)
Sets the useHierarchicalSecurityRestriction property.

Parameters:
useHierarchicalSecurityRestriction -

setAutoCommit

DataSource setAutoCommit(boolean autoCommit)
Sets the autoCommit flag. If autoCommit is set, the DataSource commits changes after each data access call. Otherwise the WFR container commits changes after the WFR execution is finished.

Parameters:
autoCommit -
Returns:

createVirtualViewField

com.archibus.db.ViewField.Immutable createVirtualViewField(java.lang.String table,
                                                           java.lang.String name,
                                                           java.lang.String fieldJavaType,
                                                           java.text.NumberFormat format)
Creates and returns virtual view field for specified Java field type.

Parameters:
table - Virtual field table name.
name - Virtual field name.
fieldJavaType - Java class name, such as "java.lang.Double" or "java.sql.Date".
format - NumberFormat instance for numeric felds, or null for other fields.
Returns:
ViewField.Immutable.

setParameter

DataSource setParameter(java.lang.String name,
                        java.lang.Object value)
Sets new value for specified parameter.

Parameters:
name -
value -

setContext

DataSource setContext(com.archibus.config.ContextCacheable.Immutable context)
Sets data source context and initializes context-dependent data source state. This method is for use in presentation-layer classes (JSP tag handlers). In event handlers use the setContext(EventHandlerContext) method.

Parameters:
context - Web Central context object, typically a UserSession.

setContext

DataSource setContext(EventHandlerContext eventHandlerContext)
Sets data source context and initializes context-dependent data source state.

Parameters:
eventHandlerContext - WFR event handler context.

setContext

DataSource setContext()
Sets data source context and initializes context-dependent data source state based on the current thread context. Can be called from event handlers, or any Java code that is called by event handlers, including scheduled rules and long-running jobs.


getTablesAndRoles

java.util.List<DataSourceImpl.TableAndRole> getTablesAndRoles()
Returns a list of table names and roles.

Returns:
List

getVisibleFields

java.util.List<com.archibus.db.ViewField.Immutable> getVisibleFields()
Returns a list of visible fields. The list includes all fields that are specified by calling addField().

Returns:
List

getVirtualFields

java.util.List<com.archibus.db.ViewField.Immutable> getVirtualFields()
Returns a list of virtual fields.

Returns:
List

getVirtualFieldDef

com.archibus.datasource.VirtualFieldDef getVirtualFieldDef(java.lang.String tableName,
                                                           java.lang.String fieldName)
Returns specified virtual field definition.

Parameters:
tableName -
fieldName -
Returns:

getCalculatedFieldDef

com.archibus.datasource.VirtualFieldDef getCalculatedFieldDef(java.lang.String tableName,
                                                              java.lang.String fieldName)
Returns specified virtual field definition.

Parameters:
tableName -
fieldName -
Returns:

getVisibleFieldsByName

java.util.Map<java.lang.String,com.archibus.db.ViewField.Immutable> getVisibleFieldsByName()
Returns a map of visible fields. The list includes all fields that are specified by calling addField().

Returns:
Map

getRestrictions

java.util.List<Restrictions.Restriction> getRestrictions()
Returns a list of restriction definitions.

Returns:
List

getRestrictionValues

java.util.Map<java.lang.String,java.lang.Object> getRestrictionValues()
Returns restrictions values passed in from the client.

Returns:

getSortFields

java.util.List<DataSourceImpl.SortField> getSortFields()
Returns a list of sort field definitions.

Returns:
List

getMainTableName

java.lang.String getMainTableName()
Returns main table name.

Returns:

getMainTableDef

com.archibus.schema.TableDef.ThreadSafe getMainTableDef()
Returns main table definition.

Returns:

getPrimaryKeyFieldNamesForTable

java.util.List<java.lang.String> getPrimaryKeyFieldNamesForTable(java.lang.String tableName)
Returns a collection of the main table's primary key field names.

Returns:

hasCustomQuery

boolean hasCustomQuery()
Returns true if the data source uses custom SQL qeury.

Returns:

hasVirtualFields

boolean hasVirtualFields()
Returns true if the data source defines virtual fields for custom SQL qeury.

Returns:

getPrimaryKeyFields

java.util.List<com.archibus.db.ViewField.Immutable> getPrimaryKeyFields()
Returns a list of primary key fields. The list includes all primary key fields of the main table.

Returns:
List

findField

com.archibus.db.ViewField.Immutable findField(java.lang.String fullName)
Returns a field definition for specified full field name.

Parameters:
fullName - Full field name, i.e. "wr.status".
Returns:
ViewField.Immutable

findVirtualField

com.archibus.db.ViewField.Immutable findVirtualField(java.lang.String fullName)
Loop through the virtual fields for the current data source and Returns a field definition for specified full field name.

Parameters:
fullName - Full field name, i.e. "wr.status".
Returns:
ViewField.Immutable

getDbFieldsForVisibleFields

java.util.List<EventHandlerBase.DbField> getDbFieldsForVisibleFields()
Returns a list of DB field definitions for all fields defined in the data source. The list order matches the SELECT clause of the data source SQL query. If the SQL query is generated, the list includes all fields defined in the dataSource element. If the SQL query is custom, the list included all fields defined in the panel element.

Returns:
List

getAllFields

java.util.List<com.archibus.db.ViewField.Immutable> getAllFields()
Returns a list of field definitions for visible and/or virtual fields.


getDbFieldsForNewRecord

java.util.List<EventHandlerBase.DbField> getDbFieldsForNewRecord()
Returns a list of DB field definitions for default new record.

Returns:
List

getDbFieldsForPrimaryKeysAsMap

java.util.Map<java.lang.String,EventHandlerBase.DbField> getDbFieldsForPrimaryKeysAsMap()
Returns a map of DB field definitions for key fields.

Returns:
Map

createPrimaryKeyIds

org.json.JSONArray createPrimaryKeyIds()
Creates primary key column definitions in JSON format from the data source. For example, data record = {wr.wr_id='9500001', wr_requestor='afm'}, result = ['wr.wr_id'].

Returns:
JSONArray containing ID attributes of the primary key values in data records.

isSqlServer

boolean isSqlServer()
Returns true if the current database server is SQL Server.


isOracle

boolean isOracle()
Returns true if the current database server is Oracle.


isSybase

boolean isSybase()
Returns true if the current database server is Sybase.


parseClientRestrictions

java.util.List<com.archibus.db.RestrictionBase.Immutable> parseClientRestrictions(java.lang.String restrictionString)
Creates parsed or SQL restriction from the string input parameter.

Parameters:
restrictionString - can contain: - single XML record; - single JSON record; - multiple JSON records; - literal SQL expression;
Returns:

formatSqlQuery

java.lang.String formatSqlQuery(java.lang.String restriction,
                                boolean doNotWrap)
Formats and returns an SQL query based on:
  • previously added tables, fields, sort fields, restrictions, and custom SQL queries;
  • current user VPA restriction;
  • client-side restriction.

    Parameters:
    restriction - String containing client-side restriction in JSON format.
    doNotWrap - TODO
    Returns:

  • formatSqlQuery

    java.lang.String formatSqlQuery(java.lang.String restriction,
                                    java.util.List sortValues,
                                    java.util.List filterValues,
                                    boolean isOrderbyAllowed,
                                    boolean doNotWrap)
    Formats and returns an SQL query based on:
  • previously added tables, fields, sort fields, restrictions, and custom SQL queries;
  • current user VPA restriction;
  • client-side restriction.

    Parameters:
    restriction - String containing client-side restriction in JSON format.
    sortValues -
    filterValues -
    isOrderbyAllowed -
    doNotWrap - TODO
    Returns:

  • formatSqlForPersistentRestrictions

    java.lang.String formatSqlForPersistentRestrictions()
    Formats SQL expression that includes VPA and hierarchical security restrictions.


    getRecord

    DataRecord getRecord()
    Retrieves a single record that contains values for all fields defined in the data source.

    Returns:
    DataRecord, or null if no record can be found.

    getRecord

    DataRecord getRecord(java.lang.String restriction)
    Retrieves a single record that contains values for all fields defined in the data source.

    Returns:
    DataRecord, or null if no record can be found.

    getRecords

    java.util.List<DataRecord> getRecords()
    Retrieves records that contains values for all fields defined in the data source. If a record limit for DataSource has not been set using setMaxRecords() method, applies global record limit defined in afm-config.xml.

    Returns:
    List of records.

    getRecords

    java.util.List<DataRecord> getRecords(java.lang.String restriction)
    Retrieves records that contains values for all fields defined in the data source. If a record limit for DataSource has not been set using setMaxRecords() method, applies global record limit defined in afm-config.xml.

    Parameters:
    restriction - Client-supplied restriction string, or null.
    Returns:
    List of records.

    getAllRecords

    java.util.List<DataRecord> getAllRecords()
    Retrieves records that contains values for all fields defined in the data source, using no record limit. WARNING: when record limit is not set, retrieving all records can take extremely long time and even lead to out-of-memory errors on very large database tables.

    Returns:
    List of records.

    queryRecords

    void queryRecords(DataSource.RecordHandler recordHandler)
    Executes SQL query and calls specified callback for each retrieved record.

    Parameters:
    recordHandler -

    queryRecords

    void queryRecords(java.lang.String restriction,
                      DataSource.RecordHandler recordHandler)
    Executes SQL query and calls specified callback for each retrieved record.

    Parameters:
    recordHandler -

    saveRecord

    DataRecord saveRecord(DataRecord record)
    Saves new or updates existing record. Returns the last saved record if the table PK is autonumbered.

    Parameters:
    record - DataRecord containing record values to be saved and old values.
    Returns:
    DataRecord containing saved field values, or null if the table PK is not autonumbered.

    deleteRecord

    void deleteRecord(DataRecord record)
    Deletes existing record.

    Parameters:
    record - DataRecord containing record to be deleted.

    deleteRecord

    void deleteRecord(java.util.Map fieldValues)
    Deletes record specified by field values.

    Parameters:
    fieldValues - Map containing record values.

    createRecord

    DataRecord createRecord()
    Creates new DataRecord with default values for all fields defined in the data source.

    Returns:
    DataRecord

    createNewRecord

    DataRecord createNewRecord()
    Creates new DataRecord with default values for all fields defined in the data source.

    Returns:
    DataRecord

    createRecordFromContext

    DataRecord createRecordFromContext()
    Creates new DataRecord with default values for all fields defined in the data source. Copies all input values set in the EventHandlerContext to the record.

    Returns:
    DataRecord

    getDefaultRecord

    DataRecord getDefaultRecord(java.lang.String restriction)
    Returns DataRecord with default values for all fields defined in the data source.

    Parameters:
    restriction - Client-supplied restriction string, or null.
    Returns:
    DataRecord

    executeUpdate

    void executeUpdate()
    Executes SQL update query, set using addQuery().


    setMaxRecords

    DataSource setMaxRecords(int maxRecords)
    Sets the max number of records that can be retrieved by consequent calls to retrieveRecords().

    Parameters:
    maxRecords - Positive number, or 0 to read all available records without limit.

    hasMoreRecords

    boolean hasMoreRecords()
    Returns true if preceding call to retrieveRecords() did not read all records due to record limit.

    Returns:

    commit

    void commit()
    Commit current database transaction.


    rollback

    void rollback()
    Rollback current database transaction.



    Copyright © 2009 ARCHIBUS, Inc. All Rights Reserved.