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

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

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

Query.isConstructType介绍

暂无

代码示例

代码示例来源:origin: tarql/tarql

public boolean isConstructType() {
  return !queries.isEmpty() && queries.get(0).isConstructType();
}

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

public boolean isConstructQuad()            { return isConstructType() && constructTemplate.containsRealQuad() ; }
// It was a mistake to extend Prologue ... but what is done is done.

代码示例来源:origin: AtomGraph/Core

/**
 * Convenience method for <pre>CONSTRUCT</pre> queries.
 * 
 * @param defaultGraphUris default graph URIs
 * @param namedGraphUris named graph URIs
 * @link #loadModel(query)
 * @param query
 * @return RDF model
 */
public Model construct(Query query, List<URI> defaultGraphUris, List<URI> namedGraphUris)
{
  if (query == null) throw new IllegalArgumentException("Query must be not null");
  if (!query.isConstructType()) throw new IllegalArgumentException("Query must be CONSTRUCT");
  
  return loadModel(query, defaultGraphUris, namedGraphUris);
}

代码示例来源:origin: tarql/tarql

public void makeTest() {
    for (Query q: queries) {
      if (q.isConstructType()) {
        q.setQuerySelectType();
      }
      q.setLimit(5);
    }
  }
}

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

public SPARQLRule(Resource rule) {
  super(rule);
  String rawString = JenaUtil.getStringProperty(rule, SH.construct);
  String queryString = SPARQLSubstitutions.withPrefixes(rawString, rule);
  query = ARQFactory.get().createQuery(queryString);
  if(!query.isConstructType()) {
    throw new IllegalArgumentException("Values of sh:construct must be CONSTRUCT queries");
  }
}

代码示例来源:origin: com.github.galigator.openllet/openllet-jena

private static QueryType getQueryType(final Query query)
{
  if (query.isSelectType())
    return QueryType.SELECT;
  if (query.isConstructType())
    return QueryType.CONSTRUCT;
  if (query.isDescribeType())
    return QueryType.DESCRIBE;
  if (query.isAskType())
    return QueryType.ASK;
  return null;
}

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

public SPARQLRule(Resource rule) {
  super(rule);
  String rawString = JenaUtil.getStringProperty(rule, SH.construct);
  String queryString = SPARQLSubstitutions.withPrefixes(rawString, rule);
  query = ARQFactory.get().createQuery(queryString);
  if(!query.isConstructType()) {
    throw new IllegalArgumentException("Values of sh:construct must be CONSTRUCT queries");
  }
}

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

private static QueryType getQueryType(final Query query)
{
  if (query.isSelectType())
    return QueryType.SELECT;
  if (query.isConstructType())
    return QueryType.CONSTRUCT;
  if (query.isDescribeType())
    return QueryType.DESCRIBE;
  if (query.isAskType())
    return QueryType.ASK;
  return null;
}

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

private static QueryType getQueryType(final Query query)
{
  if (query.isSelectType())
    return QueryType.SELECT;
  if (query.isConstructType())
    return QueryType.CONSTRUCT;
  if (query.isDescribeType())
    return QueryType.DESCRIBE;
  if (query.isAskType())
    return QueryType.ASK;
  return null;
}

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

static private String labelForQuery(Query q) {
  if ( q.isSelectType() )     return "SELECT" ; 
  if ( q.isConstructType() )  return "CONSTRUCT" ; 
  if ( q.isDescribeType() )   return "DESCRIBE" ; 
  if ( q.isAskType() )        return "ASK" ;
  if ( q.isJsonType() )       return "JSON" ;
  return "<<unknown>>" ;
}

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

/**
 * CONSTRUCT queries are mapped to result sets with the variables ?s ?p ?o
 *
 */
public static ResultSet forceExecResultSet(QueryExecution qe, Query query) {
  ResultSet result;
  if(query.isSelectType()) {
    result = qe.execSelect();
  } else if(query.isConstructType()) {
    Iterator<Triple> it = qe.execConstructTriples();
    result = org.aksw.jena_sparql_api.core.utils.ResultSetUtils.tripleIteratorToResultSet(it, new CloseableQueryExecution(qe));
  } else {
    throw new RuntimeException("Query type is not supported: " + query);
  }
  return result;
}

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

private Iterator<Triple> executeConstructStreaming(Query query) {
  if (!query.isConstructType()) {
    throw new RuntimeException("CONSTRUCT query expected. Got: ["
        + query.toString() + "]");
  }
  Query clone = query.cloneQuery();
  clone.setQuerySelectType();
  //Query selectQuery = QueryUtils.elementToQuery(query.getQueryPattern());
  clone.setQueryResultStar(true);
  ResultSetCloseable rs = executeCoreSelect(clone);
  System.out.println("Executing query as: " + clone);
  // insertPrefixesInto(result) ;
  Template template = query.getConstructTemplate();
  Iterator<Triple> result = new ConstructIterator(template, rs);
  return result;
}

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

private void printQueryResults()
{
  if (query.isSelectType())
    printSelectQueryResuts();
  else
    if (query.isConstructType())
      printConstructQueryResults();
    else
      if (query.isAskType())
        printAskQueryResult();
}

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

public static SparqlView create(String name, Query query) {
    if(!query.isConstructType()) {
      throw new RuntimeException("Query must be a construct query");
    }

    Op tmp = Algebra.compile(query.getQueryPattern());
    Op op = Algebra.toQuadForm(tmp);

    QuadPattern quadPattern = QuadPatternUtils.toQuadPattern(Quad.defaultGraphNodeGenerated, query.getConstructTemplate().getBGP());

//        QuadPattern quadPattern = new QuadPattern();
//        for(Triple triple : query.getConstructTemplate().getTriples()) {
//            quadPattern.add(new Quad(Quad.defaultGraphNodeGenerated, triple));
//        }

    SparqlView result = create(name, quadPattern, op);
    //SparqlView result = new SparqlView(name, quadPattern, new ExprList(), new VarDefinition(), op);
    return result;
  }

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

@Override
public void visitConstructResultForm(Query query1)
{
  check("Not both CONSTRUCT queries", query2.isConstructType()) ;
  check("CONSTRUCT templates", 
     query1.getConstructTemplate().equalIso(query2.getConstructTemplate(), new NodeIsomorphismMap()) ) ;
}

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

public static MappedConcept<Graph> query(Query query, Var partitionVar) {
    Assert.isTrue(query.isConstructType());

    Template template = query.getConstructTemplate();
    BasicPattern bgp = template.getBGP();

    BasicPattern newBgp = allocVarsForBlankNodes(bgp);

    //Element e = new Element
    Element newElement = new ElementTriplesBlock(newBgp);
    Template newTemplate = new Template(newBgp);

    Concept concept = new Concept(newElement, partitionVar);
    Agg<Graph> agg = AggGraph.create(newTemplate);

    MappedConcept<Graph> result = MappedConcept.create(concept, agg);
    return result;
  }
}

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

@Override
public Iterator<Quad> execConstructQuads() {
  checkNotClosed();
  if ( ! query.isConstructType() )
    throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ;
  // This causes there to be no PROJECT around the pattern.
  // That in turn, exposes the initial bindings.  
  query.setQueryResultStar(true) ;
  startQueryIterator() ;
  
  Template template = query.getConstructTemplate() ;
  return TemplateLib.calcQuads(template.getQuads(), queryIterator);
}

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

@Override
public Iterator<Triple> execConstructTriples() {
  checkNotClosed();
  if ( ! query.isConstructType() )
    throw new QueryExecException("Attempt to get a CONSTRUCT model from a "+labelForQuery(query)+" query") ;
  // This causes there to be no PROJECT around the pattern.
  // That in turn, exposes the initial bindings.  
  query.setQueryResultStar(true) ;
  startQueryIterator() ;
  
  Template template = query.getConstructTemplate() ;
  return TemplateLib.calcTriples(template.getTriples(), queryIterator);
}

代码示例来源:origin: tarql/tarql

private void processResults(TarqlQueryExecution ex) throws IOException {
  if (testQuery && ex.getFirstQuery().getConstructTemplate() != null) {
    IndentedWriter out = new IndentedWriter(System.out); 
    new FmtTemplate(out, new SerializationContext(ex.getFirstQuery())).format(ex.getFirstQuery().getConstructTemplate());
    out.flush();
  }
  if (ex.getFirstQuery().isSelectType()) {
    System.out.println(ResultSetFormatter.asText(ex.execSelect()));
  } else if (ex.getFirstQuery().isAskType()) {
    System.out.println(ResultSetFormatter.asText(ex.execSelect()));
  } else if (ex.getFirstQuery().isConstructType()) {
    resultTripleIterator = resultTripleIterator.andThen(ex.execTriples());
  } else {
    cmdError("Only query forms CONSTRUCT, SELECT and ASK are supported");
  }
}

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

private void compareDatasetResults(Dataset resultsActual, Query query)
{
  if ( results != null )
  {
    try {
      if ( ! results.isDataset() )
        fail("Expected results are not a graph: "+testItem.getName()) ;
        
      Dataset resultsExpected = results.getDataset() ;
      if ( ! IsoMatcher.isomorphic( resultsExpected.asDatasetGraph(),resultsActual.asDatasetGraph() ) )
      {
        printFailedDatasetTest(query, resultsExpected, resultsActual) ;
        fail("Results do not match: "+testItem.getName()) ;
      }
    } catch (Exception ex)
    {
      String typeName = (query.isConstructType()?"construct":"describe") ;
      fail("Exception in result testing ("+typeName+"): "+ex) ;
    }
  }
}

相关文章