Class UniqueObjectRepositoryImpl<U extends de.digitalcollections.model.UniqueObject>
java.lang.Object
de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingSortingFilteringRepositoryImpl
de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl<U>
de.digitalcollections.cudami.server.backend.impl.jdbi.UniqueObjectRepositoryImpl<U>
- All Implemented Interfaces:
PagingSortingFilteringRepository<U>,UniqueObjectRepository<U>
- Direct Known Subclasses:
HeadwordRepositoryImpl,IdentifiableRepositoryImpl,IdentifierRepositoryImpl,IdentifierTypeRepositoryImpl,LicenseRepositoryImpl,PredicateRepositoryImpl,RenderingTemplateRepositoryImpl,SubjectRepositoryImpl,TagRepositoryImpl,UrlAliasRepositoryImpl,UserRepositoryImpl
public abstract class UniqueObjectRepositoryImpl<U extends de.digitalcollections.model.UniqueObject>
extends JdbiRepositoryImpl<U>
implements UniqueObjectRepository<U>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> protected final BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> protected final BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> protected final Class<? extends de.digitalcollections.model.UniqueObject>Fields inherited from class de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl
dbi, mappingPrefix, tableAlias, tableNameFields inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingSortingFilteringRepositoryImpl
offsetForAlternativePaging -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedUniqueObjectRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class<? extends de.digitalcollections.model.UniqueObject> uniqueObjectImplClass, int offsetForAlternativePaging) -
Method Summary
Modifier and TypeMethodDescriptionprotected BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> For details select (only used in find one, not lists): if additional objects should be "joined" into instance, set bi function for doing this.protected BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> Create basic reduce rows biconsumer for reduced selects (lists, paging)protected BiConsumer<Map<UUID,U>, org.jdbi.v3.core.result.RowView> Create full reduce rows biconsumer for full selects (find one).
For a plain UniqueObject full ad basic are the same (minimal dataset of uuid, lastModified, created).booleandeleteByUuid(UUID uuid) intdeleteByUuids(List<UUID> uuids) execSelectForList(String sql, Map<String, Object> bindings) protected UUID[]extractUuids(Collection<? extends de.digitalcollections.model.UniqueObject> uniqueObjects) de.digitalcollections.model.list.paging.PageResponse<U>find(de.digitalcollections.model.list.paging.PageRequest pageRequest) protected de.digitalcollections.model.list.paging.PageResponse<U>protected de.digitalcollections.model.list.paging.PageResponse<U>find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql, Map<String, Object> argumentMappings) protected de.digitalcollections.model.list.paging.PageResponse<U>find(de.digitalcollections.model.list.paging.PageRequest pageRequest, Map<String, Object> argumentMappings) getByUuidAndFiltering(UUID uuid, de.digitalcollections.model.list.filtering.Filtering filtering) getColumnName(String modelProperty) intgetIndex(List<? extends de.digitalcollections.model.UniqueObject> list, de.digitalcollections.model.UniqueObject uniqueObject) intOn insert or update these fields will be returned to be processed byinsertUpdateCallback(UniqueObject, Map).protected Stringprotected StringDo not change order! Must match order in getSqlInsertFields!!!SQL-snippet for fields to be returned for complete field request.
If already all fields are returned with reduced fields request: just return reduced field set here, otherwise add additional fields to reduced set to get all fields.getSqlSelectAllFields(String tableAlias, String mappingPrefix) protected StringgetSqlSelectReducedFields(String tableAlias, String mappingPrefix) protected Stringprotected Stringprotected Stringprotected voidinsertUpdateCallback(U uniqueObject, Map<String, Object> returnedFields) After save and update the returned fields (declared ingetReturnedFieldsOnInsertUpdate()) can be processed here.longretrieveCount(StringBuilder sqlCount, Map<String, Object> argumentMappings) retrieveList(String fieldsSql, StringBuilder innerQuery, Map<String, Object> argumentMappings, String orderBy) retrieveList(String fieldsSql, String fieldsSqlAdditionalJoins, StringBuilder innerQuery, Map<String, Object> argumentMappings, String orderBy) protected UretrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins) protected UretrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins, Map<String, Object> argumentMappings) protected UretrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins, Map<String, Object> argumentMappings, String innerSelect) voidvoidsave(U uniqueObject, Map<String, Object> bindings, BiFunction<String, Map<String, Object>, String> sqlModifier) static StringsqlSelectReducedFields(String tableAlias, String mappingPrefix) voidvoidupdate(U uniqueObject, Map<String, Object> bindings, BiFunction<String, Map<String, Object>, String> sqlModifier) Methods inherited from class de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl
addFiltering, addFiltering, count, count, escapeTermForJsonpath, execUpdateWithList, execUpdateWithMap, filterByLocalizedTextFields, filterBySplitField, getJsonbFields, getMappingPrefix, getTableAlias, getTableName, getTargetExpression, getWhereClause, getWhereClauses, hasSplitColumn, mapFilterExpressionsToOtherTableColumnNames, retrieveNextSortIndexForParentChildren, splitToArray, splitToArrayMethods inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingSortingFilteringRepositoryImpl
addOrderBy, addPagingAndSorting, getOrderBy, supportsCaseSensitivityForPropertyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.digitalcollections.cudami.server.backend.api.repository.UniqueObjectRepository
count, create, delete, delete, getByExample, getByExampleAndFiltering, getByUuid, getRandom, save, saveOrUpdate, update
-
Field Details
-
additionalReduceRowsBiConsumer
protected final BiConsumer<Map<UUID,U extends de.digitalcollections.model.UniqueObject>, additionalReduceRowsBiConsumerorg.jdbi.v3.core.result.RowView> -
basicReduceRowsBiConsumer
protected final BiConsumer<Map<UUID,U extends de.digitalcollections.model.UniqueObject>, basicReduceRowsBiConsumerorg.jdbi.v3.core.result.RowView> -
fullReduceRowsBiConsumer
protected final BiConsumer<Map<UUID,U extends de.digitalcollections.model.UniqueObject>, fullReduceRowsBiConsumerorg.jdbi.v3.core.result.RowView> -
uniqueObjectImplClass
-
-
Constructor Details
-
UniqueObjectRepositoryImpl
protected UniqueObjectRepositoryImpl() -
UniqueObjectRepositoryImpl
-
-
Method Details
-
sqlSelectReducedFields
-
createAdditionalReduceRowsBiConsumer
protected BiConsumer<Map<UUID,U>, createAdditionalReduceRowsBiConsumer()org.jdbi.v3.core.result.RowView> For details select (only used in find one, not lists): if additional objects should be "joined" into instance, set bi function for doing this.- Returns:
- BiConsumer function
-
createBasicReduceRowsBiConsumer
Create basic reduce rows biconsumer for reduced selects (lists, paging)- Returns:
- BiConsumer function
-
createFullReduceRowsBiConcumer
Create full reduce rows biconsumer for full selects (find one).
For a plain UniqueObject full ad basic are the same (minimal dataset of uuid, lastModified, created).- Returns:
- BiConsumer function
-
deleteByUuid
- Specified by:
deleteByUuidin interfaceUniqueObjectRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
deleteByUuids
- Specified by:
deleteByUuidsin interfaceUniqueObjectRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
execSelectForList
protected List<U> execSelectForList(String sql, Map<String, Object> bindings) throws RepositoryException- Throws:
RepositoryException
-
extractUuids
protected UUID[] extractUuids(Collection<? extends de.digitalcollections.model.UniqueObject> uniqueObjects) -
find
public de.digitalcollections.model.list.paging.PageResponse<U> find(de.digitalcollections.model.list.paging.PageRequest pageRequest) throws RepositoryException - Specified by:
findin interfacePagingSortingFilteringRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
find
protected de.digitalcollections.model.list.paging.PageResponse<U> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, Map<String, Object> argumentMappings) throws RepositoryException- Throws:
RepositoryException
-
find
protected de.digitalcollections.model.list.paging.PageResponse<U> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql) throws RepositoryException - Throws:
RepositoryException
-
find
protected de.digitalcollections.model.list.paging.PageResponse<U> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql, Map<String, Object> argumentMappings) throws RepositoryException- Throws:
RepositoryException
-
getAllowedOrderByFields
- Specified by:
getAllowedOrderByFieldsin classAbstractPagingSortingFilteringRepositoryImpl- Returns:
- model properties names that are applicable for sorting, will be mapped to database column names using @see #getColumnName
-
getByUuidAndFiltering
public U getByUuidAndFiltering(UUID uuid, de.digitalcollections.model.list.filtering.Filtering filtering) throws RepositoryException - Specified by:
getByUuidAndFilteringin interfaceUniqueObjectRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
getColumnName
- Specified by:
getColumnNamein classAbstractPagingSortingFilteringRepositoryImpl- Parameters:
modelProperty- name of model property passed as String, e.g. "lastModified"- Returns:
- full qualified column name as used in sql queries ("last_modified" or e.g. "w.last_modified" if prefix used in queries)
-
getIndex
public int getIndex(List<? extends de.digitalcollections.model.UniqueObject> list, de.digitalcollections.model.UniqueObject uniqueObject) -
getIndex
-
getReturnedFieldsOnInsertUpdate
On insert or update these fields will be returned to be processed byinsertUpdateCallback(UniqueObject, Map).- Returns:
- modifiable list of fields, please do not return null
-
getSqlInsertFields
- Returns:
- SQL for field names for insert statement of
UniqueObject
-
getSqlInsertValues
Do not change order! Must match order in getSqlInsertFields!!!- Returns:
- SQL for value mapping for field names for insert statement of
UniqueObject
-
getSqlSelectAllFields
SQL-snippet for fields to be returned for complete field request.
If already all fields are returned with reduced fields request: just return reduced field set here, otherwise add additional fields to reduced set to get all fields.- Returns:
- SQL snippet
-
getSqlSelectAllFields
-
getSqlSelectAllFieldsJoins
- Returns:
- SQL for joined fields for complete field set from other table(s) (optional). Default: ""
-
getSqlSelectReducedFields
-
getSqlSelectReducedFields
-
getSqlSelectReducedFieldsJoins
- Returns:
- SQL for joined fields for reduced field set from other table(s) (optional). Default: ""
-
getSqlUpdateFieldValues
-
getUniqueField
- Specified by:
getUniqueFieldin classAbstractPagingSortingFilteringRepositoryImpl- Returns:
- name of model property that guarantees an unique sorting, e.g. a db primary key or another unique column/field
-
insertUpdateCallback
After save and update the returned fields (declared ingetReturnedFieldsOnInsertUpdate()) can be processed here.- Parameters:
uniqueObject- the object that was passed to save/updatereturnedFields- returned fields in a map of column names to values
-
retrieveCount
public long retrieveCount(StringBuilder sqlCount, Map<String, Object> argumentMappings) throws RepositoryException- Overrides:
retrieveCountin classJdbiRepositoryImpl<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
retrieveList
protected List<U> retrieveList(String fieldsSql, String fieldsSqlAdditionalJoins, StringBuilder innerQuery, Map<String, Object> argumentMappings, String orderBy) throws RepositoryException- Throws:
RepositoryException
-
retrieveList
public List<U> retrieveList(String fieldsSql, StringBuilder innerQuery, Map<String, Object> argumentMappings, String orderBy) throws RepositoryException- Throws:
RepositoryException
-
retrieveOne
protected U retrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins) throws RepositoryException - Throws:
RepositoryException
-
retrieveOne
protected U retrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins, Map<String, Object> argumentMappings) throws RepositoryException- Throws:
RepositoryException
-
retrieveOne
protected U retrieveOne(String fieldsSql, de.digitalcollections.model.list.filtering.Filtering filtering, String sqlAdditionalJoins, Map<String, Object> argumentMappings, String innerSelect) throws RepositoryException- Throws:
RepositoryException
-
save
- Specified by:
savein interfaceUniqueObjectRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
save
public void save(U uniqueObject, Map<String, Object> bindings, BiFunction<String, throws RepositoryExceptionMap<String, Object>, String> sqlModifier) - Throws:
RepositoryException
-
update
- Specified by:
updatein interfaceUniqueObjectRepository<U extends de.digitalcollections.model.UniqueObject>- Throws:
RepositoryException
-
update
public void update(U uniqueObject, Map<String, Object> bindings, BiFunction<String, throws RepositoryExceptionMap<String, Object>, String> sqlModifier) - Throws:
RepositoryException
-