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