Search in sources :

Example 6 with BuiltInCall

use of org.apache.clerezza.rdf.core.sparql.query.BuiltInCall in project stanbol by apache.

the class NewIRIAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.NewIRIAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewIRIAtom) ruleAtom;
    StringFunctionAtom bindingAtom = tmp.getBinding();
    IObjectAtom variableAtom = tmp.getNewNodeVariable();
    ClerezzaSparqlObject binding = (ClerezzaSparqlObject) adapter.adaptTo(bindingAtom, ConstructQuery.class);
    ClerezzaSparqlObject variable = (ClerezzaSparqlObject) adapter.adaptTo(variableAtom, ConstructQuery.class);
    List<Expression> iriArgumentExpressions = new ArrayList<Expression>();
    iriArgumentExpressions.add((Expression) binding.getClerezzaObject());
    BuiltInCall iriBuiltInCall = new BuiltInCall("IRI", iriArgumentExpressions);
    List<Expression> bindArgumentExpressions = new ArrayList<Expression>();
    bindArgumentExpressions.add(iriBuiltInCall);
    bindArgumentExpressions.add((Expression) variable.getClerezzaObject());
    BuiltInCall bindBuiltInCall = new BuiltInCall("BIND", bindArgumentExpressions);
    return (T) new ClerezzaSparqlObject(bindBuiltInCall);
}
Also used : ArrayList(java.util.ArrayList) BuiltInCall(org.apache.clerezza.rdf.core.sparql.query.BuiltInCall) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom) Expression(org.apache.clerezza.rdf.core.sparql.query.Expression) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)

Aggregations

ArrayList (java.util.ArrayList)6 BuiltInCall (org.apache.clerezza.rdf.core.sparql.query.BuiltInCall)6 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)6 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)6 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)5 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)4 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)4 Variable (org.apache.clerezza.rdf.core.sparql.query.Variable)2 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)2 IRI (org.apache.clerezza.commons.rdf.IRI)1 UnaryOperation (org.apache.clerezza.rdf.core.sparql.query.UnaryOperation)1 UriRefExpression (org.apache.clerezza.rdf.core.sparql.query.UriRefExpression)1 URIResource (org.apache.stanbol.rules.base.api.URIResource)1 VariableAtom (org.apache.stanbol.rules.manager.atoms.VariableAtom)1