public synchronized void executeUpdate(SPARQLQueryDefinition qdef) { this.sparqlQueryManager.clearPageLength(); this.sparqlQueryManager.executeUpdate(qdef, currentTransaction); }
try { sparqlQmgr.executeUpdate(qdef); } catch (Exception e) { exception = e.toString(); sparqlQmgr.executeUpdate(qdef); try { sparqlQmgr.executeUpdate(qdef); } catch (Exception e) { exception = e.toString();
sparqlQmgr.executeUpdate(qdef); qdef = null; sparqlQmgr.executeUpdate(qdef); try { sparqlQmgr.executeUpdate(qdef); } catch (Exception e) { exception = e.toString(); try { sparqlQmgr.executeUpdate(qdef); } catch (Exception e) { exceptionSilent = e.toString();
qdef.setBindings(bindings); sparqlQmgr.executeUpdate(qdef); qdef2.setBaseUri(baseuri2); sparqlQmgr.executeUpdate(qdef2); String q21 = "select ?s ?p ?o from <" + baseuri2 + "BindingsGraph> where {?s ?p ?o. }"; SPARQLQueryDefinition qdefValid = sparqlQmgr.newQueryDefinition().withSparql(q21); qdefNull.setBaseUri(baseuriNull); sparqlQmgr.executeUpdate(qdefNull); String qNull = "select ?s ?p ?o from <" + baseuriNull + "BindingsGraph> where {?s ?p ?o. }"; SPARQLQueryDefinition qdefNullExeSel = sparqlQmgr.newQueryDefinition().withSparql(qNull); sparqlQmgr.executeUpdate(qdefEmpty); qdefMB.setBaseUri(baseuriMB); sparqlQmgr.executeUpdate(qdefMB); String qMB = "select ?s ?p ?o from <" + baseuriMB + "BindingsGraph> where {?s ?p ?o. }"; SPARQLQueryDefinition qdefValidMB = sparqlQmgr.newQueryDefinition().withSparql(qMB);
try { tWrite = writeclient.openTransaction(); sparqlWriteQmgr.executeUpdate(qdefWrite, tWrite); sparqlWriteQmgr.executeUpdate(qdefWrite, tWrite); tWrite.commit(); sparqlReadQmgr.executeUpdate(qdefWriteError); } catch (Exception e) { exception = e.toString();
@Test public void testUsingURI() { // verify default graph String defGraphQuery = "INSERT { GRAPH <http://marklogic.com/SPARQLQDefTest/g3> " + "{ <http://marklogic.com/SPARQLQDefTest/r3> " + "<http://marklogic.com/SPARQLQDefTest/p3> " + "<http://marklogic.com/SPARQLQDefTest/o3> } } " + "WHERE { <http://marklogic.com/SPARQLQDefTest/r1> <http://marklogic.com/SPARQLQDefTest/p3> ?o }"; String defCheckQuery = "ASK WHERE { <http://marklogic.com/SPARQLQDefTest/r3> <http://marklogic.com/SPARQLQDefTest/p3> <http://marklogic.com/SPARQLQDefTest/o3> }"; SPARQLQueryDefinition qdef = smgr.newQueryDefinition(defGraphQuery); qdef.setUsingGraphUris("http://marklogic.com/SPARQLQDefTest/g1"); smgr.executeUpdate(qdef); SPARQLQueryDefinition checkDef = smgr.newQueryDefinition(defCheckQuery); checkDef.setDefaultGraphUris("http://marklogic.com/SPARQLQDefTest/g3"); assertTrue(smgr.executeAsk(checkDef)); // clean up smgr.executeUpdate(smgr.newQueryDefinition("DROP GRAPH <http://marklogic.com/SPARQLQDefTest/g3>")); assertFalse(smgr.executeAsk(checkDef)); }
sparqlQmgr.executeUpdate(qdef); qdef.setDirectory("TestMarkLogic"); sparqlQmgr.executeUpdate(qdef); strWriteHandle.with("COPY <OriginalGraph> TO <CopiedGraph>"); qdef.setSparql(strWriteHandle); sparqlQmgr.executeUpdate(qdef);
@Test public void testUsingNamedURI() { // verify default graph String defGraphQuery = "INSERT { GRAPH <http://marklogic.com/SPARQLQDefTest/g65> " + "{ <http://marklogic.com/SPARQLQDefTest/r3> " + "<http://marklogic.com/SPARQLQDefTest/p3> " + "<http://marklogic.com/SPARQLQDefTest/o3> } } " + "WHERE { GRAPH ?g { <http://marklogic.com/SPARQLQDefTest/r1> <http://marklogic.com/SPARQLQDefTest/p3> ?o } }"; String checkQuery = "ASK WHERE { <http://marklogic.com/SPARQLQDefTest/r3> <http://marklogic.com/SPARQLQDefTest/p3> <http://marklogic.com/SPARQLQDefTest/o3> }"; SPARQLQueryDefinition qdef = smgr.newQueryDefinition(defGraphQuery); // negative, no insert qdef.setUsingNamedGraphUris("http://marklogic.com/SPARQLQDefTest/baloney"); smgr.executeUpdate(qdef); SPARQLQueryDefinition checkDef = smgr.newQueryDefinition(checkQuery); checkDef.setDefaultGraphUris("http://marklogic.com/SPARQLQDefTest/g65"); assertFalse(smgr.executeAsk(checkDef)); // positive qdef.setUsingNamedGraphUris("http://marklogic.com/SPARQLQDefTest/g1"); smgr.executeUpdate(qdef); checkDef.setDefaultGraphUris("http://marklogic.com/SPARQLQDefTest/g65"); assertTrue(smgr.executeAsk(checkDef)); }
@Test public void issue_357() { // open transaction Transaction transaction = Common.client.openTransaction(); try { // insert some data under transaction String insertString="BASE <http://example.org/addressbook>\n " + "INSERT DATA { <http://example.org/id#3333> <#email> \"jonny@ramone.com\"}"; SPARQLQueryDefinition insertDef = smgr.newQueryDefinition(insertString); smgr.executeUpdate(insertDef, transaction); // ask for it w/ transaction String queryString = "ASK WHERE { <http://example.org/id#3333> <http://example.org/addressbook#email> ?o }"; SPARQLQueryDefinition booleanDef = smgr.newQueryDefinition(queryString); assertTrue(smgr.executeAsk(booleanDef,transaction)); } finally { transaction.rollback(); } }
@Test public void G_testSPARQLInsertPermissions() throws Exception { String localGraphUri = graphUri + ".SPARQLPermissions"; String sparql = "INSERT DATA { GRAPH <" + localGraphUri + "> { <s2> <p2> <o2> } }"; SPARQLQueryManager sparqlMgr = Common.client.newSPARQLQueryManager(); SPARQLQueryDefinition qdef = sparqlMgr.newQueryDefinition(sparql) .withUpdatePermission("write-privileged", Capability.READ) .withUpdatePermission("write-privileged", Capability.UPDATE); sparqlMgr.executeUpdate(qdef); GraphPermissions getPermissions = gmgr.getPermissions(localGraphUri); assertEquals(5, getPermissions.size()); assertNotNull(getPermissions.get("write-privileged")); assertEquals(2, getPermissions.get("write-privileged").size()); for ( Capability capability : getPermissions.get("write-privileged") ) { if ( capability == null ) fail("capability should not be null"); if ( capability != Capability.READ && capability != Capability.UPDATE ) { fail("capabilities should be read or update, not [" + capability + "]"); } } gmgr.delete(localGraphUri); } }
try { tx = Common.client.openTransaction(); smgr.executeUpdate(smgr.newQueryDefinition(q1), tx); smgr.executeUpdate(smgr.newQueryDefinition(q1), tx); smgr.executeUpdate(smgr.newQueryDefinition(q2), tx); smgr.executeUpdate(smgr.newQueryDefinition(d1), tx);