[Fix] Searches should search on items in cache as well
But then ignore the item from the ElementMap stream
This commit is contained in:
parent
e33950b7a1
commit
69d1f77364
|
@ -1,11 +1,13 @@
|
|||
package li.strolch.search;
|
||||
|
||||
import static li.strolch.model.StrolchModelConstants.PolicyConstants.PARAM_ORDER;
|
||||
|
||||
import li.strolch.model.Order;
|
||||
import li.strolch.model.activity.Activity;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static li.strolch.model.StrolchModelConstants.PolicyConstants.PARAM_ORDER;
|
||||
|
||||
/**
|
||||
* Performs a search for {@link Activity} elements
|
||||
*/
|
||||
|
@ -20,7 +22,13 @@ public class ActivitySearch extends StrolchSearch<Activity> {
|
|||
|
||||
@Override
|
||||
public ActivitySearch types(String... types) {
|
||||
this.navigator = tx -> tx.streamActivities(types);
|
||||
this.navigator = tx -> {
|
||||
Stream<Activity> cachedStream = tx.streamCachedActivities(types);
|
||||
Stream<Activity> stream = tx
|
||||
.streamActivities(types)
|
||||
.filter(e -> !tx.isActivityCached(e.getType(), e.getId()));
|
||||
return Stream.concat(cachedStream, stream);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import li.strolch.persistence.api.StrolchTransaction;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
|
@ -23,7 +24,11 @@ public class OrderSearch extends StrolchSearch<Order> {
|
|||
|
||||
@Override
|
||||
public OrderSearch types(String... types) {
|
||||
this.navigator = tx -> tx.streamOrders(types);
|
||||
this.navigator = tx -> {
|
||||
Stream<Order> cachedStream = tx.streamCachedOrders(types);
|
||||
Stream<Order> stream = tx.streamOrders(types).filter(e -> !tx.isOrderCached(e.getType(), e.getId()));
|
||||
return Stream.concat(cachedStream, stream);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,8 @@ package li.strolch.search;
|
|||
import li.strolch.model.Resource;
|
||||
import li.strolch.persistence.api.StrolchTransaction;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* Performs a search for {@link Resource} elements
|
||||
*/
|
||||
|
@ -17,7 +19,13 @@ public class ResourceSearch extends StrolchSearch<Resource> {
|
|||
|
||||
@Override
|
||||
public ResourceSearch types(String... types) {
|
||||
this.navigator = tx -> tx.streamResources(types);
|
||||
this.navigator = tx -> {
|
||||
Stream<Resource> cachedStream = tx.streamCachedResources(types);
|
||||
Stream<Resource> stream = tx
|
||||
.streamResources(types)
|
||||
.filter(e -> !tx.isResourceCached(e.getType(), e.getId()));
|
||||
return Stream.concat(cachedStream, stream);
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue