li.strolch.search.RootElementSearch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent Show documentation
Show all versions of agent Show documentation
Strolch Agent which is the runtime for Strolch
The newest version!
package li.strolch.search;
import java.util.stream.Stream;
import li.strolch.model.Order;
import li.strolch.model.Resource;
import li.strolch.model.StrolchRootElement;
import li.strolch.model.activity.Activity;
import li.strolch.persistence.api.StrolchTransaction;
/**
* Performs a search for any kind of root element, allowing to mix {@link Resource}, {@link Order} and {@link Activity}
* in the result
*/
public class RootElementSearch extends StrolchSearch {
private SearchNavigator navigator;
@Override
protected SearchNavigator getNavigator() {
return this.navigator;
}
@Override
public RootElementSearch types(String... types) {
this.navigator = tx -> {
Stream resources = tx.streamResources(types);
Stream activities = tx.streamActivities(types);
Stream orders = tx.streamOrders(types);
return Stream.concat(resources, Stream.concat(activities, orders));
};
return this;
}
@Override
public RootElementSearchResult search(StrolchTransaction tx) {
return new RootElementSearchResult<>(prepareSearch(tx));
}
}