use of org.apache.jena.sdb.core.Scope in project jena by apache.
the class SQLBridge2 method insertValueGetter.
private SqlNode insertValueGetter(SDBRequest request, SqlNode sqlNode, Var var) {
ScopeEntry e1 = sqlNode.getIdScope().findScopeForVar(var);
if (e1 == null) {
// Debug.
Scope scope = sqlNode.getIdScope();
// Variable not actually in results.
return sqlNode;
}
// Already in scope (from a condition)?
ScopeEntry e2 = sqlNode.getNodeScope().findScopeForVar(var);
if (e2 != null)
// Already there
return sqlNode;
SqlColumn c1 = e1.getColumn();
// Not in scope -- add a table to get it
TableDescNodes nodeTableDesc = request.getStore().getNodeTableDesc();
String tableAlias = request.genId(NodeBase);
SqlTable nTable = new SqlTable(tableAlias, nodeTableDesc.getTableName());
String nodeKeyColName = nodeTableDesc.getNodeRefColName();
SqlColumn c2 = new SqlColumn(nTable, nodeKeyColName);
nTable.setValueColumnForVar(var, c2);
// Condition for value: triple table column = node table id/hash
nTable.addNote("Var: " + var);
SqlExpr cond = new S_Equal(c1, c2);
SqlNode n = SqlBuilder.leftJoin(request, sqlNode, nTable, cond);
return n;
}
Aggregations