use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.
the class UpperCaseAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
StringFunctionAtom argument = ((org.apache.stanbol.rules.manager.atoms.UpperCaseAtom) ruleAtom).getStringFunctionAtom();
try {
SPARQLObject sparqlArgument = adapter.adaptTo(argument, SPARQLObject.class);
String sparql = "<http://www.w3.org/2005/xpath-functions#upper-case> (" + sparqlArgument.getObject() + ")";
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());
}
}
use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction 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.adapters.sparql.SPARQLFunction 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.adapters.sparql.SPARQLFunction 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);
}
use of org.apache.stanbol.rules.adapters.sparql.SPARQLFunction in project stanbol by apache.
the class NewIRIAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.NewIRIAtom tmp = (org.apache.stanbol.rules.manager.atoms.NewIRIAtom) ruleAtom;
SPARQLObject binding = adapter.adaptTo(tmp.getBinding(), SPARQLObject.class);
SPARQLObject variable = adapter.adaptTo(tmp.getNewNodeVariable(), SPARQLObject.class);
SPARQLObject sparqlObject = new SPARQLFunction("BIND(" + "IRI(" + binding.getObject() + ") AS " + variable.getObject() + ")");
return (T) sparqlObject;
}
Aggregations