public static Constraint or( QueryObjectModelFactory factory, List<Constraint> constraints) throws RepositoryException { int n = constraints.size(); if (n == 0) { return null; } else if (n == 1) { return constraints.get(0); } else { int m = n / 2; return factory.or( or(factory, constraints.subList(0, m)), or(factory, constraints.subList(m, n))); } }
public static Constraint or( QueryObjectModelFactory factory, List<Constraint> constraints) throws RepositoryException { int n = constraints.size(); if (n == 0) { return null; } else if (n == 1) { return constraints.get(0); } else { int m = n / 2; return factory.or( or(factory, constraints.subList(0, m)), or(factory, constraints.subList(m, n))); } }
private Constraint parseConstraint() throws RepositoryException { Constraint a = parseAnd(); while (readIf("OR")) { a = factory.or(a, parseAnd()); } return a; }
private Constraint parseConstraint() throws RepositoryException { Constraint a = parseAnd(); while (readIf("OR")) { a = factory.or(a, parseAnd()); } return a; }
private Constraint parseConstraint() throws RepositoryException { Constraint a = parseAnd(); while (readIf("OR")) { a = factory.or(a, parseAnd()); } return a; }
public void testOr() throws RepositoryException { Node n1 = testRootNode.addNode(nodeName1, testNodeType); n1.setProperty(propertyName1, "foo"); Node n2 = testRootNode.addNode(nodeName2, testNodeType); n2.setProperty(propertyName2, "bar"); superuser.save(); QueryObjectModel qom = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.descendantNode("s", testRootNode.getPath()), qf.or( qf.propertyExistence("s", propertyName1), qf.propertyExistence("s", propertyName2) ) ), null, null ); checkQOM(qom, new Node[]{n1, n2}); } }
/** * Test case for {@link QueryObjectModelFactory#or(Constraint, Constraint)} */ public void testOr() throws RepositoryException { PropertyExistence c1 = qf.propertyExistence(SELECTOR_NAME1, propertyName1); PropertyExistence c2 = qf.propertyExistence(SELECTOR_NAME1, propertyName2); Or or = qf.or(c1, c2); assertTrue("Not a PropertyExistence constraint", or.getConstraint1() instanceof PropertyExistence); assertTrue("Not a PropertyExistence constraint", or.getConstraint2() instanceof PropertyExistence); }
@Test public void or() throws RepositoryException { Constraint c0 = f.propertyExistence("x", "c0"); Constraint c1 = f.propertyExistence("x", "c1"); Or or = f.or(c0, c1); assertEquals(or.getConstraint1(), c0); assertEquals(or.getConstraint2(), c1); assertEquals("([x].[c0] IS NOT NULL) OR ([x].[c1] IS NOT NULL)", or.toString()); }
private void splitNot(ConstraintSplitInfo constraintSplitInfo, Not not) throws RepositoryException { Constraint constraint = not.getConstraint(); if (constraint instanceof Not) { split(constraintSplitInfo, ((Not) constraint).getConstraint()); } else if (constraint instanceof And) { And and = (And) constraint; split(constraintSplitInfo, factory.or(factory.not(and.getConstraint1()), factory.not(and.getConstraint2()))); } else if (constraint instanceof Or) { Or or = (Or) constraint; split(constraintSplitInfo, factory.and(factory.not(or.getConstraint1()), factory.not(or.getConstraint2()))); } else { splitBySelectors(constraintSplitInfo, not, getSelectorNames(constraint)); } }
private void splitNot(ConstraintSplitInfo constraintSplitInfo, Not not) throws RepositoryException { Constraint constraint = not.getConstraint(); if (constraint instanceof Not) { split(constraintSplitInfo, ((Not) constraint).getConstraint()); } else if (constraint instanceof And) { And and = (And) constraint; split(constraintSplitInfo, factory.or(factory.not(and.getConstraint1()), factory.not(and.getConstraint2()))); } else if (constraint instanceof Or) { Or or = (Or) constraint; split(constraintSplitInfo, factory.and(factory.not(or.getConstraint1()), factory.not(or.getConstraint2()))); } else { splitBySelectors(constraintSplitInfo, not, getSelectorNames(constraint)); } }