Search in sources :

Example 1 with DBQueryOperation

use of com.zimbra.cs.index.DBQueryOperation in project zm-mailbox by Zimbra.

the class ConvCountQuery method compile.

@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
    DBQueryOperation op = new DBQueryOperation();
    op.addConvCountRange(lowestCount, lowerEq, highestCount, higherEq, evalBool(bool));
    return op;
}
Also used : DBQueryOperation(com.zimbra.cs.index.DBQueryOperation)

Example 2 with DBQueryOperation

use of com.zimbra.cs.index.DBQueryOperation in project zm-mailbox by Zimbra.

the class ItemQuery method compile.

@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
    DBQueryOperation dbOp = new DBQueryOperation();
    bool = evalBool(bool);
    if (bool && isAllQuery || !bool && isNoneQuery) {
    // adding no constraints should match everything...
    } else if (bool && isNoneQuery || !bool && isAllQuery) {
        return new NoResultsQueryOperation();
    } else {
        for (ItemId iid : itemIds) {
            dbOp.addItemIdClause(mbox, iid, bool);
        }
    }
    return dbOp;
}
Also used : DBQueryOperation(com.zimbra.cs.index.DBQueryOperation) ItemId(com.zimbra.cs.service.util.ItemId) NoResultsQueryOperation(com.zimbra.cs.index.NoResultsQueryOperation)

Example 3 with DBQueryOperation

use of com.zimbra.cs.index.DBQueryOperation in project zm-mailbox by Zimbra.

the class ModseqQuery method compile.

@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
    DBQueryOperation op = new DBQueryOperation();
    long highest = -1;
    long lowest = -1;
    boolean lowestEq = false;
    boolean highestEq = false;
    switch(operator) {
        case EQ:
            highest = modseq;
            lowest = modseq;
            highestEq = true;
            lowestEq = true;
            break;
        case GT:
            lowest = modseq;
            break;
        case GTEQ:
            lowest = modseq;
            lowestEq = true;
            break;
        case LT:
            highest = modseq;
            break;
        case LTEQ:
            highest = modseq;
            highestEq = true;
            break;
    }
    op.addModSeqRange(lowest, lowestEq, highest, highestEq, evalBool(bool));
    return op;
}
Also used : DBQueryOperation(com.zimbra.cs.index.DBQueryOperation)

Example 4 with DBQueryOperation

use of com.zimbra.cs.index.DBQueryOperation in project zm-mailbox by Zimbra.

the class ConvQuery method compile.

@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
    DBQueryOperation op = new DBQueryOperation();
    op.addConvId(mbox, convId, evalBool(bool));
    return op;
}
Also used : DBQueryOperation(com.zimbra.cs.index.DBQueryOperation)

Example 5 with DBQueryOperation

use of com.zimbra.cs.index.DBQueryOperation in project zm-mailbox by Zimbra.

the class InQuery method compile.

@Override
public QueryOperation compile(Mailbox mbox, boolean bool) {
    if (specialTarget != null) {
        if (specialTarget == In.NONE) {
            return new NoResultsQueryOperation();
        } else if (specialTarget == In.ANY) {
            DBQueryOperation op = new DBQueryOperation();
            op.addAnyFolder(evalBool(bool));
            return op;
        } else {
            if (evalBool(bool)) {
                if (specialTarget == In.REMOTE) {
                    DBQueryOperation dbop = new DBQueryOperation();
                    dbop.addIsRemoteClause();
                    return dbop;
                } else {
                    assert (specialTarget == In.LOCAL);
                    DBQueryOperation dbop = new DBQueryOperation();
                    dbop.addIsLocalClause();
                    return dbop;
                }
            } else {
                if (specialTarget == In.REMOTE) {
                    DBQueryOperation dbop = new DBQueryOperation();
                    dbop.addIsLocalClause();
                    return dbop;
                } else {
                    assert (specialTarget == In.LOCAL);
                    DBQueryOperation dbop = new DBQueryOperation();
                    dbop.addIsRemoteClause();
                    return dbop;
                }
            }
        }
    }
    DBQueryOperation dbOp = new DBQueryOperation();
    if (folder != null) {
        if (includeSubfolders) {
            List<Folder> subFolders = folder.getSubfolderHierarchy();
            if (evalBool(bool)) {
                // (A or B or C)
                UnionQueryOperation union = new UnionQueryOperation();
                for (Folder sub : subFolders) {
                    DBQueryOperation dbop = new DBQueryOperation();
                    union.add(dbop);
                    if (sub instanceof Mountpoint) {
                        Mountpoint mpt = (Mountpoint) sub;
                        if (!mpt.isLocal()) {
                            dbop.addInRemoteFolder(mpt.getTarget(), "", includeSubfolders, evalBool(bool));
                        } else {
                        // TODO FIXME handle local mountpoints. Don't forget to check for infinite recursion!
                        }
                    } else {
                        dbop.addInFolder(sub, evalBool(bool));
                    }
                }
                return union;
            } else {
                // -(A or B or C) ==> -A and -B and -C
                IntersectionQueryOperation iop = new IntersectionQueryOperation();
                for (Folder f : subFolders) {
                    DBQueryOperation dbop = new DBQueryOperation();
                    iop.addQueryOp(dbop);
                    if (f instanceof Mountpoint) {
                        Mountpoint mpt = (Mountpoint) f;
                        if (!mpt.isLocal()) {
                            dbop.addInRemoteFolder(mpt.getTarget(), "", includeSubfolders, evalBool(bool));
                        } else {
                        // TODO FIXME handle local mountpoints.  Don't forget to check for infinite recursion!
                        }
                    } else {
                        dbop.addInFolder(f, evalBool(bool));
                    }
                }
                return iop;
            }
        } else {
            dbOp.addInFolder(folder, evalBool(bool));
        }
    } else if (remoteId != null) {
        dbOp.addInRemoteFolder(remoteId, subfolderPath, includeSubfolders, evalBool(bool));
    } else {
        assert (false);
    }
    return dbOp;
}
Also used : IntersectionQueryOperation(com.zimbra.cs.index.IntersectionQueryOperation) UnionQueryOperation(com.zimbra.cs.index.UnionQueryOperation) Folder(com.zimbra.cs.mailbox.Folder) DBQueryOperation(com.zimbra.cs.index.DBQueryOperation) Mountpoint(com.zimbra.cs.mailbox.Mountpoint) NoResultsQueryOperation(com.zimbra.cs.index.NoResultsQueryOperation)

Aggregations

DBQueryOperation (com.zimbra.cs.index.DBQueryOperation)5 NoResultsQueryOperation (com.zimbra.cs.index.NoResultsQueryOperation)2 IntersectionQueryOperation (com.zimbra.cs.index.IntersectionQueryOperation)1 UnionQueryOperation (com.zimbra.cs.index.UnionQueryOperation)1 Folder (com.zimbra.cs.mailbox.Folder)1 Mountpoint (com.zimbra.cs.mailbox.Mountpoint)1 ItemId (com.zimbra.cs.service.util.ItemId)1