本文整理了Java中org.apache.jackrabbit.oak.api.Root.getQueryEngine
方法的一些代码示例,展示了Root.getQueryEngine
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Root.getQueryEngine
方法的具体详情如下:
包路径:org.apache.jackrabbit.oak.api.Root
类名称:Root
方法名:getQueryEngine
[英]Get the query engine.
[中]获取查询引擎。
代码示例来源:origin: apache/jackrabbit-oak
@NotNull
public QueryEngine getQueryEngine() {
return root.getQueryEngine();
}
代码示例来源:origin: org.apache.jackrabbit/oak-jcr
@NotNull
public QueryEngine getQueryEngine() {
return root.getQueryEngine();
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Nonnull
public QueryEngine getQueryEngine() {
return root.getQueryEngine();
}
代码示例来源:origin: apache/jackrabbit-oak
@NotNull
@Override
public QueryEngine getQueryEngine() {
return base.getQueryEngine();
}
代码示例来源:origin: apache/jackrabbit-oak
QueryEngine queryEngine = root.getQueryEngine();
return queryEngine.executeQuery(
stmt.toString(), Query.XPATH,
代码示例来源:origin: apache/jackrabbit-oak
@NotNull
private Iterator<Authorizable> findAuthorizables(@NotNull String statement,
long limit,
long offset,
@Nullable AuthorizableType type) throws RepositoryException {
try {
Result query = root.getQueryEngine().executeQuery(
statement, javax.jcr.query.Query.XPATH, limit, offset,
NO_BINDINGS, namePathMapper.getSessionLocalMappings());
Iterable<? extends ResultRow> resultRows = query.getRows();
Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type));
return Iterators.filter(authorizables, new UniqueResultPredicate());
} catch (ParseException e) {
log.warn("Invalid user query: " + statement, e);
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
@Nullable
Tree getAuthorizableByPrincipal(@NotNull Principal principal) {
if (principal instanceof TreeBasedPrincipal) {
return root.getTree(((TreeBasedPrincipal) principal).getOakPath());
}
// NOTE: in contrast to JR2 the extra shortcut for ID==principalName
// can be omitted as principals names are stored in user defined
// index as well.
try {
StringBuilder stmt = new StringBuilder();
stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']');
stmt.append(" WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName");
stmt.append(QueryEngine.INTERNAL_SQL2_QUERY);
Result result = root.getQueryEngine().executeQuery(stmt.toString(),
Query.JCR_SQL2, 1, 0,
Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())),
NO_MAPPINGS);
Iterator<? extends ResultRow> rows = result.getRows().iterator();
if (rows.hasNext()) {
String path = rows.next().getPath();
return root.getTree(path);
}
} catch (ParseException ex) {
log.error("Failed to retrieve authorizable by principal", ex);
}
return null;
}
代码示例来源:origin: apache/jackrabbit-oak
@Nullable
Tree getAuthorizableByPrincipal(@NotNull Principal principal) {
if (principal instanceof TreeBasedPrincipal) {
return root.getTree(((TreeBasedPrincipal) principal).getOakPath());
}
// NOTE: in contrast to JR2 the extra shortcut for ID==principalName
// can be omitted as principals names are stored in user defined
// index as well.
try {
StringBuilder stmt = new StringBuilder();
stmt.append("SELECT * FROM [").append(UserConstants.NT_REP_AUTHORIZABLE).append(']');
stmt.append(" WHERE [").append(UserConstants.REP_PRINCIPAL_NAME).append("] = $principalName");
stmt.append(QueryEngine.INTERNAL_SQL2_QUERY);
Result result = root.getQueryEngine().executeQuery(stmt.toString(),
Query.JCR_SQL2, 1, 0,
Collections.singletonMap("principalName", PropertyValues.newString(principal.getName())),
NO_MAPPINGS);
Iterator<? extends ResultRow> rows = result.getRows().iterator();
if (rows.hasNext()) {
String path = rows.next().getPath();
return root.getTree(path);
}
} catch (ParseException ex) {
log.error("Failed to retrieve authorizable by principal", ex);
}
return null;
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
@NotNull
private Iterator<Authorizable> findAuthorizables(@NotNull String statement,
long limit,
long offset,
@Nullable AuthorizableType type) throws RepositoryException {
try {
Result query = root.getQueryEngine().executeQuery(
statement, javax.jcr.query.Query.XPATH, limit, offset,
NO_BINDINGS, namePathMapper.getSessionLocalMappings());
Iterable<? extends ResultRow> resultRows = query.getRows();
Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type));
return Iterators.filter(authorizables, new UniqueResultPredicate());
} catch (ParseException e) {
log.warn("Invalid user query: " + statement, e);
throw new RepositoryException(e);
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
@Nonnull
private Iterator<Authorizable> findAuthorizables(@Nonnull String statement,
long limit,
long offset,
@Nullable AuthorizableType type) throws RepositoryException {
try {
Result query = root.getQueryEngine().executeQuery(
statement, javax.jcr.query.Query.XPATH, limit, offset,
NO_BINDINGS, namePathMapper.getSessionLocalMappings());
Iterable<? extends ResultRow> resultRows = query.getRows();
Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type));
return Iterators.filter(authorizables, new UniqueResultPredicate());
} catch (ParseException e) {
log.warn("Invalid user query: " + statement, e);
throw new RepositoryException(e);
}
}
代码示例来源:origin: apache/jackrabbit-oak
/**
* Runs an Oak query searching for {@link #REP_EXTERNAL_PRINCIPAL_NAMES} properties
* that match the given name or name hint.
*
* NOTE: ignore any principals listed in the {@link DefaultSyncConfig.User#autoMembership}
* because they are expected to exist in the system and thus will be found
* by another principal provider instance.
*
* @param nameHint The principal name or name hint to be searched for.
* @param exactMatch boolean flag indicating if the query should search for
* exact matching.
* @return The query result.
*/
@Nullable
private Result findPrincipals(@NotNull String nameHint, boolean exactMatch) {
try {
Map<String, ? extends PropertyValue> bindings = buildBinding(nameHint, exactMatch);
String op = (exactMatch) ? " = " : " LIKE ";
String statement = "SELECT '" + REP_EXTERNAL_PRINCIPAL_NAMES + "' FROM [rep:User] WHERE PROPERTY(["
+ REP_EXTERNAL_PRINCIPAL_NAMES + "], '" + PropertyType.TYPENAME_STRING + "')"
+ op + "$" + BINDING_PRINCIPAL_NAMES + QueryEngine.INTERNAL_SQL2_QUERY;
return root.getQueryEngine().executeQuery(statement, Query.JCR_SQL2, bindings, namePathMapper.getSessionLocalMappings());
} catch (ParseException e) {
return null;
}
}
代码示例来源:origin: apache/jackrabbit-oak
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 " +
"OPTION(INDEX NAME [uuid], INDEX TAG [uuid])" +
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;
}
}
代码示例来源:origin: org.apache.jackrabbit/oak-core
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 " +
"OPTION(INDEX NAME [uuid], INDEX TAG [uuid])" +
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;
}
}
代码示例来源:origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak
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 " +
"OPTION(INDEX NAME [uuid], INDEX TAG [uuid])" +
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;
}
}
代码示例来源:origin: apache/jackrabbit-oak
private static List<String> queryUuid(ContentSession session, String uuid) throws ParseException {
Map<String, PropertyValue> bindings = Collections.singletonMap("id", PropertyValues.newString(uuid));
Result result = session.getLatestRoot().getQueryEngine().executeQuery(
"SELECT * FROM [nt:base] WHERE [jcr:uuid] = $id" + QueryEngine.INTERNAL_SQL2_QUERY,
Query.JCR_SQL2,
bindings, NO_MAPPINGS);
return StreamSupport.stream(result.getRows().spliterator(), false)
.map(r -> r.getPath())
.collect(Collectors.toList());
}
代码示例来源:origin: apache/jackrabbit-oak
Set<String> getSuggestions(String nodeType, String suggestFor) throws Exception {
Set<String> ret = Sets.newHashSet();
String suggQuery = createSuggestQuery(nodeType, suggestFor);
QueryEngine qe = root.getQueryEngine();
Result result = qe.executeQuery(suggQuery, Query.JCR_SQL2, null, null);
for (ResultRow row : result.getRows()) {
ret.add(row.getValue("suggestion").toString());
}
return ret;
}
代码示例来源:origin: apache/jackrabbit-oak
@Before
public void before() throws Exception {
session = createRepository().login(null, null);
root = session.getLatestRoot();
qe = root.getQueryEngine();
}
代码示例来源:origin: apache/jackrabbit-oak
@Before
public void before() throws Exception {
session = createRepository().login(null, null);
root = session.getLatestRoot();
qe = root.getQueryEngine();
createTestIndexNode();
}
代码示例来源:origin: apache/jackrabbit-oak
@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);
}
代码示例来源:origin: apache/jackrabbit-oak
@Before
public void before() throws Exception {
session = createRepository().login(null, null);
root = session.getLatestRoot();
qe = root.getQueryEngine();
root.getTree("/oak:index/counter").setProperty("resolution", 100);
root.getTree("/oak:index/counter").setProperty("seed", 1);
Tree content = root.getTree("/").addChild("content");
// add 200'000 nodes under /content
for (int i = 0; i < 2000; i++) {
Tree t = content.addChild("test" + i);
for (int j = 0; j < 100; j++) {
t.addChild("n" + j);
}
}
root.commit();
runAsyncIndex();
}
内容来源于网络,如有侵权,请联系作者删除!