Search in sources :

Example 16 with CQLException

use of org.geotools.filter.text.cql2.CQLException in project hale by halestudio.

the class AddConditionAction method run.

/**
 * @see org.eclipse.jface.action.Action#run()
 */
@Override
public void run() {
    EntityDefinitionService eds = PlatformUI.getWorkbench().getService(EntityDefinitionService.class);
    // create filter
    if (combine) {
        StringBuilder filterTerm = new StringBuilder();
        boolean first = true;
        for (String value : values) {
            if (first) {
                first = false;
            } else {
                filterTerm.append(" or ");
            }
            addSingleValueExpression(filterTerm, value);
        }
        Filter filter;
        try {
            filter = new FilterGeoCqlImpl(filterTerm.toString());
        } catch (CQLException e) {
            log.userError("Error creating condition", e);
            return;
        }
        // add condition context
        eds.addConditionContext(getContextEntity(), filter);
    } else {
        for (String value : values) {
            StringBuilder filterTerm = new StringBuilder();
            addSingleValueExpression(filterTerm, value);
            Filter filter;
            try {
                filter = new FilterGeoCqlImpl(filterTerm.toString());
            } catch (CQLException e) {
                log.userError("Error creating condition", e);
                return;
            }
            // add condition context
            eds.addConditionContext(getContextEntity(), filter);
        }
    }
}
Also used : Filter(eu.esdihumboldt.hale.common.instance.model.Filter) CQLException(org.geotools.filter.text.cql2.CQLException) FilterGeoCqlImpl(eu.esdihumboldt.hale.common.filter.FilterGeoCqlImpl) EntityDefinitionService(eu.esdihumboldt.hale.ui.service.entity.EntityDefinitionService)

Example 17 with CQLException

use of org.geotools.filter.text.cql2.CQLException in project ddf by codice.

the class ValidateCommand method getMetacardsFromCatalogInternal.

private List<Metacard> getMetacardsFromCatalogInternal() throws CatalogCommandException {
    List<Metacard> results = new ArrayList<>();
    try {
        QueryImpl query = new QueryImpl(getFilter());
        SourceResponse response = getCatalog().query(new QueryRequestImpl(query));
        List<Result> resultList = response.getResults();
        if (resultList != null) {
            results.addAll(resultList.stream().map(Result::getMetacard).filter(Objects::nonNull).collect(Collectors.toList()));
        }
    } catch (UnsupportedQueryException | SourceUnavailableException | FederationException | CQLException | ParseException e) {
        throw new CatalogCommandException("Error executing catalog:validate", e);
    }
    return results;
}
Also used : SourceUnavailableException(ddf.catalog.source.SourceUnavailableException) SourceResponse(ddf.catalog.operation.SourceResponse) UnsupportedQueryException(ddf.catalog.source.UnsupportedQueryException) ArrayList(java.util.ArrayList) FederationException(ddf.catalog.federation.FederationException) Result(ddf.catalog.data.Result) CatalogCommandException(org.codice.ddf.commands.util.CatalogCommandException) Metacard(ddf.catalog.data.Metacard) QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) Objects(java.util.Objects) CQLException(org.geotools.filter.text.cql2.CQLException) ParseException(java.text.ParseException)

Example 18 with CQLException

use of org.geotools.filter.text.cql2.CQLException in project sldeditor by robward-scisys.

the class LogicTests method testClass.

/**
 * Test class.
 *
 * @param objUnderTest the obj under test
 * @param noOFExpectedFilters the no OF expected filters
 */
private void testClass(FilterConfigInterface objUnderTest, int noOFExpectedFilters) {
    assertNotNull(objUnderTest.getFilterConfiguration());
    assertNotNull(objUnderTest.createFilter());
    assertNull(objUnderTest.createFilter(null));
    LogicFilterImpl filter = (LogicFilterImpl) objUnderTest.createLogicFilter(null);
    assertEquals(0, filter.getChildren().size());
    List<Filter> filterList = new ArrayList<Filter>();
    try {
        filterList.add(CQL.toFilter("filter1 >= 5"));
    } catch (CQLException e) {
        fail(e.getStackTrace().toString());
    }
    filter = (LogicFilterImpl) objUnderTest.createLogicFilter(filterList);
    if (noOFExpectedFilters > 1) {
        assertEquals(0, filter.getChildren().size());
        try {
            filterList.add(CQL.toFilter("filter2 >= 5"));
        } catch (CQLException e) {
            fail(e.getStackTrace().toString());
        }
        filter = (LogicFilterImpl) objUnderTest.createLogicFilter(filterList);
    }
    assertEquals(noOFExpectedFilters, filter.getChildren().size());
    assertTrue(objUnderTest.category().compareTo(category) == 0);
    System.out.println(filter.toString());
}
Also used : Filter(org.opengis.filter.Filter) LogicFilterImpl(org.geotools.filter.LogicFilterImpl) ArrayList(java.util.ArrayList) CQLException(org.geotools.filter.text.cql2.CQLException)

Example 19 with CQLException

use of org.geotools.filter.text.cql2.CQLException in project sldeditor by robward-scisys.

the class RuleDetails method updateFilter.

/**
 * Update filter.
 *
 * @return the filter
 */
private Filter updateFilter() {
    String filterText = fieldConfigVisitor.getText(FieldIdEnum.FILTER);
    Filter filter = originalFilter;
    if (originalFilter == null) {
        try {
            if (!filterText.isEmpty()) {
                filter = CQL.toFilter(filterText);
            }
        } catch (CQLException e) {
            ConsoleManager.getInstance().exception(this, e);
        }
    }
    return filter;
}
Also used : Filter(org.opengis.filter.Filter) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) CQLException(org.geotools.filter.text.cql2.CQLException)

Aggregations

CQLException (org.geotools.filter.text.cql2.CQLException)19 Filter (org.opengis.filter.Filter)12 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 SourceUnavailableException (ddf.catalog.source.SourceUnavailableException)3 RyaStatement (org.apache.rya.api.domain.RyaStatement)3 SimpleFeature (org.opengis.feature.simple.SimpleFeature)3 Statement (org.openrdf.model.Statement)3 ParseException (com.vividsolutions.jts.io.ParseException)2 QueryImpl (ddf.catalog.operation.impl.QueryImpl)2 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)2 Filter (eu.esdihumboldt.hale.common.instance.model.Filter)2 CloseableIteration (info.aduna.iteration.CloseableIteration)2 ParseException (java.text.ParseException)2 SolrQuery (org.apache.solr.client.solrj.SolrQuery)2 SolrServerException (org.apache.solr.client.solrj.SolrServerException)2 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)2 SolrDocumentList (org.apache.solr.common.SolrDocumentList)2 Expression (org.opengis.filter.expression.Expression)2 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)2