List<Expression> expressions = new ArrayList<Expression>();
Iterator<RuleAtom> it = rule.getBody().iterator();
while (it.hasNext()) {
RuleAtom ruleAtom = it.next();
ClerezzaSparqlObject clerezzaSparqlObject = null;
log.debug("Type to adapt {}", type);
clerezzaSparqlObject = (ClerezzaSparqlObject) adaptRuleAtomTo(ruleAtom, type);
Object clerezzaObj = clerezzaSparqlObject.getClerezzaObject();
if (clerezzaObj instanceof TriplePattern) {
triplePatterns.add((TriplePattern) clerezzaObj);
} else if (clerezzaObj instanceof Expression) {
expressions.add((Expression) clerezzaObj);
}
}
SimpleGroupGraphPattern groupGraphPattern = new SimpleGroupGraphPattern();
groupGraphPattern.addTriplePatterns(triplePatterns);
for (Expression expression : expressions) {
groupGraphPattern.addConstraint(expression);
}
triplePatterns = new HashSet<TriplePattern>();
it = rule.getHead().iterator();
while (it.hasNext()) {
RuleAtom ruleAtom = it.next();
ClerezzaSparqlObject clerezzaSparqlObject = (ClerezzaSparqlObject) adaptRuleAtomTo(ruleAtom, type);
triplePatterns.add((TriplePattern) clerezzaSparqlObject.getClerezzaObject());
}