/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
/** * Returns a comparison between the given operands using this operator. * * @param factory factory for creating the comparison * @param left operand on the left hand side * @param right operand on the right hand side * @return comparison * @throws RepositoryException if the comparison can not be created */ public Comparison comparison( QueryObjectModelFactory factory, DynamicOperand left, StaticOperand right) throws RepositoryException { return factory.comparison(left, name, right); }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Map<String, Literal> literals = new HashMap<String, Literal>(); for (Row leftRow : leftRows) { for (Value value : evaluator.getValues(leftProperty, leftRow)) { literals.put(value.getString(), factory.literal(value)); } } List<Constraint> constraints = new ArrayList<Constraint>(literals.size()); for (Literal literal : literals.values()) { constraints.add(factory.comparison( rightProperty, JCR_OPERATOR_EQUAL_TO, literal)); } return constraints; }
@Override public List<Constraint> getRightJoinConstraints(Collection<Row> leftRows) throws RepositoryException { Map<String, Literal> literals = new HashMap<String, Literal>(); for (Row leftRow : leftRows) { for (Value value : evaluator.getValues(leftProperty, leftRow)) { literals.put(value.getString(), factory.literal(value)); } } List<Constraint> constraints = new ArrayList<Constraint>(literals.size()); for (Literal literal : literals.values()) { constraints.add(factory.comparison( rightProperty, JCR_OPERATOR_EQUAL_TO, literal)); } return constraints; }
/** * Test case for {@link QueryObjectModelFactory#comparison(DynamicOperand, String, StaticOperand)} */ public void testComparison() throws RepositoryException { PropertyValue op1 = qf.propertyValue(SELECTOR_NAME1, propertyName1); BindVariableValue op2 = qf.bindVariable(VARIABLE_NAME); for (Iterator<String> it = OPERATORS.iterator(); it.hasNext(); ) { String operator = it.next(); Comparison comp = qf.comparison(op1, operator, op2); assertTrue("Not a PropertyValue operand", comp.getOperand1() instanceof PropertyValue); assertTrue("Not a BindVariableValue operand", comp.getOperand2() instanceof BindVariableValue); assertEquals("Wrong operator", operator, comp.getOperator()); } }
private QueryObjectModel createQuery(String operator, Value literal) throws RepositoryException { return qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.nodeName("s"), operator, qf.literal(literal) ) ), null, null); } }
qf.and( qf.childNode("s", testRoot), qf.comparison( qf.propertyValue("s", propertyName1), QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO, qf.and( qf.childNode("s", testRoot), qf.comparison( qf.propertyValue("s", propertyName2), QueryObjectModelFactory.JCR_OPERATOR_EQUAL_TO,
private QueryObjectModel createQuery(String operator, Value literal) throws RepositoryException { return qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.nodeLocalName("s"), operator, qf.literal(literal) ) ), null, null); } }
fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGPARENTFOLDERPATH() ), QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, fac.literal( session.getValueFactory().createValue( origParentFolderPath ) ) ); String convertedFilter = filter.replace( '*', '%' ); origNameConstraint = fac.comparison( fac.propertyValue( selectorName, pentahoJcrConstants.getPHO_ORIGNAME() ), QueryObjectModelConstants.JCR_OPERATOR_LIKE, fac.literal( session.getValueFactory().createValue( convertedFilter ) ) );
private QueryObjectModel createQuery(DynamicOperand operand, boolean toUpper, String operator, Value literal) throws RepositoryException { if (toUpper) { operand = qf.upperCase(operand); } else { operand = qf.lowerCase(operand); } return qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( operand, operator, qf.literal(literal) ) ), null, null); } }
protected void setUp() throws Exception { super.setUp(); qomQuery = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.propertyValue("s", propertyName1), QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, qf.bindVariable("v") ) ), null, null); sqlQuery = qm.createQuery(qomQuery.getStatement(), Query.JCR_SQL2); }
private QueryResult[] executeQueries(String propertyName, String operator, Value length) throws RepositoryException { QueryObjectModel qom = qf.createQuery( qf.selector(testNodeType, "s"), qf.and( qf.childNode("s", testRoot), qf.comparison( qf.length( qf.propertyValue( "s", propertyName)), operator, qf.literal(length)) ), null, null); QueryResult[] results = new QueryResult[2]; results[0] = qom.execute(); results[1] = qm.createQuery(qom.getStatement(), Query.JCR_SQL2).execute(); return results; } }
qf.and( qf.fullTextSearch("s", null, qf.literal(vf.createValue("fox"))), qf.comparison( qf.fullTextSearchScore("s"), QueryObjectModelFactory.JCR_OPERATOR_GREATER_THAN,
qomFactory.and( qomFactory.childNode("s", testRoot), qomFactory.comparison( qomFactory.lowerCase( qomFactory.propertyValue("s", propertyName1)),
@Test public void comparison() throws RepositoryException { PropertyValue p = f.propertyValue("selectorName", "propertyName"); Literal l = f.literal(vf.createValue(1)); Comparison c = f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, l); assertEquals(p, c.getOperand1()); assertEquals(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, c.getOperator()); assertEquals(l, c.getOperand2()); assertEquals("[selectorName].[propertyName] = 1", c.toString()); }
@Test public void createQuery() throws RepositoryException { Selector s = f.selector("nt:file", "x"); BindVariableValue b = f.bindVariable("var"); Constraint c = f.propertyExistence("x", "c"); PropertyValue p = f.propertyValue("x", "propertyName"); c = f.and(f.comparison(p, QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, b), c); Ordering o = f.ascending(p); Column col = f.column("x", "propertyName", "columnName"); Ordering[] ords = new Ordering[]{o}; Column[] cols = new Column[]{col}; QueryObjectModel q = f.createQuery(s, c, ords, cols); assertEquals(Query.JCR_JQOM, q.getLanguage()); String[] bv = q.getBindVariableNames(); assertEquals(1, bv.length); assertEquals("var", bv[0]); assertEquals(s, q.getSource()); assertEquals(c, q.getConstraint()); assertEquals(o, q.getOrderings()[0]); assertEquals(col, q.getColumns()[0]); }