Package javax.jcr.query

Examples of javax.jcr.query.QueryResult


     * {@inheritDoc}
     */
    public QueryResult execute() throws RepositoryException {
        checkInitialized();
        long time = System.currentTimeMillis();
        QueryResult result = query.execute();
        if (log.isDebugEnabled()) {
            time = System.currentTimeMillis() - time;
            NumberFormat format = NumberFormat.getNumberInstance();
            format.setMinimumFractionDigits(2);
            format.setMaximumFractionDigits(2);
View Full Code Here


    public Iterator<Resource> findResources(final ResourceResolver resolver,
                    final String query, final String language) {
        checkClosed();

        try {
            final QueryResult res = JcrResourceUtil.query(session, query, language);
            return new JcrNodeResourceIterator(resolver, res.getNodes(), this.dynamicClassLoader);
        } catch (final javax.jcr.query.InvalidQueryException iqe) {
            throw new QuerySyntaxException(iqe.getMessage(), query, language, iqe);
        } catch (final RepositoryException re) {
            throw new SlingException(re.getMessage(), re);
        }
View Full Code Here

        checkClosed();

        final String queryLanguage = isSupportedQueryLanguage(language) ? language : DEFAULT_QUERY_LANGUAGE;

        try {
            QueryResult result = JcrResourceUtil.query(session, query,
                queryLanguage);
            final String[] colNames = result.getColumnNames();
            final RowIterator rows = result.getRows();
            return new Iterator<ValueMap>() {
                public boolean hasNext() {
                    return rows.hasNext();
                };
View Full Code Here

            public Iterator<Resource> findResources(String query,
                    String language) {
                try {
                    final Query q = getSession().getWorkspace().getQueryManager().createQuery(query, language);
                    final QueryResult result = q.execute();
                    final NodeIterator nodes = result.getNodes();
                    return new Iterator<Resource>() {
                        public boolean hasNext() {
                            return nodes.hasNext();
                        }

                        public Resource next() {
                            Node node = nodes.nextNode();
                            try {
                                return new JcrNodeResource(resolver, node, null ,null);
                            } catch (RepositoryException e) {
                                throw new IllegalStateException(e);
                            }
                        }

                        public void remove() {
                            throw new UnsupportedOperationException("remove");
                        }
                    };
                } catch (NamingException ne) {
                    return null;
                } catch (RepositoryException re) {
                    return null;
                }
            }

            public Resource getResource(Resource base, String path) {
                // TODO Auto-generated method stub
                return null;
            }

            public Resource getResource(String path) {
                // TODO Auto-generated method stub
                return null;
            }

            public String[] getSearchPath() {
                return new String[] {"/apps/", "/libs/"};
            }

            public Iterator<Resource> listChildren(Resource parent) {
                // TODO Auto-generated method stub
                return null;
            }

            public String map(HttpServletRequest request, String resourcePath) {
                // TODO Auto-generated method stub
                return null;
            }

            public String map(String resourcePath) {
                // TODO Auto-generated method stub
                return null;
            }

            public Iterator<Map<String, Object>> queryResources(String query,
                    String language) {
                try {
                    final Query q = getSession().getWorkspace().getQueryManager().createQuery(query, language);
                    final QueryResult result = q.execute();
                    final String[] colNames = result.getColumnNames();
                    final RowIterator rows = result.getRows();
                    return new Iterator<Map<String, Object>>() {
                        public boolean hasNext() {
                            return rows.hasNext();
                        }
View Full Code Here

       
        MockControl queryCtrl = MockControl.createControl(Query.class);
        Query query = (Query) queryCtrl.getMock();

        MockControl resultCtrl = MockControl.createControl(QueryResult.class);
        QueryResult result = (QueryResult) resultCtrl.getMock();

        sessionControl.expectAndReturn(session.getWorkspace(), ws);
        wsCtrl.expectAndReturn(ws.getQueryManager(), qm);
        qmCtrl.expectAndReturn(qm.getQuery(nd), query);
        queryCtrl.expectAndReturn(query.execute(), result);
View Full Code Here

       
        MockControl queryCtrl = MockControl.createControl(Query.class);
        Query query = (Query) queryCtrl.getMock();

        MockControl resultCtrl = MockControl.createControl(QueryResult.class);
        QueryResult result = (QueryResult) resultCtrl.getMock();

        String stmt = "//*/@bogus:title";
        String language = Query.XPATH;

        sessionControl.expectAndReturn(session.getWorkspace(), ws);
View Full Code Here

       
        MockControl queryCtrl = MockControl.createControl(Query.class);
        Query query = (Query) queryCtrl.getMock();

        MockControl resultCtrl = MockControl.createControl(QueryResult.class);
        QueryResult result = (QueryResult) resultCtrl.getMock();

        sessionControl.expectAndReturn(session.getWorkspace(), ws);
        wsCtrl.expectAndReturn(ws.getQueryManager(), qm);
        qmCtrl.expectAndReturn(qm.createQuery(stmt1, language), query);
        qmCtrl.expectAndReturn(qm.createQuery(stmt2, language), query);
View Full Code Here

          Query query = manager.createQuery(statement, lang);
          if (debug)
            logger.debug("created query " + query);

          QueryResult result;
          try {
            result = query.execute();
            map.put(statement, result);
          }
          catch (RepositoryException e) {
View Full Code Here

     * {@inheritDoc}
     */
    public QueryResult execute() throws RepositoryException {
        checkInitialized();
        long time = System.nanoTime();
        QueryResult result = sessionContext.getSessionState().perform(
                new SessionOperation<QueryResult>() {
                    public QueryResult perform(SessionContext context)
                            throws RepositoryException {
                        return query.execute(offset, limit);
                    }
View Full Code Here

        setInitialized();
    }

    public QueryResult execute() throws RepositoryException {
        long time = System.nanoTime();
        final QueryResult result = sessionContext.getSessionState().perform(
                new SessionOperation<QueryResult>() {
                    public QueryResult perform(SessionContext context)
                            throws RepositoryException {
                        final QueryEngine engine = new QueryEngine(
                                sessionContext.getSessionImpl(), lqf, variables);
View Full Code Here

TOP

Related Classes of javax.jcr.query.QueryResult

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.