org.apache.jena.query.Query.getNamedGraphURIs()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(166)

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

Query.getNamedGraphURIs介绍

[英]Return the list of URIs (strings) for the named graphs (FROM NAMED clause)
[中]返回命名图的URI(字符串)列表(来自命名子句)

代码示例

代码示例来源:origin: apache/jena

  1. @Override
  2. public void visitDatasetDecl(Query query)
  3. {
  4. x ^= query.getNamedGraphURIs().hashCode() ;
  5. }

代码示例来源:origin: apache/jena

  1. /** Return true if the query has either some graph
  2. * URIs or some named graph URIs in its description.
  3. * This does not mean these URIs will be used - just that
  4. * they are noted as part of the query.
  5. */
  6. public boolean hasDatasetDescription()
  7. {
  8. if ( getGraphURIs() != null && getGraphURIs().size() > 0 )
  9. return true ;
  10. if ( getNamedGraphURIs() != null && getNamedGraphURIs().size() > 0 )
  11. return true ;
  12. return false ;
  13. }

代码示例来源:origin: TopQuadrant/shacl

  1. public FromDataset(Dataset delegate, Query query) throws GraphNotFoundException {
  2. super(delegate);
  3. defaultGraphs = new HashSet<String>(query.getGraphURIs());
  4. namedGraphs = new HashSet<String>(query.getNamedGraphURIs());
  5. initDefaultModel();
  6. }

代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl

  1. public FromDataset(Dataset delegate, Query query) throws GraphNotFoundException {
  2. super(delegate);
  3. defaultGraphs = new HashSet<String>(query.getGraphURIs());
  4. namedGraphs = new HashSet<String>(query.getNamedGraphURIs());
  5. initDefaultModel();
  6. }

代码示例来源:origin: ch.epfl.bluebrain.nexus.org.topbraid/shacl

  1. public QueryExecution createQueryExecution(Query query, Dataset dataset, QuerySolution initialBinding) {
  2. if(!query.getGraphURIs().isEmpty() || !query.getNamedGraphURIs().isEmpty()) {
  3. dataset = new FromDataset(dataset, query);
  4. }
  5. if ( LOG_QUERIES ) {
  6. // And the data - can be long.
  7. // System.err.println("~~ ~~");
  8. // RDFDataMgr.write(System.err, dataset.getDefaultModel(), Lang.TTL);
  9. System.err.println("~~ ~~");
  10. System.err.println(initialBinding);
  11. System.err.println(query);
  12. }
  13. QueryExecution qexec = QueryExecutionFactoryFilter.get().create(query, dataset, initialBinding);
  14. adjustQueryExecution(qexec);
  15. return qexec;
  16. }

代码示例来源:origin: TopQuadrant/shacl

  1. public QueryExecution createQueryExecution(Query query, Dataset dataset, QuerySolution initialBinding) {
  2. if(!query.getGraphURIs().isEmpty() || !query.getNamedGraphURIs().isEmpty()) {
  3. dataset = new FromDataset(dataset, query);
  4. }
  5. if ( LOG_QUERIES ) {
  6. // And the data - can be long.
  7. // System.err.println("~~ ~~");
  8. // RDFDataMgr.write(System.err, dataset.getDefaultModel(), Lang.TTL);
  9. System.err.println("~~ ~~");
  10. System.err.println(initialBinding);
  11. System.err.println(query);
  12. }
  13. QueryExecution qexec = QueryExecutionFactoryFilter.get().create(query, dataset, initialBinding);
  14. adjustQueryExecution(qexec);
  15. return qexec;
  16. }

代码示例来源:origin: apache/jena

  1. @Override
  2. public void setVars(Map<Var, Node> values) {
  3. setVars(values, query.getNamedGraphURIs());
  4. setVars(values, query.getGraphURIs());
  5. }

代码示例来源:origin: apache/jena

  1. @Override
  2. public void visitDatasetDecl(Query query1)
  3. {
  4. boolean b1 = Lib.equalsListAsSet(query1.getGraphURIs(), query2.getGraphURIs()) ;
  5. check("Default graph URIs", b1 ) ;
  6. boolean b2 = Lib.equalsListAsSet(query1.getNamedGraphURIs(), query2.getNamedGraphURIs()) ;
  7. check("Named graph URIs", b2 ) ;
  8. }

代码示例来源:origin: apache/jena

  1. /**
  2. * Add all the dataset information from the handler argument.
  3. * @param datasetHandler The handler to copy from.
  4. */
  5. public void addAll(DatasetHandler datasetHandler) {
  6. from(datasetHandler.query.getGraphURIs());
  7. fromNamed(datasetHandler.query.getNamedGraphURIs());
  8. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. /**
  2. * Add all the dataset information from the handler argument.
  3. * @param datasetHandler The handler to copy from.
  4. */
  5. public void addAll(DatasetHandler datasetHandler) {
  6. from(datasetHandler.query.getGraphURIs());
  7. fromNamed(datasetHandler.query.getNamedGraphURIs());
  8. }

代码示例来源:origin: org.apache.jena/jena-querybuilder

  1. @Override
  2. public void setVars(Map<Var, Node> values) {
  3. setVars(values, query.getNamedGraphURIs());
  4. setVars(values, query.getGraphURIs());
  5. }

代码示例来源:origin: apache/jena

  1. /** Decide the dataset - this modifies the query
  2. * If the query has a dataset description.
  3. */
  4. @Override
  5. protected DatasetGraph decideDataset(HttpAction action, Query query, String queryStringLog) {
  6. DatasetGraph dsg = action.getActiveDSG() ;
  7. DatasetDescription dsDesc = getDatasetDescription(action, query) ;
  8. if ( dsDesc != null ) {
  9. dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false) ;
  10. if ( query.hasDatasetDescription() ) {
  11. query.getGraphURIs().clear() ;
  12. query.getNamedGraphURIs().clear() ;
  13. }
  14. }
  15. return dsg ;
  16. }
  17. }

代码示例来源:origin: org.apache.jena/jena-fuseki-core

  1. /** Decide the dataset - this modifies the query
  2. * If the query has a dataset description.
  3. */
  4. @Override
  5. protected DatasetGraph decideDataset(HttpAction action, Query query, String queryStringLog) {
  6. DatasetGraph dsg = action.getActiveDSG() ;
  7. DatasetDescription dsDesc = getDatasetDescription(action, query) ;
  8. if ( dsDesc != null ) {
  9. dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false) ;
  10. if ( query.hasDatasetDescription() ) {
  11. query.getGraphURIs().clear() ;
  12. query.getNamedGraphURIs().clear() ;
  13. }
  14. }
  15. return dsg ;
  16. }
  17. }

代码示例来源:origin: apache/jena

  1. @Override
  2. public void visitDatasetDecl(Query query)
  3. {
  4. if ( query.getGraphURIs() != null && query.getGraphURIs().size() != 0 )
  5. {
  6. for ( String uri : query.getGraphURIs() )
  7. {
  8. out.print("FROM ") ;
  9. out.print(FmtUtils.stringForURI(uri, query)) ;
  10. out.newline() ;
  11. }
  12. }
  13. if ( query.getNamedGraphURIs() != null && query.getNamedGraphURIs().size() != 0 )
  14. {
  15. for ( String uri : query.getNamedGraphURIs() )
  16. {
  17. // One per line
  18. out.print("FROM NAMED ") ;
  19. out.print(FmtUtils.stringForURI(uri, query)) ;
  20. out.newline() ;
  21. }
  22. }
  23. }

代码示例来源:origin: Galigator/openllet

  1. protected Dataset createDataset()
  2. {
  3. if (_query.getGraphURIs().isEmpty() && _query.getNamedGraphURIs().isEmpty())
  4. return DatasetFactory.create(new ArrayList<>(_graphURIs), new ArrayList<>(_namedGraphURIs));
  5. else
  6. return DatasetFactory.create(_query.getGraphURIs(), _query.getNamedGraphURIs());
  7. }

代码示例来源:origin: apache/jena

  1. /** Return a dataset description (FROM/FROM NAMED clauses) for the query. */
  2. public DatasetDescription getDatasetDescription()
  3. {
  4. if ( ! hasDatasetDescription() )
  5. return null;
  6. DatasetDescription description = new DatasetDescription() ;
  7. description.addAllDefaultGraphURIs(getGraphURIs()) ;
  8. description.addAllNamedGraphURIs(getNamedGraphURIs()) ;
  9. return description ;
  10. }

代码示例来源:origin: apache/jena

  1. private DatasetGraph dynamicDataset(HttpAction action, Query query, DatasetGraph dsg0, DatasetDescription dsDesc0, SecurityContext sCxt) {
  2. if ( dsDesc0 == null )
  3. return dsg0;
  4. if ( ! ALLOW_FROM )
  5. ServletOps.errorBadRequest("Use GRAPH. (FROM/FROM NAMED is not compatible with data access control.)");
  6. DatasetDescription dsDesc1 = DatasetDescription.create(
  7. mask(dsDesc0.getDefaultGraphURIs(), sCxt),
  8. mask(dsDesc0.getNamedGraphURIs(), sCxt));
  9. if ( dsDesc1.isEmpty() )
  10. return DatasetGraphZero.create();
  11. // Fix up the union graph in the graphs if in FROM.
  12. // (FROM NAMED <union graph> is done by DynamicDatasets).
  13. if ( dsDesc1.getDefaultGraphURIs().contains(Quad.unionGraph.getURI())) {
  14. dsDesc1.getDefaultGraphURIs().remove(Quad.unionGraph.getURI());
  15. dsDesc1.getDefaultGraphURIs().addAll(sCxt.visibleGraphNames());
  16. }
  17. DatasetGraph dsg1 = DynamicDatasets.dynamicDataset(dsDesc1, dsg0, false) ;
  18. if ( query.hasDatasetDescription() ) {
  19. query.getGraphURIs().clear() ;
  20. query.getNamedGraphURIs().clear() ;
  21. }
  22. return dsg1 ;
  23. }

代码示例来源:origin: Galigator/openllet

  1. @Override
  2. protected Dataset createDataset()
  3. {
  4. final boolean useQueryGraphs = !_query.getGraphURIs().isEmpty() || !_query.getNamedGraphURIs().isEmpty();
  5. final Collection<String> graphURIs = useQueryGraphs ? _query.getGraphURIs() : _graphURIs;
  6. // this handler will intercept all import resolution failures and will
  7. // try to load imports from resources (helps run these tests with maven)
  8. OntDocumentManager.getInstance().setReadFailureHandler(new ResourceImportLoader());
  9. OntModel model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
  10. for (final String dataURI : graphURIs)
  11. model.read(dataURI, FileUtils.guessLang(dataURI));
  12. model.prepare();
  13. if (PelletSparqlDawgTester.CLASSIFY_KB_IN_ADVANCE)
  14. ((PelletInfGraph) model.getGraph()).getKB().classify();
  15. final Dataset dataset = DatasetFactory.create(model);
  16. final Collection<String> namedGraphURIs = useQueryGraphs ? _query.getNamedGraphURIs() : _namedGraphURIs;
  17. for (final String graphURI : namedGraphURIs)
  18. {
  19. model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC);
  20. FileManager.get().readModel(model, graphURI);
  21. dataset.addNamedModel(graphURI, model);
  22. }
  23. return dataset;
  24. }

相关文章