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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations