Class JdbiRepositoryImpl<U extends de.digitalcollections.model.UniqueObject>

Direct Known Subclasses:
DigitalObjectLinkedDataFileResourceRepositoryImpl, DigitalObjectRenderingFileResourceRepositoryImpl, EntityToEntityRelationRepositoryImpl, UniqueObjectRepositoryImpl, VersionRepositoryImpl

public abstract class JdbiRepositoryImpl<U extends de.digitalcollections.model.UniqueObject> extends AbstractPagingSortingFilteringRepositoryImpl
  • Field Details

    • dbi

      protected final org.jdbi.v3.core.Jdbi dbi
    • mappingPrefix

      protected final String mappingPrefix
    • tableAlias

      protected final String tableAlias
    • tableName

      protected final String tableName
  • Constructor Details

    • JdbiRepositoryImpl

      protected JdbiRepositoryImpl()
    • JdbiRepositoryImpl

      public JdbiRepositoryImpl(org.jdbi.v3.core.Jdbi dbi, String tableName, String tableAlias, String mappingPrefix, int offsetForAlternativePaging)
  • 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

      public long count() throws RepositoryException
      Throws:
      RepositoryException
    • count

      public long count(String commonSql, Map<String,Object> argumentMappings) throws RepositoryException
      Throws:
      RepositoryException
    • escapeTermForJsonpath

      protected final String escapeTermForJsonpath(String term)
      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

      protected int execUpdateWithList(String sql, String key, List values) throws RepositoryException
      Throws:
      RepositoryException
    • execUpdateWithMap

      protected int execUpdateWithMap(String sql, Map<String,Object> bindings) throws RepositoryException
      Throws:
      RepositoryException
    • filterByLocalizedTextFields

      protected void filterByLocalizedTextFields(de.digitalcollections.model.list.paging.PageRequest pageRequest, de.digitalcollections.model.list.paging.PageResponse<U> pageResponse, LinkedHashMap<String,Function<U,Optional<Object>>> jsonbFields)
    • 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 passed PageResponse could 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

      protected LinkedHashMap<String,Function<U,Optional<Object>>> getJsonbFields()
      Returns:
      map containing name of jsonb field and function to get the field value
    • getMappingPrefix

      public String getMappingPrefix()
    • getTableAlias

      public String getTableAlias()
    • getTableName

      public String getTableName()
    • getWhereClause

      protected String getWhereClause(de.digitalcollections.model.list.filtering.FilterCriterion<?> fc, Map<String,Object> argumentMappings, int criterionCount) throws IllegalArgumentException, UnsupportedOperationException
      Throws:
      IllegalArgumentException
      UnsupportedOperationException
    • getWhereClauses

      protected String getWhereClauses(de.digitalcollections.model.list.filtering.Filtering filtering, Map<String,Object> argumentMappings)
    • hasSplitColumn

      protected boolean hasSplitColumn(String propertName)
      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

      public String[] splitToArray(de.digitalcollections.model.text.LocalizedText localizedText)
    • splitToArray

      public String[] splitToArray(String term)