Search in sources :

Example 1 with OGCConfiguration

use of org.geotools.filter.v1_1.OGCConfiguration in project ddf by codice.

the class CswCqlTextFilter method getCqlText.

public String getCqlText(FilterType filterType) throws UnsupportedQueryException {
    Parser parser = new Parser(new OGCConfiguration());
    try {
        StringReader reader = new StringReader(marshalFilterType(filterType));
        Object parsedFilter = parser.parse(reader);
        if (parsedFilter instanceof Filter) {
            Filter filterToCql = (Filter) parsedFilter;
            LOGGER.debug("Filter to Convert to CQL => {}", filterToCql);
            String cql = ECQL.toCQL(filterToCql);
            LOGGER.debug("Generated CQL from Filter => {}", cql);
            return cql;
        } else {
            throw new UnsupportedQueryException("Query did not produce a valid filter.");
        }
    } catch (IOException | SAXException | ParserConfigurationException | JAXBException e) {
        throw new UnsupportedQueryException("Unable to create CQL Filter.", e);
    }
}
Also used : Filter(org.opengis.filter.Filter) OGCConfiguration(org.geotools.filter.v1_1.OGCConfiguration) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) JAXBException(javax.xml.bind.JAXBException) StringReader(java.io.StringReader) IOException(java.io.IOException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) Parser(org.geotools.xml.Parser) SAXException(org.xml.sax.SAXException)

Aggregations

UnsupportedQueryException (ddf.catalog.source.UnsupportedQueryException)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 JAXBException (javax.xml.bind.JAXBException)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 OGCConfiguration (org.geotools.filter.v1_1.OGCConfiguration)1 Parser (org.geotools.xml.Parser)1 Filter (org.opengis.filter.Filter)1 SAXException (org.xml.sax.SAXException)1