use of com.zimbra.cs.index.IntersectionQueryOperation 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