use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject 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);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject 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);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class DifferentAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.DifferentAtom tmp = (org.apache.stanbol.rules.manager.atoms.DifferentAtom) ruleAtom;
ExpressionAtom stringFunctionAtom1 = tmp.getStringFunctionAtom1();
ExpressionAtom stringFunctionAtom2 = tmp.getStringFunctionAtom1();
ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(stringFunctionAtom1, ConstructQuery.class);
ClerezzaSparqlObject argument2 = (ClerezzaSparqlObject) adapter.adaptTo(stringFunctionAtom2, ConstructQuery.class);
Expression lhe = (Expression) argument1.getClerezzaObject();
Expression rhe = (Expression) argument2.getClerezzaObject();
BinaryOperation binaryOperation = new BinaryOperation("!=", lhe, rhe);
return (T) new ClerezzaSparqlObject(binaryOperation);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class DivisionAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.DivisionAtom tmp = (org.apache.stanbol.rules.manager.atoms.DivisionAtom) 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);
}
use of org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject in project stanbol by apache.
the class LessThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LessThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
ClerezzaSparqlObject clerezzaArgument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument1, ConstructQuery.class);
ClerezzaSparqlObject clerezzaArgument2 = (ClerezzaSparqlObject) adapter.adaptTo(argument2, ConstructQuery.class);
Expression lhe = (Expression) clerezzaArgument1.getClerezzaObject();
Expression rhe = (Expression) clerezzaArgument2.getClerezzaObject();
return (T) new ClerezzaSparqlObject(new BinaryOperation("<", lhe, rhe));
}
Aggregations