* @param query Query to extract the keys from.
* @return A present if keys can be extracted, absent otherwise.
*/
public static Optional<Set<IJobKey>> from(Query.Builder query) {
if (Query.isJobScoped(query)) {
TaskQuery taskQuery = query.get();
ImmutableSet.Builder<IJobKey> builder = ImmutableSet.builder();
if (taskQuery.isSetJobName()) {
builder.add(from(
taskQuery.getOwner().getRole(),
taskQuery.getEnvironment(),
taskQuery.getJobName()));
}
if (taskQuery.isSetJobKeys()) {
builder.addAll(IJobKey.setFromBuilders(taskQuery.getJobKeys()));
}
return Optional.of(assertValid(builder.build()));
} else {
return Optional.absent();
}