Search in sources :

Example 1 with PropertyExistence

use of javax.jcr.query.qom.PropertyExistence in project jackrabbit-oak by apache.

the class QomTest method propertyExistence.

@Test
public void propertyExistence() throws RepositoryException {
    PropertyExistence pe = f.propertyExistence("selectorName", "propertyName");
    assertEquals("selectorName", pe.getSelectorName());
    assertEquals("propertyName", pe.getPropertyName());
    assertEquals("[selectorName].[propertyName] IS NOT NULL", pe.toString());
    assertEquals("* IS NOT NULL", f.propertyExistence(null, null).toString());
    assertEquals("[s].* IS NOT NULL", f.propertyExistence("s", null).toString());
    assertEquals("[p] IS NOT NULL", f.propertyExistence(null, "p").toString());
    assertEquals("[s].[p] IS NOT NULL", f.propertyExistence("s", "p").toString());
}
Also used : PropertyExistence(javax.jcr.query.qom.PropertyExistence) Test(org.junit.Test)

Example 2 with PropertyExistence

use of javax.jcr.query.qom.PropertyExistence in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testNot.

/**
 * Test case for {@link QueryObjectModelFactory#not(Constraint)}
 */
public void testNot() throws RepositoryException {
    PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
    Not not = qf.not(propExist);
    assertTrue("Not a property existence constraint", not.getConstraint() instanceof PropertyExistence);
}
Also used : Not(javax.jcr.query.qom.Not) PropertyExistence(javax.jcr.query.qom.PropertyExistence)

Example 3 with PropertyExistence

use of javax.jcr.query.qom.PropertyExistence in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testCreateQueryFromSourceWithConstraintAndOrdering.

public void testCreateQueryFromSourceWithConstraintAndOrdering() throws RepositoryException {
    Source selector = qf.selector(testNodeType, SELECTOR_NAME1);
    PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
    PropertyValue propValue = qf.propertyValue(SELECTOR_NAME1, propertyName1);
    Ordering ordering = qf.ascending(propValue);
    QueryObjectModel qom = qf.createQuery(selector, propExist, new Ordering[] { ordering }, null);
    assertTrue("Not a selector source", qom.getSource() instanceof Selector);
    assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
    assertEquals("Wrong size of orderings", 1, qom.getOrderings().length);
    assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
Also used : Ordering(javax.jcr.query.qom.Ordering) PropertyValue(javax.jcr.query.qom.PropertyValue) QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) PropertyExistence(javax.jcr.query.qom.PropertyExistence) Source(javax.jcr.query.qom.Source) Selector(javax.jcr.query.qom.Selector)

Example 4 with PropertyExistence

use of javax.jcr.query.qom.PropertyExistence in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testCreateQueryWithConstraint.

public void testCreateQueryWithConstraint() throws RepositoryException {
    Selector selector = qf.selector(testNodeType, SELECTOR_NAME1);
    PropertyExistence propExist = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
    QueryObjectModel qom = qf.createQuery(selector, propExist, null, null);
    assertTrue("Not a selector source", qom.getSource() instanceof Selector);
    assertTrue("Not a property existence constraint", qom.getConstraint() instanceof PropertyExistence);
    assertEquals("Wrong size of orderings", 0, qom.getOrderings().length);
    assertEquals("Wrong size of columns", 0, qom.getColumns().length);
}
Also used : QueryObjectModel(javax.jcr.query.qom.QueryObjectModel) PropertyExistence(javax.jcr.query.qom.PropertyExistence) Selector(javax.jcr.query.qom.Selector)

Example 5 with PropertyExistence

use of javax.jcr.query.qom.PropertyExistence in project jackrabbit by apache.

the class QueryObjectModelFactoryTest method testAnd.

/**
 * Test case for {@link QueryObjectModelFactory#and(Constraint, Constraint)}
 */
public void testAnd() throws RepositoryException {
    PropertyExistence c1 = qf.propertyExistence(SELECTOR_NAME1, propertyName1);
    PropertyExistence c2 = qf.propertyExistence(SELECTOR_NAME1, propertyName2);
    And and = qf.and(c1, c2);
    assertTrue("Not a PropertyExistence constraint", and.getConstraint1() instanceof PropertyExistence);
    assertTrue("Not a PropertyExistence constraint", and.getConstraint2() instanceof PropertyExistence);
}
Also used : And(javax.jcr.query.qom.And) PropertyExistence(javax.jcr.query.qom.PropertyExistence)

Aggregations

PropertyExistence (javax.jcr.query.qom.PropertyExistence)13 QueryObjectModel (javax.jcr.query.qom.QueryObjectModel)6 Selector (javax.jcr.query.qom.Selector)6 Ordering (javax.jcr.query.qom.Ordering)4 PropertyValue (javax.jcr.query.qom.PropertyValue)4 Source (javax.jcr.query.qom.Source)3 And (javax.jcr.query.qom.And)2 Column (javax.jcr.query.qom.Column)2 Not (javax.jcr.query.qom.Not)2 Or (javax.jcr.query.qom.Or)2 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 ChildNode (javax.jcr.query.qom.ChildNode)1 Comparison (javax.jcr.query.qom.Comparison)1 DescendantNode (javax.jcr.query.qom.DescendantNode)1 FullTextSearch (javax.jcr.query.qom.FullTextSearch)1 SameNode (javax.jcr.query.qom.SameNode)1 Test (org.junit.Test)1