Search in sources :

Example 21 with NumericFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom in project stanbol by apache.

the class SumAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.SumAtom tmp = (org.apache.stanbol.rules.manager.atoms.SumAtom) ruleAtom;
    NumericFunctionAtom numericFunctionAtom1 = tmp.getNumericFunctionAtom1();
    NumericFunctionAtom numericFunctionAtom2 = tmp.getNumericFunctionAtom2();
    ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(numericFunctionAtom1, ConstructQuery.class);
    ClerezzaSparqlObject argument2 = (ClerezzaSparqlObject) adapter.adaptTo(numericFunctionAtom2, ConstructQuery.class);
    Expression lhsOperand = (Expression) argument1.getClerezzaObject();
    Expression rhsOperand = (Expression) argument2.getClerezzaObject();
    BinaryOperation binaryOperation = new BinaryOperation("+", lhsOperand, rhsOperand);
    return (T) new ClerezzaSparqlObject(binaryOperation);
}
Also used : BinaryOperation(org.apache.clerezza.rdf.core.sparql.query.BinaryOperation) NumericFunctionAtom(org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom) ConstructQuery(org.apache.clerezza.rdf.core.sparql.query.ConstructQuery) Expression(org.apache.clerezza.rdf.core.sparql.query.Expression) ClerezzaSparqlObject(org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)

Aggregations

NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)21 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)8 ArrayList (java.util.ArrayList)6 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)5 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)5 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)5 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)5 Node (com.hp.hpl.jena.graph.Node)4 ClauseEntry (com.hp.hpl.jena.reasoner.rulesys.ClauseEntry)4 Functor (com.hp.hpl.jena.reasoner.rulesys.Functor)4 BinaryOperation (org.apache.clerezza.rdf.core.sparql.query.BinaryOperation)4 HigherOrderClauseEntry (org.apache.stanbol.rules.adapters.jena.HigherOrderClauseEntry)4 NodeClauseEntry (org.apache.stanbol.rules.adapters.jena.NodeClauseEntry)4 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)4 SPARQLComparison (org.apache.stanbol.rules.adapters.sparql.SPARQLComparison)3 UnavailableRuleObjectException (org.apache.stanbol.rules.base.api.UnavailableRuleObjectException)3 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)3 SPARQLFunction (org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)2 IRI (org.apache.clerezza.commons.rdf.IRI)1 FunctionCall (org.apache.clerezza.rdf.core.sparql.query.FunctionCall)1