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

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

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

Query.getConstructTemplate介绍

[英]Get the template pattern for a construct query
[中]获取构造查询的模板模式

代码示例

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

/**
 * The constructor
 * @param query The query that this handler will be modifying.
 */
public ConstructHandler(Query query) {
  this.query = query;
  constructs = new ArrayList<>();
  if (query.getConstructTemplate() != null) {
    for (Triple t : query.getConstructTemplate().getTriples()) {
      constructs.add(t);
    }
  }
}

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

/**
 * The constructor
 * @param query The query that this handler will be modifying.
 */
public ConstructHandler(Query query) {
  this.query = query;
  constructs = new ArrayList<>();
  if (query.getConstructTemplate() != null) {
    for (Triple t : query.getConstructTemplate().getTriples()) {
      constructs.add(t);
    }
  }
}

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

@Override
public void visitConstructResultForm(Query query)
{
  x ^= query.getConstructTemplate().hashCode() ;
}

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

@Override
public void visitConstructResultForm(Query query) {
  newQuery.setQueryConstructType();
  newQuery.setConstructTemplate(query.getConstructTemplate());
}

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

public static Template parseTemplate(String string)
{
  final Query query = new Query () ;
  Action action = new Action() {
    @Override
    public void exec(SPARQLParser10 parser) throws Exception
    {
      Template t = parser.ConstructTemplate() ;
      query.setConstructTemplate(t) ;
    }
  } ;
  perform(query, string, action) ;
  return query.getConstructTemplate() ;
}

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

@Override
public void visitConstructResultForm(Query query) {
  newQuery.setQueryConstructType() ;
  newQuery.setConstructTemplate(query.getConstructTemplate()) ;
}

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

public static Template parseTemplate(String string)
{
  final Query query = new Query () ;
  Action action = new Action() {
    @Override
    public void exec(SPARQLParser11 parser) throws Exception
    {
      Template t = parser.ConstructTemplate() ;
      query.setConstructTemplate(t) ;
    }
  } ;
  perform(query, string, action) ;
  return query.getConstructTemplate() ;
}

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

public static Template parseTemplate(String string)
{
  final Query query = new Query () ;
  Action action = new Action() {
    @Override
    public void exec(ARQParser parser) throws Exception
    {
      Template t = parser.ConstructTemplate() ;
      query.setConstructTemplate(t) ;
    }
  } ;
  perform(query, string, action) ;
  return query.getConstructTemplate() ;
}

代码示例来源: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

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: 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 query)
  {
    out.print("CONSTRUCT ") ;
//        if ( query.isQueryResultStar() )
//        {
//            out.print("*") ;
//            out.newline() ;
//        }
//        else
    {
      out.incIndent(BLOCK_INDENT) ;
      out.newline() ;
      Template t = query.getConstructTemplate() ;
      fmtTemplate.format(t) ;
      out.decIndent(BLOCK_INDENT) ;
    }
  }

代码示例来源: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: SmartDataAnalytics/jena-sparql-api

public static MappedConcept<DatasetGraph> query2(Query query, Var partitionVar) {
  Assert.isTrue(query.isConstructType());
  Template template = query.getConstructTemplate();
  BasicPattern bgp = template.getBGP();
  BasicPattern newBgp = allocVarsForBlankNodes(bgp);
  //org.aksw.jena_sparql_api.utils.VarUtils.
  // Allocate a fresh var for the graph
  Var g = Var.alloc("_g_");
  //Element e = new Element
  Element tmp = new ElementTriplesBlock(newBgp);
  Element newElement = new ElementNamedGraph(g, tmp);
  OpQuadPattern tmpOp = new OpQuadPattern(g, newBgp);
  QuadPattern quadPattern = tmpOp.getPattern();
  Concept concept = new Concept(newElement, partitionVar);
  Agg<DatasetGraph> agg = AggDatasetGraph.create(quadPattern);
  MappedConcept<DatasetGraph> result = MappedConcept.create(concept, agg);
  return result;
}

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

Template template = query.getConstructTemplate();
QuadPattern qp = QuadPatternUtils.toQuadPattern(Quad.defaultGraphNodeGenerated, template.getBGP());
Agg<DatasetGraph> agg = AggDatasetGraph.create(qp);

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

final Template template = _query.getConstructTemplate();

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

final Template template = _query.getConstructTemplate();

相关文章