use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.
the class DatasourceManagerImpl method _add.
private void _add(PageContext pc, ORMSession session, DataSource ds) throws PageException {
// ORMDatasourceConnection newDC = new ORMDatasourceConnection(pc,session,ds);
DatasourceConnectionPro existingDC = null;
try {
existingDC = (DatasourceConnectionPro) transConns.get(ds);
//
if (existingDC == null) {
if (isolation == Connection.TRANSACTION_NONE)
isolation = Connection.TRANSACTION_SERIALIZABLE;
ORMDatasourceConnection newDC = new ORMDatasourceConnection(pc, session, ds, isolation);
transConns.put(ds, newDC);
return;
}
if (!DatasourceConnectionImpl.equals(existingDC, ds, null, null)) {
// releaseConnection(pc,newDC);
throw new DatabaseException("can't use different connections to the same datasource inside a single transaction", null, null, existingDC);
}
if (existingDC.isAutoCommit()) {
existingDC.setAutoCommit(false);
}
return;
} catch (SQLException e) {
// ExceptionHandler.printStackTrace(e);
throw new DatabaseException(e, null, existingDC);
}
}
use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.
the class Executer method executeExpression.
/**
* Executes a Expression
* @param sql
* @param qr
* @param expression
* @param row
* @return result
* @throws PageException
*/
private Object executeExpression(PageContext pc, SQL sql, Query qr, ZExpression expression, int row) throws PageException {
String op = StringUtil.toLowerCase(expression.getOperator());
int count = expression.nbOperands();
if (op.equals("and"))
return executeAnd(pc, sql, qr, expression, row);
else if (op.equals("or"))
return executeOr(pc, sql, qr, expression, row);
if (count == 0 && op.equals("?")) {
int pos = sql.getPosition();
if (sql.getItems().length <= pos)
throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
sql.setPosition(pos + 1);
return sql.getItems()[pos].getValueForCF();
} else // 11111111111111111111111111111111111111111111111111111
if (count == 1) {
Object value = executeExp(pc, sql, qr, expression.getOperand(0), row);
// Functions
switch(op.charAt(0)) {
case 'a':
if (op.equals("abs"))
return new Double(MathUtil.abs(Caster.toDoubleValue(value)));
if (op.equals("acos"))
return new Double(Math.acos(Caster.toDoubleValue(value)));
if (op.equals("asin"))
return new Double(Math.asin(Caster.toDoubleValue(value)));
if (op.equals("atan"))
return new Double(Math.atan(Caster.toDoubleValue(value)));
break;
case 'c':
if (op.equals("ceiling"))
return new Double(Math.ceil(Caster.toDoubleValue(value)));
if (op.equals("cos"))
return new Double(Math.cos(Caster.toDoubleValue(value)));
break;
case 'e':
if (op.equals("exp"))
return new Double(Math.exp(Caster.toDoubleValue(value)));
break;
case 'f':
if (op.equals("floor"))
return new Double(Math.floor(Caster.toDoubleValue(value)));
break;
case 'i':
if (op.equals("is not null"))
return Boolean.valueOf(value != null);
if (op.equals("is null"))
return Boolean.valueOf(value == null);
break;
case 'u':
if (op.equals("upper") || op.equals("ucase"))
return Caster.toString(value).toUpperCase();
break;
case 'l':
if (op.equals("lower") || op.equals("lcase"))
return Caster.toString(value).toLowerCase();
if (op.equals("ltrim"))
return StringUtil.ltrim(Caster.toString(value), null);
if (op.equals("length"))
return new Double(Caster.toString(value).length());
break;
case 'r':
if (op.equals("rtrim"))
return StringUtil.rtrim(Caster.toString(value), null);
break;
case 's':
if (op.equals("sign"))
return new Double(MathUtil.sgn(Caster.toDoubleValue(value)));
if (op.equals("sin"))
return new Double(Math.sin(Caster.toDoubleValue(value)));
if (op.equals("soundex"))
return StringUtil.soundex(Caster.toString(value));
if (op.equals("sin"))
return new Double(Math.sqrt(Caster.toDoubleValue(value)));
break;
case 't':
if (op.equals("tan"))
return new Double(Math.tan(Caster.toDoubleValue(value)));
if (op.equals("trim"))
return Caster.toString(value).trim();
break;
}
} else // 22222222222222222222222222222222222222222222222222222
if (count == 2) {
if (op.equals("=") || op.equals("in"))
return executeEQ(pc, sql, qr, expression, row);
else if (op.equals("!=") || op.equals("<>"))
return executeNEQ(pc, sql, qr, expression, row);
else if (op.equals("<"))
return executeLT(pc, sql, qr, expression, row);
else if (op.equals("<="))
return executeLTE(pc, sql, qr, expression, row);
else if (op.equals(">"))
return executeGT(pc, sql, qr, expression, row);
else if (op.equals(">="))
return executeGTE(pc, sql, qr, expression, row);
else if (op.equals("-"))
return executeMinus(pc, sql, qr, expression, row);
else if (op.equals("+"))
return executePlus(pc, sql, qr, expression, row);
else if (op.equals("/"))
return executeDivide(pc, sql, qr, expression, row);
else if (op.equals("*"))
return executeMultiply(pc, sql, qr, expression, row);
else if (op.equals("^"))
return executeExponent(pc, sql, qr, expression, row);
Object left = executeExp(pc, sql, qr, expression.getOperand(0), row);
Object right = executeExp(pc, sql, qr, expression.getOperand(1), row);
// Functions
switch(op.charAt(0)) {
case 'a':
if (op.equals("atan2"))
return new Double(Math.atan2(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
case 'b':
if (op.equals("bitand"))
return new Double(Operator.bitand(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
if (op.equals("bitor"))
return new Double(Operator.bitor(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
case 'c':
if (op.equals("concat"))
return Caster.toString(left).concat(Caster.toString(right));
break;
case 'l':
if (op.equals("like"))
return executeLike(pc, sql, qr, expression, row);
break;
case 'm':
if (op.equals("mod"))
return new Double(Operator.modulus(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
}
throw new DatabaseException("unsopprted sql statement [" + op + "]", null, sql, null);
} else // 3333333333333333333333333333333333333333333333333333333333333333333
if (count == 3) {
if (op.equals("between"))
return executeBetween(pc, sql, qr, expression, row);
}
if (op.equals("in"))
return executeIn(pc, sql, qr, expression, row);
// print(expression);
throw new DatabaseException("unsopprted sql statement (op-count:" + expression.nbOperands() + ";operator:" + op + ") ", null, sql, null);
}
use of lucee.runtime.exp.DatabaseException 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;
}
}
use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.
the class QoQ method executeOperation.
private Object executeOperation(PageContext pc, SQL sql, Query qr, Operation operation, int row) throws PageException {
if (operation instanceof Operation2) {
Operation2 op2 = (Operation2) operation;
switch(op2.getOperator()) {
case Operation.OPERATION2_AND:
return executeAnd(pc, sql, qr, op2, row);
case Operation.OPERATION2_OR:
return executeOr(pc, sql, qr, op2, row);
case Operation.OPERATION2_XOR:
return executeXor(pc, sql, qr, op2, row);
case Operation.OPERATION2_EQ:
return executeEQ(pc, sql, qr, op2, row);
case Operation.OPERATION2_NEQ:
return executeNEQ(pc, sql, qr, op2, row);
case Operation.OPERATION2_LTGT:
return executeNEQ(pc, sql, qr, op2, row);
case Operation.OPERATION2_LT:
return executeLT(pc, sql, qr, op2, row);
case Operation.OPERATION2_LTE:
return executeLTE(pc, sql, qr, op2, row);
case Operation.OPERATION2_GT:
return executeGT(pc, sql, qr, op2, row);
case Operation.OPERATION2_GTE:
return executeGTE(pc, sql, qr, op2, row);
case Operation.OPERATION2_MINUS:
return executeMinus(pc, sql, qr, op2, row);
case Operation.OPERATION2_PLUS:
return executePlus(pc, sql, qr, op2, row);
case Operation.OPERATION2_DIVIDE:
return executeDivide(pc, sql, qr, op2, row);
case Operation.OPERATION2_MULTIPLY:
return executeMultiply(pc, sql, qr, op2, row);
case Operation.OPERATION2_EXP:
return executeExponent(pc, sql, qr, op2, row);
case Operation.OPERATION2_LIKE:
return Caster.toBoolean(executeLike(pc, sql, qr, op2, row));
case Operation.OPERATION2_NOT_LIKE:
return Caster.toBoolean(!executeLike(pc, sql, qr, op2, row));
case Operation.OPERATION2_MOD:
return executeMod(pc, sql, qr, op2, row);
}
}
if (operation instanceof Operation1) {
Operation1 op1 = (Operation1) operation;
int o = op1.getOperator();
if (o == Operation.OPERATION1_IS_NULL) {
Object value = executeExp(pc, sql, qr, op1.getExp(), row, null);
return Caster.toBoolean(value == null);
}
if (o == Operation.OPERATION1_IS_NOT_NULL) {
Object value = executeExp(pc, sql, qr, op1.getExp(), row, null);
return Caster.toBoolean(value != null);
}
Object value = executeExp(pc, sql, qr, op1.getExp(), row);
if (o == Operation.OPERATION1_MINUS)
return Caster.toDouble(-Caster.toDoubleValue(value));
if (o == Operation.OPERATION1_PLUS)
return Caster.toDouble(value);
if (o == Operation.OPERATION1_NOT)
return Caster.toBoolean(!Caster.toBooleanValue(value));
}
if (operation instanceof Operation3) {
Operation3 op3 = (Operation3) operation;
int o = op3.getOperator();
if (o == Operation.OPERATION3_BETWEEN)
return executeBetween(pc, sql, qr, op3, row);
if (o == Operation.OPERATION3_LIKE)
return executeLike(pc, sql, qr, op3, row);
}
if (!(operation instanceof OperationN))
throw new DatabaseException("invalid syntax for SQL Statement", null, sql, null);
OperationN opn = (OperationN) operation;
String op = StringUtil.toLowerCase(opn.getOperator());
Expression[] operators = opn.getOperants();
// 11111111111111111111111111111111111111111111111111111
if (operators.length == 1) {
Object value = executeExp(pc, sql, qr, operators[0], row);
// Functions
switch(op.charAt(0)) {
case 'a':
if (op.equals("abs"))
return new Double(MathUtil.abs(Caster.toDoubleValue(value)));
if (op.equals("acos"))
return new Double(Math.acos(Caster.toDoubleValue(value)));
if (op.equals("asin"))
return new Double(Math.asin(Caster.toDoubleValue(value)));
if (op.equals("atan"))
return new Double(Math.atan(Caster.toDoubleValue(value)));
break;
case 'c':
if (op.equals("ceiling"))
return new Double(Math.ceil(Caster.toDoubleValue(value)));
if (op.equals("cos"))
return new Double(Math.cos(Caster.toDoubleValue(value)));
if (op.equals("cast"))
return Caster.castTo(pc, CFTypes.toShort(operators[0].getAlias(), true, CFTypes.TYPE_UNKNOW), operators[0].getAlias(), value);
break;
case 'e':
if (op.equals("exp"))
return new Double(Math.exp(Caster.toDoubleValue(value)));
break;
case 'f':
if (op.equals("floor"))
return new Double(Math.floor(Caster.toDoubleValue(value)));
break;
case 'u':
if (op.equals("upper") || op.equals("ucase"))
return Caster.toString(value).toUpperCase();
break;
case 'l':
if (op.equals("lower") || op.equals("lcase"))
return Caster.toString(value).toLowerCase();
if (op.equals("ltrim"))
return StringUtil.ltrim(Caster.toString(value), null);
if (op.equals("length"))
return new Double(Caster.toString(value).length());
break;
case 'r':
if (op.equals("rtrim"))
return StringUtil.rtrim(Caster.toString(value), null);
break;
case 's':
if (op.equals("sign"))
return new Double(MathUtil.sgn(Caster.toDoubleValue(value)));
if (op.equals("sin"))
return new Double(Math.sin(Caster.toDoubleValue(value)));
if (op.equals("soundex"))
return StringUtil.soundex(Caster.toString(value));
if (op.equals("sin"))
return new Double(Math.sqrt(Caster.toDoubleValue(value)));
break;
case 't':
if (op.equals("tan"))
return new Double(Math.tan(Caster.toDoubleValue(value)));
if (op.equals("trim"))
return Caster.toString(value).trim();
break;
}
} else // 22222222222222222222222222222222222222222222222222222
if (operators.length == 2) {
// if(op.equals("=") || op.equals("in")) return executeEQ(pc,sql,qr,expression,row);
Object left = executeExp(pc, sql, qr, operators[0], row);
Object right = executeExp(pc, sql, qr, operators[1], row);
// Functions
switch(op.charAt(0)) {
case 'a':
if (op.equals("atan2"))
return new Double(Math.atan2(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
case 'b':
if (op.equals("bitand"))
return new Double(Operator.bitand(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
if (op.equals("bitor"))
return new Double(Operator.bitor(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
case 'c':
if (op.equals("concat"))
return Caster.toString(left).concat(Caster.toString(right));
break;
case 'm':
if (op.equals("mod"))
return new Double(Operator.modulus(Caster.toDoubleValue(left), Caster.toDoubleValue(right)));
break;
}
// throw new DatabaseException("unsopprted sql statement ["+op+"]",null,sql);
}
if (op.equals("in"))
return executeIn(pc, sql, qr, opn, row, false);
if (op.equals("not_in"))
return executeIn(pc, sql, qr, opn, row, true);
// print(expression);
throw new DatabaseException("unsopprted sql statement (" + op + ") ", null, sql, null);
}
use of lucee.runtime.exp.DatabaseException in project Lucee by lucee.
the class DebugEntryTemplatePartComparator method getDebuggingData.
@Override
public Struct getDebuggingData(PageContext pc, boolean addAddionalInfo) throws DatabaseException {
Struct debugging = new StructImpl();
// datasources
debugging.setEL(KeyConstants._datasources, ((ConfigImpl) pc.getConfig()).getDatasourceConnectionPool().meta());
// queries
List<QueryEntry> queries = getQueries();
Struct qryExe = new StructImpl();
ListIterator<QueryEntry> qryIt = queries.listIterator();
Collection.Key[] cols = new Collection.Key[] { KeyConstants._name, KeyConstants._time, KeyConstants._sql, KeyConstants._src, KeyConstants._count, KeyConstants._datasource, KeyConstants._usage, CACHE_TYPE };
String[] types = new String[] { "VARCHAR", "DOUBLE", "VARCHAR", "VARCHAR", "DOUBLE", "VARCHAR", "ANY", "VARCHAR" };
Query qryQueries = null;
try {
qryQueries = new QueryImpl(cols, types, queries.size(), "query");
} catch (DatabaseException e) {
qryQueries = new QueryImpl(cols, queries.size(), "query");
}
int row = 0;
try {
QueryEntry qe;
while (qryIt.hasNext()) {
row++;
qe = qryIt.next();
qryQueries.setAt(KeyConstants._name, row, qe.getName() == null ? "" : qe.getName());
qryQueries.setAt(KeyConstants._time, row, Long.valueOf(qe.getExecutionTime()));
qryQueries.setAt(KeyConstants._sql, row, qe.getSQL().toString());
qryQueries.setAt(KeyConstants._src, row, qe.getSrc());
qryQueries.setAt(KeyConstants._count, row, Integer.valueOf(qe.getRecordcount()));
qryQueries.setAt(KeyConstants._datasource, row, qe.getDatasource());
qryQueries.setAt(CACHE_TYPE, row, qe.getCacheType());
Struct usage = getUsage(qe);
if (usage != null)
qryQueries.setAt(KeyConstants._usage, row, usage);
Object o = qryExe.get(KeyImpl.init(qe.getSrc()), null);
if (o == null)
qryExe.setEL(KeyImpl.init(qe.getSrc()), Long.valueOf(qe.getExecutionTime()));
else
qryExe.setEL(KeyImpl.init(qe.getSrc()), Long.valueOf(((Long) o).longValue() + qe.getExecutionTime()));
}
} catch (PageException dbe) {
}
// Pages
// src,load,app,query,total
row = 0;
ArrayList<DebugEntryTemplate> arrPages = toArray();
int len = arrPages.size();
Query qryPage = new QueryImpl(new Collection.Key[] { KeyConstants._id, KeyConstants._count, KeyConstants._min, KeyConstants._max, KeyConstants._avg, KeyConstants._app, KeyConstants._load, KeyConstants._query, KeyConstants._total, KeyConstants._src }, len, "query");
try {
DebugEntryTemplate de;
// PageSource ps;
for (int i = 0; i < len; i++) {
row++;
de = arrPages.get(i);
// ps = de.getPageSource();
qryPage.setAt(KeyConstants._id, row, de.getId());
qryPage.setAt(KeyConstants._count, row, _toString(de.getCount()));
qryPage.setAt(KeyConstants._min, row, _toString(de.getMin()));
qryPage.setAt(KeyConstants._max, row, _toString(de.getMax()));
qryPage.setAt(KeyConstants._avg, row, _toString(de.getExeTime() / de.getCount()));
qryPage.setAt(KeyConstants._app, row, _toString(de.getExeTime() - de.getQueryTime()));
qryPage.setAt(KeyConstants._load, row, _toString(de.getFileLoadTime()));
qryPage.setAt(KeyConstants._query, row, _toString(de.getQueryTime()));
qryPage.setAt(KeyConstants._total, row, _toString(de.getFileLoadTime() + de.getExeTime()));
qryPage.setAt(KeyConstants._src, row, de.getSrc());
}
} catch (PageException dbe) {
}
// Pages Parts
List<DebugEntryTemplatePart> filteredPartEntries = null;
boolean hasParts = partEntries != null && !partEntries.isEmpty() && !arrPages.isEmpty();
int qrySize = 0;
if (hasParts) {
String slowestTemplate = arrPages.get(0).getPath();
filteredPartEntries = new ArrayList();
java.util.Collection<DebugEntryTemplatePartImpl> col = partEntries.values();
for (DebugEntryTemplatePart detp : col) {
if (detp.getPath().equals(slowestTemplate))
filteredPartEntries.add(detp);
}
qrySize = Math.min(filteredPartEntries.size(), MAX_PARTS);
}
Query qryPart = new QueryImpl(new Collection.Key[] { KeyConstants._id, KeyConstants._count, KeyConstants._min, KeyConstants._max, KeyConstants._avg, KeyConstants._total, KeyConstants._path, KeyConstants._start, KeyConstants._end, KeyConstants._startLine, KeyConstants._endLine, KeyConstants._snippet }, qrySize, "query");
if (hasParts) {
row = 0;
Collections.sort(filteredPartEntries, DEBUG_ENTRY_TEMPLATE_PART_COMPARATOR);
DebugEntryTemplatePart[] parts = new DebugEntryTemplatePart[qrySize];
if (filteredPartEntries.size() > MAX_PARTS)
parts = filteredPartEntries.subList(0, MAX_PARTS).toArray(parts);
else
parts = filteredPartEntries.toArray(parts);
try {
DebugEntryTemplatePart de;
// PageSource ps;
for (int i = 0; i < parts.length; i++) {
row++;
de = parts[i];
qryPart.setAt(KeyConstants._id, row, de.getId());
qryPart.setAt(KeyConstants._count, row, _toString(de.getCount()));
qryPart.setAt(KeyConstants._min, row, _toString(de.getMin()));
qryPart.setAt(KeyConstants._max, row, _toString(de.getMax()));
qryPart.setAt(KeyConstants._avg, row, _toString(de.getExeTime() / de.getCount()));
qryPart.setAt(KeyConstants._start, row, _toString(de.getStartPosition()));
qryPart.setAt(KeyConstants._end, row, _toString(de.getEndPosition()));
qryPart.setAt(KeyConstants._total, row, _toString(de.getExeTime()));
qryPart.setAt(KeyConstants._path, row, de.getPath());
if (de instanceof DebugEntryTemplatePartImpl) {
qryPart.setAt(KeyConstants._startLine, row, _toString(((DebugEntryTemplatePartImpl) de).getStartLine()));
qryPart.setAt(KeyConstants._endLine, row, _toString(((DebugEntryTemplatePartImpl) de).getEndLine()));
qryPart.setAt(KeyConstants._snippet, row, ((DebugEntryTemplatePartImpl) de).getSnippet());
}
}
} catch (PageException dbe) {
}
}
// exceptions
len = exceptions == null ? 0 : exceptions.size();
Array arrExceptions = new ArrayImpl();
if (len > 0) {
Iterator<CatchBlock> it = exceptions.iterator();
row = 0;
while (it.hasNext()) {
arrExceptions.appendEL(it.next());
}
}
// output log
// Query qryOutputLog=getOutputText();
// timers
len = timers == null ? 0 : timers.size();
Query qryTimers = new QueryImpl(new Collection.Key[] { KeyConstants._label, KeyConstants._time, KeyConstants._template }, len, "timers");
if (len > 0) {
try {
Iterator<DebugTimerImpl> it = timers.iterator();
DebugTimer timer;
row = 0;
while (it.hasNext()) {
timer = it.next();
row++;
qryTimers.setAt(KeyConstants._label, row, timer.getLabel());
qryTimers.setAt(KeyConstants._template, row, timer.getTemplate());
qryTimers.setAt(KeyConstants._time, row, Caster.toDouble(timer.getTime()));
}
} catch (PageException dbe) {
}
}
// dumps
len = dumps == null ? 0 : dumps.size();
if (!((ConfigImpl) pc.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_DUMP))
len = 0;
Query qryDumps = new QueryImpl(new Collection.Key[] { KeyConstants._output, KeyConstants._template, KeyConstants._line }, len, "dumps");
if (len > 0) {
try {
Iterator<DebugDump> it = dumps.iterator();
DebugDump dd;
row = 0;
while (it.hasNext()) {
dd = it.next();
row++;
qryDumps.setAt(KeyConstants._output, row, dd.getOutput());
if (!StringUtil.isEmpty(dd.getTemplate()))
qryDumps.setAt(KeyConstants._template, row, dd.getTemplate());
if (dd.getLine() > 0)
qryDumps.setAt(KeyConstants._line, row, new Double(dd.getLine()));
}
} catch (PageException dbe) {
}
}
// traces
len = traces == null ? 0 : traces.size();
if (!((ConfigImpl) pc.getConfig()).hasDebugOptions(ConfigImpl.DEBUG_TRACING))
len = 0;
Query qryTraces = new QueryImpl(new Collection.Key[] { KeyConstants._type, KeyConstants._category, KeyConstants._text, KeyConstants._template, KeyConstants._line, KeyConstants._action, KeyConstants._varname, KeyConstants._varvalue, KeyConstants._time }, len, "traces");
if (len > 0) {
try {
Iterator<DebugTraceImpl> it = traces.iterator();
DebugTraceImpl trace;
row = 0;
while (it.hasNext()) {
trace = it.next();
row++;
qryTraces.setAt(KeyConstants._type, row, DebugTraceImpl.toType(trace.getType(), "INFO"));
if (!StringUtil.isEmpty(trace.getCategory()))
qryTraces.setAt(KeyConstants._category, row, trace.getCategory());
if (!StringUtil.isEmpty(trace.getText()))
qryTraces.setAt(KeyConstants._text, row, trace.getText());
if (!StringUtil.isEmpty(trace.getTemplate()))
qryTraces.setAt(KeyConstants._template, row, trace.getTemplate());
if (trace.getLine() > 0)
qryTraces.setAt(KeyConstants._line, row, new Double(trace.getLine()));
if (!StringUtil.isEmpty(trace.getAction()))
qryTraces.setAt(KeyConstants._action, row, trace.getAction());
if (!StringUtil.isEmpty(trace.getVarName()))
qryTraces.setAt(KeyImpl.init("varname"), row, trace.getVarName());
if (!StringUtil.isEmpty(trace.getVarValue()))
qryTraces.setAt(KeyImpl.init("varvalue"), row, trace.getVarValue());
qryTraces.setAt(KeyConstants._time, row, new Double(trace.getTime()));
}
} catch (PageException dbe) {
}
}
// scope access
len = implicitAccesses == null ? 0 : implicitAccesses.size();
Query qryImplicitAccesseses = new QueryImpl(new Collection.Key[] { KeyConstants._template, KeyConstants._line, KeyConstants._scope, KeyConstants._count, KeyConstants._name }, len, "implicitAccess");
if (len > 0) {
try {
Iterator<ImplicitAccessImpl> it = implicitAccesses.values().iterator();
ImplicitAccessImpl das;
row = 0;
while (it.hasNext()) {
das = it.next();
row++;
qryImplicitAccesseses.setAt(KeyConstants._template, row, das.getTemplate());
qryImplicitAccesseses.setAt(KeyConstants._line, row, new Double(das.getLine()));
qryImplicitAccesseses.setAt(KeyConstants._scope, row, das.getScope());
qryImplicitAccesseses.setAt(KeyConstants._count, row, new Double(das.getCount()));
qryImplicitAccesseses.setAt(KeyConstants._name, row, das.getName());
}
} catch (PageException dbe) {
}
}
Query history = new QueryImpl(new Collection.Key[] {}, 0, "history");
try {
history.addColumn(KeyConstants._id, historyId);
history.addColumn(KeyConstants._level, historyLevel);
} catch (PageException e) {
}
if (addAddionalInfo) {
debugging.setEL(KeyConstants._cgi, pc.cgiScope());
debugging.setEL(KeyImpl.init("starttime"), new DateTimeImpl(starttime, false));
debugging.setEL(KeyConstants._id, pc.getId());
}
debugging.setEL(KeyConstants._pages, qryPage);
debugging.setEL(PAGE_PARTS, qryPart);
debugging.setEL(KeyConstants._queries, qryQueries);
debugging.setEL(KeyConstants._timers, qryTimers);
debugging.setEL(KeyConstants._traces, qryTraces);
debugging.setEL("dumps", qryDumps);
debugging.setEL(IMPLICIT_ACCESS, qryImplicitAccesseses);
// debugging.setEL(OUTPUT_LOG,qryOutputLog);
debugging.setEL(KeyConstants._history, history);
debugging.setEL(KeyConstants._exceptions, arrExceptions);
return debugging;
}
Aggregations