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);
}
}
}
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;
}
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());
}
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;
}
Aggregations