/** * Creates a download handler that requests results in specified tuple format. * * @param file Output path. * @param format Format to return the data in. */ public AGDownloadHandler(final File file, final TupleQueryResultFormat format) { this(file, format.getDefaultMIMEType()); }
/** * Creates a streaming handler that requests results in specified tuple format. * * @param format Format to return the data in. */ public AGRawStreamer(final TupleQueryResultFormat format) { this(format.getDefaultMIMEType()); }
@Override public String getRequestMIMEType() { return TupleQueryResultFormat.TSV.getDefaultMIMEType(); }
public AGTQRJSONStreamer(AGValueFactory vf) { super(TupleQueryResultFormat.JSON.getDefaultMIMEType()); this.vf = vf; }
@Override public String getRequestMIMEType() { return TupleQueryResultFormat.SPARQL.getDefaultMIMEType(); }
public AGTQRXMLStreamer(AGValueFactory vf) { super(TupleQueryResultFormat.SPARQL.getDefaultMIMEType()); this.vf = vf; }
public AGTQRTSVStreamer(AGValueFactory vf) { super(TupleQueryResultFormat.TSV.getDefaultMIMEType()); this.vf = vf; }
@Override public String getRequestMIMEType() { return TupleQueryResultFormat.JSON.getDefaultMIMEType(); }
public AGTQRHandler(TupleQueryResultFormat format, TupleQueryResultHandler tqrhandler, AGValueFactory vf, boolean recoverExternalBNodes) { super(format.getDefaultMIMEType()); this.format = format; if (recoverExternalBNodes) { this.tqrhandler = recoverBNodesTQRHandler(tqrhandler); } else { this.tqrhandler = tqrhandler; } this.vf = vf; }
public void getContextIDs(TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, AGHttpException { String url = Protocol.getContextsLocation(getRoot()); List<Header> headers = new ArrayList<>(1); headers.add(new Header(Protocol.ACCEPT_PARAM_NAME, getPreferredTQRFormat().getDefaultMIMEType())); get(url, headers, null, new AGTQRHandler(getPreferredTQRFormat(), handler, getValueFactory(), getAllowExternalBlankNodeIds())); }
public void getNamespaces(TupleQueryResultHandler handler) throws TupleQueryResultHandlerException, AGHttpException { String url = Protocol.getNamespacesLocation(getRoot()); List<Header> headers = new ArrayList<>(1); headers.add(new Header(Protocol.ACCEPT_PARAM_NAME, getPreferredTQRFormat().getDefaultMIMEType())); get(url, headers, null, new AGTQRHandler(getPreferredTQRFormat(), handler, getValueFactory(), getAllowExternalBlankNodeIds())); }
@Test public void testTupleQueryDownloadStrMIMEType() throws Exception { tupleQuery.download(output.getAbsolutePath(), TupleQueryResultFormat.CSV.getDefaultMIMEType()); checkOutput(); }
@Test public void testTupleQueryStreamMIMEType() throws Exception { final InputStream stream = tupleQuery.stream(TupleQueryResultFormat.CSV.getDefaultMIMEType()); FileUtils.copyInputStreamToFile(stream, output); checkOutput(); }
@Test public void testQueryStreamMIMEType() throws Exception { final InputStream stream = genericQuery.stream(TupleQueryResultFormat.JSON.getDefaultMIMEType()); FileUtils.copyInputStreamToFile(stream, output); checkOutput(); }
@Test public void testQueryDownloadStrMIMEType() throws Exception { genericQuery.download(output.getAbsolutePath(), TupleQueryResultFormat.CSV.getDefaultMIMEType()); checkOutput(); }
@Test public void testTupleQueryDownloadMIMEType() throws Exception { tupleQuery.download(output, TupleQueryResultFormat.CSV.getDefaultMIMEType()); checkOutput(); }
@Test public void testQueryDownloadMIMEType() throws Exception { genericQuery.download(output, TupleQueryResultFormat.CSV.getDefaultMIMEType()); checkOutput(); }
public TupleQueryResult getTupleQueryResult(String url) throws AGHttpException { Header[] headers = {new Header(ACCEPT_PARAM_NAME, TupleQueryResultFormat.SPARQL.getDefaultMIMEType())}; NameValuePair[] params = new NameValuePair[0]; TupleQueryResultBuilder builder = new TupleQueryResultBuilder(); // TODO: avoid using AGValueFactory(null) AGTQRHandler handler = new AGTQRHandler(TupleQueryResultFormat.SPARQL, builder, new AGValueFactory(null), false); get(url, headers, params, handler); return builder.getQueryResult(); }
private Request createSPARQLQueryRequest(String theQuery) { HttpResource aRes = new HttpResourceImpl(mURL); Request aQueryRequest; // auto prefix queries w/ rdf and rdfs namespaces ParameterList aParams = new ParameterList() .add(PARAM_QUERY, theQuery); if (mUseGetForQueries) { aQueryRequest = aRes.initGet() .addHeader(HttpHeaders.Accept.getName(), TupleQueryResultFormat.SPARQL.getDefaultMIMEType()) .setParameters(aParams); } else { aQueryRequest = aRes.initPost() .addHeader(HttpHeaders.ContentType.getName(), MimeTypes.FormUrlEncoded.getMimeType()) .addHeader(HttpHeaders.Accept.getName(), TupleQueryResultFormat.SPARQL.getDefaultMIMEType()) .setBody(aParams.getURLEncoded()); } return aQueryRequest; }