private static Predicate<Task> queryFilter(final TaskQuery query) {
return new Predicate<Task>() {
@Override
public boolean apply(Task canonicalTask) {
IScheduledTask task = canonicalTask.storedTask;
ITaskConfig config = task.getAssignedTask().getTask();
if (query.getRole() != null
&& !StringUtils.isBlank(query.getRole())
&& !query.getRole().equals(config.getJob().getRole())) {
return false;
}
if (query.getEnvironment() != null
&& !query.getEnvironment().equals(config.getEnvironment())) {
return false;
}
if (query.getJobName() != null && !query.getJobName().equals(config.getJobName())) {
return false;
}
if (query.getJobKeysSize() > 0
&& !query.getJobKeys().contains(config.getJob().newBuilder())) {
return false;
}
if (query.getTaskIds() != null && !query.getTaskIds().contains(Tasks.id(task))) {
return false;
}