"CASE WHEN ou.value IS NOT NULL THEN ou.value" + " WHEN olu.value IS NOT NULL THEN olu.value"
+ " WHEN ob.value IS NOT NULL THEN ob.value"
+ " WHEN ol.value IS NOT NULL THEN ol.value ELSE oll.value END");
query.select().column("od", "value");
query.select().column("og", "value");
SqlJoinBuilder join;
if (pred != null) {
join = query.from(uris.getShortTableName(), "pu");
// TODO what about long predicate URIs?
join = join.join(tableName, "t");
}
else {
join = query.from(tableName, "t");
}
if (pred == null) {
join.join(uris.getShortTableName(), "pu").on("id", "t.pred");
}
join.leftjoin(uris.getShortTableName(), "cu").on("id", "t.ctx");
join.leftjoin(uris.getLongTableName(), "clu").on("id", "t.ctx");
join.leftjoin(bnodes.getName(), "cb").on("id", "t.ctx");
join.leftjoin(uris.getShortTableName(), "su").on("id", "t.subj");
join.leftjoin(uris.getLongTableName(), "slu").on("id", "t.subj");
join.leftjoin(bnodes.getName(), "sb").on("id", "t.subj");
join.leftjoin(uris.getShortTableName(), "ou").on("id", "t.obj");
join.leftjoin(uris.getLongTableName(), "olu").on("id", "t.obj");
join.leftjoin(bnodes.getName(), "ob").on("id", "t.obj");
join.leftjoin(literals.getLabelTable().getName(), "ol").on("id", "t.obj");
join.leftjoin(literals.getLongLabelTable().getName(), "oll").on("id", "t.obj");
join.leftjoin(literals.getLanguageTable().getName(), "og").on("id", "t.obj");
join.leftjoin(literals.getDatatypeTable().getName(), "od").on("id", "t.obj");
if (ctxs != null && ctxs.length > 0) {
Number[] ids = new Number[ctxs.length];
for (int i = 0; i < ids.length; i++) {
ids[i] = vf.getInternalId(ctxs[i]);
}