Class JdbiRepositoryImpl<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>
- Direct Known Subclasses:
DigitalObjectLinkedDataFileResourceRepositoryImpl,DigitalObjectRenderingFileResourceRepositoryImpl,EntityToEntityRelationRepositoryImpl,UniqueObjectRepositoryImpl,VersionRepositoryImpl
public abstract class JdbiRepositoryImpl<U extends de.digitalcollections.model.UniqueObject>
extends AbstractPagingSortingFilteringRepositoryImpl
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.jdbi.v3.core.Jdbiprotected final Stringprotected final Stringprotected final StringFields inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingSortingFilteringRepositoryImpl
offsetForAlternativePaging -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJdbiRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, int offsetForAlternativePaging) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFiltering(de.digitalcollections.model.list.filtering.Filtering filtering, StringBuilder sqlQuery, Map<String, Object> argumentMappings) voidaddFiltering(de.digitalcollections.model.list.paging.PageRequest pageRequest, StringBuilder sqlQuery, Map<String, Object> argumentMappings) longcount()longprotected final StringescapeTermForJsonpath(String term) Escape characters that must not appear in jsonpath inner strings.protected intexecUpdateWithList(String sql, String key, List values) protected intexecUpdateWithMap(String sql, Map<String, Object> bindings) protected voidfilterByLocalizedTextFields(de.digitalcollections.model.list.paging.PageRequest pageRequest, de.digitalcollections.model.list.paging.PageResponse<U> pageResponse, LinkedHashMap<String, Function<U, Optional<Object>>> jsonbFields) protected voidfilterBySplitField(de.digitalcollections.model.list.paging.PageResponse<U> pageResponse, de.digitalcollections.model.list.filtering.FilterCriterion<String> filter, Function<U, Optional<Object>> retrieveField) Special logic to filter by label, optionally paying attention to the language.protected StringgetTargetExpression(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc) Map expression to target SQL expression (i.e.protected StringgetWhereClause(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc, Map<String, Object> argumentMappings, int criterionCount) protected StringgetWhereClauses(de.digitalcollections.model.list.filtering.Filtering filtering, Map<String, Object> argumentMappings) protected booleanhasSplitColumn(String propertName) Override this method for check of split fields that exist in the repository's contextprotected voidmapFilterExpressionsToOtherTableColumnNames(de.digitalcollections.model.list.filtering.Filtering filtering, AbstractPagingSortingFilteringRepositoryImpl otherRepository) protected longretrieveCount(StringBuilder sqlCount, Map<String, Object> argumentMappings) protected IntegerretrieveNextSortIndexForParentChildren(org.jdbi.v3.core.Jdbi dbi, String tableName, String columNameParentUuid, UUID parentUuid) String[]splitToArray(de.digitalcollections.model.text.LocalizedText localizedText) String[]splitToArray(String term) Methods inherited from class de.digitalcollections.cudami.server.backend.impl.database.AbstractPagingSortingFilteringRepositoryImpl
addOrderBy, addPagingAndSorting, getAllowedOrderByFields, getColumnName, getOrderBy, getUniqueField, supportsCaseSensitivityForProperty
-
Field Details
-
dbi
protected final org.jdbi.v3.core.Jdbi dbi -
mappingPrefix
-
tableAlias
-
tableName
-
-
Constructor Details
-
JdbiRepositoryImpl
protected JdbiRepositoryImpl() -
JdbiRepositoryImpl
-
-
Method Details
-
addFiltering
public void addFiltering(de.digitalcollections.model.list.filtering.Filtering filtering, StringBuilder sqlQuery, Map<String, Object> argumentMappings) -
addFiltering
public void addFiltering(de.digitalcollections.model.list.paging.PageRequest pageRequest, StringBuilder sqlQuery, Map<String, Object> argumentMappings) -
count
- Throws:
RepositoryException
-
count
- Throws:
RepositoryException
-
escapeTermForJsonpath
Escape characters that must not appear in jsonpath inner strings.This method should always be used to clean up strings, e.g. search terms, that are intended to appear in an jsonpath inner string, i.e. between double quotes. If the inserted term contains double quotes then the jsonpath breaks. Hence we remove double quotes at start and end of the provided string (they do not have any meaning for the search at all) and escape the remaining ones with a backslash.
- Parameters:
term- can be null- Returns:
- term with forbidden characters removed or escaped
-
execUpdateWithList
- Throws:
RepositoryException
-
execUpdateWithMap
- Throws:
RepositoryException
-
filterByLocalizedTextFields
-
filterBySplitField
protected void filterBySplitField(de.digitalcollections.model.list.paging.PageResponse<U> pageResponse, de.digitalcollections.model.list.filtering.FilterCriterion<String> filter, Function<U, Optional<Object>> retrieveField) Special logic to filter by label, optionally paying attention to the language. The passedPageResponsecould be modified.- Parameters:
pageResponse- the response from the repo, must always contain the request too (if everything goes right)
-
getTargetExpression
protected String getTargetExpression(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc) throws IllegalArgumentException Map expression to target SQL expression (i.e. column name).- Parameters:
fc- filter criterion containing given expression- Returns:
- target SQL expression used for one operand in WHERE clause
- Throws:
IllegalArgumentException
-
getJsonbFields
- Returns:
- map containing name of jsonb field and function to get the field value
-
getMappingPrefix
-
getTableAlias
-
getTableName
-
getWhereClause
protected String getWhereClause(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc, Map<String, Object> argumentMappings, int criterionCount) throws IllegalArgumentException, UnsupportedOperationException -
getWhereClauses
-
hasSplitColumn
Override this method for check of split fields that exist in the repository's context- Parameters:
propertName- java property name- Returns:
- corresponding split-column for property exists
-
mapFilterExpressionsToOtherTableColumnNames
protected void mapFilterExpressionsToOtherTableColumnNames(de.digitalcollections.model.list.filtering.Filtering filtering, AbstractPagingSortingFilteringRepositoryImpl otherRepository) -
retrieveCount
protected long retrieveCount(StringBuilder sqlCount, Map<String, Object> argumentMappings) throws RepositoryException- Throws:
RepositoryException
-
retrieveNextSortIndexForParentChildren
protected Integer retrieveNextSortIndexForParentChildren(org.jdbi.v3.core.Jdbi dbi, String tableName, String columNameParentUuid, UUID parentUuid) throws RepositoryException - Throws:
RepositoryException
-
splitToArray
-
splitToArray
-