use of com.b2international.index.revision.DefaultRevisionIndex in project snow-owl by b2ihealthcare.
the class IndexResource method before.
@Override
protected void before() throws Throwable {
if (INIT.compareAndSet(false, true)) {
mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
client = Indexes.createIndexClient(UUID.randomUUID().toString(), mapper, new Mappings(), indexSettings.get());
index = new DefaultIndex(client);
revisionIndex = new DefaultRevisionIndex(index, new TimestampProvider.Default(), mapper);
}
// apply mapper changes first
objectMapperConfigurator.accept(mapper);
// then mapping changes
revisionIndex.admin().updateMappings(new Mappings(types));
// then settings changes
revisionIndex.admin().updateSettings(indexSettings.get());
// then make sure we have all indexes ready for tests
revisionIndex.admin().create();
}
use of com.b2international.index.revision.DefaultRevisionIndex 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;
}
use of com.b2international.index.revision.DefaultRevisionIndex in project snow-owl by b2ihealthcare.
the class SnowOwlPlugin method preRun.
@Override
public void preRun(SnowOwlConfiguration configuration, Environment env) throws Exception {
if (env.isServer()) {
final ObjectMapper mapper = env.service(ObjectMapper.class);
final Index resourceIndex = Indexes.createIndex(RESOURCES_INDEX, mapper, new Mappings(ResourceDocument.class, VersionDocument.class), env.service(IndexSettings.class).forIndex(env.service(RepositoryConfiguration.class).getIndexConfiguration(), RESOURCES_INDEX));
final RevisionIndex revisionIndex = new DefaultRevisionIndex(resourceIndex, env.service(TimestampProvider.class), mapper);
env.services().registerService(ResourceRepository.class, new ResourceRepository(revisionIndex));
}
}
Aggregations