当前位置: 首页>>代码示例>>Java>>正文


Java QueryResult.getNodes方法代码示例

本文整理汇总了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();
  }
 
开发者ID:adaptto,项目名称:2015-sling-rookie-session,代码行数:20,代码来源:JcrQuerySample.java

示例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;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:33,代码来源:BlogServiceImpl.java

示例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;
}
 
开发者ID:fasseg,项目名称:fcrepo4-scape,代码行数:41,代码来源:ConnectorService.java

示例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;
    }
}
 
开发者ID:jreijn,项目名称:hippo-addon-restful-webservices,代码行数:25,代码来源:GroupsResource.java

示例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);
    }
  }
 
开发者ID:exo-addons,项目名称:marketplace-extension,代码行数:17,代码来源:UIAddOnSearchResult.java

示例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;
}
 
开发者ID:aperto,项目名称:magnolia-vanity-url,代码行数:28,代码来源:VanityUrlService.java

示例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;

}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:25,代码来源:WebResourceInventoryManagerImpl.java

示例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();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:18,代码来源:StorageUpdate10.java

示例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();		
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:23,代码来源:StorageUpdate12.java

示例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();
	
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:27,代码来源:StorageUpdate15.java

示例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();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:18,代码来源:StorageUpdate6.java

示例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
    	}
    } 	
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:18,代码来源:StorageUpdate8.java

示例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();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:19,代码来源:StorageUpdate3.java

示例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);
            }
        }
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:32,代码来源:PublicationProcessor.java

示例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);
            }
        }
    }
}
 
开发者ID:NHS-digital-website,项目名称:hippo,代码行数:28,代码来源:PublicationDepublishProcessor.java


注:本文中的javax.jcr.query.QueryResult.getNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。