use of io.spine.base.Event in project core-java by SpineEventEngine.
the class EventStorage method iterator.
Iterator<Event> iterator(EventStreamQuery query) {
final EventRecordStorage storage = recordStorage();
final Map<EventId, EntityRecord> records = storage.readAll(query);
final Collection<EventEntity> entities = transform(records.entrySet(), storageRecordToEntity());
// TODO:2017-05-19:dmytro.dashenkov: Remove after the Entity Column approach is implemented.
final Collection<EventEntity> filtered = filter(entities, createEntityFilter(query));
final List<EventEntity> entityList = newArrayList(filtered);
Collections.sort(entityList, EventEntity.comparator());
final Iterator<Event> result = Iterators.transform(entityList.iterator(), getEventFunc());
return result;
}
use of io.spine.base.Event in project core-java by SpineEventEngine.
the class EventEnricher method enrich.
/**
* Enriches the passed event.
*
* @throws IllegalArgumentException if the passed event cannot be enriched
* @see #canBeEnriched(Event)
*/
public Event enrich(Event event) {
checkTypeRegistered(event);
checkEnabled(event);
final EventEnvelope envelope = EventEnvelope.of(event);
final Action action = new Action(this, envelope);
final Event result = action.perform();
return result;
}
use of io.spine.base.Event in project core-java by SpineEventEngine.
the class TestEventFactory method createEvent.
/**
* Creates an event produced at the passed time.
*/
public Event createEvent(Message messageOrAny, @Nullable Version version, Timestamp atTime) {
final Event event = createEvent(messageOrAny, version);
final EventContext context = event.getContext().toBuilder().setTimestamp(atTime).build();
final Event result = event.toBuilder().setContext(context).build();
return result;
}
use of io.spine.base.Event in project core-java by SpineEventEngine.
the class AggregateStorageShould method generateEvent.
private static Event generateEvent() {
final TestEventFactory eventFactory = newInstance(AggregateStorageShould.class);
final Event result = eventFactory.createEvent(EventMessage.projectCreated());
return result;
}
use of io.spine.base.Event in project core-java by SpineEventEngine.
the class EventClass method of.
/**
* Creates a new instance of the event class by passed event instance.
*
* <p>If an instance of {@link Event} (which implements {@code Message}) is passed to
* this method, enclosing event message will be un-wrapped to determine the class of the event.
*
* @param event an event instance
* @return new instance
*/
public static EventClass of(Message event) {
final Message message = checkNotNull(event);
if (message instanceof Event) {
final Event eventRecord = (Event) event;
final Message enclosed = Events.getMessage(eventRecord);
return of(enclosed.getClass());
}
final EventClass result = of(message.getClass());
return result;
}
Aggregations