Search in sources :

Example 6 with QueryImpl

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

the class Admin method doGetCustomTagMappings.

/**
 * @throws PageException
 */
private void doGetCustomTagMappings() throws PageException {
    Mapping[] mappings = config.getCustomTagMappings();
    lucee.runtime.type.Query qry = new QueryImpl(new String[] { "archive", "strarchive", "physical", "strphysical", "virtual", "hidden", "physicalFirst", "readonly", "inspect" }, mappings.length, "query");
    for (int i = 0; i < mappings.length; i++) {
        MappingImpl m = (MappingImpl) mappings[i];
        int row = i + 1;
        qry.setAt("archive", row, m.getArchive());
        qry.setAt("strarchive", row, m.getStrArchive());
        qry.setAt("physical", row, m.getPhysical());
        qry.setAt("strphysical", row, m.getStrPhysical());
        qry.setAt("virtual", row, m.getVirtual());
        qry.setAt("hidden", row, Caster.toBoolean(m.isHidden()));
        qry.setAt("physicalFirst", row, Caster.toBoolean(m.isPhysicalFirst()));
        qry.setAt("readonly", row, Caster.toBoolean(m.isReadonly()));
        qry.setAt("inspect", row, ConfigWebUtil.inspectTemplate(m.getInspectTemplateRaw(), ""));
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Mapping(lucee.runtime.Mapping) MappingImpl(lucee.runtime.MappingImpl) Query(lucee.runtime.type.Query)

Example 7 with QueryImpl

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

the class Admin method _doGetLogSettings.

private Query _doGetLogSettings() {
    Map<String, LoggerAndSourceData> loggers = config.getLoggers();
    Query qry = new QueryImpl(new String[] { "name", "level", "appenderClass", "appenderBundleName", "appenderBundleVersion", "appenderArgs", "layoutClass", "layoutBundleName", "layoutBundleVersion", "layoutArgs", "readonly" }, 0, lucee.runtime.type.util.ListUtil.last("logs", '.'));
    int row = 0;
    Iterator<Entry<String, LoggerAndSourceData>> it = loggers.entrySet().iterator();
    Entry<String, LoggerAndSourceData> e;
    LoggerAndSourceData logger;
    while (it.hasNext()) {
        e = it.next();
        logger = e.getValue();
        if (logger.getDyn())
            continue;
        row = qry.addRow();
        // row++;
        qry.setAtEL("name", row, e.getKey());
        qry.setAtEL("level", row, logger.getLevel().toString());
        qry.setAtEL("appenderClass", row, logger.getAppenderClassDefinition().getClassName());
        qry.setAtEL("appenderBundleName", row, logger.getAppenderClassDefinition().getName());
        qry.setAtEL("appenderBundleVersion", row, logger.getAppenderClassDefinition().getVersionAsString());
        qry.setAtEL("appenderArgs", row, toStruct(logger.getAppenderArgs()));
        qry.setAtEL("layoutClass", row, logger.getLayoutClassDefinition().getClassName());
        qry.setAtEL("layoutBundleName", row, logger.getLayoutClassDefinition().getName());
        qry.setAtEL("layoutBundleVersion", row, logger.getLayoutClassDefinition().getVersionAsString());
        qry.setAtEL("layoutArgs", row, toStruct(logger.getLayoutArgs()));
        qry.setAtEL("readonly", row, logger.getReadOnly());
    }
    return qry;
}
Also used : LoggerAndSourceData(lucee.commons.io.log.LoggerAndSourceData) QueryImpl(lucee.runtime.type.QueryImpl) DebugEntry(lucee.runtime.config.DebugEntry) Entry(java.util.Map.Entry) GatewayEntry(lucee.runtime.gateway.GatewayEntry) Query(lucee.runtime.type.Query)

Example 8 with QueryImpl

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

the class DBInfo method typeIndex.

private void typeIndex(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);
    ResultSet tables = metaData.getIndexInfo(dbname, schema, table, false, true);
    lucee.runtime.type.Query qry = new QueryImpl(tables, "query", pageContext.getTimeZone());
    // type int 2 string
    int rows = qry.getRecordcount();
    String strType;
    int type, card;
    for (int row = 1; row <= rows; row++) {
        // type
        switch(type = Caster.toIntValue(qry.getAt(KeyConstants._type, row))) {
            case 0:
                strType = "Table Statistic";
                break;
            case 1:
                strType = "Clustered Index";
                break;
            case 2:
                strType = "Hashed Index";
                break;
            case 3:
                strType = "Other Index";
                break;
            default:
                strType = Caster.toString(type);
        }
        qry.setAt(KeyConstants._type, row, strType);
        // CARDINALITY
        card = Caster.toIntValue(qry.getAt(CARDINALITY, row), 0);
        qry.setAt(CARDINALITY, row, Caster.toDouble(card));
    }
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Stopwatch(lucee.runtime.timer.Stopwatch) ResultSet(java.sql.ResultSet) Query(lucee.runtime.type.Query)

Example 9 with QueryImpl

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

the class DBInfo method typeProcedureColumns.

private void typeProcedureColumns(DatabaseMetaData metaData) throws SQLException, PageException {
    required("procedure", procedure);
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    procedure = setCase(metaData, procedure);
    pattern = setCase(metaData, pattern);
    if (StringUtil.isEmpty(pattern, true))
        pattern = null;
    String schema = null;
    int index = procedure.indexOf('.');
    if (index > 0) {
        schema = procedure.substring(0, index);
        procedure = procedure.substring(index + 1);
    }
    lucee.runtime.type.Query qry = new QueryImpl(metaData.getProcedureColumns(dbname, schema, procedure, 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 10 with QueryImpl

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

the class DBInfo method typeVersion.

private void typeVersion(DatabaseMetaData metaData) throws PageException, SQLException {
    Stopwatch stopwatch = new Stopwatch(Stopwatch.UNIT_NANO);
    stopwatch.start();
    Key[] columns = new Key[] { DATABASE_PRODUCTNAME, DATABASE_VERSION, DRIVER_NAME, DRIVER_VERSION, JDBC_MAJOR_VERSION, JDBC_MINOR_VERSION };
    String[] types = new String[] { "VARCHAR", "VARCHAR", "VARCHAR", "VARCHAR", "DOUBLE", "DOUBLE" };
    lucee.runtime.type.Query qry = new QueryImpl(columns, types, 1, "query");
    qry.setAt(DATABASE_PRODUCTNAME, 1, metaData.getDatabaseProductName());
    qry.setAt(DATABASE_VERSION, 1, metaData.getDatabaseProductVersion());
    qry.setAt(DRIVER_NAME, 1, metaData.getDriverName());
    qry.setAt(DRIVER_VERSION, 1, metaData.getDriverVersion());
    qry.setAt(JDBC_MAJOR_VERSION, 1, new Double(metaData.getJDBCMajorVersion()));
    qry.setAt(JDBC_MINOR_VERSION, 1, new Double(metaData.getJDBCMinorVersion()));
    qry.setExecutionTime(stopwatch.time());
    pageContext.setVariable(name, qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Stopwatch(lucee.runtime.timer.Stopwatch) Key(lucee.runtime.type.Collection.Key) 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