use of org.apache.stanbol.rules.base.api.SPARQLObject 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.base.api.SPARQLObject 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.base.api.SPARQLObject in project stanbol by apache.
the class DivisionAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
org.apache.stanbol.rules.manager.atoms.DivisionAtom tmp = (org.apache.stanbol.rules.manager.atoms.DivisionAtom) ruleAtom;
NumericFunctionAtom argument1 = tmp.getNumericFunctionAtom1();
NumericFunctionAtom argument2 = tmp.getNumericFunctionAtom2();
SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
String sparqlFunction1 = sparqlArgument1.getObject();
String sparqlFunction2 = sparqlArgument2.getObject();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(sparqlFunction1);
sb.append("/");
sb.append(sparqlFunction2);
sb.append(")");
return (T) new SPARQLFunction(sb.toString());
}
use of org.apache.stanbol.rules.base.api.SPARQLObject 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.base.api.SPARQLObject in project stanbol by apache.
the class StartsWithAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption {
org.apache.stanbol.rules.manager.atoms.StartsWithAtom tmp = (org.apache.stanbol.rules.manager.atoms.StartsWithAtom) ruleAtom;
StringFunctionAtom argument = tmp.getArgument();
StringFunctionAtom term = tmp.getTerm();
try {
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#starts-with> (" + argumentSparql + ", " + termSparql + ")");
} 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());
}
}
Aggregations