Search in sources :

Example 21 with SPARQLFunction

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

the class LocalNameAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    IObjectAtom argument = ((org.apache.stanbol.rules.manager.atoms.LocalNameAtom) ruleAtom).getUriResource();
    SPARQLObject sparqlObject = adapter.adaptTo(argument, SPARQLObject.class);
    String sparql = "<http://jena.hpl.hp.com/ARQ/function#localname>(" + 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 22 with SPARQLFunction

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

the class ResourceAtom method adapt.

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

Example 23 with SPARQLFunction

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

the class UObjectAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) {
    org.apache.stanbol.rules.manager.atoms.UObjectAtom tmp = (org.apache.stanbol.rules.manager.atoms.UObjectAtom) ruleAtom;
    int actualType = tmp.getActualType();
    Object argument = tmp.getArgument();
    String argumentSPARQL = null;
    switch(actualType) {
        case 0:
            argumentSPARQL = "\"" + argument + "\"^^<http://www.w3.org/2001/XMLSchema#string>";
            break;
        case 1:
            argumentSPARQL = argument.toString() + "^^<http://www.w3.org/2001/XMLSchema#int>";
            break;
        case 2:
            argumentSPARQL = "?" + argument.toString().replace(Symbols.variablesPrefix, "");
            break;
        default:
            break;
    }
    if (argumentSPARQL != null) {
        return (T) new SPARQLFunction(argumentSPARQL);
    } else {
        return null;
    }
}
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