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());
}
}
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);
}
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);
}
}
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);
}
}
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;
}
}
Aggregations