PropertySet finalProperties = resolvePropertySet(lens, in, focus);
Iterator<ISelector> focusPSI = finalProperties.iterator();
r.setTitle(resolveLabel(in, focus));
this._resultModelHash.putResult(FresnelUtilities.dupResource(focus), r);
while (focusPSI.hasNext()) {
ISelector selector = focusPSI.next();
if (selector.canSelectStatements()) {
try {
Iterator<Statement> selects = selector.selectStatements(in, focus);
if (!selects.hasNext() &&
(selector instanceof PropertySelector || selector instanceof PropertyDescription)) {
if (selector instanceof PropertySelector) {
URI predicate = ((PropertySelector) selector).getProperty();
PropertyResult pr = r.getProperties().lookup(predicate);
if (null == pr) {
NoSuchPropertyResult nspr = new NoSuchPropertyResult(FresnelUtilities.dupURI(predicate), selector, r);
nspr.setTitle(resolveLabel(in, predicate));
r.addProperty(nspr);
this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), nspr);
RepositoryConnection nconn = this._notModel.getConnection();
nconn.add(FresnelUtilities.dupResource(focus), FresnelUtilities.dupURI(predicate), new LiteralImpl("empty"));
nconn.close();
} // if it's not null, there's nothing to do
} else {
Iterator<Statement> pi = ((PropertyDescription) selector).getProperty().selectStatements(in, focus);
if (pi.hasNext()) {
URI predicate = pi.next().getPredicate();
PropertyResult pr = r.getProperties().lookup(predicate);
if (null == pr) {
NoSuchPropertyResult nspr = new NoSuchPropertyResult(FresnelUtilities.dupURI(predicate), selector, r);
nspr.setTitle(resolveLabel(in, predicate));
r.addProperty(nspr);
this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), nspr);
RepositoryConnection nconn = this._notModel.getConnection();
nconn.add(FresnelUtilities.dupResource(focus), FresnelUtilities.dupURI(predicate), new LiteralImpl("empty"));
nconn.close();
} // if it's not null, there's nothing to do
}
}
}
while (selects.hasNext()) {
Statement selected = selects.next();
RepositoryConnection mconn = this._model.getConnection();
mconn.add(selected.getSubject(), selected.getPredicate(), selected.getObject(), selected.getContext());
mconn.commit();
mconn.close();
URI predicate;
boolean inverse = !selected.getSubject().equals(focus);
Value object = inverse ? selected.getSubject() : selected.getObject();
if (selector instanceof PropertyDescription && ((PropertyDescription)selector).getProperty() instanceof FSESelector) {
predicate = new URIImpl("fsl://" + ((FSESelector)((PropertyDescription)selector).getProperty()).get_fse());
}
else
predicate = selected.getPredicate();
PropertyResult pr = r.getProperties().lookup(predicate, inverse);
if (null == pr) {
pr = new PropertyResult(FresnelUtilities.dupURI(predicate), selector, r, inverse);
pr.setTitle(resolveLabel(in, predicate));
r.addProperty(pr);
// this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), pr);
} else {
// if somehow this property was already marked as NoSuchProperty, then
// replace it with a real result
if (!pr.isInModel()) {
r.getProperties().removePropertyResult(pr);
pr = new PropertyResult(FresnelUtilities.dupURI(predicate), selector, r);
pr.setTitle(resolveLabel(in, predicate));
r.addProperty(pr);
// this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), pr);
}
}
// cb
this._propertyResultModelHash.putResult(FresnelUtilities.dupURI(predicate), pr);
if (object instanceof Resource) {
Resource objResource = (Resource) object;
Result subr = new Result(FresnelUtilities.dupResource(objResource), group, lens, in);
Iterator<Statement> types = r.getTypesStatements();
RepositoryConnection tmconn = this._typesModel.getConnection();
tmconn.setAutoCommit(false);
while(types.hasNext()) {
Statement s = types.next();
tmconn.add(s.getSubject(), s.getPredicate(), s.getObject(), s.getContext());
}
tmconn.commit();
tmconn.setAutoCommit(true);
tmconn.close();
if (selector instanceof PropertyDescription) {
PropertyDescription selectorPD = (PropertyDescription) selector;
if (current == max) {
// if we've hit the limit, stop with sublensing
subr.setTitle(resolveLabel(in, objResource));
} else {
// pick a sublens to apply to the resource
int newdepth = (selectorPD.getDepth() + current < max) ? selectorPD.getDepth() + current : max;
Lens sublens = null;
Iterator<Lens> sublensesIt = selectorPD.getSublensesIterator();
boolean match = false;
matched:
while (sublensesIt.hasNext()) {
sublens = sublensesIt.next();
Iterator<ISelector> domainIt = sublens.getDomainSet().iterator();
while (domainIt.hasNext()) {
ISelector subdomain = domainIt.next();
if (subdomain.canSelect(in, objResource)) {
subr = applyLens(group, in, sublens, objResource, current + 1, newdepth);
match = true;
break matched;
}
}