Search in sources :

Example 1 with HarmonizationDatasetIndexedEvent

use of org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent in project mica2 by obiba.

the class HarmonizedDatasetService method indexAll.

public void indexAll(boolean mustIndexVariables) {
    Set<HarmonizationDataset> publishedDatasets = Sets.newHashSet(findAllPublishedDatasets());
    findAllDatasets().forEach(dataset -> {
        try {
            eventBus.post(new DatasetUpdatedEvent(dataset));
            if (publishedDatasets.contains(dataset)) {
                Map<String, List<DatasetVariable>> harmonizationVariables = mustIndexVariables && publishedDatasets.contains(dataset) ? populateHarmonizedVariablesMap(dataset) : null;
                Iterable<DatasetVariable> datasetVariables = mustIndexVariables && publishedDatasets.contains(dataset) ? wrappedGetDatasetVariables(dataset) : null;
                eventBus.post(new DatasetPublishedEvent(dataset, datasetVariables, harmonizationVariables, getCurrentUsername()));
            }
        } catch (Exception e) {
            log.error(String.format("Error indexing dataset %s", dataset), e);
        }
    });
    eventBus.post(new HarmonizationDatasetIndexedEvent());
}
Also used : HarmonizationDatasetIndexedEvent(org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent) DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent) NoSuchVariableException(org.obiba.magma.NoSuchVariableException) NoSuchDatasetException(org.obiba.mica.dataset.NoSuchDatasetException) NoSuchEntityException(org.obiba.mica.NoSuchEntityException) NoSuchValueTableException(org.obiba.magma.NoSuchValueTableException) MagmaRuntimeException(org.obiba.magma.MagmaRuntimeException) NoSuchStudyException(org.obiba.mica.study.NoSuchStudyException) ExecutionException(java.util.concurrent.ExecutionException) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Aggregations

List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 Collectors.toList (java.util.stream.Collectors.toList)1 MagmaRuntimeException (org.obiba.magma.MagmaRuntimeException)1 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)1 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)1 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)1 NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)1 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)1 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)1 DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)1 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)1 HarmonizationDatasetIndexedEvent (org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent)1 NoSuchStudyException (org.obiba.mica.study.NoSuchStudyException)1