Search in sources :

Example 6 with SPARQLFunction

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

the class NumericVariableAtom method adapt.

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

Example 7 with SPARQLFunction

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

the class StringAtom method adapt.

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

Example 8 with SPARQLFunction

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

the class SubstringAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
    org.apache.stanbol.rules.manager.atoms.SubstringAtom tmp = (org.apache.stanbol.rules.manager.atoms.SubstringAtom) ruleAtom;
    StringFunctionAtom stringFunctionAtom = tmp.getStringFunctionAtom();
    NumericFunctionAtom startAtom = tmp.getStart();
    NumericFunctionAtom lengthAtom = tmp.getLength();
    try {
        SPARQLObject stringSparqlAtom = adapter.adaptTo(stringFunctionAtom, SPARQLObject.class);
        SPARQLObject startSparqlAtom = adapter.adaptTo(startAtom, SPARQLObject.class);
        SPARQLObject lengthSparqlAtom = adapter.adaptTo(lengthAtom, SPARQLObject.class);
        String uriResourceString = stringSparqlAtom.getObject();
        String start = startSparqlAtom.getObject();
        String length = lengthSparqlAtom.getObject();
        String sparql = "<http://www.w3.org/2005/xpath-functions#substring> (" + uriResourceString + ", " + start + ", " + length + ")";
        return (T) new SPARQLFunction(sparql);
    } catch (UnsupportedTypeForExportException e) {
        throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
    } catch (UnavailableRuleObjectException e) {
        throw new org.apache.stanbol.rules.base.api.RuleAtomCallExeption(getClass());
    }
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) UnavailableRuleObjectException(org.apache.stanbol.rules.base.api.UnavailableRuleObjectException) NumericFunctionAtom(org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom) RuleAtomCallExeption(org.apache.stanbol.rules.base.api.RuleAtomCallExeption) SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction) StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom) UnsupportedTypeForExportException(org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)

Example 9 with SPARQLFunction

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

the class NewLiteralAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.NewLiteralAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewLiteralAtom) ruleAtom;
    SPARQLObject binding = adapter.adaptTo(tmp.getBinding(), SPARQLObject.class);
    SPARQLObject variable = adapter.adaptTo(tmp.getNewNodeVariable(), SPARQLObject.class);
    SPARQLObject sparqlObject = new SPARQLFunction("BIND(" + binding.getObject() + " AS " + variable.getObject() + ")");
    return (T) sparqlObject;
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) SPARQLFunction(org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)

Example 10 with SPARQLFunction

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

the class StringVariableAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.StringVariableAtom tmp = (org.apache.stanbol.rules.manager.atoms.StringVariableAtom) ruleAtom;
    String variableName = tmp.getVariableName();
    return (T) new SPARQLFunction("?" + variableName);
}
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