use of org.apache.stanbol.rules.base.api.SPARQLObject in project stanbol by apache.
the class LessThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LessThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
String arg1 = sparqlArgument1.getObject();
String arg2 = sparqlArgument2.getObject();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(arg1);
sb.append(" < ");
sb.append(arg2);
sb.append(")");
return (T) new SPARQLComparison(sb.toString());
}
use of org.apache.stanbol.rules.base.api.SPARQLObject in project stanbol by apache.
the class LocalNameAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
IObjectAtom argument = ((org.apache.stanbol.rules.manager.atoms.LocalNameAtom) ruleAtom).getUriResource();
SPARQLObject sparqlObject = adapter.adaptTo(argument, SPARQLObject.class);
String sparql = "<http://jena.hpl.hp.com/ARQ/function#localname>(" + sparqlObject.getObject() + ")";
return (T) new SPARQLFunction(sparql);
}
use of org.apache.stanbol.rules.base.api.SPARQLObject in project stanbol by apache.
the class ClassAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
String argument1SPARQL = null;
String argument2SPARQL = null;
boolean negativeArg = false;
boolean negativeClass = false;
org.apache.stanbol.rules.manager.atoms.ClassAtom tmp = (org.apache.stanbol.rules.manager.atoms.ClassAtom) ruleAtom;
SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getClassResource(), SPARQLObject.class);
if (negativeArg || negativeClass) {
String optional = sparqlArgument1.getObject() + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> " + sparqlArgument2.getObject();
ArrayList<String> filters = new ArrayList<String>();
if (negativeArg) {
filters.add("!bound(" + argument1SPARQL + ")");
}
if (negativeClass) {
filters.add("!bound(" + argument2SPARQL + ")");
}
String[] filterArray = new String[filters.size()];
filterArray = filters.toArray(filterArray);
return (T) new SPARQLNot(optional, filterArray);
} else {
return (T) new SPARQLTriple(sparqlArgument1.getObject() + " <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> " + sparqlArgument2.getObject());
}
}
use of org.apache.stanbol.rules.base.api.SPARQLObject in project stanbol by apache.
the class GreaterThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnsupportedTypeForExportException, UnavailableRuleObjectException {
org.apache.stanbol.rules.manager.atoms.GreaterThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.GreaterThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
String arg1 = sparqlArgument1.getObject();
String arg2 = sparqlArgument2.getObject();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(arg1);
sb.append(" > ");
sb.append(arg2);
sb.append(")");
return (T) new SPARQLComparison(sb.toString());
}
use of org.apache.stanbol.rules.base.api.SPARQLObject in project stanbol by apache.
the class LessEqualThanAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom tmp = (org.apache.stanbol.rules.manager.atoms.LessEqualThanAtom) ruleAtom;
ExpressionAtom argument1 = tmp.getArgument1();
ExpressionAtom argument2 = tmp.getArgument2();
SPARQLObject sparqlArgument1 = adapter.adaptTo(argument1, SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(argument2, SPARQLObject.class);
String arg1 = sparqlArgument1.getObject();
String arg2 = sparqlArgument2.getObject();
StringBuilder sb = new StringBuilder();
sb.append("(");
sb.append(arg1);
sb.append(" <= ");
sb.append(arg2);
sb.append(")");
return (T) new SPARQLComparison(sb.toString());
}
Aggregations