Search in sources :

Example 11 with SPARQLFunction

use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.

the class VariableAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) {
    org.apache.stanbol.rules.manager.atoms.VariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.VariableAtom) ruleAtom;
    String variableName = tmp.getVariableName();
    return (T) new SPARQLFunction("?" + variableName);
}
Also used : SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)

Example 12 with SPARQLFunction

use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.

the class DivisionAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    org.apache.stanbol.rules.manager.atoms.DivisionAtom tmp = (org.apache.stanbol.rules.manager.atoms.DivisionAtom) ruleAtom;
    NumericFunctionAtom argument1 = tmp.getNumericFunctionAtom1();
    NumericFunctionAtom argument2 = tmp.getNumericFunctionAtom2();
    SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
    SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
    String sparqlFunction1 = sparqlArgument1.getObject();
    String sparqlFunction2 = sparqlArgument2.getObject();
    StringBuilder sb = new StringBuilder();
    sb.append("(");
    sb.append(sparqlFunction1);
    sb.append("/");
    sb.append(sparqlFunction2);
    sb.append(")");
    return (T) new SPARQLFunction(sb.toString());
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) NumericFunctionAtom(org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom) SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)

Example 13 with SPARQLFunction

use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.

the class LengthAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.LengthAtom tmp = (org.apache.stanbol.rules.manager.atoms.LengthAtom) ruleAtom;
    StringFunctionAtom argument = tmp.getStringFunctionAtom();
    SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
    String arg = sparqlArgument.getObject();
    String sparql = "<http://www.w3.org/2005/xpath-functions#string-length> (" + arg + ")";
    return (T) new SPARQLFunction(sparql);
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction) StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)

Example 14 with SPARQLFunction

use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.

the class NamespaceAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.NamespaceAtom tmp = (org.apache.stanbol.rules.manager.atoms.NamespaceAtom) ruleAtom;
    IObjectAtom argument = tmp.getUriResource();
    SPARQLObject sparqlObject = adapter.adaptTo(argument, SPARQLObject.class);
    String sparql = "<http://jena.hpl.hp.com/ARQ/function#namespace>(" + sparqlObject.getObject() + ")";
    return (T) new SPARQLFunction(sparql);
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) IObjectAtom(org.apache.stanbol.rules.manager.atoms.IObjectAtom) SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)

Example 15 with SPARQLFunction

use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.

the class NumberAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) {
    org.apache.stanbol.rules.manager.atoms.NumberAtom tmp = (org.apache.stanbol.rules.manager.atoms.NumberAtom) ruleAtom;
    String number = tmp.getNumber();
    return (T) new SPARQLFunction(number);
}
Also used : SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)

Aggregations

SPARQLFunction (org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)23 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)16 StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)8 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)4 UnavailableRuleObjectException (org.apache.stanbol.rules.base.api.UnavailableRuleObjectException)4 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)4 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)3 NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)2 RuleAtom (org.apache.stanbol.rules.base.api.RuleAtom)1 URIResource (org.apache.stanbol.rules.base.api.URIResource)1 AtomList (org.apache.stanbol.rules.base.api.util.AtomList)1 ExpressionAtom (org.apache.stanbol.rules.manager.atoms.ExpressionAtom)1