use of org.obiba.mica.dataset.domain.HarmonizationDataset 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));
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class HarmonizedDatasetService method saveInternal.
//
// Private methods
//
@SuppressWarnings("OverlyLongMethod")
private void saveInternal(HarmonizationDataset dataset, String comment) {
HarmonizationDataset saved = prepareSave(dataset);
HarmonizationDatasetState harmonizationDatasetState = findEntityState(dataset, HarmonizationDatasetState::new);
if (!dataset.isNew())
ensureGitRepository(harmonizationDatasetState);
harmonizationDatasetState.incrementRevisionsAhead();
harmonizationDatasetStateRepository.save(harmonizationDatasetState);
saved.setLastModifiedDate(DateTime.now());
harmonizationDatasetRepository.save(saved);
gitService.save(saved, comment);
helper.getPublishedVariables(saved);
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset 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.domain.HarmonizationDataset 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);
Map<String, List<DatasetVariable>> harmonizationVariables = populateHarmonizedVariablesMap(dataset);
eventBus.post(new DatasetPublishedEvent(dataset, wrappedGetDatasetVariables(dataset), harmonizationVariables, getCurrentUsername(), cascadingScope));
// helper.asyncBuildDatasetVariablesCache(dataset, harmonizationVariables);
} else {
unPublishState(id);
eventBus.post(new DatasetUnpublishedEvent(dataset));
}
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class PublishedDataschemaDatasetVariableResource method getVariableSummaries.
@GET
@Path("/summary")
@Timed
public List<Math.SummaryStatisticsDto> getVariableSummaries() {
ImmutableList.Builder<Math.SummaryStatisticsDto> builder = ImmutableList.builder();
HarmonizationDataset dataset = getDataset(HarmonizationDataset.class, datasetId);
dataset.getBaseStudyTables().forEach(table -> {
try {
String studyId = table.getStudyId();
builder.add(datasetService.getVariableSummary(dataset, variableName, studyId, table.getProject(), table.getTable()).getWrappedDto());
} catch (NoSuchVariableException | NoSuchValueTableException e) {
// case the study has not implemented this dataschema variable
builder.add(Math.SummaryStatisticsDto.newBuilder().setResource(variableName).build());
}
});
return builder.build();
}
Aggregations