Search in sources :

Example 31 with Query

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);
}
Also used : Array(lucee.runtime.type.Array) QueryImpl(lucee.runtime.type.QueryImpl) Query(lucee.runtime.type.Query)

Example 32 with Query

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;
}
Also used : Array(lucee.runtime.type.Array) Query(lucee.runtime.type.Query) QueryColumn(lucee.runtime.type.QueryColumn) ArrayImpl(lucee.runtime.type.ArrayImpl) Collection(lucee.runtime.type.Collection)

Example 33 with Query

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());
}
Also used : VariableReference(lucee.runtime.type.ref.VariableReference) Scope(lucee.runtime.type.scope.Scope) Query(lucee.runtime.type.Query) PageContextImpl(lucee.runtime.PageContextImpl) ExpressionException(lucee.runtime.exp.ExpressionException)

Example 34 with Query

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);
}
Also used : QueryImpl(lucee.runtime.type.QueryImpl) Mapping(lucee.runtime.Mapping) MappingImpl(lucee.runtime.MappingImpl) Query(lucee.runtime.type.Query)

Example 35 with Query

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));
    }
}
Also used : RHExtension(lucee.runtime.extension.RHExtension) ApplicationException(lucee.runtime.exp.ApplicationException) Query(lucee.runtime.type.Query) ExtensionDefintion(lucee.runtime.extension.ExtensionDefintion) IOException(java.io.IOException)

Aggregations

Query (lucee.runtime.type.Query)82 QueryImpl (lucee.runtime.type.QueryImpl)52 Struct (lucee.runtime.type.Struct)19 Array (lucee.runtime.type.Array)16 Collection (lucee.runtime.type.Collection)14 Iterator (java.util.Iterator)13 PageException (lucee.runtime.exp.PageException)12 Map (java.util.Map)11 StructImpl (lucee.runtime.type.StructImpl)11 ApplicationException (lucee.runtime.exp.ApplicationException)10 Stopwatch (lucee.runtime.timer.Stopwatch)10 Key (lucee.runtime.type.Collection.Key)9 List (java.util.List)8 IOException (java.io.IOException)7 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 QueryColumn (lucee.runtime.type.QueryColumn)7 Enumeration (java.util.Enumeration)6 Entry (java.util.Map.Entry)6 FunctionException (lucee.runtime.exp.FunctionException)6