Search in sources :

Example 6 with FunctionCall

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

the class SubstringAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.SubstringAtom tmp = (org.apache.stanbol.rules.manager.atoms.SubstringAtom) ruleAtom;
    StringFunctionAtom argument = tmp.getStringFunctionAtom();
    NumericFunctionAtom start = tmp.getStart();
    NumericFunctionAtom length = tmp.getLength();
    ClerezzaSparqlObject clerezzaArgument = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
    ClerezzaSparqlObject clerezzaStart = (ClerezzaSparqlObject) adapter.adaptTo(start, ConstructQuery.class);
    ClerezzaSparqlObject clerezzaLength = (ClerezzaSparqlObject) adapter.adaptTo(length, ConstructQuery.class);
    List<Expression> argumentExpressions = new ArrayList<Expression>();
    argumentExpressions.add((Expression) clerezzaArgument.getClerezzaObject());
    argumentExpressions.add((Expression) clerezzaStart.getClerezzaObject());
    argumentExpressions.add((Expression) clerezzaLength.getClerezzaObject());
    FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#substring>"), argumentExpressions);
    return (T) new ClerezzaSparqlObject(functionCall);
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) ArrayList(java.util.ArrayList) NumericFunctionAtom(org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom) 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) FunctionCall(org.apache.clerezza.rdf.core.sparql.query.FunctionCall)

Example 7 with FunctionCall

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

the class ConcatAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.ConcatAtom tmp = (org.apache.stanbol.rules.manager.atoms.ConcatAtom) ruleAtom;
    StringFunctionAtom argument1Atom = tmp.getArgument1();
    StringFunctionAtom argument2Atom = tmp.getArgument2();
    ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument1Atom, ConstructQuery.class);
    ClerezzaSparqlObject argument2 = (ClerezzaSparqlObject) adapter.adaptTo(argument2Atom, ConstructQuery.class);
    List<Expression> argumentExpressions = new ArrayList<Expression>();
    argumentExpressions.add((Expression) argument1.getClerezzaObject());
    argumentExpressions.add((Expression) argument2.getClerezzaObject());
    FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#concat>"), argumentExpressions);
    return (T) new ClerezzaSparqlObject(functionCall);
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) ArrayList(java.util.ArrayList) 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) FunctionCall(org.apache.clerezza.rdf.core.sparql.query.FunctionCall)

Aggregations

ArrayList (java.util.ArrayList)7 IRI (org.apache.clerezza.commons.rdf.IRI)7 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)7 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)7 FunctionCall (org.apache.clerezza.rdf.core.sparql.query.FunctionCall)7 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)7 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)7 NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)1