Search in sources :

Example 1 with EventId

use of io.spine.base.EventId in project core-java by SpineEventEngine.

the class EventStorage method createStorage.

@Override
protected EventRecordStorage createStorage(StorageFactory factory) {
    final RecordStorage<EventId> recordStorage = super.createStorage(factory);
    final EventRecordStorage storage = factory.createEventStorage(recordStorage);
    return storage;
}
Also used : EventRecordStorage(io.spine.server.storage.EventRecordStorage) EventId(io.spine.base.EventId)

Example 2 with EventId

use of io.spine.base.EventId 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 3 with EventId

use of io.spine.base.EventId in project core-java by SpineEventEngine.

the class EventIdSequence method next.

/**
     * Generates the next event ID in the sequence.
     */
EventId next() {
    count.incrementAndGet();
    final String value = buildValue();
    final EventId result = EventId.newBuilder().setValue(value).build();
    return result;
}
Also used : EventId(io.spine.base.EventId) Identifiers.idToString(io.spine.base.Identifiers.idToString)

Example 4 with EventId

use of io.spine.base.EventId in project core-java by SpineEventEngine.

the class EventsShould method provide_EventId_stringifier.

@Test
public void provide_EventId_stringifier() {
    final EventId id = event.getId();
    final String str = Stringifiers.toString(id);
    final EventId convertedBack = Stringifiers.fromString(str, EventId.class);
    assertEquals(id, convertedBack);
}
Also used : EventId(io.spine.base.EventId) Test(org.junit.Test)

Example 5 with EventId

use of io.spine.base.EventId in project core-java by SpineEventEngine.

the class EventsShould method accept_generated_event_id.

@Test
public void accept_generated_event_id() {
    final EventId eventId = event.getId();
    assertEquals(eventId, checkValid(eventId));
}
Also used : EventId(io.spine.base.EventId) Test(org.junit.Test)

Aggregations

EventId (io.spine.base.EventId)6 Event (io.spine.base.Event)2 EventRecordStorage (io.spine.server.storage.EventRecordStorage)2 Test (org.junit.Test)2 EventContext (io.spine.base.EventContext)1 Identifiers.idToString (io.spine.base.Identifiers.idToString)1 EntityRecord (io.spine.server.entity.EntityRecord)1 IntegrationEvent (io.spine.server.integration.IntegrationEvent)1 IntegrationEventContext (io.spine.server.integration.IntegrationEventContext)1