Package javax.jcr.query

Examples of javax.jcr.query.QueryManager.createQuery()


       
        Query q;
        QueryResult result;
        RowIterator it;
       
        q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);
        result = q.execute();
        it = result.getRows();
        assertTrue(it.hasNext());
        String plan = it.nextRow().getValue("plan").getString();
        // should not use the index on "jcr:primaryType"
View Full Code Here


        assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " +
                "where [nt:base].[node2/node3/jcr:primaryType] is not null */",
                plan);
       
        // verify the result
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        result = q.execute();
        it = result.getRows();
        assertTrue(it.hasNext());
        String path = it.nextRow().getValue("path").getString();
        assertEquals("/testroot/node1", path);
View Full Code Here

        Row row;
        String s;
       
        String xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";
       
        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(.)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") >= 0);
View Full Code Here

        assertTrue(s, s.indexOf("Hello World") >= 0);
        assertTrue(s, s.indexOf("Description") >= 0);
       
        xpath = "//*[jcr:contains(., 'hello')]/rep:excerpt(.) order by jcr:path descending";

        q = qm.createQuery(xpath, "xpath");
        it = q.execute().getRows();
        row = it.nextRow();
        s = row.getValue("rep:excerpt(text)").getString();
        assertTrue(s, s.indexOf("<strong>hello</strong> world") >= 0);
        assertTrue(s, s.indexOf("description") < 0);
View Full Code Here

        String sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where contains([text], 'hello OR hallo') order by [jcr:path]";
       
        Query q;
       
        q = qm.createQuery("explain " + sql2, Query.JCR_SQL2);

        assertEquals("[nt:base] as [nt:base] /* traverse \"*\" " +
                "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",
                getResult(q.execute(), "plan"));
       
View Full Code Here

                "where contains([nt:base].[text], cast('hello OR hallo' as string)) */",
                getResult(q.execute(), "plan"));
       
        // verify the result
        // uppercase "OR" mean logical "or"
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("/testroot/node1, /testroot/node2, /testroot/node3",
                getResult(q.execute(), "path"));

        // lowercase "or" mean search for the term "or"
        sql2 = "select [jcr:path] as [path] from [nt:base] " +
View Full Code Here

                getResult(q.execute(), "path"));

        // lowercase "or" mean search for the term "or"
        sql2 = "select [jcr:path] as [path] from [nt:base] " +
                "where contains([text], 'hello or hallo') order by [jcr:path]";
        q = qm.createQuery(sql2, Query.JCR_SQL2);
        assertEquals("",
                getResult(q.execute(), "path"));

    }
   
View Full Code Here

        acMgr.setPolicy(tmpl.getPath(), tmpl);
        adminSession.save();

        Session anonymousSession = getRepository().login(new GuestCredentials());
        QueryManager qm = anonymousSession.getWorkspace().getQueryManager();
        Query q = qm.createQuery("/jcr:root/home//social/relationships/following//*[id='aaron.mcdonald@mailinator.com']", Query.XPATH);
        QueryResult r = q.execute();
        RowIterator it = r.getRows();
        Assert.assertTrue(it.hasNext());
    }

View Full Code Here

            }
        }

        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

        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

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.