Class DbQuery

java.lang.Object
org.n52.sensorweb.server.db.old.dao.DbQuery

public class DbQuery extends Object
  • Field Details

  • Constructor Details

    • DbQuery

      public DbQuery(org.n52.io.request.IoParameters parameters)
  • Method Details

    • removeSpatialFilter

      public DbQuery removeSpatialFilter()
      Creates a new instance and removes spatial filter parameters.
      Returns:
      a new instance with spatial filters removed
    • getGeometryFactory

      public org.locationtech.jts.geom.GeometryFactory getGeometryFactory()
    • replaceWith

      public DbQuery replaceWith(String parameter, String... values)
      Create a new instance and replaces given parameter values.
      Parameters:
      parameter - the parameter which values to be replaced
      values - the new values
      Returns:
      a new instance with containing the new parameter values
    • replaceWith

      public DbQuery replaceWith(String parameter, Collection<String> values)
    • removeAllOf

      public DbQuery removeAllOf(String... parameterNames)
      Creates a new instance and removes all given parameters.
      Parameters:
      parameterNames - the parameters to remove
      Returns:
      a new instance with given parameters removed
    • getDatabaseSridCode

      public String getDatabaseSridCode()
    • setDatabaseSridCode

      public void setDatabaseSridCode(String databaseSridCode)
    • getHrefBase

      public String getHrefBase()
    • getLocale

      public String getLocale()
    • getLocaleForLabel

      public String getLocaleForLabel()
    • isDefaultLocal

      public boolean isDefaultLocal()
    • getSearchTerm

      public String getSearchTerm()
    • getTimespan

      public org.joda.time.Interval getTimespan()
    • getLastValueMatches

      public org.joda.time.Interval getLastValueMatches()
    • getLevel

      public Integer getLevel()
    • getSpatialFilter

      public org.locationtech.jts.geom.Geometry getSpatialFilter()
    • isExpanded

      public boolean isExpanded()
    • isMatchDomainIds

      public boolean isMatchDomainIds()
    • setComplexParent

      public void setComplexParent(boolean complex)
    • isComplexParent

      public boolean isComplexParent()
    • isSetDatasetTypeFilter

      public boolean isSetDatasetTypeFilter()
    • isSetObservationTypeFilter

      public boolean isSetObservationTypeFilter()
    • isSetValueTypeFilter

      public boolean isSetValueTypeFilter()
    • getValueTypes

      public Collection<String> getValueTypes()
    • addTimespanTo

      public <E> org.springframework.data.jpa.domain.Specification<E> addTimespanTo()
    • addFilters

      public <E> org.springframework.data.jpa.domain.Specification<E> addFilters(String datasetProperty)
    • addFilters

      public <E> org.springframework.data.jpa.domain.Specification<E> addFilters(String datasetProperty, jakarta.persistence.EntityManager entityManager)
      Dataset filters plus the services filter, both applied to root.<datasetProperty>.
      Type Parameters:
      E - the root entity type
      Parameters:
      datasetProperty - the association from the root to the dataset, or empty if the root is the dataset
      entityManager - used to check whether the sampling model is mapped, may be null (the samplings filter is then skipped)
      Returns:
      the specification
    • createServiceFilter

      public jakarta.persistence.criteria.Predicate createServiceFilter(jakarta.persistence.criteria.Path<?> from, jakarta.persistence.criteria.CriteriaBuilder cb)
      from.service.id IN (:services), or a conjunction when no services are requested.
      Parameters:
      from - the dataset (or another entity with a service association)
      cb - the criteria builder
      Returns:
      the predicate
    • addDetachedFilters

      public <E> org.springframework.data.jpa.domain.Specification<E> addDetachedFilters(String datasetName)
    • addDetachedFilters

      public <E> org.springframework.data.jpa.domain.Specification<E> addDetachedFilters(String datasetName, jakarta.persistence.EntityManager entityManager)
      select DatasetEntity.id where (restrictions), then outer.<datasetName>.id IN (subquery).
      Type Parameters:
      E - the root entity type
      Parameters:
      datasetName - the association from the root to the dataset, or empty if the root is the dataset
      entityManager - used to check whether the sampling model is mapped, may be null (the samplings filter is then skipped)
      Returns:
      the specification
    • datasetFilterPredicate

      public jakarta.persistence.criteria.Predicate datasetFilterPredicate(jakarta.persistence.criteria.Path<?> datasetId, jakarta.persistence.criteria.AbstractQuery<?> query, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.EntityManager entityManager)
      datasetId IN (select dataset.id where <request filters>), or a conjunction when the request sets none of the dataset filters.

      Takes the dataset id path rather than an association name, so callers can apply it to a dataset join they already hold (for example inside their own subquery) instead of joining the dataset a second time.

      Parameters:
      datasetId - the path to the dataset id to restrict
      query - the (sub)query to create the filter subquery in
      cb - the criteria builder
      entityManager - used to check whether the sampling model is mapped, may be null (the samplings filter is then skipped)
      Returns:
      the predicate
    • datasetAndSamplingRestrictions

      public List<jakarta.persistence.criteria.Predicate> datasetAndSamplingRestrictions(jakarta.persistence.criteria.From<org.n52.series.db.beans.DatasetEntity,?> dataset, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.EntityManager entityManager)
      Only the datasets and samplings request filters, applied directly to a dataset root the caller already holds (no subquery). Meant for callers whose dataset subquery already applies DatasetQuerySpecifications.matchFilters(), which covers the other dataset filters.
      Parameters:
      dataset - the dataset root to restrict
      cb - the criteria builder
      entityManager - used to check whether the sampling model is mapped, may be null (the samplings filter is then skipped)
      Returns:
      the active restrictions, empty if neither filter is set
    • createIdFilter

      public jakarta.persistence.criteria.Predicate createIdFilter(Set<String> filterValues, jakarta.persistence.criteria.From<?,?> from, jakarta.persistence.criteria.CriteriaBuilder cb)
    • addResultTimeFilter

      public <E extends org.n52.series.db.beans.DataEntity<?>> org.springframework.data.jpa.domain.Specification<E> addResultTimeFilter()
    • getParameters

      public org.n52.io.request.IoParameters getParameters()
    • getFilterResolver

      public org.n52.io.request.FilterResolver getFilterResolver()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withoutFieldsFilter

      public DbQuery withoutFieldsFilter()
    • withoutSelectFilter

      public DbQuery withoutSelectFilter()
    • withSubSelectFilter

      public DbQuery withSubSelectFilter(String selection)
    • expandWithNextValuesBeyondInterval

      public boolean expandWithNextValuesBeyondInterval()
    • isIncludeHierarchy

      public boolean isIncludeHierarchy()
      Returns:
      the includeHierarchy
    • setIncludeHierarchy

      public DbQuery setIncludeHierarchy(boolean includeHierarchy)
      Parameters:
      includeHierarchy - the includeHierarchy to set
      Returns:
      this
    • getSelectOriginal

      public Set<String> getSelectOriginal()
    • isFormatToUnixTime

      public boolean isFormatToUnixTime()
    • getNumberFormat

      public NumberFormat getNumberFormat()