public Value getValue(String propertyName) throws ItemNotFoundException, RepositoryException { if (propertyName.startsWith(REP_EXCERPT)) { propertyName = REP_EXCERPT + "(" + excerptPath + ")"; } return row.getValue(propertyName); }
public Object call(Query query) throws RepositoryException { RowIterator rows = query.execute().getRows(); assertTrue("empty result", rows.hasNext()); Row r = rows.nextRow(); assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName1).getString()); assertEquals("unexpected value", TEST_VALUE, r.getValue(columnName2).getString()); return null; } });
@Override protected String featureValueOf(Row row) { try { return row.getValue(columnName).getString(); } catch (RepositoryException e) { throw new RuntimeException(e); } } };
/** {@inheritDoc} */ public Value getValue(String propertyName) throws RepositoryException, RemoteException { try { return SerialValueFactory.makeSerialValue(row.getValue(propertyName)); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
@Override public void validate( int rowNumber, Row row ) throws RepositoryException { String actualValue = row.getValue("car:maker").getString(); expectedMakers.remove(actualValue); } }).validate(query, result);
public Value getValue( String columnLabel ) throws SQLException { notClosed(); isRowSet(); try { return row.getValue(columnLabel); } catch (PathNotFoundException pnfe) { return null; } catch (RepositoryException e) { throw new SQLException(e.getLocalizedMessage(), e); } }
@Override public boolean isTraversal(ResourceResolver resourceResolver, String language, String statement) throws RepositoryException { final QueryManager queryManager = resourceResolver.adaptTo(Session.class).getWorkspace().getQueryManager(); final Query query = queryManager.createQuery("explain " + statement, language); final QueryResult queryResult = query.execute(); final RowIterator rows = queryResult.getRows(); final Row firstRow = rows.nextRow(); final String plan = firstRow.getValue("plan").getString(); return StringUtils.contains(plan, " /* traverse "); }
public Object next() throws NoSuchElementException { Row next = (Row) super.next(); try { return superuser.getItem(next.getValue("jcr:path").getString()); } catch (RepositoryException e) { throw new NoSuchElementException(); } } }, nodes);
static String getResult(QueryResult result, String propertyName) throws RepositoryException { StringBuilder buff = new StringBuilder(); RowIterator it = result.getRows(); while (it.hasNext()) { if (buff.length() > 0) { buff.append(", "); } buff.append(it.nextRow().getValue(propertyName).getString()); } return buff.toString(); }
@Override public RowResult has( String columnName, long value ) throws RepositoryException { assertThat(row.getValue(columnName).getLong(), is(value)); return this; }
static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException { List<String> results = Lists.newArrayList(); RowIterator it = result.getRows(); while (it.hasNext()) { Row row = it.nextRow(); results.add(row.getValue(propertyName).getString()); } return results; }
static List<String> getResult(QueryResult result, String propertyName) throws RepositoryException { List<String> results = Lists.newArrayList(); RowIterator it = result.getRows(); while (it.hasNext()) { Row row = it.nextRow(); results.add(row.getValue(propertyName).getString()); } return results; }
@Override public void validate( int rowNumber, Row row ) throws RepositoryException { String pathStr = row.getValue("jcr:path").getString(); Path path = path(pathStr); if (lastPath != null) { assertThat(path.compareTo(lastPath) >= 0, is(true)); } lastPath = path; } };
private static double getCost(Session session, String xpath) throws RepositoryException { QueryManager qm = session.getWorkspace().getQueryManager(); QueryResult qr = qm.createQuery("explain measure " + xpath, "xpath").execute(); Row r = qr.getRows().nextRow(); String plan = r.getValue("plan").getString(); String cost = plan.substring(plan.lastIndexOf('{')); JsonObject json = parseJson(cost); double c = Double.parseDouble(json.getProperties().get("a")); return c; }
protected void assertResultsHaveRows( QueryResult result, String columnName, String... rowValuesAsStrings ) throws RepositoryException { RowIterator iter = result.getRows(); int i = 0; while (iter.hasNext()) { Row row = iter.nextRow(); assertThat(row.getValue(columnName).getString(), is(rowValuesAsStrings[i++])); } }
private static String getQueryPlan(RepositoryFixture fixture, String query) throws RepositoryException, IOException { Session session = fixture.getAdminSession(); QueryManager qm = session.getWorkspace().getQueryManager(); Query explain = qm.createQuery("explain "+query, Query.JCR_SQL2); QueryResult explainResult = explain.execute(); Row explainRow = explainResult.getRows().nextRow(); String explanation = explainRow.getValue("plan").getString(); session.logout(); return explanation; }
@Override public void validate( int rowNumber, Row row ) throws RepositoryException { String id = row.getValue("mode:id").getString(); Node nodeFromQuery = row.getNode(); assertSame(nodeFromQuery, expectedNode); assertSame(nodeFromQuery.getIdentifier(), id); } }).validate(query, result);
private static String getPlan(Session session, String xpath) throws RepositoryException { QueryManager qm = session.getWorkspace().getQueryManager(); QueryResult qr = qm.createQuery("explain " + xpath, "xpath").execute(); Row r = qr.getRows().nextRow(); String plan = r.getValue("plan").getString(); return plan; }
private Set<String> getSuggestions(String query) throws Exception { QueryManager queryManager = session.getWorkspace().getQueryManager(); QueryResult result = queryManager.createQuery(query, Query.JCR_SQL2).execute(); RowIterator rows = result.getRows(); Set<String> suggestions = newHashSet(); while (rows.hasNext()) { suggestions.add(rows.nextRow().getValue("suggestion").getString()); } return suggestions; }
private Set<String> getSpellchecks(String query) throws Exception { QueryManager queryManager = session.getWorkspace().getQueryManager(); QueryResult result = queryManager.createQuery(query, Query.JCR_SQL2).execute(); RowIterator rows = result.getRows(); Set<String> suggestions = newHashSet(); while (rows.hasNext()) { suggestions.add(rows.nextRow().getValue("spellcheck").getString()); } return suggestions; }