Search in sources :

Example 6 with ScopeEntry

use of org.apache.jena.sdb.core.ScopeEntry in project jena by apache.

the class SQLBridge2 method buildProject.

@Override
protected void buildProject() {
    for (Var v : getProject()) {
        if (!v.isNamedVar())
            continue;
        ScopeEntry e = getSqlNode().getNodeScope().findScopeForVar(v);
        if (e == null) {
            // Should be a column mentioned in the SELECT which is not mentioned in this block
            continue;
        }
        SqlColumn vCol = e.getColumn();
        SqlTable table = vCol.getTable();
        String sqlVarName = allocSqlName(v);
        // Need to allocate aliases because otherwise we need to access
        // "table.column" as a label and "." is illegal in a label
        String vLex = SQLUtils.gen(sqlVarName, "lex");
        // Call overrideable helper method for lex column (Oracle)
        SqlColumn cLex = getLexSqlColumn(table);
        String vLexNChar = SQLUtils.gen(sqlVarName, "lexNChar");
        // Call overrideable helper method for lex column (Oracle)
        SqlColumn cLexNChar = getLexNCharSqlColumn(table);
        String vDatatype = SQLUtils.gen(sqlVarName, "datatype");
        SqlColumn cDatatype = new SqlColumn(table, "datatype");
        String vLang = SQLUtils.gen(sqlVarName, "lang");
        SqlColumn cLang = new SqlColumn(table, "lang");
        String vType = SQLUtils.gen(sqlVarName, "type");
        SqlColumn cType = new SqlColumn(table, "type");
        addProject(cLex, vLex);
        // Oracle NCLOB support
        if (cLexNChar != null) {
            addProject(cLexNChar, vLexNChar);
        }
        addProject(cDatatype, vDatatype);
        addProject(cLang, vLang);
        addProject(cType, vType);
        addAnnotation(sqlVarName + "=" + v.toString());
    }
    setAnnotation();
}
Also used : ScopeEntry(org.apache.jena.sdb.core.ScopeEntry) Var(org.apache.jena.sparql.core.Var) SqlTable(org.apache.jena.sdb.core.sqlnode.SqlTable) SqlColumn(org.apache.jena.sdb.core.sqlexpr.SqlColumn)

Aggregations

ScopeEntry (org.apache.jena.sdb.core.ScopeEntry)6 Var (org.apache.jena.sparql.core.Var)5 SqlColumn (org.apache.jena.sdb.core.sqlexpr.SqlColumn)4 S_Equal (org.apache.jena.sdb.core.sqlexpr.S_Equal)2 SqlExpr (org.apache.jena.sdb.core.sqlexpr.SqlExpr)2 SqlNode (org.apache.jena.sdb.core.sqlnode.SqlNode)2 SqlTable (org.apache.jena.sdb.core.sqlnode.SqlTable)2 Scope (org.apache.jena.sdb.core.Scope)1