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);
}
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 + ")");
}
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);
}
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;
}
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);
}
Aggregations