use of org.obiba.mica.dataset.event.DatasetPublishedEvent 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());
}
use of org.obiba.mica.dataset.event.DatasetPublishedEvent in project mica2 by obiba.
the class HarmonizedDatasetService method indexHarmonizedVariables.
private void indexHarmonizedVariables(HarmonizationDataset dataset) {
if (!dataset.getBaseStudyTables().isEmpty()) {
dataset.getBaseStudyTables().forEach(studyTable -> {
Future<Iterable<DatasetVariable>> future = helper.asyncGetDatasetVariables(() -> getDatasetVariables(dataset, studyTable));
try {
Iterable<DatasetVariable> harmonizationVariables = future.get();
eventBus.post(new DatasetPublishedEvent(dataset, null, harmonizationVariables, getCurrentUsername()));
} catch (InterruptedException e) {
if (e.getCause() instanceof MagmaRuntimeException) {
throw new DatasourceNotAvailableException(e.getCause());
}
throw Throwables.propagate(e.getCause());
} catch (ExecutionException e) {
throw Throwables.propagate(e);
}
});
}
}
use of org.obiba.mica.dataset.event.DatasetPublishedEvent in project mica2 by obiba.
the class HarmonizedDatasetService method indexByIds.
public void indexByIds(List<String> ids, boolean mustIndexVariables) {
List<String> includeIds = ids.isEmpty() ? findAllIds() : ids;
List<HarmonizationDataset> datasets = findAllDatasets(includeIds);
HashSet<HarmonizationDataset> publishedDatasets = Sets.newHashSet(findPublishedDatasets(includeIds));
datasets.forEach(dataset -> {
try {
eventBus.post(new DatasetUpdatedEvent(dataset));
if (publishedDatasets.contains(dataset)) {
if (mustIndexVariables && publishedDatasets.contains(dataset)) {
eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), null, getCurrentUsername()));
indexHarmonizedVariables(dataset);
}
}
} catch (Exception e) {
log.error(String.format("Error indexing dataset %s", dataset), e);
}
});
}
use of org.obiba.mica.dataset.event.DatasetPublishedEvent in project mica2 by obiba.
the class HarmonizedDatasetService method publish.
/**
* Apply dataset publication flag.
*
* @param id
* @param published
*/
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") })
public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) {
HarmonizationDataset dataset = findById(id);
helper.evictCache(dataset);
if (published) {
checkIsPublishable(dataset);
publishState(id);
eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), null, getCurrentUsername(), cascadingScope));
indexHarmonizedVariables(dataset);
} else {
unPublishState(id);
eventBus.post(new DatasetUnpublishedEvent(dataset));
}
}
use of org.obiba.mica.dataset.event.DatasetPublishedEvent in project mica2 by obiba.
the class CollectedDatasetService method publish.
/**
* Apply dataset publication flag.
*
* @param id
* @param published
*/
@Caching(evict = { @CacheEvict(value = "aggregations-metadata", key = "'dataset'") })
public void publish(@NotNull String id, boolean published, PublishCascadingScope cascadingScope) {
StudyDataset dataset = findById(id);
helper.evictCache(dataset);
if (published) {
checkIsPublishable(dataset);
Iterable<DatasetVariable> variables = wrappedGetDatasetVariables(dataset);
publishState(id);
prepareForIndex(dataset);
eventBus.post(new DatasetPublishedEvent(dataset, variables, getCurrentUsername(), cascadingScope));
// helper.asyncBuildDatasetVariablesCache(dataset, variables);
} else {
unPublishState(id);
eventBus.post(new DatasetUnpublishedEvent(dataset));
}
}
Aggregations