Class FESCriterionGenerator

    • Constructor Summary

      Constructors 
      Constructor Description
      FESCriterionGenerator​(org.hibernate.Criteria criteria, boolean unsupportedIsTrue, boolean matchDomainIds, boolean complexParent)
      Creates a new FESCriterionGenerator.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected String addAlias​(String property)
      Add a alias for the specified property to the criteria.
      org.hibernate.criterion.Criterion create​(org.n52.shetland.ogc.filter.Filter<?> filter)
      Create a Criterion for the supplied Filter.
      protected org.hibernate.criterion.Criterion createComparison​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
      Create a Criterion for the supplied operator, property and value.
      protected org.hibernate.criterion.Criterion createComparison​(org.n52.shetland.ogc.filter.ComparisonFilter filter, Object value)
      Create a Criterion for the supplied filter.
      protected abstract org.hibernate.criterion.Criterion createDataCriterion​(org.hibernate.criterion.Criterion criterion)
      Create a Criterion for a property of the associated data entity.
      protected abstract org.hibernate.criterion.Criterion createDatasetCriterion​(String property, org.n52.shetland.ogc.filter.ComparisonFilter filter)
      Create a Criterion for a property of the associated data set.
      protected abstract org.hibernate.criterion.Criterion createDatasetCriterion​(String property, org.n52.shetland.ogc.filter.SpatialFilter filter)
      Create a Criterion for a property of the associated data set.
      protected abstract org.hibernate.criterion.Criterion createResultCriterion​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
      Create a Criterion for the specified result filter.
      protected org.hibernate.criterion.Criterion createSpatialFilterCriterion​(org.n52.shetland.ogc.filter.SpatialFilter filter)
      Create a spatial filter criterion for the supplied filter.
      protected org.hibernate.Criteria getCriteria()
      Get the criteria this generator creates criterions for.
      protected Stream<org.hibernate.criterion.DetachedCriteria> getResultSubqueries​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
      Create a stream of subqueries that apply the comparison filter to the result value of the data entity.
      protected boolean isComplexParent()
      If the queries should result in the parent observation and hide the child observations.
      protected boolean isMatchDomainIds()
      Ff filter on observation parameters like feature, offering or procedure should match on their respective domain identifiers or on the primary keys in the database
      protected boolean isUnsupportedIsTrue()
      If the generator encounters a filter expression it could not translate it may generate a criterion that is always true or always false depending on this flag
      static Optional<BigDecimal> parseBigDecimal​(String value)
      Trys to parse value as a BigDecimal.
      static Optional<Boolean> parseBoolean​(String value)
      Trys to parse value as a boolean.
      static Optional<Double> parseDouble​(String value)
      Trys to parse value as a double.
      static Optional<Integer> parseInt​(String value)
      Trys to parse value as a int.
      static Optional<Long> parseLong​(String value)
      Trys to parse value as a long.
      static org.n52.shetland.ogc.gml.time.Time parseTime​(String value)
      Parse the value either as a TimeInstant or as a TimePeriod.
      protected org.hibernate.criterion.Criterion unparsableTime​(String value, IllegalArgumentException ex)
      Creates a criterion for an unparsable date time value.
      protected org.hibernate.criterion.Criterion unsupported​(Enum<?> filter)
      Creates a criterion for an unsupported filter.
      protected org.hibernate.criterion.Criterion unsupported​(Object o)
      Creates a criterion for an unsupported filter.
      protected org.hibernate.criterion.Criterion unsupported​(org.n52.shetland.ogc.filter.Filter<?> filter)
      Creates a criterion for an unsupported filter.
    • Constructor Detail

      • FESCriterionGenerator

        public FESCriterionGenerator​(org.hibernate.Criteria criteria,
                                     boolean unsupportedIsTrue,
                                     boolean matchDomainIds,
                                     boolean complexParent)
        Creates a new FESCriterionGenerator.
        Parameters:
        criteria - the criteria
        unsupportedIsTrue - if the generator encounters a filter expression it could not translate it may generate a criterion that is always true or always false depending on this flag
        matchDomainIds - if filter on observation parameters like feature, offering or procedure should match on their respective domain identifiers or on the primary keys in the database
        complexParent - if the queries should result in the parent observation and hide the child observations
    • Method Detail

      • getCriteria

        protected org.hibernate.Criteria getCriteria()
        Get the criteria this generator creates criterions for.
        Returns:
        the criteria
      • isUnsupportedIsTrue

        protected boolean isUnsupportedIsTrue()
        If the generator encounters a filter expression it could not translate it may generate a criterion that is always true or always false depending on this flag
        Returns:
        the flag
      • isMatchDomainIds

        protected boolean isMatchDomainIds()
        Ff filter on observation parameters like feature, offering or procedure should match on their respective domain identifiers or on the primary keys in the database
        Returns:
        if domain identifiers should be matched
      • isComplexParent

        protected boolean isComplexParent()
        If the queries should result in the parent observation and hide the child observations.
        Returns:
        if the queries should result in the parent observation and hide the child observations
      • addAlias

        protected String addAlias​(String property)
        Add a alias for the specified property to the criteria.
        Parameters:
        property - the property
        Returns:
        the alias
      • create

        public org.hibernate.criterion.Criterion create​(org.n52.shetland.ogc.filter.Filter<?> filter)
        Create a Criterion for the supplied Filter.
        Parameters:
        filter - the filter
        Returns:
        the criterion
      • createSpatialFilterCriterion

        protected org.hibernate.criterion.Criterion createSpatialFilterCriterion​(org.n52.shetland.ogc.filter.SpatialFilter filter)
        Create a spatial filter criterion for the supplied filter.
        Parameters:
        filter - the filter
        Returns:
        the criterion
      • createComparison

        protected org.hibernate.criterion.Criterion createComparison​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
        Create a Criterion for the supplied operator, property and value.
        Parameters:
        filter - the filter
        Returns:
        the criterion
      • createComparison

        protected org.hibernate.criterion.Criterion createComparison​(org.n52.shetland.ogc.filter.ComparisonFilter filter,
                                                                     Object value)
        Create a Criterion for the supplied filter. value may hold a typed value to be used instead of the filter's string value.
        Parameters:
        filter - the filter
        value - a optional object to be used instead of the filter's string value
        Returns:
        the criterion
      • unsupported

        protected org.hibernate.criterion.Criterion unsupported​(org.n52.shetland.ogc.filter.Filter<?> filter)
        Creates a criterion for an unsupported filter.
        Parameters:
        filter - the filter
        Returns:
        the restriction
      • unsupported

        protected org.hibernate.criterion.Criterion unsupported​(Enum<?> filter)
        Creates a criterion for an unsupported filter.
        Parameters:
        filter - the filter
        Returns:
        the restriction
      • unsupported

        protected org.hibernate.criterion.Criterion unsupported​(Object o)
        Creates a criterion for an unsupported filter.
        Parameters:
        o - the unsupported object
        Returns:
        the restriction
      • unparsableTime

        protected org.hibernate.criterion.Criterion unparsableTime​(String value,
                                                                   IllegalArgumentException ex)
        Creates a criterion for an unparsable date time value.
        Parameters:
        value - the value
        ex - the causing exception
        Returns:
        the criterion
      • getResultSubqueries

        protected Stream<org.hibernate.criterion.DetachedCriteria> getResultSubqueries​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
        Create a stream of subqueries that apply the comparison filter to the result value of the data entity. No projection is applied to the subqueries, this should be done in the calling method.
        Parameters:
        filter - the filter
        Returns:
        a stream of subqueries for the data entity
      • createResultCriterion

        protected abstract org.hibernate.criterion.Criterion createResultCriterion​(org.n52.shetland.ogc.filter.ComparisonFilter filter)
        Create a Criterion for the specified result filter.
        Parameters:
        filter - the filter
        Returns:
        the criterion
      • createDatasetCriterion

        protected abstract org.hibernate.criterion.Criterion createDatasetCriterion​(String property,
                                                                                    org.n52.shetland.ogc.filter.ComparisonFilter filter)
        Create a Criterion for a property of the associated data set.
        Parameters:
        property - the property of the data set to apply the filter to
        filter - the comparison filter
        Returns:
        the criterion
      • createDatasetCriterion

        protected abstract org.hibernate.criterion.Criterion createDatasetCriterion​(String property,
                                                                                    org.n52.shetland.ogc.filter.SpatialFilter filter)
        Create a Criterion for a property of the associated data set.
        Parameters:
        property - the property of the data set to apply the filter to
        filter - the spatial filter
        Returns:
        the criterion
      • createDataCriterion

        protected abstract org.hibernate.criterion.Criterion createDataCriterion​(org.hibernate.criterion.Criterion criterion)
        Create a Criterion for a property of the associated data entity.
        Parameters:
        criterion - the criterion
        Returns:
        the criterion
      • parseTime

        public static org.n52.shetland.ogc.gml.time.Time parseTime​(String value)
                                                            throws IllegalArgumentException
        Parse the value either as a TimeInstant or as a TimePeriod.
        Parameters:
        value - the string value
        Returns:
        the time
        Throws:
        IllegalArgumentException - if the value does not represent a valud time instant or period
      • parseLong

        public static Optional<Long> parseLong​(String value)
        Trys to parse value as a long.
        Parameters:
        value - the value
        Returns:
        the parsed value or Optional.empty()
      • parseInt

        public static Optional<Integer> parseInt​(String value)
        Trys to parse value as a int.
        Parameters:
        value - the value
        Returns:
        the parsed value or Optional.empty()
      • parseDouble

        public static Optional<Double> parseDouble​(String value)
        Trys to parse value as a double.
        Parameters:
        value - the value
        Returns:
        the parsed value or Optional.empty()
      • parseBigDecimal

        public static Optional<BigDecimal> parseBigDecimal​(String value)
        Trys to parse value as a BigDecimal.
        Parameters:
        value - the value
        Returns:
        the parsed value or Optional.empty()
      • parseBoolean

        public static Optional<Boolean> parseBoolean​(String value)
        Trys to parse value as a boolean.
        Parameters:
        value - the value
        Returns:
        the parsed value or Optional.empty()