Search in sources :

Example 41 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class Admin method doGetRunningThreads.

private void doGetRunningThreads() throws PageException {
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "Id", "Start", "Timeout", "ThreadType", "StackTrace", "TagContext", "Label", "RootPath", "ConfigFile", "URL" }, 0, "query");
    if (type == TYPE_WEB) {
        fillGetRunningThreads(qry, pageContext.getConfig());
    } else {
        ConfigServer cs = pageContext.getConfig().getConfigServer(password);
        ConfigWeb[] webs = cs.getConfigWebs();
        for (int i = 0; i < webs.length; i++) {
            fillGetRunningThreads(qry, webs[i]);
        }
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) ConfigServer(lucee.runtime.config.ConfigServer) ConfigWeb(lucee.runtime.config.ConfigWeb) Query(lucee.runtime.type.Query)

Example 42 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class DBInfo method typeTables.

private void typeTables(DatabaseMetaData metaData) throws PageException, SQLException {
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    pattern = setCase(metaData, pattern);
    lucee.runtime.type.Query qry = new QueryImpl(metaData.getTables(dbname, null, pattern, null), "query", pageContext.getTimeZone());
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Stopwatch(lucee.runtime.timer.Stopwatch) Query(lucee.runtime.type.Query)

Example 43 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class DBInfo method typeColumns.

private void typeColumns(DatabaseMetaData metaData) throws PageException, SQLException {
    required("table", table);
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    table = setCase(metaData, table);
    pattern = setCase(metaData, pattern);
    if (StringUtil.isEmpty(pattern, true))
        pattern = null;
    String schema = null;
    int index = table.indexOf('.');
    if (index > 0) {
        schema = table.substring(0, index);
        table = table.substring(index + 1);
    }
    checkTable(metaData);
    Query qry = new QueryImpl(metaData.getColumns(dbname, schema, table, pattern), "query", pageContext.getTimeZone());
    int len = qry.getRecordcount();
    if (qry.getColumn(COLUMN_DEF, null) != null)
        qry.rename(COLUMN_DEF, COLUMN_DEFAULT_VALUE);
    else if (qry.getColumn(COLUMN_DEFAULT, null) != null)
        qry.rename(COLUMN_DEFAULT, COLUMN_DEFAULT_VALUE);
    // make sure decimal digits exists
    QueryColumn col = qry.getColumn(DECIMAL_DIGITS, null);
    if (col == null) {
        Array arr = new ArrayImpl();
        for (int i = 1; i <= len; i++) {
            arr.append(lucee.runtime.op.Constants.DOUBLE_ZERO);
        }
        qry.addColumn(DECIMAL_DIGITS, arr);
    }
    // add is primary
    Map primaries = new HashMap();
    String tblName;
    Array isPrimary = new ArrayImpl();
    Set set;
    Object o;
    for (int i = 1; i <= len; i++) {
        // decimal digits
        o = qry.getAt(DECIMAL_DIGITS, i, null);
        if (o == null)
            qry.setAtEL(DECIMAL_DIGITS, i, lucee.runtime.op.Constants.DOUBLE_ZERO);
        set = (Set) primaries.get(tblName = (String) qry.getAt(TABLE_NAME, i));
        if (set == null) {
            set = toSet(metaData.getPrimaryKeys(dbname, null, tblName), true, "COLUMN_NAME");
            primaries.put(tblName, set);
        }
        isPrimary.append(set.contains(qry.getAt(COLUMN_NAME, i)) ? "YES" : "NO");
    }
    qry.addColumn(IS_PRIMARYKEY, isPrimary);
    // add is foreignkey
    Map foreigns = new HashMap();
    Array isForeign = new ArrayImpl();
    Array refPrim = new ArrayImpl();
    Array refPrimTbl = new ArrayImpl();
    // Map map,inner;
    Map<String, Map<String, SVArray>> map;
    Map<String, SVArray> inner;
    for (int i = 1; i <= len; i++) {
        map = (Map) foreigns.get(tblName = (String) qry.getAt(TABLE_NAME, i));
        if (map == null) {
            map = toMap(metaData.getImportedKeys(dbname, schema, table), true, "FKCOLUMN_NAME", new String[] { "PKCOLUMN_NAME", "PKTABLE_NAME" });
            foreigns.put(tblName, map);
        }
        inner = map.get(qry.getAt(COLUMN_NAME, i));
        if (inner != null) {
            isForeign.append("YES");
            refPrim.append(inner.get("PKCOLUMN_NAME"));
            refPrimTbl.append(inner.get("PKTABLE_NAME"));
        } else {
            isForeign.append("NO");
            refPrim.append("N/A");
            refPrimTbl.append("N/A");
        }
    }
    qry.addColumn(IS_FOREIGNKEY, isForeign);
    qry.addColumn(REFERENCED_PRIMARYKEY, refPrim);
    qry.addColumn(REFERENCED_PRIMARYKEY_TABLE, refPrimTbl);
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : HashSet(java.util.HashSet) ResultSet(java.sql.ResultSet) Set(java.util.Set) Query(lucee.runtime.type.Query) HashMap(java.util.HashMap) ArrayImpl(lucee.runtime.type.ArrayImpl) Stopwatch(lucee.runtime.timer.Stopwatch) SVArray(lucee.runtime.type.SVArray) Array(lucee.runtime.type.Array) QueryImpl(lucee.runtime.type.QueryImpl) QueryColumn(lucee.runtime.type.QueryColumn) SVArray(lucee.runtime.type.SVArray) HashMap(java.util.HashMap) Map(java.util.Map)

Example 44 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class DBInfo method typeProcedures.

private void typeProcedures(DatabaseMetaData metaData) throws SQLException, PageException {
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    String schema = null;
    pattern = setCase(metaData, pattern);
    if (StringUtil.isEmpty(pattern, true)) {
        pattern = null;
    }
    lucee.runtime.type.Query qry = new QueryImpl(metaData.getProcedures(dbname, schema, pattern), "query", pageContext.getTimeZone());
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Stopwatch(lucee.runtime.timer.Stopwatch) Query(lucee.runtime.type.Query)

Example 45 with QueryImpl

use of lucee.runtime.type.QueryImpl in project Lucee by lucee.

the class DBInfo method typeForeignKeys.

private void typeForeignKeys(DatabaseMetaData metaData) throws PageException, SQLException {
    required("table", table);
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    table = setCase(metaData, table);
    int index = table.indexOf('.');
    String schema = null;
    if (index > 0) {
        schema = table.substring(0, index);
        table = table.substring(index + 1);
    }
    checkTable(metaData);
    lucee.runtime.type.Query qry = new QueryImpl(metaData.getExportedKeys(dbname, schema, table), "query", pageContext.getTimeZone());
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Stopwatch(lucee.runtime.timer.Stopwatch) Query(lucee.runtime.type.Query)

Aggregations

QueryImpl (lucee.runtime.type.QueryImpl)82 Query (lucee.runtime.type.Query)65 Collection (lucee.runtime.type.Collection)17 Struct (lucee.runtime.type.Struct)16 StructImpl (lucee.runtime.type.StructImpl)13 PageException (lucee.runtime.exp.PageException)12 Key (lucee.runtime.type.Collection.Key)12 Iterator (java.util.Iterator)11 Map (java.util.Map)10 ApplicationException (lucee.runtime.exp.ApplicationException)10 Array (lucee.runtime.type.Array)10 DatabaseException (lucee.runtime.exp.DatabaseException)9 Stopwatch (lucee.runtime.timer.Stopwatch)9 HashMap (java.util.HashMap)8 Resource (lucee.commons.io.res.Resource)7 BundleCollection (lucee.loader.osgi.BundleCollection)7 Entry (java.util.Map.Entry)6 IOException (java.io.IOException)5 ResultSet (java.sql.ResultSet)5 ArrayImpl (lucee.runtime.type.ArrayImpl)5