@Override public Stream<T> getCollectionStream(Repository repository) { IndexedCollection<EntityHandle<Deleted>> deletedCollection = repository.getIndexEngine().getIndexedCollection(Deleted.class); IndexedCollection<EntityHandle<Undeleted>> undeletedCollection = repository.getIndexEngine().getIndexedCollection(Undeleted.class); ResultSet<EntityHandle<E>> resultSet = repository .query(klass, not(existsIn(deletedCollection, idAttribute, Deleted.REFERENCE_ID, not(existsIn(undeletedCollection, Deleted.ID, Undeleted.DELETED_ID))))); return streamOf(resultSet) .map(h -> loader.load(repository, h.get().uuid()).get()) .onClose(resultSet::close); }
default Optional<Deleted> deleted() { Not<EntityHandle<Deleted>> additionalQuery = not(existsIn(getRepository().getIndexEngine() .getIndexedCollection(Undeleted.class), Deleted.ID, Undeleted.DELETED_ID)); return latestAssociatedEntity(Deleted.class, Deleted.REFERENCE_ID, Deleted.TIMESTAMP, additionalQuery); }
@Override public Stream<T> getCollectionStream(Repository repository) { IndexedCollection<EntityHandle<Deleted>> deletedCollection = repository.getIndexEngine() .getIndexedCollection(Deleted.class); IndexedCollection<EntityHandle<Undeleted>> undeletedCollection = repository.getIndexEngine() .getIndexedCollection( Undeleted.class); Query<EntityHandle<Deleted>> query = and(not(existsIn(undeletedCollection, Deleted.ID, Undeleted.DELETED_ID)), isLatestEntity(deletedCollection, new DeletedQueryFunction(), Deleted.TIMESTAMP)); ResultSet<EntityHandle<Deleted>> resultSet = repository.query(Deleted.class, query); return streamOf(resultSet) .map(h -> loader.load(repository, h.get().reference()).get()) .onClose(resultSet::close); }