Search in sources :

Example 31 with PropertyValue

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

the class ContentRemoteResultTest method testNameColumn.

@Test
public void testNameColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.NAME).when(value).getType();
    doReturn("value").when(value).getValue(Type.NAME);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("value", remoteValue.asName());
}
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 32 with PropertyValue

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

the class IdentifierManager method resolveUUID.

private String resolveUUID(PropertyValue uuid) {
    try {
        Map<String, PropertyValue> bindings = Collections.singletonMap("id", uuid);
        Result result = root.getQueryEngine().executeQuery("SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id" + QueryEngine.INTERNAL_SQL2_QUERY, Query.JCR_SQL2, bindings, NO_MAPPINGS);
        String path = null;
        for (ResultRow rr : result.getRows()) {
            if (path != null) {
                log.error("multiple results for identifier lookup: " + path + " vs. " + rr.getPath());
                return null;
            } else {
                path = rr.getPath();
            }
        }
        return path;
    } catch (ParseException ex) {
        log.error("query failed", ex);
        return null;
    }
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) ParseException(java.text.ParseException) Result(org.apache.jackrabbit.oak.api.Result)

Example 33 with PropertyValue

use of org.apache.jackrabbit.oak.api.PropertyValue 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 34 with PropertyValue

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

the class ContentRemoteResultTest method testWeakReferenceColumn.

@Test
public void testWeakReferenceColumn() {
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.WEAKREFERENCE).when(value).getType();
    doReturn("value").when(value).getValue(Type.WEAKREFERENCE);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals("value", remoteValue.asWeakReference());
}
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 35 with PropertyValue

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

the class ContentRemoteResultTest method testMultiDateColumn.

@Test
public void testMultiDateColumn() {
    Date first = new Date(4);
    Date second = new Date(2);
    PropertyValue value = mock(PropertyValue.class);
    doReturn(Type.DATES).when(value).getType();
    doReturn(toFormattedDates(first, second)).when(value).getValue(Type.DATES);
    ResultRow row = mock(ResultRow.class);
    doReturn(value).when(row).getValue("column");
    ContentRemoteResult result = createResult(row);
    RemoteValue remoteValue = result.getColumnValue("column");
    assertEquals(asList(4L, 2L), remoteValue.asMultiDate());
}
Also used : ResultRow(org.apache.jackrabbit.oak.api.ResultRow) PropertyValue(org.apache.jackrabbit.oak.api.PropertyValue) RemoteValue(org.apache.jackrabbit.oak.remote.RemoteValue) Date(java.util.Date) Test(org.junit.Test)

Aggregations

PropertyValue (org.apache.jackrabbit.oak.api.PropertyValue)57 Test (org.junit.Test)28 ResultRow (org.apache.jackrabbit.oak.api.ResultRow)26 RemoteValue (org.apache.jackrabbit.oak.remote.RemoteValue)24 Tree (org.apache.jackrabbit.oak.api.Tree)5 ParseException (java.text.ParseException)4 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 ArrayList (java.util.ArrayList)3 Result (org.apache.jackrabbit.oak.api.Result)3 Date (java.util.Date)2 Blob (org.apache.jackrabbit.oak.api.Blob)2 LiteralImpl (org.apache.jackrabbit.oak.query.ast.LiteralImpl)2 StaticOperandImpl (org.apache.jackrabbit.oak.query.ast.StaticOperandImpl)2 FulltextQueryIndex (org.apache.jackrabbit.oak.spi.query.QueryIndex.FulltextQueryIndex)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 BigDecimal (java.math.BigDecimal)1 Calendar (java.util.Calendar)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 InvalidQueryException (javax.jcr.query.InvalidQueryException)1