Class IdentifiableRepositoryImpl<I extends de.digitalcollections.model.identifiable.Identifiable>
- java.lang.Object
-
- de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingAndSortingRepositoryImpl
-
- de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl
-
- de.digitalcollections.cudami.server.backend.impl.jdbi.identifiable.IdentifiableRepositoryImpl<I>
-
- All Implemented Interfaces:
IdentifiableRepository<I>
- Direct Known Subclasses:
EntityRepositoryImpl,FamilyNameRepositoryImpl,FileResourceMetadataRepositoryImpl,GivenNameRepositoryImpl,WebpageRepositoryImpl
@Repository public class IdentifiableRepositoryImpl<I extends de.digitalcollections.model.identifiable.Identifiable> extends JdbiRepositoryImpl implements IdentifiableRepository<I>
-
-
Field Summary
Fields Modifier and Type Field Description BiFunction<Map<UUID,I>,org.jdbi.v3.core.result.RowView,Map<UUID,I>>additionalReduceRowsBiFunctionBiFunction<Map<UUID,I>,org.jdbi.v3.core.result.RowView,Map<UUID,I>>basicReduceRowsBiFunctionBiFunction<Map<UUID,I>,org.jdbi.v3.core.result.RowView,Map<UUID,I>>fullReduceRowsBiFunctionprotected ClassidentifiableImplClassstatic StringMAPPING_PREFIXprotected StringsqlSelectAllFieldsprotected StringsqlSelectAllFieldsJoinsprotected StringsqlSelectReducedFieldsstatic StringTABLE_ALIASstatic StringTABLE_NAME-
Fields inherited from class de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl
dbi, mappingPrefix, tableAlias, tableName
-
Fields inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingAndSortingRepositoryImpl
offsetForAlternativePaging
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedIdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, CudamiConfig cudamiConfig)protectedIdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, int offsetForAlternativePaging)protectedIdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, String sqlSelectAllFieldsJoins, int offsetForAlternativePaging)protectedIdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, String sqlSelectAllFieldsJoins, BiFunction<Map<UUID,I>,org.jdbi.v3.core.result.RowView,Map<UUID,I>> additionalReduceRowsBiFunction, int offsetForAlternativePaging)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected StringaddCrossTablePageRequestParams(de.digitalcollections.model.list.paging.PageRequest pageRequest, StringBuilder innerQuery, String crossTableAlias)voidaddRelatedEntity(UUID identifiableUuid, UUID entityUuid)voidaddRelatedFileresource(UUID identifiableUuid, UUID fileResourceUuid)protected StringaddSearchTermMappings(String searchTerm, Map<String,Object> argumentMappings)Add the search term to the argument map.booleandelete(List<UUID> uuids)protected voidextendReducedIdentifiable(I identifiable, org.jdbi.v3.core.result.RowView rowView)Extend the reduced Identifiable by the contents of the provided RowViewde.digitalcollections.model.list.paging.PageResponse<I>find(de.digitalcollections.model.list.paging.PageRequest pageRequest)protected de.digitalcollections.model.list.paging.PageResponse<I>find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql)protected de.digitalcollections.model.list.paging.PageResponse<I>find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql, Map<String,Object> argumentMappings)protected de.digitalcollections.model.list.paging.PageResponse<I>find(de.digitalcollections.model.list.paging.PageRequest pageRequest, Map<String,Object> argumentMappings)de.digitalcollections.model.list.paging.PageResponse<I>findByLanguageAndInitial(de.digitalcollections.model.list.paging.PageRequest pageRequest, String language, String initial)Deprecated.List<I>getAllFull()protected List<String>getAllowedOrderByFields()List<I>getAllReduced()IgetByIdentifier(de.digitalcollections.model.identifiable.Identifier identifier)IgetByUuidAndFiltering(UUID uuid, de.digitalcollections.model.list.filtering.Filtering filtering)StringgetColumnName(String modelProperty)intgetIndex(List<? extends de.digitalcollections.model.identifiable.Identifiable> list, de.digitalcollections.model.identifiable.Identifiable identifiable)intgetIndex(List<UUID> list, UUID uuid)List<Locale>getLanguages()List<de.digitalcollections.model.identifiable.entity.Entity>getRelatedEntities(UUID identifiableUuid)List<de.digitalcollections.model.identifiable.resource.FileResource>getRelatedFileResources(UUID identifiableUuid)protected List<String>getSearchTermTemplates(String tableAlias, String originalSearchTerm)static StringgetSqlInsertFields()static StringgetSqlInsertValues()StringgetSqlSelectAllFields()static StringgetSqlSelectAllFields(String tableAlias, String mappingPrefix)StringgetSqlSelectReducedFields()static StringgetSqlSelectReducedFields(String tableAlias, String mappingPrefix)static StringgetSqlUpdateFieldValues()protected StringgetUniqueField()protected StringgetWhereClause(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc, Map<String,Object> argumentMappings, int criterionCount)longretrieveCount(StringBuilder sqlCount, Map<String,Object> argumentMappings)List<I>retrieveList(String fieldsSql, StringBuilder innerQuery, Map<String,Object> argumentMappings, String orderBy)IretrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering)IretrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering, Map<String,Object> argumentMappings)IretrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering, Map<String,Object> argumentMappings, String innerSelect)Isave(I identifiable, Map<String,Object> bindings)List<de.digitalcollections.model.identifiable.entity.Entity>setRelatedEntities(UUID identifiableUuid, List<de.digitalcollections.model.identifiable.entity.Entity> entities)List<de.digitalcollections.model.identifiable.resource.FileResource>setRelatedFileResources(UUID identifiableUuid, List<de.digitalcollections.model.identifiable.resource.FileResource> fileResources)protected String[]splitToArray(de.digitalcollections.model.text.LocalizedText localizedText)protected booleansupportsCaseSensitivityForProperty(String modelProperty)Returns whether the passed property can be sorted case sensitive (in general).Iupdate(I identifiable, Map<String,Object> bindings)-
Methods inherited from class de.digitalcollections.cudami.server.backend.impl.jdbi.JdbiRepositoryImpl
addFiltering, addFiltering, addSearchTerm, count, count, escapeTermForJsonpath, getCommonSearchSql, getFilterClauses, getMappingPrefix, getTableAlias, getTableName, mapFilterExpressionsToOtherTableColumnNames, retrieveNextSortIndexForParentChildren
-
Methods inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingAndSortingRepositoryImpl
addOrderBy, addPageRequestParams, getOrderBy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.digitalcollections.cudami.server.backend.api.repository.identifiable.IdentifiableRepository
addRelatedEntity, addRelatedFileresource, count, delete, find, getByIdentifier, getByUuid, getRelatedEntities, getRelatedFileResources, save, setRelatedEntities, setRelatedFileResources, update
-
-
-
-
Field Detail
-
MAPPING_PREFIX
public static final String MAPPING_PREFIX
- See Also:
- Constant Field Values
-
TABLE_ALIAS
public static final String TABLE_ALIAS
- See Also:
- Constant Field Values
-
TABLE_NAME
public static final String TABLE_NAME
- See Also:
- Constant Field Values
-
additionalReduceRowsBiFunction
public BiFunction<Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>,org.jdbi.v3.core.result.RowView,Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>> additionalReduceRowsBiFunction
-
basicReduceRowsBiFunction
public final BiFunction<Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>,org.jdbi.v3.core.result.RowView,Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>> basicReduceRowsBiFunction
-
fullReduceRowsBiFunction
public final BiFunction<Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>,org.jdbi.v3.core.result.RowView,Map<UUID,I extends de.digitalcollections.model.identifiable.Identifiable>> fullReduceRowsBiFunction
-
identifiableImplClass
protected final Class identifiableImplClass
-
sqlSelectAllFields
protected String sqlSelectAllFields
-
sqlSelectAllFieldsJoins
protected final String sqlSelectAllFieldsJoins
-
sqlSelectReducedFields
protected String sqlSelectReducedFields
-
-
Constructor Detail
-
IdentifiableRepositoryImpl
@Autowired protected IdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, CudamiConfig cudamiConfig)
-
IdentifiableRepositoryImpl
protected IdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, int offsetForAlternativePaging)
-
IdentifiableRepositoryImpl
protected IdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, String sqlSelectAllFieldsJoins, int offsetForAlternativePaging)
-
IdentifiableRepositoryImpl
protected IdentifiableRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, Class identifiableImplClass, String sqlSelectAllFields, String sqlSelectReducedFields, String sqlInsertFields, String sqlInsertValues, String sqlUpdateFieldValues, String sqlSelectAllFieldsJoins, BiFunction<Map<UUID,I>,org.jdbi.v3.core.result.RowView,Map<UUID,I>> additionalReduceRowsBiFunction, int offsetForAlternativePaging)
-
-
Method Detail
-
getSqlInsertFields
public static String getSqlInsertFields()
-
getSqlInsertValues
public static String getSqlInsertValues()
-
getSqlSelectAllFields
public static String getSqlSelectAllFields(String tableAlias, String mappingPrefix)
-
getSqlSelectReducedFields
public static String getSqlSelectReducedFields(String tableAlias, String mappingPrefix)
-
getSqlUpdateFieldValues
public static String getSqlUpdateFieldValues()
-
addCrossTablePageRequestParams
protected String addCrossTablePageRequestParams(de.digitalcollections.model.list.paging.PageRequest pageRequest, StringBuilder innerQuery, String crossTableAlias)
-
addRelatedEntity
public void addRelatedEntity(UUID identifiableUuid, UUID entityUuid)
- Specified by:
addRelatedEntityin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
addRelatedFileresource
public void addRelatedFileresource(UUID identifiableUuid, UUID fileResourceUuid)
- Specified by:
addRelatedFileresourcein interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
addSearchTermMappings
protected String addSearchTermMappings(String searchTerm, Map<String,Object> argumentMappings)
Description copied from class:JdbiRepositoryImplAdd the search term to the argument map. By overriding this method custom modifications can be made. Belongs toJdbiRepositoryImpl.getSearchTermTemplates(String, String)andJdbiRepositoryImpl.addSearchTerm(PageRequest, StringBuilder, Map).- Overrides:
addSearchTermMappingsin classJdbiRepositoryImpl- Parameters:
searchTerm- original term from thePageRequest- Returns:
- the search term that should be used for the
ListResponse.setExecutedSearchTerm(String)
-
delete
public boolean delete(List<UUID> uuids)
- Specified by:
deletein interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
extendReducedIdentifiable
protected void extendReducedIdentifiable(I identifiable, org.jdbi.v3.core.result.RowView rowView)
Extend the reduced Identifiable by the contents of the provided RowView- Parameters:
identifiable- the reduced IdentifiablerowView- the rowView
-
find
protected de.digitalcollections.model.list.paging.PageResponse<I> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, Map<String,Object> argumentMappings)
-
find
protected de.digitalcollections.model.list.paging.PageResponse<I> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql, Map<String,Object> argumentMappings)
-
find
protected de.digitalcollections.model.list.paging.PageResponse<I> find(de.digitalcollections.model.list.paging.PageRequest pageRequest, String commonSql)
-
find
public de.digitalcollections.model.list.paging.PageResponse<I> find(de.digitalcollections.model.list.paging.PageRequest pageRequest)
- Specified by:
findin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
findByLanguageAndInitial
@Deprecated public de.digitalcollections.model.list.paging.PageResponse<I> findByLanguageAndInitial(de.digitalcollections.model.list.paging.PageRequest pageRequest, String language, String initial)
Deprecated.- Specified by:
findByLanguageAndInitialin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getAllFull
public List<I> getAllFull()
- Specified by:
getAllFullin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getAllReduced
public List<I> getAllReduced()
- Specified by:
getAllReducedin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getAllowedOrderByFields
protected List<String> getAllowedOrderByFields()
- Specified by:
getAllowedOrderByFieldsin classAbstractPagingAndSortingRepositoryImpl- Returns:
- model properties names that are applicable for sorting, will be mapped to database column names using @see #getColumnName
-
getByIdentifier
public I getByIdentifier(de.digitalcollections.model.identifiable.Identifier identifier)
- Specified by:
getByIdentifierin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getByUuidAndFiltering
public I getByUuidAndFiltering(UUID uuid, de.digitalcollections.model.list.filtering.Filtering filtering)
- Specified by:
getByUuidAndFilteringin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getColumnName
public String getColumnName(String modelProperty)
- Specified by:
getColumnNamein classAbstractPagingAndSortingRepositoryImpl- 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.identifiable.Identifiable> list, de.digitalcollections.model.identifiable.Identifiable identifiable)
-
getLanguages
public List<Locale> getLanguages()
- Specified by:
getLanguagesin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getRelatedEntities
public List<de.digitalcollections.model.identifiable.entity.Entity> getRelatedEntities(UUID identifiableUuid)
- Specified by:
getRelatedEntitiesin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getRelatedFileResources
public List<de.digitalcollections.model.identifiable.resource.FileResource> getRelatedFileResources(UUID identifiableUuid)
- Specified by:
getRelatedFileResourcesin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
getSearchTermTemplates
protected List<String> getSearchTermTemplates(String tableAlias, String originalSearchTerm)
- Overrides:
getSearchTermTemplatesin classJdbiRepositoryImpl
-
getSqlSelectAllFields
public String getSqlSelectAllFields()
-
getSqlSelectReducedFields
public String getSqlSelectReducedFields()
-
getUniqueField
protected String getUniqueField()
- Specified by:
getUniqueFieldin classAbstractPagingAndSortingRepositoryImpl- Returns:
- name of model property that guarantees an unique sorting, e.g. a db primary key or another unique column/field
-
getWhereClause
protected String getWhereClause(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc, Map<String,Object> argumentMappings, int criterionCount) throws IllegalArgumentException, UnsupportedOperationException
- Overrides:
getWhereClausein classJdbiRepositoryImpl- Throws:
IllegalArgumentExceptionUnsupportedOperationException
-
retrieveCount
public long retrieveCount(StringBuilder sqlCount, Map<String,Object> argumentMappings)
-
retrieveList
public List<I> retrieveList(String fieldsSql, StringBuilder innerQuery, Map<String,Object> argumentMappings, String orderBy)
-
retrieveOne
public I retrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering)
-
retrieveOne
public I retrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering, Map<String,Object> argumentMappings)
-
retrieveOne
public I retrieveOne(String fieldsSql, String sqlSelectAllFieldsJoins, de.digitalcollections.model.list.filtering.Filtering filtering, Map<String,Object> argumentMappings, String innerSelect)
-
save
public I save(I identifiable, Map<String,Object> bindings)
- Specified by:
savein interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
setRelatedEntities
public List<de.digitalcollections.model.identifiable.entity.Entity> setRelatedEntities(UUID identifiableUuid, List<de.digitalcollections.model.identifiable.entity.Entity> entities)
- Specified by:
setRelatedEntitiesin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
setRelatedFileResources
public List<de.digitalcollections.model.identifiable.resource.FileResource> setRelatedFileResources(UUID identifiableUuid, List<de.digitalcollections.model.identifiable.resource.FileResource> fileResources)
- Specified by:
setRelatedFileResourcesin interfaceIdentifiableRepository<I extends de.digitalcollections.model.identifiable.Identifiable>
-
splitToArray
protected String[] splitToArray(de.digitalcollections.model.text.LocalizedText localizedText)
-
supportsCaseSensitivityForProperty
protected boolean supportsCaseSensitivityForProperty(String modelProperty)
Description copied from class:AbstractPagingAndSortingRepositoryImplReturns whether the passed property can be sorted case sensitive (in general). This method should be kept in sync withAbstractPagingAndSortingRepositoryImpl.getAllowedOrderByFields().- Specified by:
supportsCaseSensitivityForPropertyin classAbstractPagingAndSortingRepositoryImpl- Parameters:
modelProperty- the property name (similar toAbstractPagingAndSortingRepositoryImpl.getColumnName(java.lang.String))- Returns:
trueonly if case (in)sensitive sorting is possible
-
-