本文整理汇总了Java中com.hp.hpl.jena.query.Query.setQuerySelectType方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setQuerySelectType方法的具体用法?Java Query.setQuerySelectType怎么用?Java Query.setQuerySelectType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.query.Query
的用法示例。
在下文中一共展示了Query.setQuerySelectType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluate
import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
@Override
public Var evaluate(NodeSelector nodeSelector, ElementGroup elementGroup, Var var, LDPathEvaluatorConfiguration evaluatorConfiguration) {
UnionSelector unionSelector = (UnionSelector) nodeSelector;
NodeSelector nodeSelectorLeft = unionSelector.getLeft();
NodeSelector nodeSelectorRight = unionSelector.getRight();
ElementGroup leftGroup = new ElementGroup();
ElementGroup rightGroup = new ElementGroup();
Var leftVar = LDPathEvaluator.evaluate(nodeSelectorLeft, leftGroup, var, evaluatorConfiguration);
Var rightVar = LDPathEvaluator.evaluate(nodeSelectorRight, rightGroup, var, evaluatorConfiguration);
Var subVar = Var.alloc(VarIDGenerator.createID());
Query leftSubQuery = new Query();
leftGroup.addElement(new ElementBind(subVar, new NodeValueNode(leftVar.asNode())));
leftSubQuery.setQueryPattern(leftGroup);
leftSubQuery.addResultVar(var);
leftSubQuery.addResultVar(subVar);
leftSubQuery.setQuerySelectType();
ElementSubQuery leftESubQuery = new ElementSubQuery(leftSubQuery);
Query rightSubQuery = new Query();
rightGroup.addElement(new ElementBind(subVar, new NodeValueNode(rightVar.asNode())));
rightSubQuery.setQueryPattern(rightGroup);
rightSubQuery.addResultVar(var);
rightSubQuery.addResultVar(subVar);
rightSubQuery.setQuerySelectType();
ElementSubQuery rightESubQuery = new ElementSubQuery(rightSubQuery);
ElementUnion elementUnion = new ElementUnion();
elementUnion.addElement(leftESubQuery);
elementUnion.addElement(rightESubQuery);
elementGroup.addElement(elementUnion);
return subVar;
}
示例2: evaluate
import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
public static <T extends ResourceObject> Query evaluate(QueryServiceConfiguration queryServiceDTO, URI rootType) throws ParseException {
Query query = QueryFactory.make();
query.setQuerySelectType();
ElementGroup elementGroup = new ElementGroup();
Var objectVar = Var.alloc("root");
// Creating and adding the first triple - could be something like: "?objectVar rdf:type oa:Annotation
Triple t1 = new Triple(objectVar, RDF.type.asNode(), NodeFactory.createURI(rootType.toString()));
elementGroup.addTriplePattern(t1);
// Evaluating the criteria
for (Criteria c : queryServiceDTO.getCriteria()) {
SesameValueBackend backend = new SesameValueBackend();
LdPathParser parser = new LdPathParser(backend, queryServiceDTO.getConfiguration(), new StringReader(c.getLdpath()));
Var var = LDPathEvaluator.evaluate(parser.parseSelector(queryServiceDTO.getPrefixes()), elementGroup, objectVar, queryServiceDTO.getEvaluatorConfiguration());
if (c.getConstraint() != null) {
String resolvedConstraint = resolveConstraintPrefix(c.getConstraint(), queryServiceDTO, parser);
EvalComparison.evaluate(elementGroup, c, var, resolvedConstraint);
}
}
// Adding all generated patterns to the query object
query.setQueryPattern(elementGroup);
// Choose what we want so select - SELECT ?annotation in this case
query.addResultVar(objectVar);
// Setting the default prefixes, like rdf: or dc:
query.getPrefixMapping().setNsPrefixes(queryServiceDTO.getPrefixes());
return query;
}
示例3: createQuery
import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
private Query createQuery() {
Query query = QueryFactory.create();
query.setQuerySelectType();
query.setDistinct(true);
query.addResultVar(CONCEPT_SCHEME.getName());
query.addResultVar(LANGUAGE.getName());
query.addResultVar(LABEL.getName());
query.addResultVar(SORT_PRIORITY.getName());
query.setQueryPattern(createBody());
return query;
}
开发者ID:eENVplus,项目名称:tf-exploitation-server,代码行数:12,代码来源:DataSourceConfigurationProviderServiceModule.java
示例4: graphBaseFind
import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
@Override
protected ExtendedIterator<Triple> graphBaseFind(TripleMatch m) {
Node s = m.getMatchSubject() ;
Var sVar = null ;
if ( s == null )
{
sVar = Var.alloc("s") ;
s = sVar ;
}
Node p = m.getMatchPredicate() ;
Var pVar = null ;
if ( p == null )
{
pVar = Var.alloc("p") ;
p = pVar ;
}
Node o = m.getMatchObject() ;
Var oVar = null ;
if ( o == null )
{
oVar = Var.alloc("o") ;
o = oVar ;
}
Triple triple = new Triple(s, p ,o) ;
BasicPattern pattern = new BasicPattern() ;
pattern.add(triple) ;
ElementTriplesBlock element = new ElementTriplesBlock(pattern);
Query query = new Query();
query.setQuerySelectType();
query.setQueryResultStar(true);
query.setQueryPattern(element);
// query.setDistinct(true);
boolean resNotEmpty = true;
query.setLimit(tripleSliceSize);
long offsetCounter = 0;
Set<Triple> triples = new HashSet<Triple>() ;
while (resNotEmpty) {
long offset = tripleSliceSize * offsetCounter++;
query.setOffset(offset);
QueryExecution qe = QueryExecutionFactory.sparqlService(serviceURI, query);
logger.debug(query.serialize());
ResultSet res = qe.execSelect();
if (!res.hasNext()) resNotEmpty = false;
while(res.hasNext()) {
QuerySolution sol = res.nextSolution();
Node subj;
if (s.isVariable()) {
subj = sol.get("s").asNode();
} else {
subj= s;
}
Node pred;
if (p.isVariable()) {
pred = sol.get("p").asNode();
} else {
pred = p;
}
Node obj;
if (o.isVariable()) {
obj = sol.get("o").asNode();
} else {
obj = o;
}
Triple resTriple = new Triple(subj, pred, obj);
triples.add(resTriple);
}
qe.close();
}
return WrappedIterator.createNoRemove(triples.iterator()) ;
}