ProcessedQuery query = new ProcessedQuery();
Map<Node,Resource> nodeToClass = new HashMap<Node,Resource>(); // for sanity checking
for (Triple triple: triples)
{
Node subject = triple.getSubject();
Node predicate = triple.getPredicate();
Node object = triple.getObject();
if (predicate.isVariable())
throw new UnanswerableException("I can't do predicate matches (yet).");
if (predicate.equals(RDF.Nodes.type)) // RDB map is staticly typed, so this is not that useful
{
if (object.isConcrete())
{
Resource theClass = (Resource) configModel.asRDFNode(object);
Table table = class2table.get(theClass);
if (table == null)
throw new InconsistentException("Unknown class: " + object);
checkClasses(subject, theClass, nodeToClass);
nodeToClass.put(subject, theClass);
query.add(subject, table); // Just add the subject and table to the query.
}
else
throw new UnanswerableException("No type matches (yet)");
continue;
}
Resource prop = (Resource) configModel.getRDFNode(predicate);
if (!prop2col.containsKey(prop))
throw new InconsistentException("Unknown predicate: " + triple);
/* Domain / Range checks -- subjects have types specific to tables, objects are literals */
checkClasses(subject, prop.getProperty(RDFS.domain).getResource(), nodeToClass);
checkClasses(object, RDFS.Literal, nodeToClass);
//if (subject.isConcrete())
// throw new UnanswerableException("Concrete subject given: " + triple);
if (object.isConcrete() && !object.isLiteral())
throw new UnanswerableException("Object is resource: " + triple);
// Ok, that's all the problem cases out the way (well, mostly)
Col col = prop2col.get(prop);