use of org.apache.stanbol.rules.adapters.sparql.SPARQLTriple 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.adapters.sparql.SPARQLTriple in project stanbol by apache.
the class DatavaluedPropertyAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.DatavaluedPropertyAtom) ruleAtom;
SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
SPARQLObject sparqlDT = adapter.adaptTo(tmp.getDatatypeProperty(), SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getArgument2(), SPARQLObject.class);
return (T) new SPARQLTriple(sparqlArgument1.getObject() + " " + sparqlDT.getObject() + " " + sparqlArgument2.getObject());
}
use of org.apache.stanbol.rules.adapters.sparql.SPARQLTriple in project stanbol by apache.
the class IndividualPropertyAtom method adapt.
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(RuleAtom ruleAtom) throws RuleAtomCallExeption, UnavailableRuleObjectException, UnsupportedTypeForExportException {
org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom tmp = (org.apache.stanbol.rules.manager.atoms.IndividualPropertyAtom) ruleAtom;
SPARQLObject sparqlArgument1 = adapter.adaptTo(tmp.getArgument1(), SPARQLObject.class);
SPARQLObject sparqlDT = adapter.adaptTo(tmp.getObjectProperty(), SPARQLObject.class);
SPARQLObject sparqlArgument2 = adapter.adaptTo(tmp.getArgument2(), SPARQLObject.class);
return (T) new SPARQLTriple(sparqlArgument1.getObject() + " " + sparqlDT.getObject() + " " + sparqlArgument2.getObject());
}
Aggregations