org.openrdf.query.Dataset.getNamedGraphs()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.openrdf.query.Dataset.getNamedGraphs()方法的一些代码示例,展示了Dataset.getNamedGraphs()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dataset.getNamedGraphs()方法的具体详情如下:
包路径:org.openrdf.query.Dataset
类名称:Dataset
方法名:getNamedGraphs

Dataset.getNamedGraphs介绍

[英]Gets the named graph URIs of this dataset. An empty named graph set and a non-empty default graph set indicates that there are no named graphs. However, if both the default graph set and the named graph set are empty, that indicates that the store's default behaviour should be used.
[中]获取此数据集的命名图URI。空的命名图集和非空的默认图集表示没有命名图。但是,如果默认图形集和命名图形集都为空,则表示应使用存储的默认行为。

代码示例

代码示例来源:origin: org.openrdf.sesame/sesame-query

public Set<IRI> getNamedGraphs() {
  Set<IRI> set = primary.getNamedGraphs();
  if (set == null || set.isEmpty())
    return fallback.getNamedGraphs();
  return set;
}

代码示例来源:origin: blazegraph/database

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();
  
}

代码示例来源:origin: org.openrdf.sesame/sesame-sail-rdbms

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();
}

代码示例来源:origin: blazegraph/database

@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();
//        }
  }

代码示例来源:origin: org.openrdf.sesame/sesame-http-client

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)));

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-optimistic

if (sp.getScope() == Scope.DEFAULT_CONTEXTS) {
  graphs = dataset.getDefaultGraphs();
  emptyGraph = graphs.isEmpty() && !dataset.getNamedGraphs().isEmpty();
  graphs = dataset.getNamedGraphs();
  emptyGraph = graphs.isEmpty() && !dataset.getDefaultGraphs().isEmpty();

代码示例来源:origin: blazegraph/database

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();
  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-queryparser-sparql-compliance

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();
  }
}

代码示例来源:origin: org.openrdf.sesame/sesame-sparql-testsuite

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();
  }
}

代码示例来源:origin: blazegraph/database

public DatasetNode(final Dataset dataset, final boolean update) {
  
  this(DataSetSummary.toInternalValues(dataset.getDefaultGraphs()),
      DataSetSummary.toInternalValues(dataset.getNamedGraphs()),
      update);
}

代码示例来源:origin: com.blazegraph/bigdata-core

public DatasetNode(final Dataset dataset, final boolean update) {
  
  this(DataSetSummary.toInternalValues(dataset.getDefaultGraphs()),
      DataSetSummary.toInternalValues(dataset.getNamedGraphs()),
      update);
}

代码示例来源:origin: blazegraph/database

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();
  
}

代码示例来源:origin: it.unibz.inf.ontop/ontop-quest-db

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;
}

代码示例来源:origin: blazegraph/database

@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();
//        }
  }

代码示例来源:origin: blazegraph/database

: 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));

代码示例来源:origin: blazegraph/database

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();
  }
}

代码示例来源:origin: org.openrdf.alibaba/alibaba-repository-sparql

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();
    }
  }
}

代码示例来源:origin: blazegraph/database

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;
}

代码示例来源:origin: com.blazegraph/bigdata-core

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;
}

代码示例来源:origin: blazegraph/database

@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();
  }
}

相关文章