@Override public String getString() { return fullTextSearchExpression(); }
@Override public String getString() { return fullTextSearchExpression(); }
final Literal visitorLiteral = new Literal(fullTextSearchExpression());
@Override public void visit( FullTextSearch fullText ) { append("CONTAINS(").append(fullText.selectorName()); if (fullText.getPropertyName() != null) { append('.').appendPropertyName(fullText.getPropertyName()); } sb.append(",'").append(fullText.fullTextSearchExpression()).append("')"); }
@Test public void shouldParseConstraintFromStringWithIsContainsExpressionWithSelectorNameAndProperty() { Constraint constraint = parser.parseConstraint(tokens("CONTAINS(tableA.propertyA,'term1 term2 -term3')"), typeSystem, mock(Source.class)); assertThat(constraint, is(instanceOf(FullTextSearch.class))); FullTextSearch search = (FullTextSearch)constraint; assertThat(search.selectorName(), is(selectorName("tableA"))); assertThat(search.getPropertyName(), is("propertyA")); assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3")); }
@Test public void shouldParseConstraintFromStringWithIsContainsExpressionWithSelectorNameAndAnyProperty() { Constraint constraint = parser.parseConstraint(tokens("CONTAINS(tableA.*,'term1 term2 -term3')"), typeSystem, mock(Source.class)); assertThat(constraint, is(instanceOf(FullTextSearch.class))); FullTextSearch search = (FullTextSearch)constraint; assertThat(search.selectorName(), is(selectorName("tableA"))); assertThat(search.getPropertyName(), is(nullValue())); assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3")); }
@Test public void shouldParseConstraintFromStringWithIsContainsExpressionWithPropertyAndNoSelectorNameOnlyIfThereIsOneSelectorSource() { NamedSelector selector = new NamedSelector(selectorName("tableA")); Constraint constraint = parser.parseConstraint(tokens("CONTAINS(propertyA,'term1 term2 -term3')"), typeSystem, selector); assertThat(constraint, is(instanceOf(FullTextSearch.class))); FullTextSearch search = (FullTextSearch)constraint; assertThat(search.selectorName(), is(selectorName("tableA"))); assertThat(search.getPropertyName(), is("propertyA")); assertThat(search.fullTextSearchExpression(), is("term1 term2 -term3")); }
@Test public void shouldParseConstraintFromStringWithOrExpressionWithNoParentheses() { NamedSelector selector = new NamedSelector(selectorName("tableA")); Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') OR CONTAINS(p1,term1)"), typeSystem, selector); assertThat(constraint, is(instanceOf(Or.class))); Or or = (Or)constraint; assertThat(or.left(), is(instanceOf(SameNode.class))); SameNode same = (SameNode)or.left(); assertThat(same.selectorName(), is(selectorName("tableA"))); assertThat(same.getPath(), is("/a/b/c")); assertThat(or.right(), is(instanceOf(FullTextSearch.class))); FullTextSearch search = (FullTextSearch)or.right(); assertThat(search.selectorName(), is(selectorName("tableA"))); assertThat(search.getPropertyName(), is("p1")); assertThat(search.fullTextSearchExpression(), is("term1")); }
@Test public void shouldParseConstraintFromStringWithAndExpressionWithNoParentheses() { NamedSelector selector = new NamedSelector(selectorName("tableA")); Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') AND CONTAINS(p1,term1)"), typeSystem, selector); assertThat(constraint, is(instanceOf(And.class))); And and = (And)constraint; assertThat(and.left(), is(instanceOf(SameNode.class))); SameNode same = (SameNode)and.left(); assertThat(same.selectorName(), is(selectorName("tableA"))); assertThat(same.getPath(), is("/a/b/c")); assertThat(and.right(), is(instanceOf(FullTextSearch.class))); FullTextSearch search = (FullTextSearch)and.right(); assertThat(search.selectorName(), is(selectorName("tableA"))); assertThat(search.getPropertyName(), is("p1")); assertThat(search.fullTextSearchExpression(), is("term1")); }
@Test public void shouldParseConstraintFromStringWithMultipleAndExpressions() { NamedSelector selector = new NamedSelector(selectorName("tableA")); Constraint constraint = parser.parseConstraint(tokens("ISSAMENODE('/a/b/c') AND CONTAINS(p1,term1) AND CONTAINS(p2,term2)"), typeSystem, selector); assertThat(constraint, is(instanceOf(And.class))); And and = (And)constraint; assertThat(and.left(), is(instanceOf(SameNode.class))); SameNode same = (SameNode)and.left(); assertThat(same.selectorName(), is(selectorName("tableA"))); assertThat(same.getPath(), is("/a/b/c")); assertThat(and.right(), is(instanceOf(And.class))); And secondAnd = (And)and.right(); assertThat(secondAnd.left(), is(instanceOf(FullTextSearch.class))); FullTextSearch search1 = (FullTextSearch)secondAnd.left(); assertThat(search1.selectorName(), is(selectorName("tableA"))); assertThat(search1.getPropertyName(), is("p1")); assertThat(search1.fullTextSearchExpression(), is("term1")); assertThat(secondAnd.right(), is(instanceOf(FullTextSearch.class))); FullTextSearch search2 = (FullTextSearch)secondAnd.right(); assertThat(search2.selectorName(), is(selectorName("tableA"))); assertThat(search2.getPropertyName(), is("p2")); assertThat(search2.fullTextSearchExpression(), is("term2")); }
return new FullTextSearch(search.selectorName(), search.fullTextSearchExpression());
return new FullTextSearch(search.selectorName(), search.fullTextSearchExpression());
return new StringQuery(fts.fullTextSearchExpression());
SelectorName replacement = rewrittenSelectors.get(search.selectorName()); if (replacement == null) return search; return new FullTextSearch(replacement, search.getPropertyName(), search.fullTextSearchExpression());
SelectorName replacement = rewrittenSelectors.get(search.selectorName()); if (replacement == null) return search; return new FullTextSearch(replacement, search.getPropertyName(), search.fullTextSearchExpression());
if (newSelectorName != null) { node.addSelector(newSelectorName); return new FullTextSearch(newSelectorName, search.getPropertyName(), search.fullTextSearchExpression(), search.getFullTextSearchExpression()); search.fullTextSearchExpression(), search.getFullTextSearchExpression());
if (newSelectorName != null) { node.addSelector(newSelectorName); return new FullTextSearch(newSelectorName, search.getPropertyName(), search.fullTextSearchExpression(), search.getFullTextSearchExpression()); search.fullTextSearchExpression(), search.getFullTextSearchExpression());