use of lucee.runtime.type.Query in project Lucee by lucee.
the class QueryNew method call.
public static lucee.runtime.type.Query call(PageContext pc, Object columnNames, Object columnTypes, Object data) throws PageException {
Array cn = toArray(pc, columnNames, 1);
lucee.runtime.type.Query qry;
if (StringUtil.isEmpty(columnTypes))
qry = new QueryImpl(cn, 0, "query");
else
qry = new QueryImpl(cn, toArray(pc, columnTypes, 2), 0, "query");
if (data == null)
return qry;
return populate(pc, qry, data);
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class QuerySetColumn method call.
public static String call(PageContext pc, Query query, String columnName, String newColumnName) throws PageException {
columnName = columnName.trim();
newColumnName = newColumnName.trim();
Collection.Key src = KeyImpl.getInstance(columnName);
Collection.Key trg = KeyImpl.getInstance(newColumnName);
Query qp = Caster.toQuery(query, null);
if (qp != null)
qp.rename(src, trg);
else {
QueryColumn qc = query.removeColumn(src);
Array content = new ArrayImpl();
int len = qc.size();
for (int i = 1; i <= len; i++) {
content.setE(i, qc.get(i, null));
}
query.addColumn(trg, content, qc.getType());
}
return null;
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class ValueList method toColumn.
protected static QueryColumn toColumn(PageContext pc, String strQueryColumn) throws PageException {
// if(strQueryColumn.indexOf('.')<1)
// throw new ExpressionException("invalid query column definition ["+strQueryColumn+"]");
VariableReference ref = ((PageContextImpl) pc).getVariableReference(strQueryColumn);
if (ref.getParent() instanceof Scope)
throw new ExpressionException("invalid query column definition [" + strQueryColumn + "]");
Query query = Caster.toQuery(ref.getParent());
return query.getColumn(ref.getKey());
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method doGetComponentMappings.
private void doGetComponentMappings() throws PageException {
Mapping[] mappings = config.getComponentMappings();
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);
}
use of lucee.runtime.type.Query in project Lucee by lucee.
the class Admin method doGetLocalExtension.
private void doGetLocalExtension() throws PageException {
String id = getString("admin", action, "id");
boolean asBinary = getBoolV("asBinary", false);
if (asBinary) {
Iterator<ExtensionDefintion> it = DeployHandler.getLocalExtensions(config).iterator();
ExtensionDefintion ext;
while (it.hasNext()) {
ext = it.next();
if (id.equalsIgnoreCase(ext.getId())) {
try {
pageContext.setVariable(getString("admin", action, "returnVariable"), IOUtil.toBytes(ext.getSource()));
return;
} catch (IOException e) {
throw Caster.toPageException(e);
}
}
}
throw new ApplicationException("there is no local extension with id " + id);
} else {
List<RHExtension> locals = RHExtension.toRHExtensions(DeployHandler.getLocalExtensions(config));
Query qry = RHExtension.toQuery(config, locals.toArray(new RHExtension[locals.size()]));
int rows = qry.getRecordcount();
String _id;
int row = 0;
for (int r = 1; r <= rows; r++) {
_id = Caster.toString(qry.getAt(KeyConstants._id, r), null);
if (id.equalsIgnoreCase(_id)) {
row = r;
break;
}
}
if (row == 0)
throw new ApplicationException("there is no local extension with id " + id);
pageContext.setVariable(getString("admin", action, "returnVariable"), Caster.toStruct(qry, row));
}
}
Aggregations