use of org.obiba.mica.dataset.domain.DatasetVariable 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);
}
});
}
use of org.obiba.mica.dataset.domain.DatasetVariable 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));
}
}
use of org.obiba.mica.dataset.domain.DatasetVariable 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.DatasetVariable in project mica2 by obiba.
the class PublishedCollectedDatasetVariableResource method getContingencyCsv.
@GET
@Path("/contingency/_export")
@Produces("text/csv")
@Timed
public Response getContingencyCsv(@QueryParam("by") String crossVariable) throws IOException {
Pair<DatasetVariable, DatasetVariable> variables = getContingencyVariables(crossVariable);
ByteArrayOutputStream res = new CsvContingencyWriter(variables.getFirst(), variables.getSecond()).write(getContingencyDto(variables.getFirst(), variables.getSecond()));
return Response.ok(res.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"contingency-table-%s-%s.csv\"", variableName, crossVariable)).build();
}
use of org.obiba.mica.dataset.domain.DatasetVariable in project mica2 by obiba.
the class PublishedCollectedDatasetVariableResource method getContingencyExcel.
@GET
@Path("/contingency/_export")
@Produces("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
@Timed
public Response getContingencyExcel(@QueryParam("by") String crossVariable) throws IOException {
Pair<DatasetVariable, DatasetVariable> variables = getContingencyVariables(crossVariable);
ByteArrayOutputStream res = new ExcelContingencyWriter(variables.getFirst(), variables.getSecond()).write(getContingencyDto(variables.getFirst(), variables.getSecond()));
return Response.ok(res.toByteArray()).header("Content-Disposition", String.format("attachment; filename=\"contingency-table-%s-%s.xlsx\"", variableName, crossVariable)).build();
}
Aggregations