use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class Schedule method doList.
/**
* @throws PageException
*/
private void doList() throws PageException {
// if(tr ue) throw new PageRuntimeException("qqq");
ScheduleTask[] tasks = scheduler.getAllScheduleTasks();
final String v = "VARCHAR";
String[] cols = new String[] { "task", "path", "file", "startdate", "starttime", "enddate", "endtime", "url", "port", "interval", "timeout", "username", "password", "proxyserver", "proxyport", "proxyuser", "proxypassword", "resolveurl", "publish", "valid", "paused", "autoDelete" };
String[] types = new String[] { v, v, v, "DATE", "OTHER", "DATE", "OTHER", v, v, v, v, v, v, v, v, v, v, v, "BOOLEAN", v, "BOOLEAN", "BOOLEAN" };
lucee.runtime.type.Query query = new QueryImpl(cols, types, tasks.length, "query");
try {
for (int i = 0; i < tasks.length; i++) {
int row = i + 1;
ScheduleTask task = tasks[i];
query.setAt(KeyConstants._task, row, task.getTask());
if (task.getResource() != null) {
query.setAt(KeyConstants._path, row, task.getResource().getParent());
query.setAt(KeyConstants._file, row, task.getResource().getName());
}
query.setAt("publish", row, Caster.toBoolean(task.isPublish()));
query.setAt("startdate", row, task.getStartDate());
query.setAt("starttime", row, task.getStartTime());
query.setAt("enddate", row, task.getEndDate());
query.setAt("endtime", row, task.getEndTime());
query.setAt(KeyConstants._url, row, printUrl(task.getUrl()));
query.setAt(KeyConstants._port, row, Caster.toString(HTTPUtil.getPort(task.getUrl())));
query.setAt("interval", row, task.getStringInterval());
query.setAt("timeout", row, Caster.toString(task.getTimeout() / 1000));
query.setAt("valid", row, Caster.toString(task.isValid()));
if (task.hasCredentials()) {
query.setAt("username", row, task.getCredentials().getUsername());
query.setAt("password", row, task.getCredentials().getPassword());
}
ProxyData pd = task.getProxyData();
if (ProxyDataImpl.isValid(pd)) {
query.setAt("proxyserver", row, pd.getServer());
if (pd.getPort() > 0)
query.setAt("proxyport", row, Caster.toString(pd.getPort()));
if (ProxyDataImpl.hasCredentials(pd)) {
query.setAt("proxyuser", row, pd.getUsername());
query.setAt("proxypassword", row, pd.getPassword());
}
}
query.setAt("resolveurl", row, Caster.toString(task.isResolveURL()));
query.setAt("paused", row, Caster.toBoolean(task.isPaused()));
query.setAt("autoDelete", row, Caster.toBoolean(((ScheduleTaskImpl) task).isAutoDelete()));
}
pageContext.setVariable(result, query);
} catch (DatabaseException e) {
}
}
use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class Ansi92 method select.
@Override
public Query select(Config config, String cfid, String applicationName, DatasourceConnection dc, int type, Log log, boolean createTableIfNotExist) throws PageException {
String strType = VariableInterpreter.scopeInt2String(type);
Query query = null;
SQL sqlSelect = new SQLImpl("select data from " + PREFIX + "_" + strType + "_data where cfid=? and name=? and expires > ?", new SQLItem[] { new SQLItemImpl(cfid, Types.VARCHAR), new SQLItemImpl(applicationName, Types.VARCHAR), new SQLItemImpl(now(config), Types.VARCHAR) });
PageContext pc = ThreadLocalPageContext.get();
try {
query = new QueryImpl(pc, dc, sqlSelect, -1, -1, null, "query");
} catch (DatabaseException de) {
if (dc == null || !createTableIfNotExist)
throw de;
// table does not exist???
try {
SQL sql = createSQL(dc, DataSourceUtil.isMySQL(dc) ? "longtext" : "ntext", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException _de) {
// don't like "ntext", try text
try {
SQL sql = createSQL(dc, "text", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException __de) {
// don't like text, try "memo"
try {
SQL sql = createSQL(dc, "memo", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException ___de) {
// don't like "memo", try clob
try {
SQL sql = createSQL(dc, "clob", strType);
ScopeContext.info(log, sql.toString());
new QueryImpl(pc, dc, sql, -1, -1, null, "query");
} catch (DatabaseException ____de) {
___de.initCause(__de);
__de.initCause(_de);
_de.initCause(de);
// we could not create the table, so there seem to be an other ecception we cannot solve
DatabaseException exp = new DatabaseException("Unable to select from your client storage database, and was also unable to create the tables. Here's the exceptions we encountered.", null, null, dc);
exp.initCause(de);
throw exp;
}
}
}
}
query = new QueryImpl(pc, dc, sqlSelect, -1, -1, null, "query");
}
ScopeContext.info(log, sqlSelect.toString());
return query;
}
use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class FeedQuery method toQuery.
public static Query toQuery(Struct data, boolean hasDC) throws DatabaseException {
Query qry = new QueryImpl(hasDC ? COLUMNS_WITH_DC : COLUMNS, 0, "");
String version = Caster.toString(data.get(VERSION, ""), "");
Array items = null;
if (StringUtil.startsWithIgnoreCase(version, "rss") || StringUtil.startsWithIgnoreCase(version, "rdf")) {
items = Caster.toArray(data.get(ITEM, null), null);
if (items == null) {
Struct sct = Caster.toStruct(data.get(version, null), null, false);
if (sct != null) {
items = Caster.toArray(sct.get(ITEM, null), null);
}
}
return toQuery(true, qry, items);
} else if (StringUtil.startsWithIgnoreCase(version, "atom")) {
items = Caster.toArray(data.get(ENTRY, null), null);
return toQuery(false, qry, items);
}
return qry;
}
use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class RSSHandler method init.
private void init(InputSource is) throws SAXException, IOException, DatabaseException {
properties = new StructImpl();
items = new QueryImpl(COLUMNS, 0, "query");
xmlReader = XMLUtil.createXMLReader();
xmlReader.setContentHandler(this);
xmlReader.setErrorHandler(this);
// xmlReader.setEntityResolver(new TagLibEntityResolver());
xmlReader.parse(is);
// properties.setEL("encoding",is.getEncoding());
}
use of lucee.runtime.type.QueryImpl in project Lucee by lucee.
the class Admin method doGetJars.
private void doGetJars() throws PageException {
Resource lib = config.getLibraryDirectory();
lucee.runtime.type.Query qry = new QueryImpl(new Key[] { KeyConstants._name, KeyConstants._source, KeyConstants._info }, new String[] { "varchar", "varchar", "varchar" }, 0, "jars");
if (lib.isDirectory()) {
Resource[] children = lib.listResources(new ExtensionResourceFilter(new String[] { ".jar", ".zip" }, false, true));
for (int i = 0; i < children.length; i++) {
qry.addRow();
qry.setAt(KeyConstants._name, i + 1, children[i].getName());
qry.setAt(KeyConstants._source, i + 1, children[i].getAbsolutePath());
try {
qry.setAt(KeyConstants._info, i + 1, new BundleFile(children[i]).info());
} catch (Exception e) {
}
}
}
pageContext.setVariable(getString("admin", action, "returnVariable"), qry);
}
Aggregations