use of org.apache.stanbol.rules.adapters.sparql.SPARQLNot 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());
}
}
Aggregations