当前位置: 首页>>代码示例>>Java>>正文


Java Query.setQueryPattern方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.query.Query.setQueryPattern方法的典型用法代码示例。如果您正苦于以下问题:Java Query.setQueryPattern方法的具体用法?Java Query.setQueryPattern怎么用?Java Query.setQueryPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.query.Query的用法示例。


在下文中一共展示了Query.setQueryPattern方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:anno4j,项目名称:anno4j,代码行数:41,代码来源:UnionSelectorEvaluator.java

示例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;
    }
 
开发者ID:anno4j,项目名称:anno4j,代码行数:38,代码来源:EvalQuery.java

示例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: parseElement

import com.hp.hpl.jena.query.Query; //导入方法依赖的package包/类
public static Element parseElement(String string) {
    final Query query = new Query();
    Action action = new Action() {
        @Override
        public void exec(CQELSParser parser) throws Exception {
            Element el = parser.GroupGraphPattern();
            query.setQueryPattern(el);
        }
    };
    perform(query, string, action);
    return query.getQueryPattern();
}
 
开发者ID:KMax,项目名称:cqels,代码行数:13,代码来源:ParserCQELS.java

示例5: 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()) ;
	}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:82,代码来源:SparqlGraph.java


注:本文中的com.hp.hpl.jena.query.Query.setQueryPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。