package gw.solr.mapper uses gw.xsd.config.solr_search_config.DataProperty uses gw.solr.utils.PLSolrUtils uses gw.api.util.Range uses java.lang.Integer uses java.lang.Double uses java.lang.Comparable uses java.util.List /** * To ease creation of range queries terms in a Solr query. * * @param T type to use for endpoints of the range */ @ReadOnly abstract class RangeMapper> implements ISolrQueryMapper> { /** * Accepts two parameters from the data property list and formats an appropriate * range query based on the type and value of the query data * * @return Range<T> for the data range for this query field, or null if no * query against this field is required. Data should not be quoted or * encoded. This will be handled by the caller according to the encoder * registered for this query term. */ override function mapQuery(queryDataProperties : List, dataHolder : IDataHolder) : Range { PLSolrUtils.validate( queryDataProperties.Count == 2, "Range mapper requires exactly two criterion.") var lower = dataHolder.lookup(queryDataProperties.get(0)) var upper = dataHolder.lookup(queryDataProperties.get(1)) var theRange : Range = null if(lower != null) { if(upper != null) { theRange = Range.closed(lower, upper) } else { theRange = Range.from(lower) } } else if(upper != null) { theRange = Range.before(upper) } return theRange } /** * For string range queries */ static class BuildStringRange extends RangeMapper { } /** * For integer numeric range queries */ static class BuildIntegerRange extends RangeMapper { } /** * For long numeric range queries */ static class BuildLongRange extends RangeMapper { } /** * For double numeric range queries */ static class BuildDoubleRange extends RangeMapper { } }