Search in sources :

Example 1 with DatasetUpdatedEvent

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

the class CollectedDatasetService method index.

/**
 * Index the dataset
 *
 * @param id
 */
public void index(@NotNull String id) {
    StudyDataset dataset = findById(id);
    prepareForIndex(dataset);
    eventBus.post(new DatasetUpdatedEvent(dataset));
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 2 with DatasetUpdatedEvent

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

the class CollectedDatasetService method indexDatasets.

private void indexDatasets(Set<StudyDataset> publishedDatasets, List<StudyDataset> datasets, boolean mustIndexVariables) {
    datasets.forEach(dataset -> {
        try {
            eventBus.post(new DatasetUpdatedEvent(dataset));
            if (publishedDatasets.contains(dataset)) {
                prepareForIndex(dataset);
                Iterable<DatasetVariable> variables = mustIndexVariables && publishedDatasets.contains(dataset) ? wrappedGetDatasetVariables(dataset) : null;
                eventBus.post(new DatasetPublishedEvent(dataset, variables, getCurrentUsername()));
            }
        } catch (Exception e) {
            log.error(String.format("Error indexing dataset %s", dataset), e);
        }
    });
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) DatasetVariable(org.obiba.mica.dataset.domain.DatasetVariable) 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) NoSuchStudyException(org.obiba.mica.study.NoSuchStudyException)

Example 3 with DatasetUpdatedEvent

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

the class HarmonizedDatasetService method index.

/**
 * Index the dataset and associated variables.
 *
 * @param id
 */
public void index(@NotNull String id) {
    HarmonizationDataset dataset = findById(id);
    eventBus.post(new DatasetUpdatedEvent(dataset));
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 4 with DatasetUpdatedEvent

use of org.obiba.mica.dataset.event.DatasetUpdatedEvent 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)

Example 5 with DatasetUpdatedEvent

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

the class DatasetStateUpgrade method migrateDataset.

private <T extends AbstractGitPersistableService, T1 extends EntityStateRepository> void migrateDataset(Dataset dataset, T datasetService, T1 stateRepository, Supplier<EntityState> supplier) {
    EntityState state = datasetService.findEntityState(dataset, supplier);
    state.incrementRevisionsAhead();
    stateRepository.save(state);
    eventBus.post(new DatasetUpdatedEvent(dataset));
    gitService.save(dataset, "System upgrade");
    if (state.isPublished()) {
        datasetService.publishState(dataset.getId());
        eventBus.post(new DatasetPublishedEvent(dataset, null, null));
    }
}
Also used : DatasetUpdatedEvent(org.obiba.mica.dataset.event.DatasetUpdatedEvent) EntityState(org.obiba.mica.core.domain.EntityState) DatasetPublishedEvent(org.obiba.mica.dataset.event.DatasetPublishedEvent)

Aggregations

DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)6 DatasetPublishedEvent (org.obiba.mica.dataset.event.DatasetPublishedEvent)3 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)2 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)2 NoSuchEntityException (org.obiba.mica.NoSuchEntityException)2 NoSuchDatasetException (org.obiba.mica.dataset.NoSuchDatasetException)2 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)2 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)2 StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)2 NoSuchStudyException (org.obiba.mica.study.NoSuchStudyException)2 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 EntityState (org.obiba.mica.core.domain.EntityState)1 StudyDatasetState (org.obiba.mica.dataset.domain.StudyDatasetState)1 HarmonizationDatasetIndexedEvent (org.obiba.mica.dataset.event.HarmonizationDatasetIndexedEvent)1