sirius.biz.jobs.system.SystemJobsFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sirius-biz Show documentation
Show all versions of sirius-biz Show documentation
Provides a framework for building web based business applications
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.biz.jobs.system;
import sirius.biz.jobs.JobDescription;
import sirius.biz.jobs.JobsFactory;
import sirius.kernel.commons.Strings;
import sirius.kernel.di.GlobalContext;
import sirius.kernel.di.std.Part;
import sirius.kernel.di.std.Parts;
import sirius.kernel.di.std.Register;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.function.Consumer;
import java.util.stream.Stream;
/**
* Created by aha on 22.07.16.
*/
@Register
public class SystemJobsFactory implements JobsFactory {
public static final String SYSTEM = "system";
@Parts(SystemJobDescription.class)
private Collection jobs;
@Part
private GlobalContext ctx;
@Override
public void collectJobs(@Nullable String query, Consumer jobsCollector) {
Stream stream = jobs.stream();
if (Strings.isFilled(query)) {
String filterQuery = query.trim().toLowerCase();
stream = stream.filter(j -> j.getTitle().contains(filterQuery));
}
stream.forEach(jobsCollector);
}
@Override
public JobDescription resolve(String name) {
return ctx.findPart(name, SystemJobDescription.class);
}
@Nonnull
@Override
public String getName() {
return SYSTEM;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy