All Downloads are FREE. Search and download functionalities are using the official Maven repository.

li.strolch.search.RootElementSearch Maven / Gradle / Ivy

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));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy