Search in sources :

Example 1 with StringFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.

the class CreateLabelAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    org.apache.stanbol.rules.manager.atoms.CreateLabelAtom tmp = (org.apache.stanbol.rules.manager.atoms.CreateLabelAtom) ruleAtom;
    StringFunctionAtom stringFunctionAtom = tmp.getStringFunctionAtom();
    System.out.println("Argument instance of " + stringFunctionAtom.getClass().getCanonicalName());
    SPARQLObject sparqlArgument1 = adapter.adaptTo(stringFunctionAtom, SPARQLObject.class);
    String argument = sparqlArgument1.getObject();
    if (argument.startsWith(Symbols.variablesPrefix)) {
        argument = "?" + argument.replace(Symbols.variablesPrefix, "");
    }
    String sparql = "<http://www.stlab.istc.cnr.it/semion/function#createLabel>(" + argument + ")";
    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 2 with StringFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.

the class EndsWithAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
    org.apache.stanbol.rules.manager.atoms.EndsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.EndsWithAtom) ruleAtom;
    StringFunctionAtom argument = tmp.getArgument();
    StringFunctionAtom term = tmp.getTerm();
    SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
    SPARQLObject sparqlTerm = adapter.adaptTo(term, SPARQLObject.class);
    String argumentSparql = sparqlArgument.getObject();
    String termSparql = sparqlTerm.getObject();
    return (T) new SPARQLComparison("<http://www.w3.org/2005/xpath-functions#ends-with> (" + argumentSparql + ", " + termSparql + ")");
}
Also used : SPARQLObject(org.apache.stanbol.rules.base.api.SPARQLObject) SPARQLComparison(org.apache.stanbol.rules.adapters.sparql.SPARQLComparison) StringFunctionAtom(org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)

Example 3 with StringFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom 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 4 with StringFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.

the class LetAtom method adapt.

@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
    org.apache.stanbol.rules.manager.atoms.LetAtom tmp = (org.apache.stanbol.rules.manager.atoms.LetAtom) ruleAtom;
    String variableArgument = tmp.getVariable().toString().replace(Symbols.variablesPrefix, "");
    StringFunctionAtom argument = tmp.getParameterFunctionAtom();
    SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
    String arg = sparqlArgument.getObject();
    String let = "LET (?" + variableArgument + " := " + arg + ")";
    SPARQLObject sparqlObject = new SPARQLFunction(let);
    return (T) sparqlObject;
}
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 5 with StringFunctionAtom

use of org.apache.stanbol.rules.manager.atoms.StringFunctionAtom in project stanbol by apache.

the class LowerCaseAtom method adapt.

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

Aggregations

StringFunctionAtom (org.apache.stanbol.rules.manager.atoms.StringFunctionAtom)38 ArrayList (java.util.ArrayList)15 Expression (org.apache.clerezza.rdf.core.sparql.query.Expression)11 ClerezzaSparqlObject (org.apache.stanbol.rules.adapters.clerezza.ClerezzaSparqlObject)11 ConstructQuery (org.apache.clerezza.rdf.core.sparql.query.ConstructQuery)10 SPARQLObject (org.apache.stanbol.rules.base.api.SPARQLObject)10 RuleAtomCallExeption (org.apache.stanbol.rules.base.api.RuleAtomCallExeption)9 SPARQLFunction (org.apache.stanbol.rules.adapters.sparql.SPARQLFunction)8 IRI (org.apache.clerezza.commons.rdf.IRI)7 FunctionCall (org.apache.clerezza.rdf.core.sparql.query.FunctionCall)7 IObjectAtom (org.apache.stanbol.rules.manager.atoms.IObjectAtom)6 BuiltInCall (org.apache.clerezza.rdf.core.sparql.query.BuiltInCall)4 UnavailableRuleObjectException (org.apache.stanbol.rules.base.api.UnavailableRuleObjectException)4 UnsupportedTypeForExportException (org.apache.stanbol.rules.base.api.UnsupportedTypeForExportException)4 NumericFunctionAtom (org.apache.stanbol.rules.manager.atoms.NumericFunctionAtom)4 ArgumentSWRLAtom (org.apache.stanbol.rules.adapters.swrl.ArgumentSWRLAtom)3 HigherOrderSWRLAtom (org.apache.stanbol.rules.adapters.swrl.HigherOrderSWRLAtom)3 OWLDataFactory (org.semanticweb.owlapi.model.OWLDataFactory)3 SWRLArgument (org.semanticweb.owlapi.model.SWRLArgument)3 SWRLAtom (org.semanticweb.owlapi.model.SWRLAtom)3