Search in sources :

Example 21 with QueryImpl

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

the class Admin method doGetDebugEntry.

private void doGetDebugEntry() throws PageException {
    DebugEntry[] entries = config.getDebugEntries();
    String rtn = getString("admin", action, "returnVariable");
    lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._id, LABEL, IP_RANGE, READONLY, KeyConstants._type, CUSTOM }, entries.length, rtn);
    pageContext.setVariable(rtn, qry);
    DebugEntry de;
    for (int i = 0; i < entries.length; i++) {
        int row = i + 1;
        de = entries[i];
        qry.setAtEL(KeyConstants._id, row, de.getId());
        qry.setAtEL(LABEL, row, de.getLabel());
        qry.setAtEL(IP_RANGE, row, de.getIpRangeAsString());
        qry.setAtEL(KeyConstants._type, row, de.getType());
        qry.setAtEL(READONLY, row, Caster.toBoolean(de.isReadOnly()));
        qry.setAtEL(CUSTOM, row, de.getCustom());
    }
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) DebugEntry(lucee.runtime.config.DebugEntry) Query(lucee.runtime.type.Query)

Example 22 with QueryImpl

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

the class Admin method doGetCPPCFXTags.

private void doGetCPPCFXTags() throws PageException {
    Map map = config.getCFXTagPool().getClasses();
    lucee.runtime.type.Query qry = new QueryImpl(new Collection.Key[] { KeyConstants._displayname, KeyConstants._sourcename, KeyConstants._readonly, PROCEDURE, KeyConstants._name, KeyConstants._isvalid, SERVER_LIBRARY, KEEP_ALIVE }, 0, "query");
    Iterator it = map.keySet().iterator();
    int row = 0;
    while (it.hasNext()) {
        CFXTagClass tag = (CFXTagClass) map.get(it.next());
        if (tag instanceof CPPCFXTagClass) {
            row++;
            qry.addRow(1);
            CPPCFXTagClass ctag = (CPPCFXTagClass) tag;
            qry.setAt(KeyConstants._displayname, row, tag.getDisplayType());
            qry.setAt(KeyConstants._sourcename, row, tag.getSourceName());
            qry.setAt(KeyConstants._readonly, row, Caster.toBoolean(tag.isReadOnly()));
            qry.setAt(KeyConstants._isvalid, row, Caster.toBoolean(tag.isValid()));
            qry.setAt(KeyConstants._name, row, ctag.getName());
            qry.setAt(PROCEDURE, row, ctag.getProcedure());
            qry.setAt(SERVER_LIBRARY, row, ctag.getServerLibrary());
            qry.setAt(KEEP_ALIVE, row, Caster.toBoolean(ctag.getKeepAlive()));
        }
    }
    pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Iterator(java.util.Iterator) BundleCollection(lucee.loader.osgi.BundleCollection) Collection(lucee.runtime.type.Collection) CFXTagClass(lucee.runtime.cfx.customtag.CFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) JavaCFXTagClass(lucee.runtime.cfx.customtag.JavaCFXTagClass) CPPCFXTagClass(lucee.runtime.cfx.customtag.CPPCFXTagClass) Map(java.util.Map) HashMap(java.util.HashMap) Query(lucee.runtime.type.Query)

Example 23 with QueryImpl

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

the class WDDXConverter method _deserializeQuery.

/**
 * Desirialize a Query Object
 *
 * @param recordset
 *            Query Object as XML Element
 * @return Query Object
 * @throws ConverterException
 */
private Object _deserializeQuery(Element recordset) throws ConverterException {
    try {
        // create Query Object
        Query query = new QueryImpl(lucee.runtime.type.util.ListUtil.listToArray(recordset.getAttribute("fieldNames"), ','), Caster.toIntValue(recordset.getAttribute("rowCount")), "query");
        NodeList list = recordset.getChildNodes();
        int len = list.getLength();
        for (int i = 0; i < len; i++) {
            Node node = list.item(i);
            if (node instanceof Element) {
                _deserializeQueryField(query, (Element) node);
            }
        }
        return query;
    } catch (PageException e) {
        throw toConverterException(e);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 24 with QueryImpl

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

the class XMLConverter method _deserializeQuery.

/**
 * Desirialize a Query Object
 * @param recordset Query Object as XML Element
 * @return Query Object
 * @throws ConverterException
 */
private Object _deserializeQuery(Element recordset) throws ConverterException {
    try {
        // create Query Object
        Query query = new QueryImpl(lucee.runtime.type.util.ListUtil.listToArray(recordset.getAttribute("fieldNames"), ','), Caster.toIntValue(recordset.getAttribute("rowCount")), "query");
        NodeList list = recordset.getChildNodes();
        int len = list.getLength();
        for (int i = 0; i < len; i++) {
            Node node = list.item(i);
            if (node instanceof Element) {
                _deserializeQueryField(query, (Element) node);
            }
        }
        return query;
    } catch (PageException e) {
        throw toConverterException(e);
    }
}
Also used : PageException(lucee.runtime.exp.PageException) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element)

Example 25 with QueryImpl

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

the class HSQLDBHandler method __execute.

public static QueryImpl __execute(PageContext pc, SQL sql, int maxrows, int fetchsize, TimeSpan timeout, Stopwatch stopwatch, Set<String> tables, boolean doSimpleTypes) throws PageException {
    ArrayList<String> usedTables = new ArrayList<String>();
    synchronized (lock) {
        QueryImpl nqr = null;
        ConfigImpl config = (ConfigImpl) pc.getConfig();
        DatasourceConnectionPool pool = config.getDatasourceConnectionPool();
        DatasourceConnection dc = pool.getDatasourceConnection(config, config.getDataSource(QOQ_DATASOURCE_NAME), "sa", "");
        Connection conn = dc.getConnection();
        try {
            DBUtil.setAutoCommitEL(conn, false);
            // sql.setSQLString(HSQLUtil.sqlToZQL(sql.getSQLString(),false));
            try {
                Iterator<String> it = tables.iterator();
                // int len=tables.size();
                while (it.hasNext()) {
                    // tables.get(i).toString();
                    String tableName = it.next().toString();
                    String modTableName = tableName.replace('.', '_');
                    String modSql = StringUtil.replace(sql.getSQLString(), tableName, modTableName, false);
                    sql.setSQLString(modSql);
                    addTable(conn, pc, modTableName, Caster.toQuery(pc.getVariable(tableName)), doSimpleTypes, usedTables);
                }
                DBUtil.setReadOnlyEL(conn, true);
                try {
                    nqr = new QueryImpl(pc, dc, sql, maxrows, fetchsize, timeout, "query", null, false, false);
                } finally {
                    DBUtil.setReadOnlyEL(conn, false);
                    DBUtil.commitEL(conn);
                    DBUtil.setAutoCommitEL(conn, true);
                }
            } catch (SQLException e) {
                DatabaseException de = new DatabaseException("there is a problem to execute sql statement on query", null, sql, null);
                de.setDetail(e.getMessage());
                throw de;
            }
        } finally {
            removeAll(conn, usedTables);
            DBUtil.setAutoCommitEL(conn, true);
            pool.releaseDatasourceConnection(dc);
        // manager.releaseConnection(dc);
        }
        nqr.setExecutionTime(stopwatch.time());
        return nqr;
    }
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DatabaseException(lucee.runtime.exp.DatabaseException) ConfigImpl(lucee.runtime.config.ConfigImpl)

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