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

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

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

Query.hasDatasetDescription介绍

[英]Return true if the query has either some graph URIs or some named graph URIs in its description. This does not mean these URIs will be used - just that they are noted as part of the query.
[中]如果查询的描述中包含一些图URI或一些命名图URI,则返回true。这并不意味着将使用这些URI,只是将它们作为查询的一部分加以说明。

代码示例

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

protected Dataset dealWithNoDataset(Query query)  {
  if ( query.hasDatasetDescription() )
    return null;
  return DatasetFactory.createTxnMem();
  //throw new CmdException("No dataset provided") ; 
}

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

private static boolean doesQueryHaveDataset(Query query)
{
  return query.hasDatasetDescription() ;
}

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

protected Dataset dealWithNoDataset(Query query)  {
  if ( query.hasDatasetDescription() )
    return null;
  return DatasetFactory.createTxnMem();
  //throw new CmdException("No dataset provided") ; 
}

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

/** Decide the dataset - this modifies the query
   *  If the query has a dataset description.
   */
  @Override
  protected DatasetGraph decideDataset(HttpAction action, Query query, String queryStringLog) {
    DatasetGraph dsg = action.getActiveDSG() ;
    DatasetDescription dsDesc = getDatasetDescription(action, query) ;
    if ( dsDesc != null ) {
      dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false) ;
      if ( query.hasDatasetDescription() ) {
        query.getGraphURIs().clear() ;
        query.getNamedGraphURIs().clear() ;
      }
    }
    return dsg ;
  }
}

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

/** Decide the dataset - this modifies the query
   *  If the query has a dataset description.
   */
  @Override
  protected DatasetGraph decideDataset(HttpAction action, Query query, String queryStringLog) {
    DatasetGraph dsg = action.getActiveDSG() ;
    DatasetDescription dsDesc = getDatasetDescription(action, query) ;
    if ( dsDesc != null ) {
      dsg = DynamicDatasets.dynamicDataset(dsDesc, dsg, false) ;
      if ( query.hasDatasetDescription() ) {
        query.getGraphURIs().clear() ;
        query.getNamedGraphURIs().clear() ;
      }
    }
    return dsg ;
  }
}

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

/** Create a dataset description, given a query and context.
 * The context overrides the query FROM/FROM NAMED.
 * If neither the context nor query has a dataset description, return null.
 * The context uses the key {@link ARQConstants#sysDatasetDescription}.
 */
public static DatasetDescription create(Query query, Context context)
{
  if ( context != null && context.isDefined(ARQConstants.sysDatasetDescription) )
  {
    try {
      return (DatasetDescription)context.get(ARQConstants.sysDatasetDescription) ;
    } catch (ClassCastException ex)
    {
      throw new ARQException("Unexpected type (expected DatasetDescription): "+ex.getMessage()) ;
    }
  }
  
  if ( query != null && query.hasDatasetDescription() )
    return query.getDatasetDescription() ;
  
  return null ;
}

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

private DatasetGraph prepareDataset(DatasetGraph originalDataset, Query query) {
  DatasetDescription dsDesc = DatasetDescription.create(query, context) ;
  DatasetGraph dsg = originalDataset;
  
  if ( dsg != null ) { 
    if ( dsDesc != null ) {
      if ( query.hasDatasetDescription() )
        dsg = dynamicDataset(dsDesc, dsg, false);
    }
    return dsg;
  }
  // No DatasetGraph
  if ( ! query.hasDatasetDescription() ) 
    throw new QueryExecException("No dataset and no dataset description for query");
  // DatasetDescription : Build it.
  String baseURI = query.getBaseURI() ;
  if ( baseURI == null )
    baseURI = IRIResolver.chooseBaseURI().toString() ;
  dsg = DatasetUtils.createDatasetGraph(dsDesc, baseURI ) ;
  return dsg ;
}

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

/** Return a dataset description (FROM/FROM NAMED clauses) for the query. */  
public DatasetDescription getDatasetDescription()
{
  if ( ! hasDatasetDescription() )
    return null;
  
  DatasetDescription description = new DatasetDescription() ;
  
  description.addAllDefaultGraphURIs(getGraphURIs()) ;
  description.addAllNamedGraphURIs(getNamedGraphURIs()) ;
  return description ;
}

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

private DatasetGraph dynamicDataset(HttpAction action, Query query, DatasetGraph dsg0, DatasetDescription dsDesc0, SecurityContext sCxt) {
  if ( dsDesc0 == null )
    return dsg0;
  if ( ! ALLOW_FROM )
    ServletOps.errorBadRequest("Use GRAPH. (FROM/FROM NAMED is not compatible with data access control.)");
  
  DatasetDescription dsDesc1 = DatasetDescription.create(
    mask(dsDesc0.getDefaultGraphURIs(), sCxt),
    mask(dsDesc0.getNamedGraphURIs(),   sCxt));
  if ( dsDesc1.isEmpty() )
    return DatasetGraphZero.create();
  // Fix up the union graph in the graphs if in FROM.
  // (FROM NAMED <union graph> is done by DynamicDatasets).
  if ( dsDesc1.getDefaultGraphURIs().contains(Quad.unionGraph.getURI())) {
    dsDesc1.getDefaultGraphURIs().remove(Quad.unionGraph.getURI());
    dsDesc1.getDefaultGraphURIs().addAll(sCxt.visibleGraphNames());
  }
  
  DatasetGraph dsg1 = DynamicDatasets.dynamicDataset(dsDesc1, dsg0, false) ;
  if ( query.hasDatasetDescription() ) {
     query.getGraphURIs().clear() ;
     query.getNamedGraphURIs().clear() ;
  }
  return dsg1 ;
}

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

if ( dataset == null && !query.hasDatasetDescription() ) {
  System.err.println("Dataset not specified in query nor provided on command line.");
  throw new TerminationException(1);

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

if ( dataset == null && !query.hasDatasetDescription() ) {
  System.err.println("Dataset not specified in query nor provided on command line.");
  throw new TerminationException(1);

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

@Override
public void startVisit(Query query) {
  newQuery.setSyntax(query.getSyntax());
  if (query.explicitlySetBaseURI())
    newQuery.setBaseURI(query.getPrologue().getResolver());
  newQuery.setQueryResultStar(query.isQueryResultStar());
  if (query.hasDatasetDescription()) {
    DatasetDescription desc = query.getDatasetDescription();
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addGraphURI(x);
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addNamedGraphURI(x);
  }
  // Aggregators.
  newQuery.getAggregators().addAll(query.getAggregators());
}

代码示例来源:origin: SmartDataAnalytics/jena-sparql-api

@Override
public void startVisit(Query query) {
  newQuery.setSyntax(query.getSyntax()) ;
  if ( query.explicitlySetBaseURI() )
    newQuery.setBaseURI(query.getPrologue().getResolver()) ;
  newQuery.setQueryResultStar(query.isQueryResultStar()) ;
  if ( query.hasDatasetDescription() ) {
    DatasetDescription desc = query.getDatasetDescription() ;
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addGraphURI(x) ;
    for (String x : desc.getDefaultGraphURIs())
      newQuery.addNamedGraphURI(x) ;
  }
  // Aggregators.
  newQuery.getAggregators().addAll(query.getAggregators()) ;
}

相关文章