コード例 #1
0
  @Test
  public void testUpdateWorks() {
    ReconnectingDatasetGraph toQuery =
        (ReconnectingDatasetGraph)
            ((Dataset) AssemblerUtils.build("basic.ttl", SDBConnect.TYPE)).asDatasetGraph();
    toQuery.getDatasetGraph().getStore().getTableFormatter().format();
    UpdateRequest ur =
        UpdateFactory.create("insert data { <http://example.com/> <http://example.com/prop> 1 }");
    UpdateProcessor u = UpdateExecutionFactory.create(ur, toQuery);
    u.execute();

    assertTrue("Update works", !toQuery.getDatasetGraph().isEmpty());
  }
コード例 #2
0
  @Test
  public void testUnionWorks() {
    Dataset ds = (Dataset) AssemblerUtils.build("union.ttl", SDBConnect.TYPE);
    ReconnectingDatasetGraph toQuery = (ReconnectingDatasetGraph) ds.asDatasetGraph();
    toQuery.getDatasetGraph().getStore().getTableFormatter().format();
    UpdateRequest ur =
        UpdateFactory.create(
            "insert data {"
                + "graph <http://example.com/a> { <http://example.com/1> <http://example.com/prop> 1 }"
                + "graph <http://example.com/b> { <http://example.com/2> <http://example.com/prop> 2 }"
                + "}");
    UpdateProcessor u = UpdateExecutionFactory.create(ur, toQuery);
    u.execute();

    QueryExecution qe = QueryExecutionFactory.create("SELECT * { ?s ?p ?o }", ds);
    ResultSetRewindable r = ResultSetFactory.makeRewindable(qe.execSelect());

    assertEquals("We have a union!", 2, r.size());
  }
コード例 #3
0
  @Override
  protected UpdateProcessor createUpdateProcessor(UpdateRequest u) {
    UpdateProcessRemoteBase proc =
        (UpdateProcessRemoteBase)
            UpdateExecutionFactory.createRemote(u, this.remoteConn.getUpdateEndpoint());

    // Apply HTTP settings
    if (this.client != null) {
      proc.setClient(this.client);
    }

    // Apply default and named graphs if appropriate
    if (this.remoteConn.getUsingGraphURIs() != null) {
      proc.setDefaultGraphs(this.remoteConn.getUsingGraphURIs());
    }
    if (this.remoteConn.getNamedGraphURIs() != null) {
      proc.setNamedGraphs(this.remoteConn.getUsingNamedGraphURIs());
    }

    return proc;
  }