Search in sources :

Example 1 with BranchChangedEvent

use of com.b2international.snowowl.core.branch.BranchChangedEvent in project snow-owl by b2ihealthcare.

the class TerminologyRepository method initIndex.

private RevisionIndex initIndex(final ServiceProvider context, Mappings mappings) {
    final ObjectMapper mapper = context.service(ObjectMapper.class);
    IndexConfiguration indexConfiguration = context.service(RepositoryConfiguration.class).getIndexConfiguration();
    final IndexClient indexClient = Indexes.createIndexClient(repositoryId, mapper, mappings, context.service(IndexSettings.class).forIndex(indexConfiguration, repositoryId));
    final Index index = new DefaultIndex(indexClient);
    final RevisionIndex revisionIndex = new DefaultRevisionIndex(index, context.service(TimestampProvider.class), mapper);
    revisionIndex.branching().addBranchChangeListener(path -> {
        new BranchChangedEvent(repositoryId, path).publish(context.service(IEventBus.class));
    });
    // register IndexClient per terminology
    bind(IndexClient.class, indexClient);
    // register index and revision index access, the underlying index is the same
    bind(Index.class, index);
    bind(RevisionIndex.class, revisionIndex);
    // register branching services
    bind(BaseRevisionBranching.class, revisionIndex.branching());
    return revisionIndex;
}
Also used : DefaultIndex(com.b2international.index.DefaultIndex) TimestampProvider(com.b2international.index.revision.TimestampProvider) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) IndexClient(com.b2international.index.IndexClient) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) Index(com.b2international.index.Index) RevisionIndex(com.b2international.index.revision.RevisionIndex) DefaultRevisionIndex(com.b2international.index.revision.DefaultRevisionIndex) DefaultIndex(com.b2international.index.DefaultIndex) RepositoryConfiguration(com.b2international.snowowl.core.config.RepositoryConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BranchChangedEvent(com.b2international.snowowl.core.branch.BranchChangedEvent) IEventBus(com.b2international.snowowl.eventbus.IEventBus) IndexConfiguration(com.b2international.snowowl.core.config.IndexConfiguration)

Aggregations

DefaultIndex (com.b2international.index.DefaultIndex)1 Index (com.b2international.index.Index)1 IndexClient (com.b2international.index.IndexClient)1 DefaultRevisionIndex (com.b2international.index.revision.DefaultRevisionIndex)1 RevisionIndex (com.b2international.index.revision.RevisionIndex)1 TimestampProvider (com.b2international.index.revision.TimestampProvider)1 BranchChangedEvent (com.b2international.snowowl.core.branch.BranchChangedEvent)1 IndexConfiguration (com.b2international.snowowl.core.config.IndexConfiguration)1 RepositoryConfiguration (com.b2international.snowowl.core.config.RepositoryConfiguration)1 IEventBus (com.b2international.snowowl.eventbus.IEventBus)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1