Package org.jboss.dna.graph.query

Examples of org.jboss.dna.graph.query.QueryResults$Cursor


    @Test
    public void shouldFindNodesBySimpleQueryWithNameCriteriaThatMatchesNoNodes() {
        indexWorkspace(workspaceName1);
        String query = "SELECT model, maker FROM __ALLNODES__ WHERE NAME() LIKE 'Toyota%[2]'";
        QueryResults results = query(workspaceName1, query);
        assertRowCount(results, 0);

    }
View Full Code Here


    @Test
    public void shouldFindNodesBySimpleQueryWithPathCriteria() {
        indexWorkspace(workspaceName1);
        String query = "SELECT model, maker FROM __ALLNODES__ WHERE PATH() LIKE '/Cars[%]/Hy%/Toyota%' OR PATH() LIKE '/Cars[1]/Utility[1]/%'";
        QueryResults results = query(workspaceName1, query);
        assertRowCount(results, 6);

    }
View Full Code Here

    @Test
    public void shouldFindNodesBySimpleQueryWithDescendantCriteria() {
        indexWorkspace(workspaceName1);
        String query = "SELECT model, maker FROM __ALLNODES__ WHERE ISDESCENDANTNODE('/Cars/Hybrid')";
        QueryResults results = query(workspaceName1, query);
        assertRowCount(results, 3);

    }
View Full Code Here

         * @see javax.jcr.query.Query#execute()
         */
        public QueryResult execute() throws RepositoryException {
            // Submit immediately to the workspace graph ...
            Schemata schemata = session.workspace().nodeTypeManager().schemata();
            QueryResults result = session.repository().queryManager().query(session.workspace().getName(),
                                                                            query,
                                                                            schemata,
                                                                            hints,
                                                                            variables);
            checkForProblems(result.getProblems());
            if (Query.XPATH.equals(language)) {
                return new XPathQueryResult(session, result);
            }
            return new JcrQueryResult(session, result);
        }
View Full Code Here

         *
         * @see javax.jcr.query.Query#execute()
         */
        public QueryResult execute() throws RepositoryException {
            // Submit immediately to the workspace graph ...
            QueryResults result = session.repository().queryManager().search(session.workspace().getName(),
                                                                             statement,
                                                                             MAXIMUM_RESULTS_FOR_FULL_TEXT_SEARCH_QUERIES,
                                                                             0);
            checkForProblems(result.getProblems());
            return new JcrQueryResult(session, result);
        }
View Full Code Here

        Schemata schemata = getRepositorySchemata();

        Set<String> workspaceNames = repository.workspaceNames();
        for (String workspaceName : workspaceNames) {
            QueryResults result = repository.queryManager().query(workspaceName, command, schemata, null, null);

            if (result.getRowCount() > 0) {
                return true;
            }
        }

        return false;
View Full Code Here

                               + "% less than indexing time during loading)");
        }

        // Make sure we're finding the results ...
        // print = true;
        QueryResults results = search(workspaceName1, "Toyota Prius", 10, 0);
        assertThat(results, is(notNullValue()));
        assertRowCount(results, 2);
        Location location1 = (Location)(results.getTuples().get(0)[0]);
        Location location2 = (Location)(results.getTuples().get(1)[0]);
        assertThat(location1.getPath(), is(path("/Cars/Hybrid/Toyota Prius")));
        assertThat(location2.getPath(), is(path("/Cars/Hybrid/Toyota Highlander")));

    }
View Full Code Here

    @Test
    public void shouldUpdateIndexesWhenDeletingNodesInSource() {
        loadContent(content);

        // Make sure we're finding the results ...
        QueryResults results = search(workspaceName1, "Toyota Prius", 10, 0);
        assertThat(results, is(notNullValue()));
        assertRowCount(results, 2);
        Location location1 = (Location)(results.getTuples().get(0)[0]);
        Location location2 = (Location)(results.getTuples().get(1)[0]);
        assertThat(location1.getPath(), is(path("/Cars/Hybrid/Toyota Prius")));
        assertThat(location2.getPath(), is(path("/Cars/Hybrid/Toyota Highlander")));

        String query = "SELECT model, maker FROM __ALLNODES__ WHERE PATH() LIKE '/Cars[%]/Hy%/Toyota%' OR PATH() LIKE '/Cars[1]/Utility[1]/%'";
        results = query(workspaceName1, query);
        assertRowCount(results, 6);

        content.useWorkspace(workspaceName1);
        content.delete("/Cars/Hybrid/Toyota Prius");

        // Make sure we don't find the 'Prius' anymore, but we still should find the 'Highlander' ...
        results = search(workspaceName1, "Toyota Prius", 10, 0);
        assertThat(results, is(notNullValue()));
        assertRowCount(results, 1);
        location1 = (Location)(results.getTuples().get(0)[0]);
        assertThat(location1.getPath(), is(path("/Cars/Hybrid/Toyota Highlander")));

        query = "SELECT model, maker FROM __ALLNODES__ WHERE PATH() LIKE '/Cars[%]/Hy%/Toyota%' OR PATH() LIKE '/Cars[1]/Utility[1]/%'";
        results = query(workspaceName1, query);
        assertRowCount(results, 5);
View Full Code Here

    @Test
    public void shouldUpdateIndexesWhenUpdatingPropertiesInSource() {
        loadContent(content);

        // Make sure we're finding the results ...
        QueryResults results = search(workspaceName1, "Toyota Prius", 10, 0);
        assertThat(results, is(notNullValue()));
        assertRowCount(results, 2);
        Location location1 = (Location)(results.getTuples().get(0)[0]);
        Location location2 = (Location)(results.getTuples().get(1)[0]);
        assertThat(location1.getPath(), is(path("/Cars/Hybrid/Toyota Prius")));
        assertThat(location2.getPath(), is(path("/Cars/Hybrid/Toyota Highlander")));

        String query = "SELECT model, maker, year FROM __ALLNODES__ WHERE PATH() LIKE '/Cars[1]/Utility[1]/Ford F-150[1]' AND year = 2008";
        results = query(workspaceName1, query);
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.query.QueryResults$Cursor

Copyright © 2018 www.massapicom. 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.