cssLinkI.close();
RepositoryResult<Statement> groupPrimaries = conn.getStatements(selected, FresnelCore.primaryClasses, (Value) null, false);
if (groupPrimaries.hasNext()) {
Statement primaryStmt = groupPrimaries.next();
if (groupPrimaries.hasNext()) throw new UnresolvableException("Too many fresnel:primaryClass predicates used, only one expected.");
Value primaryObj = primaryStmt.getObject();
if (primaryObj instanceof Resource && RDFList.isRDFList(in, (Resource) primaryObj)) {
List primaries = new RDFList(in, (Resource) primaryObj).asJavaList();
Iterator primaryDomains = primaries.iterator();
while (primaryDomains.hasNext()) {
Value domainNode = (Value) primaryDomains.next();
ISelector domain = null;
if (domainNode instanceof Resource) {
// This is a type selector
domain = new TypeSelector((Resource) domainNode);
} else if (domainNode instanceof Literal) {
Literal domainL = (Literal) domainNode;
// TODO: catch bad expressions? throw exceptions?
if (domainL.getDatatype().equals(FresnelCoreTypes.fslSelector)) {
domain = new FSESelector(domainL.getLabel(), _fslContext, conf.getNamespaceMap());
} else if (domainL.getDatatype().equals(FresnelCoreTypes.sparqlSelector)) {
domain = new SPARQLSelector(domainL.getLabel(), conf.getNamespaces());
}
} else {
throw new ParsingException("Could not read member fresnel:primaryClass rdf:List.");
}
out.addPrimary(domain);
}
} else {
throw new ParsingException("Could not read object of fresnel:primaryClass predicate, expecting an rdf:List.");
}
}
groupPrimaries.close();
conn.close();
} catch (RepositoryException e) {
throw new UnresolvableException("Problem connecting to repository: " + e.getLocalizedMessage());
}
return out;
}