public List<String> runQuery(String query) throws Exception { Properties props = new Properties(); List<String> result = new ArrayList<String>(); Properties outProps = getOutputProperties(props); try (ResultCursor<XQItemAccessor> cursor = xRepo.getQueryManagement().executeQuery(query, null, props)) { for (XQItemAccessor item: cursor) { result.add(proc.convertToString(item, outProps)); } } return result; }
protected ResultCursor<XQItemAccessor> query(String query, Map<String, Object> params, Properties props) throws Exception { if (props == null) { props = getDocumentProperties(); props.setProperty(pn_document_headers, String.valueOf(DocumentAccessor.HDR_CONTENT)); } ResultCursor<XQItemAccessor> result = getQueryManagement().executeQuery(query, params, props); assertNotNull(result); return result; }
@Override public String queryDocumentByUri(String uri) throws Exception { String query = "for $doc in fn:doc(\"" + uri + "\")\n" + "return $doc\n"; try (ResultCursor<String> cursor = xRepo.getQueryManagement().executeQuery(query, null, new Properties())) { String result = null; if (!cursor.isEmpty()) { result = cursor.iterator().next(); // proc.convertToString(itr.next(), null); } return result; } }
@Override public String queryDocumentFromCollection() throws Exception { String query = "for $doc in fn:collection()\n" + "return $doc\n"; try (ResultCursor<String> cursor = xRepo.getQueryManagement().executeQuery(query, null, new Properties())) { String result = null; if (!cursor.isEmpty()) { result = cursor.iterator().next(); // proc.convertToString(itr.next(), null); } return result; } }
public void run() { QueryManagement queryMgr = getQueryManager(); try (ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(params.query, params.params, params.props)) { int idx = 0; for (XQItemAccessor item: cursor) { if (idx > 0) { output.write(splitter); } String chunk = item.getItemAsString(null); logger.trace("postQuery; idx: {}; chunk: {}", idx, chunk); output.write(chunk); idx++; } } catch (Exception ex) { // XDMException, IOException. handle it somehow ? logger.error("postQuery.error", ex); throw new WebApplicationException(ex, Status.INTERNAL_SERVER_ERROR); } finally { try { output.close(); } catch (IOException ex) { // } } } }.start();
logger.trace("apply; going to execute query: {}\n with params: {} and props: {}", query, params, props); try { cursor = repo.getQueryManagement().executeQuery(query, params, props); empty = cursor.isEmpty(); } catch (BagriException ex) {
@Override public ResultCursor executeXQuery(String query, XQStaticContext ctx) throws XQException { Properties props = collectProperties(ctx); props = ensureProperty(props, pn_query_command, "false"); try { Map<String, Object> params = getXQItemParams(); return getQueryManagement().executeQuery(query, params, props); } catch (XPathException | BagriException ex) { throw getXQException(ex); } }
props = ensureProperty(props, pn_query_command, "true"); QueryManagement qMgr = getQueryManagement(); ResultCursorBase cursor = (ResultCursorBase) qMgr.executeQuery(command, params, props); result = new Integer(1);
try { if (useXDM) { ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(query, params, props); result = extractResult(cursor, props); cursor.close();
try { if (useXDM) { ResultCursor<XQItemAccessor> cursor = queryMgr.executeQuery(query, null, props); result = extractResult(cursor, props); cursor.close();