Class BasicDataSource
- All Implemented Interfaces:
com.isomorphic.base.IAutoConfigurable
,com.isomorphic.datasource.Committable
,com.isomorphic.datasource.FreeResourcesHandler
,com.isomorphic.datasource.IType
,IToJSON
,Serializable
- Direct Known Subclasses:
AIDataSource
,HibernateDataSource
,JPADataSource
,RestConnector
,SQLDataSource
BasicDataSource is the right class to extend when creating a custom DataSource connector.
- See Also:
-
Field Summary
Fields inherited from class com.isomorphic.datasource.DataSource
OP_ADD, OP_CLIENT_EXPORT, OP_CUSTOM, OP_DOWNLOAD_FILE, OP_FETCH, OP_GET_FILE, OP_GET_FILE_VERSION, OP_HAS_FILE, OP_HAS_FILE_VERSION, OP_LIST_FILE_VERSIONS, OP_LIST_FILES, OP_LOAD_SCHEMA, OP_REMOVE, OP_REMOVE_FILE, OP_REMOVE_FILE_VERSION, OP_RENAME_FILE, OP_SAVE_FILE, OP_UNIQUE_NAME, OP_UPDATE, OP_VALIDATE, OP_VIEW_FILE
-
Method Summary
Modifier and TypeMethodDescriptionThis method returns the auditDataSource
associated with thisDataSource
if it has the audit=true property set.getAuditRecord
(DSRequest req, Map inValues) Convenience version of thethree-argument version
, but the third argument (oldvalues) is null, so is not suitable for "update" requestsgetAuditRecord
(DSRequest req, Map inValues, Map oldValues) Given a base record, a contextDSRequest
and optionally an "old" record, returns a record with all the audit fields populated in accordance with the rules specified in theDataSource
's audit configuration.boolean
Returns true if this dataSource declares a custom default fetch operation: that is, anoperationBinding
withoperationType "fetch"
and no declaredoperationId
boolean
Returns true if this dataSource declares either aserverObject
orserverScript
property (see the client-side docs for details of those two properties).boolean
shouldAutoJoinTransaction
(DSRequest dsRequest) Returns true if the parameter DSRequest should automatically join an existing transaction, taking into account the DSRequest-specific override provided byDSRequest.setJoinTransaction(java.lang.Boolean)
, thetransaction policy
of the controlling RPCManager (if there is one), and autoJoinTransactions settings at the operationBinding, DataSource, dbName and global system levels.boolean
shouldAutoStartTransaction
(DSRequest req, boolean ignoreExistingTransaction) Returns true if the parameter DSRequest should automatically start a new transaction, taking into account the DSRequest-specific override provided byDSRequest.setJoinTransaction(java.lang.Boolean)
, thetransaction policy
of the controlling RPCManager (if there is one), and autoJoinTransactions settings at the operationBinding, DataSource, dbName and global system levelsvoid
Transforms the values for fields declared multiple:true in the incoming DSRequest.void
transformMultipleFields
(DSResponse res, DSRequest req) Transform the values for fields declared multiple:true in a DSResponse.protected void
writeMultiAudits
(List valueSets, DSRequest originatingDSRequest) Writes a collection of audit records to the audit DataSource associated with this DataSource.Methods inherited from class com.isomorphic.datasource.DataSource
add, add, addDynamicDSGenerator, addDynamicDSGenerator, addDynamicDSGenerator, clearDynamicDSGenerators, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, execute, executeAdd, executeCustom, executeFetch, executeFileSource, executeRemove, executeUpdate, fetch, fetch, fetchById, fetchById, fetchById, fetchSingle, fetchSingle, filter, filter, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, fromXML, get1ManyRelationFields, getAuditChangedFieldsFieldName, getAuditRevisionFieldName, getAuditTimestampFieldName, getAuditTypeFieldName, getAuditUserFieldName, getDefaultDynamicDSGenerator, getDirectFields, getDynamicDSGenerators, getEnumConstantProperty, getEnumOrdinalProperty, getEnumTranslateStrategy, getFieldNames, getFile, getFileAsInputStream, getFileAsString, getFileContentsField, getFileFormatField, getFileNameField, getFileTypeField, getID, getJoinDSName, getJoinDSName, getListProperties, getListProperties, getListProperty, getManyManyRelationFields, getMapProperty, getName, getNonIncludedFields, getObjectProperty, getOperationProperty, getPrimaryKey, getProperties, getProperties, getProperties, getProperty, getPropertyJavaClass, getRecordXPath, getRelatedDisplayRecord, getRelatedDisplayRecord, getRelatedDSName, getRelatedDSName, getRelatedTableAlias, getRelationFields, getTableName, getTransactionObject, getTransactionObject, has1ManyRelationFields, hasFile, hasManyManyRelationFields, hasRecord, hasRecord, hasRelationFields, initialized, is1ManyRelationField, isManyManyRelationField, isModificationOperation, isRelationField, isServerOnly, listFiles, listFiles, listFiles, listFiles, listFiles, listFiles, remove, removeDynamicDSGenerator, removeDynamicDSGenerator, removeDynamicDSGenerator, removeFile, renameFile, saveFile, setEnumConstantProperty, setEnumOrdinalProperty, setEnumTranslateStrategy, setOmitNullMapValuesInResponse, setProperties, transformImportValue, transformImportValue, transformResponse, update, update, validate, validate, validate, validateRecord
-
Method Details
-
getAuditRecord
Convenience version of thethree-argument version
, but the third argument (oldvalues) is null, so is not suitable for "update" requests- Parameters:
req
- DSRequest required to provide context essential to generating correct audit properties (for example, so we know the type of operation)inValues
- The "base record" to provide an audit record for- Returns:
- a record populated with audit values, based on the base record
- Throws:
Exception
- if an error occurs while generating the audit record
-
getAuditRecord
Given a base record, a contextDSRequest
and optionally an "old" record, returns a record with all the audit fields populated in accordance with the rules specified in theDataSource
's audit configuration. This includes dropping fields that are markedaudit: never
, for example. See the client-side docs for the DataSource "audit" property for a full discussion of the options.This method is used by SmartClient's automatic auditing facility, but it can also be called from user code (eg, from a DMI) if you wish to leverage the framework's ability to generate audit records in accordance with the configuration rules, for some manual process.
- Parameters:
req
- DSRequest required to provide context essential to generating correct audit properties (for example, so we know the type of operation)inValues
- The "base record" to provide an audit record foroldValues
- The record as it was prior to updating, generally available from the request'soldValues
. This parameter is only applicable to "update" operations; if it is not supplied for an update operation, we are unable to generate a fully correct audit record because we cannot populate the "changedFields" value- Returns:
- a record populated with audit values, based on the base record
- Throws:
Exception
- if an error occurs while generating the audit record
-
writeMultiAudits
Writes a collection of audit records to the audit DataSource associated with this DataSource. Is only applicable to suitable originating operations of type "add"; a "suitable" operation is one that added multiple records in a batch using the "multipleValues" strategy (scan the client-side documentation for "multiInsertStrategy"), and was for a dataSource that has no fields of type "sequence"Note, the framework will call this method automatically in the appropriate circumstances, as long as the "sql.multi.insert.allowAudit" flag is set to
true
in yourserver.properties
file. Alternatively, you can call it manually from your own code.- Parameters:
valueSets
- List of records to write audit records fororiginatingDSRequest
- The "add" DSRequest that wrote the records we are going to audit. Required for essential context- Throws:
Exception
- if an error occurs while writing audit records
-
shouldAutoStartTransaction
public boolean shouldAutoStartTransaction(DSRequest req, boolean ignoreExistingTransaction) throws Exception Returns true if the parameter DSRequest should automatically start a new transaction, taking into account the DSRequest-specific override provided byDSRequest.setJoinTransaction(java.lang.Boolean)
, thetransaction policy
of the controlling RPCManager (if there is one), and autoJoinTransactions settings at the operationBinding, DataSource, dbName and global system levelsThis method is part of the Automatic Transactions feature, which is effective only in Power edition and above.
- Parameters:
req
- The DSRequest to checkignoreExistingTransaction
- If true, indicates that we should not take into account any existing transaction for this RPCManager when deciding if a transaction should be autoStarted. This is useful if you want to know if a request would have started a new transaction if one hadn't already been started.- Returns:
- true if a transaction should be auto-started for this request
- Throws:
Exception
- if an error occurs while checking transaction settings
-
shouldAutoJoinTransaction
Returns true if the parameter DSRequest should automatically join an existing transaction, taking into account the DSRequest-specific override provided byDSRequest.setJoinTransaction(java.lang.Boolean)
, thetransaction policy
of the controlling RPCManager (if there is one), and autoJoinTransactions settings at the operationBinding, DataSource, dbName and global system levels.This method is part of the Automatic Transactions feature, which is effective only in Power edition and above.
- Parameters:
dsRequest
- The DSRequest to check.- Returns:
- true if the request should auto-join an existing transaction
- Throws:
Exception
- if an error occurs while checking transaction settings
-
getAuditDataSource
This method returns the auditDataSource
associated with thisDataSource
if it has the audit=true property set.The audit
DataSource
can only be accessed by ID if the originalDataSource
has been accessed first.- Returns:
- The audit
DataSource
if audit was enabled, or null.
-
transformMultipleFields
Transforms the values for fields declared multiple:true in the incoming DSRequest. This allows advanced queries to take place on fields declared as multiple:true.See client-side docs for DataSourceField.multipleStorage for possible behaviors. This transformation is performed in DataSource.execute(), before operationType-specific methods like executeFetch or executeUpdate() are called.
- Overrides:
transformMultipleFields
in classDataSource
- Parameters:
req
- the request to be transformed.
-
transformMultipleFields
Transform the values for fields declared multiple:true in a DSResponse.See client-side docs for DataSourceField.multipleStorage for possible behaviors. This transformation is performed in DataSource.execute(), after operationType-specific methods like executeFetch or executeUpdate() are called.
- Overrides:
transformMultipleFields
in classDataSource
- Parameters:
res
- the DSResponse to be transformed.req
- the corresponding DSRequest, for context
-
hasCustomLogic
public boolean hasCustomLogic()Returns true if this dataSource declares either aserverObject
orserverScript
property (see the client-side docs for details of those two properties). Note, you can also add custom logic to a DataSource by creating a custom subclass and overriding theexecute(()
method (for example), but this method does not take account of such customizations. If you need to know if a DataSource instance might have custom logic by virtue of being a subclass, you can use native Java approaches: either do an instanceof check, or override
hasCustomLogic()
in yout subclass and cause it to return true. -
hasCustomDefaultFetchOperation
public boolean hasCustomDefaultFetchOperation()Returns true if this dataSource declares a custom default fetch operation: that is, anoperationBinding
withoperationType "fetch"
and no declaredoperationId
-