from.addFilter(new SqlEq(new IdColumn(var), existing));
}
else if (value != null && !var.isImplied()) {
try {
NumberValue vc = new NumberValue(vf.getInternalId(value));
from.addFilter(new SqlEq(new RefIdColumn(var), vc));
}
catch (RdbmsException e) {
throw new RdbmsException(e);
}
}
else {
vars.put(var.getName(), var);
}
if (!var.isHiddenOrConstant() && value == null) {
SelectProjection proj = new SelectProjection();
proj.setVar(var);
proj.setId(new RefIdColumn(var));
proj.setStringValue(coalesce(new URIColumn(var), new BNodeColumn(var), new LabelColumn(var),
new LongLabelColumn(var), new LongURIColumn(var)));
proj.setDatatype(new DatatypeColumn(var));
proj.setLanguage(new LanguageColumn(var));
query.addSqlSelectVar(proj);
}
}
if (contexts.length > 0) {
RdbmsResource[] ids = vf.asRdbmsResource(contexts);
RefIdColumn var = new RefIdColumn(c);
SqlExpr in = null;
for (RdbmsResource id : ids) {
NumberValue longValue;
try {
longValue = new NumberValue(vf.getInternalId(id));
}
catch (RdbmsException e) {
throw new RdbmsException(e);
}
SqlEq eq = new SqlEq(var.clone(), longValue);
if (in == null) {
in = eq;
}
else {
in = new SqlOr(in, eq);