@Override public int hashCode() { return getConstraint().hashCode(); }
@Override public int hashCode() { return getConstraint().hashCode(); }
protected boolean indexAppliesTo( Not not ) { return indexAppliesTo(not.getConstraint()); }
protected boolean indexAppliesTo( Not not ) { return indexAppliesTo(not.getConstraint()); }
@Override public void visit( Not not ) { strategy.visit(not); enqueue(not.getConstraint()); visitNext(); }
@Override public void visit( Not not ) { strategy.visit(not); enqueue(not.getConstraint()); visitNext(); }
@Override public void visit( Not not ) { append("NOT "); append('('); not.getConstraint().accept(this); append(')'); }
@Override public void visit( Not not ) { append("NOT "); append('('); not.getConstraint().accept(this); append(')'); }
@Test public void shouldParseConstraintFromStringWithNotSameNodeExpression() { Constraint constraint = parser.parseConstraint(tokens("NOT(ISSAMENODE(tableA,'/a/b/c'))"), typeSystem, mock(Source.class)); assertThat(constraint, is(instanceOf(Not.class))); Not not = (Not)constraint; assertThat(not.getConstraint(), is(instanceOf(SameNode.class))); SameNode same = (SameNode)not.getConstraint(); assertThat(same.selectorName(), is(selectorName("tableA"))); assertThat(same.getPath(), is("/a/b/c")); }
@Test public void shouldParseNotPropertyExistanceFromPropertyNameWithSelectorNameAndPropertyNameFollowedByIsNull() { Constraint constraint = parser.parsePropertyExistance(tokens("tableA.property1 IS NULL"), typeSystem, mock(Source.class)); assertThat(constraint, is(instanceOf(Not.class))); Not not = (Not)constraint; assertThat(not.getConstraint(), is(instanceOf(PropertyExistence.class))); PropertyExistence p = (PropertyExistence)not.getConstraint(); assertThat(p.getPropertyName(), is("property1")); assertThat(p.selectorName(), is(selectorName("tableA"))); }
Constraint oldInner = not.getConstraint(); Constraint newInner = rewrite(context, oldInner); if (oldInner != newInner) {
Constraint oldInner = not.getConstraint(); Constraint newInner = rewrite(context, oldInner); if (oldInner != newInner) {
@Test public void shouldParseConstraintFromStringWithValidNotBetweenExpression() { NamedSelector selector = new NamedSelector(selectorName("tableA")); Constraint constraint = parser.parseConstraint(tokens("tableA.id NOT BETWEEN 'lower' AND 'upper'"), typeSystem, selector); assertThat(constraint, is(instanceOf(Not.class))); constraint = ((Not)constraint).getConstraint(); assertThat(constraint, is(instanceOf(Between.class))); Between between = (Between)constraint; assertThat(between.isLowerBoundIncluded(), is(true)); assertThat(between.isUpperBoundIncluded(), is(true)); assertThat(between.getOperand(), is(instanceOf(PropertyValue.class))); PropertyValue operand = (PropertyValue)between.getOperand(); assertThat(operand.selectorName(), is(selector.name())); assertThat(operand.getPropertyName(), is("id")); assertThat(between.getLowerBound(), is(instanceOf(Literal.class))); assertThat(between.getLowerBound(), is(instanceOf(Literal.class))); assertThat(between.getLowerBound(), is(literal("lower"))); assertThat(between.getUpperBound(), is(literal("upper"))); }
/** * Tests that the child nodes (but no grandchild nodes) are returned. */ @Test public void shouldParseSelectWithChildAxisCriteria() { query = parse("SELECT * FROM nt:base WHERE jcr:path LIKE '/a/b/%' AND NOT jcr:path LIKE '/a/b/%/%'"); // SELECT * ... assertThat(query.columns().isEmpty(), is(true)); // FROM ... NamedSelector selector = (NamedSelector)query.source(); assertThat(selector.name(), is(selectorName("nt:base"))); assertThat(selector.aliasOrName(), is(selectorName("nt:base"))); assertThat(selector.alias(), is(nullValue())); // WHERE ... And and = isAnd(query.constraint()); Comparison comparison1 = isComparison(and.left()); assertThat(comparison1.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base")))); assertThat(comparison1.getOperand2(), is((StaticOperand)literal("/a/b/%"))); Not not = isNot(and.right()); Comparison comparison2a = isComparison(not.getConstraint()); assertThat(comparison2a.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base")))); assertThat(comparison2a.getOperand2(), is((StaticOperand)literal("/a/b/%/%"))); }
/** * Tests that the child nodes (but no grandchild nodes) are returned. */ @Test public void shouldParseSelectWithChildAxisCriteria() { query = parse("SELECT * FROM [nt:base] WHERE PATH() LIKE '/a/b/%' AND NOT PATH() LIKE '/a/b/%/%'"); // SELECT * ... assertThat(query.columns().isEmpty(), is(true)); // FROM ... NamedSelector selector = (NamedSelector)query.source(); assertThat(selector.name(), is(selectorName("nt:base"))); assertThat(selector.aliasOrName(), is(selectorName("nt:base"))); assertThat(selector.alias(), is(nullValue())); // WHERE ... And and = isAnd(query.constraint()); Comparison comparison1 = isComparison(and.left()); assertThat(comparison1.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base")))); assertThat(comparison1.getOperand2(), is((StaticOperand)literal("/a/b/%"))); Not not = isNot(and.right()); Comparison comparison2a = isComparison(not.getConstraint()); assertThat(comparison2a.getOperand1(), is((DynamicOperand)nodePath(selectorName("nt:base")))); assertThat(comparison2a.getOperand2(), is((StaticOperand)literal("/a/b/%/%"))); }
Constraint wrapped = replaceReferencesToRemovedSource(context, not.getConstraint(), rewrittenSelectors); if (wrapped == not.getConstraint()) return not; return new Not(wrapped);
Constraint wrapped = replaceSubqueriesWithBindVariables(context, not.getConstraint(), subqueriesByVariableName); if (wrapped == not.getConstraint()) return not; return new Not(wrapped);
Constraint wrapped = replaceAliasesWithProperties(context, not.getConstraint(), propertyByAlias); if (wrapped == not.getConstraint()) return not; return new Not(wrapped);
Constraint wrapped = replaceAliasesWithProperties(context, not.getConstraint(), propertyByAlias); if (wrapped == not.getConstraint()) return not; return new Not(wrapped);
Constraint wrapped = replaceReferences(context, not.getConstraint(), mapping, node); return wrapped == not.getConstraint() ? not : new Not(wrapped);