class SearchIndexDaoHelper {

    public void activateSearchIndex(SearchIndexEntity currentSearchIndexEntity)
    {
        // Get all the search index entities of the respective type.
        List<SearchIndexEntity> searchIndexEntities = searchIndexDao.getSearchIndexEntities(currentSearchIndexEntity.getType());

        // Exclude the current search index entity and de-activate the other entities.
        searchIndexEntities.stream().filter(searchIndexEntity -> !currentSearchIndexEntity.equals(searchIndexEntity)).collect(Collectors.toList())
            .forEach(searchIndexEntity -> {
                searchIndexEntity.setActive(Boolean.FALSE);
                searchIndexDao.saveAndRefresh(searchIndexEntity);
            });

        // Set the current search index entity to active.
        currentSearchIndexEntity.setActive(Boolean.TRUE);
        searchIndexDao.saveAndRefresh(currentSearchIndexEntity);
    }

}