Example code for data source operation execution with manual transaction handling:
DSRequest req = new DSRequest("myDS", "fetch"); req.setFreeOnExecute(false); DSResponse resp = req.execute(); List dataList = resp.getDataList(); //... traverse through persistent object tree // Commit current transaction. ((JPADataSource) r.getDataSource()).onSuccess(); // Release entity manager. ((JPADataSource) r.getDataSource()).freeResources(req);Implementation is not thread-safe. Data source acquiring mechanism ensures that single instance of this class will be used in one thread only.
DSRequest
.static final String
static final String
protected Class
protected String
protected String
protected JPAConnectionHolder
protected jakarta.persistence.EntityManager
static final Character
protected Boolean
static final String
protected Class
static final String
protected List<DSResponse>
static final String
protected boolean
protected boolean
protected Object
static final String
protected Boolean
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
static String
escapeValueForFilter(Object value, char escapeChar)
executeAdd(DSRequest req)
executeFetch(DSRequest req)
executeRemove(DSRequest dsRequest)
executeUpdate(DSRequest req)
void
freeResources(DSRequest req)
EntityManager
.DSField
by specified name.getFieldNames(boolean dropIgnored)
getTransactionObjectKey(boolean longForm)
void
void
void
markTransactionForRollBack(DSResponse dsResponse)
getAuditDataSource, getAuditRecord, getAuditRecord, hasCustomDefaultFetchOperation, hasCustomLogic, shouldAutoJoinTransaction, shouldAutoStartTransaction, transformMultipleFields, transformMultipleFields, writeMultiAudits
add, add, addDynamicDSGenerator, addDynamicDSGenerator, addDynamicDSGenerator, clearDynamicDSGenerators, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, convertRelativeDates, executeFileSource, 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
false
- simple class name usage. To resolve class name collisions this setting can be set to true
(should be used with provider supporting fully-qualified class name usage).DSRequest
.execute()
call. true
- related updates will be generated; false
- related updates will not be generated; null
- related updates will be generated only for "add" and "update" operations, related updates will not be generated for "remove" operation.Exception
schemaBean
- String
Fully qualified class name.id
- String
Id for newly created data source.extended
- boolean
Extended properties will be captured if set to true
.Map<String, Object>
created data source configuration or null
if it can not be created.dropIgnored
- boolean
true
- ignored fields are dropped; false
- ignored fields are included;List
field names.DSField
by specified name. First checks data source configured fields. Checks request configured fields if it is not found within data source configured fields. Returns null
if fieldName
parameter is null
or field is not found.getField
in class BasicDataSource
fieldName
- the name of the field whose definition you wantDSField
field.DataSource.transformMultipleFields(DSRequest)
and DataSource.transformMultipleFields(DSResponse)
.execute
in class DataSource
req
- The DSRequest object representing this operationException
- if an error occurs during request executionexecuteFetch
in class DataSource
req
- The DSRequest object representing this operationException
- if an error occurs during the fetch operationexecuteAdd
in class DataSource
req
- The DSRequest object representing this operationException
- if an error occurs during the add operationexecuteRemove
in class DataSource
dsRequest
- The DSRequest object representing this operationException
- if an error occurs during the remove operationexecuteUpdate
in class DataSource
req
- The DSRequest object representing this operationException
- if an error occurs during the update operationvalue
- Object
Value which should be escaped.escapeChar
- char
escape character.String
Escaped string value.DSResponse
is provided - sets it's status to failure.dsResponse
- DSResponse
status will be set to failure if provided. Can be null
.EntityManager
. When participating in automatic transactions - closes EntityManager
stored in connectionHolder
object. If connectionHolder
is not initialized (meaning we did not participate in automatic transaction) - closes current EntityManager
.