@Override
	protected Query buildQuery() {
		Query query = new Query();
		ElementGroup elg = new ElementGroup();
		ElementUnion eu = new ElementUnion();
		for(int i=0;i<bindings.size();i++) {
			Binding binding = bindings.get(i);
			Node subject = QueryUtil.replacewithBinding(triple.getSubject(), binding);
			Node predicate = QueryUtil.replacewithBinding(triple.getPredicate(), binding);
			Node object = QueryUtil.replacewithBinding(triple.getObject(), binding);
			if(subject.isVariable()) {
				subject = Var.createVariable(subject.getName()+"_"+i);
			}
			
			if(predicate.isVariable()) {
				predicate = Var.createVariable(predicate.getName()+"_"+i);
			}
			
			if(object.isVariable()) {
				object = Var.createVariable(object.getName()+"_"+i);
			}
			
			Triple newtriple = new Triple(subject,predicate,object);
			ElementTriplesBlock tb = new ElementTriplesBlock();
			tb.addTriple(newtriple);
			eu.addElement(tb);
		}
		
		List<Element> elements = eu.getElements();
		
		if(elements.size() > 1) {
			elg.addElement(eu);
		}
		else {
			elg.addTriplePattern(((ElementTriplesBlock)elements.get(0)).getPattern().get(0));
		}
		query.setQueryPattern(elg);
		query.setQueryResultStar(true);
		query.setQuerySelectType();
		return query;
	}