Search in sources :

Example 6 with ResultRow

use of org.apache.jackrabbit.oak.api.ResultRow in project jackrabbit-oak by apache.

the class NodeCounterIndexTest method executeXPathQuery.

protected String executeXPathQuery(String statement) throws ParseException {
    Result result = qe.executeQuery(statement, "xpath", null, NO_MAPPINGS);
    StringBuilder buff = new StringBuilder();
    for (ResultRow row : result.getRows()) {
        for (PropertyValue v : row.getValues()) {
            buff.append(v);
        }
    }
    return buff.toString();
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) Result(org.apache.jackrabbit.oak.api.Result)

Example 7 with ResultRow

use of org.apache.jackrabbit.oak.api.ResultRow in project jackrabbit-oak by apache.

the class QueryTest method queryOnStableRevision.

@Test
public void queryOnStableRevision() throws Exception {
    ContentSession s = repository.login(null, null);
    Root r = s.getLatestRoot();
    Tree t = r.getTree("/").addChild("test");
    t.addChild("node1").setProperty("jcr:primaryType", "nt:base");
    t.addChild("node2").setProperty("jcr:primaryType", "nt:base");
    t.addChild("node3").setProperty("jcr:primaryType", "nt:base");
    r.commit();
    ContentSession s2 = repository.login(null, null);
    Root r2 = s2.getLatestRoot();
    r.getTree("/test").getChild("node2").remove();
    r.commit();
    Result result = r2.getQueryEngine().executeQuery("test//element(*, nt:base)", Query.XPATH, QueryEngine.NO_BINDINGS, QueryEngine.NO_MAPPINGS);
    Set<String> paths = new HashSet<String>();
    for (ResultRow rr : result.getRows()) {
        paths.add(rr.getPath());
    }
    assertEquals(new HashSet<String>(Arrays.asList("/test/node1", "/test/node2", "/test/node3")), paths);
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) Root(org.apache.jackrabbit.oak.api.Root) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) Result(org.apache.jackrabbit.oak.api.Result) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with ResultRow

use of org.apache.jackrabbit.oak.api.ResultRow in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testReferenceColumn.

@Test
public void testReferenceColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.REFERENCE).when(value).getType();
    doReturn("value").when(value).getValue(Type.REFERENCE);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("value", remoteValue.asReference());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Example 9 with ResultRow

use of org.apache.jackrabbit.oak.api.ResultRow in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testMultiStringColumn.

@Test
public void testMultiStringColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.STRINGS).when(value).getType();
    doReturn(asList("a", "b")).when(value).getValue(Type.STRINGS);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList("a", "b"), remoteValue.asMultiText());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Example 10 with ResultRow

use of org.apache.jackrabbit.oak.api.ResultRow in project jackrabbit-oak by apache.

the class ContentRemoteResultTest method testMultiBooleanColumn.

@Test
public void testMultiBooleanColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.BOOLEANS).when(value).getType();
    doReturn(asList(true, false)).when(value).getValue(Type.BOOLEANS);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList(true, false), remoteValue.asMultiBoolean());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Test(org.junit.Test)

Aggregations

ResultRow (org.apache.jackrabbit.oak.api.ResultRow)41 Test (org.junit.Test)29 PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)26 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)24 Result (org.apache.jackrabbit.oak.api.Result)12 Tree (org.apache.jackrabbit.oak.api.Tree)4 ParseException (java.text.ParseException)3 Root (org.apache.jackrabbit.oak.api.Root)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Iterator (java.util.Iterator)2 NoSuchElementException (java.util.NoSuchElementException)2 Nonnull (javax.annotation.Nonnull)2 NodeIterator (javax.jcr.NodeIterator)2 RowIterator (javax.jcr.query.RowIterator)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 PrefetchOptions (org.apache.jackrabbit.oak.jcr.query.PrefetchIterator.PrefetchOptions)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1