Search in sources :

Example 1 with UpdateLoad

use of org.apache.jena.sparql.modify.request.UpdateLoad in project jena by apache.

the class UpdateProgrammatic method main.

public static void main(String[] args) {
    Dataset dataset = DatasetFactory.createTxnMem();
    UpdateRequest request = UpdateFactory.create();
    request.add(new UpdateDrop(Target.ALL));
    request.add(new UpdateCreate("http://example/g2"));
    request.add(new UpdateLoad("file:etc/update-data.ttl", "http://example/g2"));
    UpdateAction.execute(request, dataset);
    System.out.println("# Debug format");
    SSE.write(dataset);
    System.out.println();
    System.out.println("# N-Quads: S P O G");
    RDFDataMgr.write(System.out, dataset, Lang.NQUADS);
}
Also used : UpdateCreate(org.apache.jena.sparql.modify.request.UpdateCreate) UpdateLoad(org.apache.jena.sparql.modify.request.UpdateLoad) Dataset(org.apache.jena.query.Dataset) UpdateDrop(org.apache.jena.sparql.modify.request.UpdateDrop)

Example 2 with UpdateLoad

use of org.apache.jena.sparql.modify.request.UpdateLoad in project jena by apache.

the class load method execUpdate.

@Override
protected void execUpdate(DatasetGraph graphStore) {
    if (loadFiles.size() == 0)
        throw new CmdException("Nothing to do");
    UpdateRequest req = new UpdateRequest();
    for (String filename : loadFiles) {
        UpdateLoad loadReq = new UpdateLoad(filename, graphName);
        req.add(loadReq);
    }
    if (true) {
        // Need a better way
        monitor(graphStore.getDefaultGraph());
        for (Iterator<Node> iter = graphStore.listGraphNodes(); iter.hasNext(); ) {
            Graph g = graphStore.getGraph(iter.next());
            monitor(g);
        }
    }
    UpdateExecutionFactory.create(req, graphStore).execute();
    if (dump) {
        IndentedWriter out = IndentedWriter.stdout;
        SSE.write(graphStore);
        out.flush();
    }
}
Also used : IndentedWriter(org.apache.jena.atlas.io.IndentedWriter) DatasetGraph(org.apache.jena.sparql.core.DatasetGraph) Graph(org.apache.jena.graph.Graph) CmdException(jena.cmd.CmdException) UpdateRequest(org.apache.jena.update.UpdateRequest) UpdateLoad(org.apache.jena.sparql.modify.request.UpdateLoad) Node(org.apache.jena.graph.Node)

Aggregations

UpdateLoad (org.apache.jena.sparql.modify.request.UpdateLoad)2 CmdException (jena.cmd.CmdException)1 IndentedWriter (org.apache.jena.atlas.io.IndentedWriter)1 Graph (org.apache.jena.graph.Graph)1 Node (org.apache.jena.graph.Node)1 Dataset (org.apache.jena.query.Dataset)1 DatasetGraph (org.apache.jena.sparql.core.DatasetGraph)1 UpdateCreate (org.apache.jena.sparql.modify.request.UpdateCreate)1 UpdateDrop (org.apache.jena.sparql.modify.request.UpdateDrop)1 UpdateRequest (org.apache.jena.update.UpdateRequest)1