Java Code Examples for org.apache.jena.query.Query#cloneQuery()

The following examples show how to use org.apache.jena.query.Query#cloneQuery() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OWLQLSPARQLCompiler.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
private Query primCompile(Query query, Set<String> allVars) {
	// query must already be in dnf 
	Element e = query.getQueryPattern();
	Element newelt;	
	/*if (e instanceof ElementUnion) {
		ElementUnion union= new ElementUnion();
		for (Element ge : ((ElementUnion) e).getElements()) {
			Set<String> distinguishedVars = getMultipleOccurrenceVars(getVisibleVarsToOccurrences(ge));
			distinguishedVars.addAll(query.getResultVars());
			ExpandBasicGraphPatterns ebgp = new ExpandBasicGraphPatterns();
			Element newge = ebgp.expand(query.getQueryPattern(),  new LinkedList<String>(distinguishedVars), allVars);
			union.addElement(newge);
		}
		newelt = union;
	} else {
		Set<String> distinguishedVars = getMultipleOccurrenceVars(getVisibleVarsToOccurrences(e));*/
		ExpandBasicGraphPatterns ebgp = new ExpandBasicGraphPatterns();
		//distinguishedVars.addAll(query.getResultVars());
		newelt = ebgp.expand(query.getQueryPattern(), /* new LinkedList<String>(distinguishedVars),*/ allVars);
		
	//}
	Query ret = query.cloneQuery();
	ret.setQueryPattern(newelt);
	return ret;
	
}
 
Example 2
Source File: QueryPatternSimplification.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visit(ElementSubQuery e) {
	Query sq = e.getQuery();
	QueryPatternSimplification qps = new QueryPatternSimplification();
	sq.getQueryPattern().visit(qps);
	Element newelt = qps.getResult();
	Query newsq = sq.cloneQuery();
	newsq.setQueryPattern(newelt);
	result = new ElementSubQuery(newsq);
}
 
Example 3
Source File: QueryPatternSimplification.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public Query simplify(Query q) {
	QueryPatternSimplification qps = new QueryPatternSimplification();
	q.getQueryPattern().visit(qps);
	Element newelt = qps.getResult();
	Query ret = q.cloneQuery();
	ret.setQueryPattern(newelt);
	return ret;
}
 
Example 4
Source File: RuleSystemToUnionQuery.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void visit(ElementSubQuery e) {
	Query sq = e.getQuery();
	VariableSubstitutionElementVisitor qps = new VariableSubstitutionElementVisitor(oldVar2NewValue);
	sq.getQueryPattern().visit(qps);
	Element newelt = qps.getResult();
	Query newsq = sq.cloneQuery();
	newsq.setQueryPattern(newelt);
	result = new ElementSubQuery(newsq);
}