本文整理汇总了Java中javax.jcr.query.QueryResult.getNodes方法的典型用法代码示例。如果您正苦于以下问题:Java QueryResult.getNodes方法的具体用法?Java QueryResult.getNodes怎么用?Java QueryResult.getNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.query.QueryResult
的用法示例。
在下文中一共展示了QueryResult.getNodes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryJcrContent
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
String queryJcrContent(Session session) throws RepositoryException {
// get query manager
QueryManager queryManager = session.getWorkspace().getQueryManager();
// query for all nodes with tag "JCR"
Query query = queryManager.createQuery("/jcr:root/content/adaptto//*[tags='JCR']", Query.XPATH);
// iterate over results
QueryResult result = query.execute();
NodeIterator nodes = result.getNodes();
StringBuilder output = new StringBuilder();
while (nodes.hasNext()) {
Node node = nodes.nextNode();
output.append("path=" + node.getPath() + "\n");
}
return output.toString();
}
示例2: getPosts
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
/**
* Get blog posts with pagination
*
* @param offset The starting point of blog posts to return.
* @param limit The number of blog posts to return.
* @return The blog posts.
*/
public NodeIterator getPosts(Long offset, Long limit) {
NodeIterator nodes = null;
if (session != null) {
try {
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(BLOG_QUERY, Query.JCR_SQL2);
if (offset != null) {
query.setOffset(offset);
}
if (limit != null) {
query.setLimit(limit);
}
QueryResult result = query.execute();
nodes = result.getNodes();
} catch (RepositoryException e) {
LOGGER.error("Could not search repository", e);
}
}
return nodes;
}
示例3: searchObjectOfType
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
/**
* Search objects in Fedora with a given JCR Mixin Type using a simple term
*
* @param session
* the {@link Session} to use for the operation
* @param mixinType
* the mixin type to look for
* @param terms
* the search term to match objects against
* @param offset
* the offset of the search results
* @param limit
* the maximum number of search results
* @return a {@link java.util.List} containing the paths of the found objects in
* Fedora
* @throws RepositoryException
* if an error occurred searching in Fedora
*/
public List<String> searchObjectOfType(final Session session, final String mixinType, final String terms, final int offset, final int limit)
throws RepositoryException {
final QueryManager queryManager = session.getWorkspace().getQueryManager();
final QueryObjectModelFactory factory = queryManager.getQOMFactory();
final Source selector = factory.selector(mixinType, "resourcesSelector");
final Constraint constraints = factory.fullTextSearch("resourcesSelector", null, factory.literal(session.getValueFactory().createValue(terms)));
final Query query = factory.createQuery(selector, constraints, null, null);
query.setLimit(limit);
query.setOffset(offset);
final QueryResult result = query.execute();
final NodeIterator it = result.getNodes();
final List<String> uris = new ArrayList<>();
while (it.hasNext()) {
Node n = it.nextNode();
uris.add(n.getPath());
}
return uris;
}
示例4: getGroupNodeByName
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
/**
* Gets the Node for the specified name. If no node with the specified name exists, null is returned.
*
* @param groupName the name of the Group to return
* @return the Node with name groupName
*/
public Node getGroupNodeByName(final String groupName) {
final String escapedGroupName = Text.escapeIllegalJcr10Chars(ISO9075.encode(NodeNameCodec.encode(groupName, true)));
final String queryString = QUERY_GROUP.replace("{}", escapedGroupName);
try {
@SuppressWarnings("deprecation") final Query query = getQueryManager().createQuery(queryString, Query.SQL);
final QueryResult queryResult = query.execute();
final NodeIterator iterator = queryResult.getNodes();
if (!iterator.hasNext()) {
return null;
}
final Node node = iterator.nextNode();
return node;
} catch (RepositoryException e) {
log.error("Unable to check if group '{}' exists, returning true", groupName, e);
return null;
}
}
示例5: getDBResource
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void getDBResource(String sqlQuery) throws Exception {
QueryResult result = this.excSQL(sqlQuery, true);
NodeIterator it = result.getNodes();
while (it.hasNext()) {
Node findedNode = it.nextNode();
if (super.getChildById(findedNode.getUUID()) == null) {
UIAddOnSearchOne uiAddOnSearchOne = addChild(UIAddOnSearchOne.class, null, findedNode.getUUID());
uiAddOnSearchOne.setNodeId(findedNode.getUUID());
uiAddOnSearchOne.setCanEdit(this.getCanEdit());
}
this.data.add(findedNode);
}
}
示例6: queryForVanityUrlNode
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
/**
* Query for a vanity url node.
*
* @param vanityUrl vanity url from request
* @param siteName site name from aggegation state
* @return first vanity url node of result or null, if nothing found
*/
public Node queryForVanityUrlNode(final String vanityUrl, final String siteName) {
Node node = null;
try {
Session jcrSession = MgnlContext.getJCRSession(VanityUrlModule.WORKSPACE);
QueryManager queryManager = jcrSession.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(QUERY, JCR_SQL2);
query.bindValue(PN_VANITY_URL, new StringValue(vanityUrl));
query.bindValue(PN_SITE, new StringValue(siteName));
QueryResult queryResult = query.execute();
NodeIterator nodes = queryResult.getNodes();
if (nodes.hasNext()) {
node = nodes.nextNode();
}
} catch (RepositoryException e) {
LOGGER.error("Error message.", e);
}
return node;
}
示例7: getWebResources
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
public Map<String, String> getWebResources(Session session)
throws RepositoryException {
Map<String, String> result = new HashMap<String, String>();
Query query = session
.getWorkspace()
.getQueryManager()
.createQuery(
"SELECT * FROM [webresource:WebResourceGroup] as webResourceGroupSet",
Query.JCR_SQL2);
QueryResult queryResult = query.execute();
NodeIterator queryIt = queryResult.getNodes();
while (queryIt.hasNext()) {
Node webResourceNode = queryIt.nextNode();
result.put(webResourceNode.getProperty(WebResourceGroup.NAME)
.getString(), webResourceNode.getPath());
}
return result;
}
示例8: modifyDashboardState
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void modifyDashboardState() throws RepositoryException {
LOG.info("Modify dashboard state - add columnCount property");
String path = StorageConstants.DASHBOARDS_ROOT;
String className = "ro.nextreports.server.domain.DashboardState";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@className='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " dashboard state nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("columnCount", 2);
}
getTemplate().save();
}
示例9: addRuntimeNameProperty
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void addRuntimeNameProperty() throws RepositoryException {
String statement =
"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) +
"//*[@className='ro.nextreports.server.domain.Report']" +
"//*[fn:name()='parametersValues']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("RuntimeHistory : Found " + nodes.getSize() + " parameterValues nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
NodeIterator childrenIt = node.getNodes();
while (childrenIt.hasNext()) {
Node child = childrenIt.nextNode();
child.setProperty("runtimeName", child.getName());
}
}
getTemplate().save();
}
示例10: updateTemplateNodes
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void updateTemplateNodes() throws RepositoryException {
// add shortcutType node to all report templates nodes
String statement =
"/jcr:root" + ISO9075.encodePath(StorageConstants.REPORTS_ROOT) +
"//*[@className='ro.nextreports.server.domain.Report']/templates";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Add shortcutType node to all report templates nodes : Found " + nodes.getSize() + " report nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
NodeIterator templatesForReport = node.getNodes();
while (templatesForReport.hasNext()) {
Node template = templatesForReport.nextNode();
Node shortcutTypeNode = template.addNode("shortcutType");
shortcutTypeNode.setProperty("type", 0);
shortcutTypeNode.setProperty("timeType", 0);
shortcutTypeNode.setProperty("timeUnits", 0);
}
}
getTemplate().save();
}
示例11: addAnalystUserProfile
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void addAnalystUserProfile() throws RepositoryException {
LOG.info("User profile analyst");
String path = StorageConstants.USERS_ROOT ;
String className = "ro.nextreports.server.domain.User";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@className='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("profile", "analyst");
}
getTemplate().save();
}
示例12: updateInternalSettings
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void updateInternalSettings() throws RepositoryException {
// find all internalSettings nodes from DASHBOARDS and change chartId property in entityId
String statement = "/jcr:root" + ISO9075.encodePath(StorageConstants.DASHBOARDS_ROOT) + "//*[fn:name()='internalSettings']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " internalSettings nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
try {
Property prop = node.getProperty("chartId");
node.setProperty("entityId", prop.getValue());
prop.remove();
} catch (PathNotFoundException ex) {
// if property not found we have nothing to do
}
}
}
示例13: renameChartWidgetClassName
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
private void renameChartWidgetClassName() throws RepositoryException {
LOG.info("Rename chart widget class name");
String path = StorageConstants.DASHBOARDS_ROOT;
String className = "ro.nextreports.server.web.chart.ChartWidget";
String newClassName = "ro.nextreports.server.web.dashboard.chart.ChartWidget";
String statement = "/jcr:root" + ISO9075.encodePath(path) + "//*[@widgetClassName='" + className + "']";
QueryResult queryResult = getTemplate().query(statement);
NodeIterator nodes = queryResult.getNodes();
LOG.info("Found " + nodes.getSize() + " nodes");
while (nodes.hasNext()) {
Node node = nodes.nextNode();
node.setProperty("widgetClassName", newClassName);
}
getTemplate().save();
}
示例14: processNode
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
@Override
public void processNode(Node node, List<String> validStatuses) throws RepositoryException {
if (!hasValidDocumentType(node, TYPE_PUBLICATION)) {
return;
}
streamDocumentVariants(node)
.filter((document) -> hasValidStateAndType(document, validStatuses, TYPE_PUBLICATION))
.forEach(this::setSearchableFlag);
// now the tricky bit - update all datasets documents belonging to this publication,
// only if publication name is "content"
if ("content".equals(node.getName())) {
boolean searchable = isPubliclyAccessible(node.getNode(node.getName()));
String query = "SELECT * FROM [publicationsystem:dataset] WHERE ISDESCENDANTNODE (["
+ node.getParent().getPath() + "])";
QueryResult res = node.getSession()
.getWorkspace()
.getQueryManager()
.createQuery(query, Query.JCR_SQL2)
.execute();
for (NodeIterator i = res.getNodes(); i.hasNext(); ) {
Node doc = i.nextNode();
if (hasValidStateAndType(doc, validStatuses, "publicationsystem:dataset")) {
updateDataset(doc, searchable);
}
}
}
}
示例15: processNode
import javax.jcr.query.QueryResult; //导入方法依赖的package包/类
@Override
public void processNode(Node node, List<String> validStatuses) throws RepositoryException {
if (!hasValidDocumentType(node, TYPE_PUBLICATION)) {
return;
}
// now the tricky bit - update all datasets documents belonging to this publication,
// only if publication name is "content"
// This will ensure that "orphan" datasets are not searchable.
if ("content".equals(node.getName())) {
String query = "SELECT * FROM [publicationsystem:dataset] WHERE ISDESCENDANTNODE (["
+ node.getParent().getPath() + "])";
QueryResult res = node.getSession()
.getWorkspace()
.getQueryManager()
.createQuery(query, Query.JCR_SQL2)
.execute();
for (NodeIterator i = res.getNodes(); i.hasNext(); ) {
Node doc = i.nextNode();
if (hasValidStateAndType(doc, validStatuses, "publicationsystem:dataset")) {
updateDataset(doc, false);
}
}
}
}