use of org.apache.cxf.jaxrs.ext.search.PrimitiveStatement in project cxf by apache.
the class LuceneQueryVisitor method visit.
public void visit(SearchCondition<T> sc) {
if (state.get() == null) {
reset();
}
PrimitiveStatement statement = sc.getStatement();
if (statement != null) {
if (statement.getProperty() != null) {
state.get().peek().add(buildSimpleQuery(sc.getConditionType(), statement.getProperty(), statement.getValue()));
}
} else {
state.get().push(new ArrayList<>());
for (SearchCondition<T> condition : sc.getSearchConditions()) {
condition.accept(this);
}
boolean orCondition = sc.getConditionType() == ConditionType.OR;
List<Query> queries = state.get().pop();
state.get().peek().add(createCompositeQuery(queries, orCondition));
}
}
use of org.apache.cxf.jaxrs.ext.search.PrimitiveStatement in project cxf by apache.
the class FiqlParserTest method testParseComplex2.
@Test
public void testParseComplex2() throws SearchParseException {
SearchCondition<Condition> filter = parser.parse("name==ami*,level=gt=10");
assertEquals(ConditionType.OR, filter.getConditionType());
List<SearchCondition<Condition>> conditions = filter.getSearchConditions();
assertEquals(2, conditions.size());
PrimitiveStatement st1 = conditions.get(0).getStatement();
PrimitiveStatement st2 = conditions.get(1).getStatement();
assertTrue((ConditionType.EQUALS.equals(st1.getCondition()) && ConditionType.GREATER_THAN.equals(st2.getCondition())) || (ConditionType.EQUALS.equals(st2.getCondition()) && ConditionType.GREATER_THAN.equals(st1.getCondition())));
assertTrue(filter.isMet(new Condition("ami", 0, new Date())));
assertTrue(filter.isMet(new Condition("foo", 20, null)));
assertFalse(filter.isMet(new Condition("foo", 0, null)));
}
use of org.apache.cxf.jaxrs.ext.search.PrimitiveStatement in project cxf by apache.
the class FiqlParserTest method testParseComplex1.
@Test
public void testParseComplex1() throws SearchParseException {
SearchCondition<Condition> filter = parser.parse("name==ami*;level=gt=10");
assertEquals(ConditionType.AND, filter.getConditionType());
List<SearchCondition<Condition>> conditions = filter.getSearchConditions();
assertEquals(2, conditions.size());
PrimitiveStatement st1 = conditions.get(0).getStatement();
PrimitiveStatement st2 = conditions.get(1).getStatement();
assertTrue((ConditionType.EQUALS.equals(st1.getCondition()) && ConditionType.GREATER_THAN.equals(st2.getCondition())) || (ConditionType.EQUALS.equals(st2.getCondition()) && ConditionType.GREATER_THAN.equals(st1.getCondition())));
assertTrue(filter.isMet(new Condition("amichalec", 12, new Date())));
assertTrue(filter.isMet(new Condition("ami", 12, new Date())));
assertFalse(filter.isMet(new Condition("ami", 8, null)));
assertFalse(filter.isMet(new Condition("am", 20, null)));
}
Aggregations