Search in sources :

Example 6 with Expression

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

the class LowerCaseAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.LowerCaseAtom tmp = (org.apache.stanbol.rules.manager.atoms.LowerCaseAtom) ruleAtom;
    StringFunctionAtom argument = tmp.getStringFunctionAtom();
    ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
    List<Expression> argumentExpressions = new ArrayList<Expression>();
    argumentExpressions.add((Expression) argument1.getClerezzaObject());
    FunctionCall functionCall = new FunctionCall(new IRI("<http://www.w3.org/2005/xpath-functions#lower-case>"), 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)

Example 7 with Expression

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

the class MultiplicationAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.MultiplicationAtom tmp = (org.apache.stanbol.rules.manager.atoms.MultiplicationAtom) 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)

Example 8 with Expression

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

the class GreaterEqualThanAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterEqualThanAtom) 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));
}
Also used : BinaryOperation(org.apache.clerezza.rdf.core.sparql.query.BinaryOperation) ExpressionAtom(org.apache.stanbol.rules.manager.atoms.ExpressionAtom) 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)

Example 9 with Expression

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

the class EndsWithAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.EndsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.EndsWithAtom) ruleAtom;
    StringFunctionAtom argument = tmp.getArgument();
    StringFunctionAtom term = tmp.getTerm();
    ClerezzaSparqlObject argument1 = (ClerezzaSparqlObject) adapter.adaptTo(argument, ConstructQuery.class);
    ClerezzaSparqlObject argument2 = (ClerezzaSparqlObject) adapter.adaptTo(term, 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#ends-with>"), 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)

Example 10 with Expression

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

the class GreaterThanAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.GreaterThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterThanAtom) 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));
}
Also used : BinaryOperation(org.apache.clerezza.rdf.core.sparql.query.BinaryOperation) ExpressionAtom(org.apache.stanbol.rules.manager.atoms.ExpressionAtom) 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

Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)26 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)25 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)22 ArrayList (java.util.ArrayList)14 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)11 BinaryOperation (org.apache.clerezza.rdf.core.sparql.query.BinaryOperation)10 IRI (org.apache.clerezza.commons.rdf.IRI)8 FunctionCall (org.apache.clerezza.rdf.core.sparql.query.FunctionCall)7 BuiltInCall (org.apache.clerezza.rdf.core.sparql.query.BuiltInCall)6 ExpressionAtom (org.apache.stanbol.rules.manager.atoms.ExpressionAtom)6 NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)5 Variable (org.apache.clerezza.rdf.core.sparql.query.Variable)4 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)4 LiteralExpression (org.apache.clerezza.rdf.core.sparql.query.LiteralExpression)2 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)2 HashSet (java.util.HashSet)1 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)1 TriplePattern (org.apache.clerezza.rdf.core.sparql.query.TriplePattern)1 UnaryOperation (org.apache.clerezza.rdf.core.sparql.query.UnaryOperation)1 UriRefExpression (org.apache.clerezza.rdf.core.sparql.query.UriRefExpression)1