Search in sources :

Example 1 with Event

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;
}
Also used : EntityRecord(io.spine.server.entity.EntityRecord) EventRecordStorage(io.spine.server.storage.EventRecordStorage) EventId(io.spine.base.EventId) Event(io.spine.base.Event)

Example 2 with Event

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;
}
Also used : EventEnvelope(io.spine.envelope.EventEnvelope) Event(io.spine.base.Event)

Example 3 with Event

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;
}
Also used : EventContext(io.spine.base.EventContext) Event(io.spine.base.Event)

Example 4 with Event

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;
}
Also used : TestEventFactory(io.spine.test.TestEventFactory) Event(io.spine.base.Event)

Example 5 with Event

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;
}
Also used : Message(com.google.protobuf.Message) Event(io.spine.base.Event)

Aggregations

Event (io.spine.base.Event)32 Test (org.junit.Test)14 Message (com.google.protobuf.Message)7 EventContext (io.spine.base.EventContext)4 IntegrationEvent (io.spine.server.integration.IntegrationEvent)4 StringValue (com.google.protobuf.StringValue)3 EventFactory (io.spine.server.command.EventFactory)3 TestEventFactory (io.spine.test.TestEventFactory)3 ProjectId (io.spine.test.projection.ProjectId)3 ProjectCreated (io.spine.test.projection.event.ProjectCreated)3 Duration (com.google.protobuf.Duration)2 Command (io.spine.base.Command)2 EventId (io.spine.base.EventId)2 EventStore (io.spine.server.event.EventStore)2 IntegrationEventContext (io.spine.server.integration.IntegrationEventContext)2 ImmutableCollection (com.google.common.collect.ImmutableCollection)1 Any (com.google.protobuf.Any)1 Timestamp (com.google.protobuf.Timestamp)1 CommandContext (io.spine.base.CommandContext)1 Events.getMessage (io.spine.base.Events.getMessage)1