use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class MockQuery method addTypeFilter.
public void addTypeFilter(String type, String versions) {
Filter filter = null;
if (versions != null && !versions.isEmpty()) {
String[] typeVersions = versions.split(",");
List<Filter> typeVersionPairsFilters = new ArrayList<Filter>();
for (String version : typeVersions) {
PropertyIsEqualTo typeFilter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
PropertyIsEqualTo versionFilter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE_VERSION), FILTER_FACTORY.literal(version));
typeVersionPairsFilters.add(FILTER_FACTORY.and(typeFilter, versionFilter));
}
if (!typeVersionPairsFilters.isEmpty()) {
filter = FILTER_FACTORY.or(typeVersionPairsFilters);
} else {
filter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
}
} else {
filter = FILTER_FACTORY.equals(FILTER_FACTORY.property(Metacard.CONTENT_TYPE), FILTER_FACTORY.literal(type));
}
if (filter != null) {
filters.add(filter);
this.filter = getFilter();
}
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitPropertyIsEqualTo.
@Test
public void testVisitPropertyIsEqualTo() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equals(attrExpr, val);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(true));
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class TestPubSubOgcFilter method testContextualFeatureEvaluate.
@Test
@Ignore
public void testContextualFeatureEvaluate() throws TransformerException {
SimpleFeature feature = generateSampleFeature();
FilterFactory filterFactory = new FilterFactoryImpl();
PropertyIsEqualTo filter = filterFactory.equal(filterFactory.property("name"), filterFactory.literal("FirstFeature"), true);
printFilter(filter);
assertTrue(filter.evaluate(feature));
}
use of org.opengis.filter.PropertyIsEqualTo in project sldeditor by robward-scisys.
the class UniqueValueRenderer method createFilter.
/**
* Creates the filter.
*
* @param rule the rule
* @param fieldsElement the fields element
* @param fieldDelimiterElement the field delimiter element
* @param value the value
*/
private void createFilter(Rule rule, JsonElement fieldsElement, JsonElement fieldDelimiterElement, String value) {
if (fieldsElement == null)
return;
if (value == null) {
rule.setElseFilter(true);
} else {
List<String> fieldList = new ArrayList<String>();
JsonArray fieldArray = fieldsElement.getAsJsonArray();
for (int fieldIndex = 0; fieldIndex < fieldArray.size(); fieldIndex++) {
JsonElement jsonFieldElement = fieldArray.get(fieldIndex);
if (jsonFieldElement != null) {
JsonObject fieldObj = jsonFieldElement.getAsJsonObject();
fieldList.add(fieldObj.get("name").getAsString());
}
}
String[] values = null;
if (fieldDelimiterElement != null) {
values = value.split(fieldDelimiterElement.getAsString());
} else {
values = new String[1];
values[0] = value;
}
List<Filter> filterList = new ArrayList<Filter>();
int index = 0;
while (index < values.length) {
Expression fieldExpression = filterFactory.property(fieldList.get(index));
Expression valueExpression = filterFactory.literal(values[index]);
PropertyIsEqualTo filter = filterFactory.equals(fieldExpression, valueExpression);
filterList.add(filter);
index++;
}
Filter completeFilter = null;
if (filterList.size() > 1) {
completeFilter = filterFactory.and(filterList);
} else if (filterList.size() == 1) {
completeFilter = filterList.get(0);
}
rule.setFilter(completeFilter);
}
}
use of org.opengis.filter.PropertyIsEqualTo in project ddf by codice.
the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsEqualTo.
@Test
public void testVisitPropertyIsEqualTo() {
Expression val = factory.literal("foo");
PropertyIsEqualTo filter = factory.equals(attrExpr, val);
PropertyIsEqualTo duplicate = (PropertyIsEqualTo) visitor.visit(filter, null);
assertThat(duplicate.getExpression1(), is(attrExpr));
assertThat(duplicate.getExpression2(), is(val));
assertThat(duplicate.isMatchingCase(), is(true));
}
Aggregations