public BigdataRemoteTupleQuery(RemoteRepository remote, String query, String baseURI) throws Exception { super(baseURI); this.q = remote.prepareTupleQuery(query); }
/** * Adds RDF data to the remote repository. * * @param add * The RDF data to be added. * * @return The mutation count. */ public long add(final AddOp add) throws Exception { return add(add, UUID.randomUUID()/*queryId*/); }
checkResponseCode(resp = doConnect(opts)); final ContextsResult result = contextsResults(resp);
@Override protected void flushStatements(final List<Statement> m_inserts, final List<Statement> m_removes) { // handle batch removes try { final RemoveOp rop = m_removes.size() > 0 ? new RemoveOp(m_removes) : null; final AddOp iop = m_inserts.size() > 0 ? new AddOp(m_inserts) : null; if (rop != null && iop != null) { // Execute update. m_repo.update(rop, iop); } else if (iop != null) { // Execute add m_repo.add(iop); } else if (rop != null) { // Execute remove. m_repo.remove(rop); } } catch (Exception e) { throw new RuntimeException("Unable to flush statements", e); } }
/** * Return a {@link RemoteRepository} for this connection. * * @see RemoteRepositoryManager#new */ protected RemoteRepository getRepositoryForConnection() { final IRemoteTx tx = remoteTx.get(); if (tx != null) { /* * Return a RemoteRepository that will use a view that is consistent * with an isolated view of the transaction. */ final RemoteRepository rtmp = repo.getRemoteRepository(); final String sparqlEndpointURL = rtmp.getSparqlEndPoint(); final RemoteRepositoryManager rmgr = rtmp.getRemoteRepositoryManager(); return rmgr.getRepositoryForURL(sparqlEndpointURL, tx); } /* * The returned repository does not add the ×tamp= URL query * parameter. */ return repo.getRemoteRepository(); }
RemoteRepository.asGraph(tmp.getServiceDescription()); final TupleQueryResult result = tmp.prepareTupleQuery( "SELECT (COUNT(*) as ?count) {?s ?p ?o}") .evaluate(); tmp.prepareUpdate( "PREFIX : <http://www.bigdata.com> \n" + "INSERT DATA {:a :b :c}").evaluate(); tmp.getServiceDescription(); result = tmp.prepareTupleQuery( "SELECT (COUNT(*) as ?count) {?s ?p ?o}") .evaluate(); tmp.prepareUpdate( "PREFIX : <http://www.bigdata.com> \n" + "INSERT DATA {:a :b :c}").evaluate();
/** * Test of POST w/ BODY having data to be loaded. */ protected void doInsertWithBodyTest(final String method, final int ntriples, /*final String servlet,*/ final RDFFormat format) throws Exception { final byte[] data = genNTRIPLES(ntriples, format); // final File file = File.createTempFile("bigdata-testnssclient", ".data"); /* * Only for testing. Clients should use AddOp(File, RDFFormat). */ final AddOp add = new AddOp(data, format); assertEquals(ntriples, m_repo.add(add)); // Verify the expected #of statements in the store. { final String queryStr = "select * where {?s ?p ?o}"; final IPreparedTupleQuery query = m_repo.prepareTupleQuery(queryStr); assertEquals(ntriples, countResults(query.evaluate())); } }
g.add(bryan, RDFS.LABEL, label2); m_repo.add(new AddOp(g)); "}"; assertSameGraph(expected, m_repo.prepareGraphQuery(queryStr));
.asGraph(m_repo.getServiceDescription()); 1, f.createURI(m_repo.getSparqlEndPoint())));
public BigdataRemoteGraphQuery(RemoteRepository remote, String query, String baseURI) throws Exception { super(baseURI); this.q = remote.prepareGraphQuery(query); }
public BigdataGraphClient(final RemoteRepository repo, final BlueprintsValueFactory factory) { this(repo.getBigdataSailRemoteRepository(), factory); }
/** * <code>LIST-TX</code>: Return the set of active transactions. */ public Iterator<IRemoteTxState0> listTx() { final ConnectOptions opts = new ConnectOptions(mgr.getBaseServiceURL() + "/tx"); opts.method = "GET"; JettyResponseListener response = null; try { RemoteRepository.checkResponseCode(response = mgr.doConnect(opts)); // Note: iterator return supports streaming results (not implemented). return multiTxResponse(response).iterator(); } catch (Exception e) { throw new RuntimeException(e); } finally { if (response != null) response.abort(); } }
/** * Removes RDF data from the remote repository. * * @param remove * The RDF data to be removed. * * @return The mutation count. * * @see <a href="http://trac.bigdata.com/ticket/1177"> Resource... contexts * not encoded/decoded according to openrdf semantics (REST API) </a> */ public long remove(final RemoveOp remove) throws Exception { return remove(remove, UUID.randomUUID()); }
/** * Test supposed to check if constants in BIND expressions will be resolved */ public void test_ticket_1717() throws Exception { { // Clear DB per task description (Executing the query over the empty database) m_repo.remove(new RemoveOp(null, null, null)); String query = "SELECT ?z ?s1 { ?s ?p ?o . BIND(?o+1 AS ?z) BIND(?z+1 AS ?z2) }"; final TupleQuery tq = m_repo.getBigdataSailRemoteRepository().getConnection().prepareTupleQuery(QueryLanguage.SPARQL, query, null); final TupleQueryResult tqr = tq.evaluate(); try { int count = 0; while (tqr.hasNext()) { System.out.println(tqr.next()); count++; } assertEquals(0,count); // asserting successful execution of the query, as it was failing while parsing } finally { tqr.close(); } } }
opts.addRequestParam("context-uri", toStrings(add.context)); try { checkResponseCode(response = doConnect(opts)); final MutationResult result = mutationResults(response); cancel(uuid); } catch (Exception ex) { log.warn(ex);
/** * Execute an ASK query including a SERVICE keyword which gets sent back to this server. * The test succeeeds if the query returns true, and fails otherwise * @param args * @throws IOException */ public void test_simple() throws Exception { setMethodisPostUrlEncodedData(); // m_repo.getRemoteRepositoryManager().createRepository(namespace, properties); BigdataSailRemoteRepositoryConnection conn = m_repo.getBigdataSailRemoteRepository().getConnection(); conn.prepareUpdate(QueryLanguage.SPARQL, "INSERT { <http://s1> <http://p> \"Test123\" } WHERE { }").execute(); checkResults(conn, 1); conn.prepareUpdate(QueryLanguage.SPARQL, "INSERT { <http://s2> <http://p> \"Test234\"^^xsd:string } WHERE { }").execute(); checkResults(conn, 2); conn.prepareUpdate(QueryLanguage.SPARQL, "INSERT { <http://s3> <http://p> \"Test345\" } WHERE { }").execute(); checkResults(conn, 3); m_repo.getRemoteRepositoryManager().rebuildTextIndex(namespace, true); checkResults(conn, 3); }
assertTrue(m_repo.hasStatement(null,// s final long mutationCount = m_repo.remove(new RemoveOp(null/* s */, RDFS.LABEL/* p */, null/* o */)); assertFalse(m_repo.hasStatement(null,// s
@Override public String toString() { return super.toString() + "{sparqlEndpoint=" + sparqlEndpointURL + ", mgr=" + getRemoteRepositoryManager() + (tx == null ? "" : ", tx=" + tx) + "}"; }
checkResponseCode(response = doConnect(opts)); final MutationResult result = mutationResults(response);
try { checkResponseCode(resp = doConnect(opts));