T - Bean class.public abstract class ObjectDataSourceImpl<T> extends DataSourceImpl implements ObjectDataSource<T>
In addition to methods provided by the regular DataSourceImpl that retrieve/update/delete generic DataRecords, it provides methods that retrieve/update/delete custom objects. These methods convert objects to/from DataRecords and then delegate to the DataSourceImpl methods to persist these DataRecords. For ORM, this class uses Spring BeanWrapper: http://static.springsource.org/spring/docs/2.5.x/reference/validation.html. The BeanWrapper supports nested properties. See DrawingPropertiesDataSource.createFieldToPropertyMapping() for an example.
DataSourceImpl.Parameter, DataSourceImpl.SortField, DataSourceImpl.TableAndRoleDataSource.RecordHandler| Modifier and Type | Field and Description |
|---|---|
protected java.lang.String |
beanName
Spring bean name.
|
static java.lang.String |
DOT
Constant: "." - SQL separator between table and field names.
|
protected java.util.Map<java.lang.String,java.lang.String> |
fieldToPropertyMapping
Map contains database field names as keys and Cost property names as values.
|
protected java.lang.String |
tableName
Database table name.
|
applyVpaRestrictions, basicRulesLog, calculatedFieldDefs, CASCADE_HANDLER, cascadeHandler, customSqlQueries, database, databaseRole, dataSourceDef, doNotWrapCustomSql, eventHandlerContext, expressionContext, fieldNames, fieldNamesForNewRecord, hasMoreRecords, isAutoCommit, isDistinct, keyFieldsByFullName, locale, log, mainTableDef, mainTableName, maxRecords, parameters, parametersChanged, parentContext, persistentRestrictions, primaryKeyFields, project, query, restrictions, restrictionValues, SCRIPT_INJECTION_HANDLER, scriptInjectionHandler, sortFields, SQL_INJECTION_HANDLER, sqlInjectionHandler, standardQueries, tablesAndRoles, useHierarchicalSecurityRestriction, virtualFieldDefs, virtualFields, visibleFields, visibleFieldsByNameDATA_TYPE_BOOLEAN, DATA_TYPE_CURRENCY, DATA_TYPE_DATE, DATA_TYPE_DOUBLE, DATA_TYPE_INTEGER, DATA_TYPE_MEMO, DATA_TYPE_NUMBER, DATA_TYPE_TEXT, DATA_TYPE_TIME, DATA_TYPE_VERBATIM, DB_ROLE_DATA, DB_ROLE_SCHEMA, DB_ROLE_SECURITY, ROLE_MAIN, ROLE_STANDARD, SORT_ASC, SORT_DESC| Modifier | Constructor and Description |
|---|---|
protected |
ObjectDataSourceImpl(java.lang.String beanName,
java.lang.String tableName)
Constructor, called from concrete subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addAllFields()
Adds fields specified by getFieldsToProperties() method to the DataSource.
|
protected void |
convertObjectToRecord(T bean,
com.archibus.datasource.data.DataRecord record,
boolean includeAutonumberedFields)
Converts the bean instance to a data record.
|
protected void |
convertObjectToRecord(T bean,
T oldBean,
com.archibus.datasource.data.DataRecord record,
boolean includeAutonumberedFields)
Converts two bean instances (new and old) to a data record that can be saved to the database.
|
protected java.util.List<T> |
convertRecordsToObjects(java.util.List<com.archibus.datasource.data.DataRecord> records)
Converts the list of data records to the list of bean instances.
|
T |
convertRecordToObject(com.archibus.datasource.data.DataRecord record)
Converts the data record to a bean instance.
|
protected java.util.Map<java.lang.String,java.lang.String> |
createFieldToPropertyMapping()
Creates field-to-property mapping.
|
protected java.util.Map<java.lang.String,java.lang.String> |
createFieldToPropertyMapping(java.lang.String[][] fieldsToProperties)
Creates full field name-to-property mapping from the supplied fieldsToProperties, which
contains field name to property name mapping.
|
void |
delete(T bean) |
java.util.List<T> |
find(com.archibus.model.view.datasource.AbstractRestrictionDef restriction) |
T |
get(java.lang.Object id) |
T |
get(com.archibus.datasource.PrimaryKeysValues pkValues)
Returns the persistent object with the given PK values, or null if there is no such object.
|
protected abstract java.lang.String[][] |
getFieldsToProperties()
Gets field name to property name mapping.
|
boolean |
isIdLookupEnabled()
Whether this data source can use lookup fields.
|
T |
save(T bean) |
void |
update(T bean) |
void |
update(T bean,
T oldBean) |
addCalculatedField, addField, addField, addField, addField, addParameter, addParameter, addParameter, addParameter, addPersistentRestrictions, addQuery, addQuery, addRestriction, addRestriction, addRestrictionsToQuery, addSort, addSort, addSort, addTable, addTable, addVirtualField, addVirtualField, addVirtualField, checkAutoCommit, checkSetContext, clearRestrictions, commit, copyProperties, createCopy, createNewRecord, createPrimaryKeyIds, createRecord, createRecordFromContext, createSqlForLastAddedPK, createVirtualField, createVirtualViewField, deleteRecord, deleteRecord, enableIdLookup, evaluateExpressions, evaluateSqlExpressions, executeUpdate, executeUpdateRequired, findField, findKeyField, findTable, findVirtualField, formatJoin, formatSqlForPersistentRestrictions, formatSqlForPersistentRestrictionsForTable, formatSqlForPersistentRestrictionsForTableAndRole, formatSqlForRestriction, formatSqlQuery, formatSqlQuery, formatSqlQuery, formatSqlQuery, formatSqlQueryForField, getAllFields, getAllRecords, getCalculatedFieldDef, getContext, getDatabaseRole, getDataSourceDef, getDbFieldsForNewRecord, getDbFieldsForPrimaryKeys, getDbFieldsForPrimaryKeysAsMap, getDbFieldsForVisibleFields, getDefaultRecord, getFieldNames, getId, getMainTableDef, getMainTableName, getParameters, getPKeyFieldNamesForTable, getPrimaryKeyFieldNamesForTable, getPrimaryKeyFields, getQueries, getQueryInstance, getRecord, getRecord, getRecords, getRecords, getRecords, getRecords, getRecords, getRecords, getRestrictionRelativeOperation, getRestrictions, getRestrictionValues, getSortFields, getTablesAndRoles, getTitle, getViewName, getVirtualFieldDef, getVirtualFields, getVisibleFields, getVisibleFieldsByName, hasCustomQuery, hasMoreRecords, hasVirtualFields, isDistinct, isOracle, isSqlServer, isSybase, parseClientRestrictions, queryRecords, queryRecords, rollback, saveRecord, setApplyVpaRestrictions, setAutoCommit, setContext, setContext, setContext, setDatabaseRole, setDataSourceDef, setDistinct, setDoNotWrapCustomSql, setId, setMaxRecords, setParameter, setRestrictionRelativeOperation, setTitle, setUseHierarchicalSecurityRestriction, setViewName, updateRecord, useCascadeHandler, useVirtualFieldsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddCalculatedField, addField, addField, addField, addField, addParameter, addParameter, addParameter, addParameter, addQuery, addQuery, addRestriction, addRestriction, addSort, addSort, addSort, addTable, addTable, addVirtualField, addVirtualField, addVirtualField, clearRestrictions, commit, createNewRecord, createPrimaryKeyIds, createRecord, createRecordFromContext, createVirtualViewField, deleteRecord, deleteRecord, enableIdLookup, executeUpdate, executeUpdateRequired, findField, findVirtualField, formatJoin, formatSqlForPersistentRestrictions, formatSqlForPersistentRestrictionsForTable, formatSqlForPersistentRestrictionsForTableAndRole, formatSqlForRestriction, formatSqlQuery, formatSqlQuery, formatSqlQueryForField, getAllFields, getAllRecords, getCalculatedFieldDef, getDataSourceDef, getDbFieldsForNewRecord, getDbFieldsForPrimaryKeysAsMap, getDbFieldsForVisibleFields, getDefaultRecord, getFieldNames, getId, getMainTableDef, getMainTableName, getParameters, getPrimaryKeyFieldNamesForTable, getPrimaryKeyFields, getQueries, getRecord, getRecord, getRecords, getRecords, getRecords, getRecords, getRecords, getRecords, getRestrictions, getRestrictionValues, getSortFields, getTablesAndRoles, getTitle, getViewName, getVirtualFieldDef, getVirtualFields, getVisibleFields, getVisibleFieldsByName, hasCustomQuery, hasMoreRecords, hasVirtualFields, isDistinct, isOracle, isSqlServer, isSybase, parseClientRestrictions, queryRecords, queryRecords, rollback, saveRecord, setApplyVpaRestrictions, setAutoCommit, setContext, setContext, setContext, setDatabaseRole, setDataSourceDef, setDistinct, setId, setMaxRecords, setParameter, setTitle, setUseHierarchicalSecurityRestriction, setViewName, updateRecordpublic static final java.lang.String DOT
protected final java.lang.String beanName
protected final java.lang.String tableName
protected java.util.Map<java.lang.String,java.lang.String> fieldToPropertyMapping
protected ObjectDataSourceImpl(java.lang.String beanName,
java.lang.String tableName)
tableName - Database table name.beanName - Spring bean name.public boolean isIdLookupEnabled()
isIdLookupEnabled in interface DataSourceisIdLookupEnabled in class DataSourceImplprotected abstract java.lang.String[][] getFieldsToProperties()
public T get(com.archibus.datasource.PrimaryKeysValues pkValues)
get in interface ObjectDataSource<T>pkValues - Primary key values.public java.util.List<T> find(com.archibus.model.view.datasource.AbstractRestrictionDef restriction)
find in interface com.archibus.core.dao.IDao<T>public void update(T bean, T oldBean)
update in interface com.archibus.core.dao.IDao<T>public T convertRecordToObject(com.archibus.datasource.data.DataRecord record)
record - The data record.protected java.util.List<T> convertRecordsToObjects(java.util.List<com.archibus.datasource.data.DataRecord> records)
records - The list of data record.protected void convertObjectToRecord(T bean, com.archibus.datasource.data.DataRecord record, boolean includeAutonumberedFields)
bean - The bean instance.record - The data record with all fields.includeAutonumberedFields - If true, all field values including auto-numbered are copied
to the record; if false, only non-auto-numbered field values are copied.protected void convertObjectToRecord(T bean, T oldBean, com.archibus.datasource.data.DataRecord record, boolean includeAutonumberedFields)
bean - The bean instance with changed values.oldBean - The bean instance with previous values (as existed in the database).record - The data record with all fields.includeAutonumberedFields - If true, all field values including auto-numbered are copied
to the record; if false, only non-auto-numbered field values are copied.protected java.util.Map<java.lang.String,java.lang.String> createFieldToPropertyMapping(java.lang.String[][] fieldsToProperties)
fieldsToProperties - protected java.util.Map<java.lang.String,java.lang.String> createFieldToPropertyMapping()
protected void addAllFields()