|
| 1 | +package org.apache.jena.update; |
| 2 | + |
| 3 | +import java.io.InputStream; |
| 4 | +import java.util.Iterator; |
| 5 | + |
| 6 | +import org.apache.jena.sparql.core.DatasetGraph; |
| 7 | +import org.apache.jena.sparql.core.Prologue; |
| 8 | +import org.apache.jena.sparql.engine.binding.Binding; |
| 9 | +import org.apache.jena.sparql.engine.iterator.IterAbortable; |
| 10 | +import org.apache.jena.sparql.lang.UpdateParser; |
| 11 | +import org.apache.jena.sparql.modify.UpdateEngineFactory; |
| 12 | +import org.apache.jena.sparql.modify.UpdateEngineRegistry; |
| 13 | +import org.apache.jena.sparql.modify.UpdateProcessorStreamingBase; |
| 14 | +import org.apache.jena.sparql.util.Context; |
| 15 | + |
| 16 | +public sealed interface UpdateSource { |
| 17 | + // String getBaseURI(); |
| 18 | + Iterator<Update> iterator(); |
| 19 | + |
| 20 | + // InputStream input |
| 21 | + // UsingList usingList, String baseURI, Syntax syntax |
| 22 | + public record UpdateSourceIterable(Iterator<Update> iterator) implements UpdateSource {} |
| 23 | + |
| 24 | + public record UpdateSourceUpdateRequest(UpdateRequest updateRequest) implements UpdateSource { |
| 25 | +// @Override |
| 26 | +// public String getBaseURI() { |
| 27 | +// return updateRequest.getBaseURI(); |
| 28 | +// } |
| 29 | + |
| 30 | + @Override |
| 31 | + public Iterator<Update> iterator() { |
| 32 | + return updateRequest.iterator(); |
| 33 | + } |
| 34 | + } |
| 35 | + |
| 36 | + |
| 37 | + // Everything for local updates comes through one of these two make methods |
| 38 | + /*package*/ static UpdateProcessorStreaming makeStreaming(DatasetGraph datasetGraph, Binding inputBinding, Context context) { |
| 39 | + Prologue prologue = new Prologue(); |
| 40 | + Context cxt = Context.setupContextForDataset(context, datasetGraph); |
| 41 | + UpdateEngineFactory f = UpdateEngineRegistry.get().find(datasetGraph, cxt); |
| 42 | + UpdateProcessorStreamingBase uProc = new UpdateProcessorStreamingBase(datasetGraph, inputBinding, prologue, cxt, f); |
| 43 | + // uProc.getUpdateSink(). |
| 44 | + return uProc; |
| 45 | + } |
| 46 | + |
| 47 | +// public static IterAbortable<Update> toIterator(InputStream input, Prologue prologue) { |
| 48 | +// UpdateParser parser = UpdateFactory.setupParser(uProc.getPrologue(), baseURI, syntax); |
| 49 | +// parser.parse(sink, uProc.getPrologue(), input); |
| 50 | +// |
| 51 | +// } |
| 52 | +} |
0 commit comments