Examples of QueryManager


Examples of javax.jcr.query.QueryManager

     */
    private Query getQuery(SearchInfo sInfo)
            throws InvalidQueryException, RepositoryException, DavException {

        Node rootNode = getRepositorySession().getRootNode();
        QueryManager qMgr = getRepositorySession().getWorkspace().getQueryManager();

        // test if query is defined by requested repository node
        String itemPath = locator.getRepositoryPath();
        if (!rootNode.getPath().equals(itemPath)) {
            String qNodeRelPath = itemPath.substring(1);
            if (rootNode.hasNode(qNodeRelPath)) {
                Node qNode = rootNode.getNode(qNodeRelPath);
                if (qNode.isNodeType(JcrConstants.NT_QUERY)) {
                    return qMgr.getQuery(qNode);
                }
            }
        }

        Query q;
        if (sInfo != null) {
            q = qMgr.createQuery(sInfo.getQuery(), sInfo.getLanguageName());
        } else {
            throw new DavException(DavServletResponse.SC_BAD_REQUEST, locator.getResourcePath() + " is not a nt:query node -> searchRequest body required.");
        }

        /* test if resource path does not exist -> thus indicating that
View Full Code Here

Examples of javax.jcr.query.QueryManager

        // if the session has locks, we logout the session and drop it,
        // as there is no easy way of finding the temporary locks and
        // unlocking them, we could use the search, however ???
        try {
            QueryManager qm = session.getWorkspace().getQueryManager();
            // FIXME - this search searches for all locks for the user of the session
            //         so if the user has more than one session, locks from other
            //         sessions will be delivered as well.
            Query q = qm.createQuery(
                "/jcr:root//element(*,mix:lockable)[@jcr:lockOwner='"
                    + session.getUserID() + "']", Query.XPATH);
            NodeIterator ni = q.execute().getNodes();
            while (ni.hasNext()) {
                Node node = ni.nextNode();
View Full Code Here

Examples of javax.jcr.query.QueryManager

    }
  }

  protected Iterator<Node> _getReferents(Node referenced, String propertyName) throws RepositoryException {
    String path = referenced.getPath();
    QueryManager queryMgr = session.getWorkspace().getQueryManager();
    Query query = queryMgr.createQuery("SELECT * FROM nt:base WHERE " + propertyName + "='" + path + "'", Query.SQL);
    QueryResult result = query.execute();
    @SuppressWarnings("unchecked") Iterator<Node> nodes = result.getNodes();
    return new AbstractFilterIterator<Node, Node>(nodes) {
      private Node current;
      protected Node adapt(Node node) {
View Full Code Here

Examples of javax.jcr.query.QueryManager

    }

    public void shouldCreateQuery() throws Exception {
        String statement = "Some query syntax";

        QueryManager queryManager = workspace.getQueryManager();
        Query query = queryManager.createQuery(statement, Query.XPATH);

        assertThat(query, is(notNullValue()));
        assertThat(query.getLanguage(), is(Query.XPATH));
        assertThat(query.getStatement(), is(statement));
    }
View Full Code Here

Examples of javax.jcr.query.QueryManager

    @Test
    public void shouldStoreQueryAsNode() throws Exception {
        String statement = "Some query syntax";

        QueryManager queryManager = workspace.getQueryManager();
        Query query = queryManager.createQuery(statement, Query.XPATH);

        Node node = query.storeAsNode("/storedQuery");
        assertThat(node, is(notNullValue()));
        assertThat(node.getPrimaryNodeType().getName(), is("nt:query"));
        assertThat(node.getProperty("jcr:language").getString(), is(Query.XPATH));
View Full Code Here

Examples of javax.jcr.query.QueryManager

    @Test
    public void shouldLoadStoredQuery() throws Exception {
        String statement = "Some query syntax";

        QueryManager queryManager = workspace.getQueryManager();
        Query query = queryManager.createQuery(statement, Query.XPATH);

        Node node = query.storeAsNode("/storedQuery");

        Query loaded = queryManager.getQuery(node);

        assertThat(loaded, is(notNullValue()));
        assertThat(loaded.getLanguage(), is(Query.XPATH));
        assertThat(loaded.getStatement(), is(statement));
        assertThat(loaded.getStoredQueryPath(), is(node.getPath()));
View Full Code Here

Examples of javax.jcr.query.QueryManager

        Node n = testRootNode.addNode(nodeName1, testNodeType);
        n.addMixin(mixVersionable);
        superuser.save();
        VersionManager vMgr = superuser.getWorkspace().getVersionManager();
        vMgr.checkpoint(n.getPath());
        QueryManager qm = superuser.getWorkspace().getQueryManager();
        Version v = vMgr.getBaseVersion(n.getPath());
        Query q = qm.createQuery("//element(*, nt:version)[@jcr:uuid = '" +
                v.getIdentifier() + "']", Query.XPATH);
        NodeIterator nodes = q.execute().getNodes();
        assertTrue(nodes.hasNext());
        assertTrue(nodes.nextNode() instanceof Version);
        RowIterator rows = q.execute().getRows();
View Full Code Here

Examples of javax.jcr.query.QueryManager

    private Query createQuery(Session session,
                              String statement,
                              String language,
                              Map<String, String> namespaces)
            throws InvalidQueryException, RepositoryException {
        QueryManager qMgr = session.getWorkspace().getQueryManager();

        // apply namespace mappings to session
        Map<String, String> previous = setNamespaceMappings(session, namespaces);
        try {
            return qMgr.createQuery(statement, language);
        } finally {
            // reset namespace mappings
            setNamespaceMappings(session, previous);
        }
    }
View Full Code Here

Examples of javax.jcr.query.QueryManager

            create(session);
    }

    @Override
    public void runTest() throws Exception {
        QueryManager manager = session.getWorkspace().getQueryManager();
        for (int i = 0; i < NODE_COUNT; i++) {
            Query query = createQuery(manager, i);
            NodeIterator iterator = query.execute().getNodes();
            while (iterator.hasNext()) {
                Node node = iterator.nextNode();
View Full Code Here

Examples of javax.jcr.query.QueryManager

                create(session);
    }

    @Override
    public void runTest() throws Exception {
        QueryManager manager = session.getWorkspace().getQueryManager();
        for (int i = 0; i < NODE_COUNT; i++) {
            Query query = createQuery(manager, i);
            NodeIterator iterator = query.execute().getNodes();
            while (iterator.hasNext()) {
                Node node = iterator.nextNode();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.