public Set<IRI> getNamedGraphs() { Set<IRI> set = primary.getNamedGraphs(); if (set == null || set.isEmpty()) return fallback.getNamedGraphs(); return set; }
protected String readInputData(Dataset dataset) throws Exception { final StringBuilder sb = new StringBuilder(); if (dataset != null) { Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { URL graphURL = new URL(graphURI.toString()); InputStream in = graphURL.openStream(); sb.append(IOUtil.readString(in)); } } return sb.toString(); }
private Set<URI> getGraphs(StatementPattern sp) { if (dataset == null) return null; if (dataset.getDefaultGraphs().isEmpty() && dataset.getNamedGraphs().isEmpty()) return null; if (sp.getScope() == Scope.DEFAULT_CONTEXTS) return dataset.getDefaultGraphs(); return dataset.getNamedGraphs(); }
@Override protected void uploadDataset(Dataset dataset) throws Exception { // RepositoryConnection con = dataRep.getConnection(); // try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } // } // finally { // con.close(); // } }
new BasicNameValuePair(Protocol.DEFAULT_GRAPH_PARAM_NAME, String.valueOf(defaultGraphURI))); for (IRI namedGraphURI : dataset.getNamedGraphs()) { queryParams.add( new BasicNameValuePair(Protocol.NAMED_GRAPH_PARAM_NAME, String.valueOf(namedGraphURI)));
if (sp.getScope() == Scope.DEFAULT_CONTEXTS) { graphs = dataset.getDefaultGraphs(); emptyGraph = graphs.isEmpty() && !dataset.getNamedGraphs().isEmpty(); graphs = dataset.getNamedGraphs(); emptyGraph = graphs.isEmpty() && !dataset.getDefaultGraphs().isEmpty();
protected void uploadDataset(Dataset dataset) throws Exception { RepositoryConnection con = dataRep.getConnection(); try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } } finally { con.close(); } }
private void uploadDataset(Dataset dataset) throws Exception { RepositoryConnection con = dataRep.getConnection(); try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } } finally { con.close(); } }
protected final void uploadDataset(Dataset dataset) throws Exception { RepositoryConnection con = dataRep.getConnection(); try { // Merge default and named graphs to filter duplicates Set<IRI> graphURIs = new HashSet<IRI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((IRI)graphURI), graphURI); } } finally { con.close(); } }
public DatasetNode(final Dataset dataset, final boolean update) { this(DataSetSummary.toInternalValues(dataset.getDefaultGraphs()), DataSetSummary.toInternalValues(dataset.getNamedGraphs()), update); }
public DatasetNode(final Dataset dataset, final boolean update) { this(DataSetSummary.toInternalValues(dataset.getDefaultGraphs()), DataSetSummary.toInternalValues(dataset.getNamedGraphs()), update); }
protected String readInputData(Dataset dataset) throws Exception { final StringBuilder sb = new StringBuilder(); if (dataset != null) { Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { URL graphURL = new URL(graphURI.toString()); InputStream in = graphURL.openStream(); sb.append(IOUtil.readString(in)); } } return sb.toString(); }
private Ontology getTBox(Dataset dataset) throws Exception { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); OntologyVocabulary vb = ofac.createVocabulary(); for (URI graphURI : graphURIs) { Ontology o = getOntology(graphURI, graphURI); vb.merge(o.getVocabulary()); // TODO: restore copying ontology axioms (it was copying from result into result, at least since July 2013) //for (SubPropertyOfAxiom ax : result.getSubPropertyAxioms()) // result.add(ax); //for (SubClassOfAxiom ax : result.getSubClassAxioms()) // result.add(ax); } Ontology result = ofac.createOntology(vb); return result; }
@Override protected void uploadDataset(Dataset dataset) throws Exception { // RepositoryConnection con = dataRep.getConnection(); // try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } // } // finally { // con.close(); // } }
: RemoteRepositoryDecls.DEFAULT_GRAPH_URI, defaultGraphs); String[] namedGraphs = new String[dataset.getNamedGraphs().size()]; i=0; for (URI namedGraphURI : dataset.getNamedGraphs()) { namedGraphs[i++] = String.valueOf(String.valueOf(namedGraphURI));
protected void uploadDataset(Dataset dataset) throws Exception { RepositoryConnection con = dataRep.getConnection(); try { // Merge default and named graphs to filter duplicates Set<URI> graphURIs = new HashSet<URI>(); graphURIs.addAll(dataset.getDefaultGraphs()); graphURIs.addAll(dataset.getNamedGraphs()); for (Resource graphURI : graphURIs) { upload(((URI)graphURI), graphURI); } } finally { con.close(); } }
protected HttpMethodBase getResponse() throws HttpException, IOException, QueryEvaluationException { PostMethod post = new PostMethod(url); post.addParameter("query", getQueryString()); if (dataset != null) { for (URI graph : dataset.getDefaultGraphs()) { post.addParameter("default-graph-uri", graph.stringValue()); } for (URI graph : dataset.getNamedGraphs()) { post.addParameter("named-graph-uri", graph.stringValue()); } } post.addRequestHeader("Accept", getAccept()); boolean completed = false; try { if (client.executeMethod(post) >= 400) { throw new QueryEvaluationException(post .getResponseBodyAsString()); } completed = true; return post; } finally { if (!completed) { post.abort(); } } }
private Dataset handleDataset(final AbstractTripleStore store, final Dataset dataset) { if (dataset != null) { DatasetImpl newDataset = new DatasetImpl(); for (final URI uri: dataset.getDefaultGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addDefaultGraph(value); } for (final URI uri: dataset.getDefaultRemoveGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addDefaultRemoveGraph(value); } for (final URI uri: dataset.getNamedGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addNamedGraph(value); } URI value = handleDatasetGraph(store, dataset.getDefaultInsertGraph()); newDataset.setDefaultInsertGraph(value); return newDataset; } return dataset; }
private Dataset handleDataset(final AbstractTripleStore store, final Dataset dataset) { if (dataset != null) { DatasetImpl newDataset = new DatasetImpl(); for (final URI uri: dataset.getDefaultGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addDefaultGraph(value); } for (final URI uri: dataset.getDefaultRemoveGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addDefaultRemoveGraph(value); } for (final URI uri: dataset.getNamedGraphs()) { URI value = handleDatasetGraph(store, uri); newDataset.addNamedGraph(value); } URI value = handleDatasetGraph(store, dataset.getDefaultInsertGraph()); newDataset.setDefaultInsertGraph(value); return newDataset; } return dataset; }
@Test public void testTupleQueryDataset() throws Exception { final TupleQuery tq = con.prepareTupleQuery(QueryLanguage.SPARQL, "select * where {?s ?p ?o}"); tq.setDataset(dataset); final TupleQueryResult tqr = tq.evaluate(); try { assertEquals(defaultGraphs,tq.getDataset().getDefaultGraphs()); assertEquals(namedGraphs,tq.getDataset().getNamedGraphs()); Collection<String> optsDefaultGraphs = Arrays.asList(remote.data.opts.requestParams.get(RemoteRepositoryDecls.DEFAULT_GRAPH_URI)); assertTrue(optsDefaultGraphs.contains(defaultGraph1.stringValue())); assertTrue(optsDefaultGraphs.contains(defaultGraph2.stringValue())); List<String> requestDefaultGraphs = remote.data.request.getParams().get(RemoteRepositoryDecls.DEFAULT_GRAPH_URI).getValues(); assertTrue(requestDefaultGraphs.contains(defaultGraph1.stringValue())); assertTrue(requestDefaultGraphs.contains(defaultGraph2.stringValue())); Collection<String> optsNamedGraphs = Arrays.asList(remote.data.opts.requestParams.get(RemoteRepositoryDecls.NAMED_GRAPH_URI)); assertTrue(optsNamedGraphs.contains(namedGraph1.stringValue())); assertTrue(optsNamedGraphs.contains(namedGraph2.stringValue())); List<String> requestNamedGraphs = remote.data.request.getParams().get(RemoteRepositoryDecls.NAMED_GRAPH_URI).getValues(); assertTrue(requestNamedGraphs.contains(namedGraph1.stringValue())); assertTrue(requestNamedGraphs.contains(namedGraph2.stringValue())); } finally { tqr.close(); } }