use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DraftHarmonizedDatasetResource method update.
@PUT
@Timed
public Response update(Mica.DatasetDto datasetDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
checkPermission("/draft/harmonized-dataset", "EDIT");
if (!datasetDto.hasId() || !datasetDto.getId().equals(id))
throw new IllegalArgumentException("Not the expected dataset id");
Dataset dataset = dtos.fromDto(datasetDto);
if (!(dataset instanceof HarmonizationDataset))
throw new IllegalArgumentException("An harmonization dataset is expected");
datasetService.save((HarmonizationDataset) dataset, comment);
return Response.noContent().build();
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DraftHarmonizedDatasetResource method getFacets.
@POST
@Path("/facets")
public List<Search.QueryResultDto> getFacets(Search.QueryTermsDto query) {
checkPermission("/draft/harmonized-dataset", "VIEW");
ImmutableList.Builder<Search.QueryResultDto> builder = ImmutableList.builder();
HarmonizationDataset dataset = getDataset();
for (BaseStudyTable table : dataset.getBaseStudyTables()) {
builder.add(datasetService.getFacets(query, table));
}
return builder.build();
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DraftHarmonizedDatasetsResource method create.
@POST
@Path("/harmonized-datasets")
@Timed
@RequiresPermissions({ "/draft/harmonized-dataset:ADD" })
public Response create(Mica.DatasetDto datasetDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
Dataset dataset = dtos.fromDto(datasetDto);
if (!(dataset instanceof HarmonizationDataset))
throw new IllegalArgumentException("An harmonization dataset is expected");
datasetService.save((HarmonizationDataset) dataset, comment);
return Response.created(uriInfo.getBaseUriBuilder().segment("draft", "harmonized-dataset", dataset.getId()).build()).build();
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class HarmonizationDatasetUpgrade method execute.
@Override
public void execute(Version version) {
log.info("Executing harmonization datasets network tables upgrade");
List<HarmonizationDataset> datasets = harmonizationDatasetRepository.findAll();
datasets.forEach(dataset -> {
int i = 0;
for (StudyTable st : dataset.getStudyTables()) {
st.setWeight(i++);
}
});
harmonizationDatasetRepository.save(datasets);
eventBus.post(new IndexDatasetsEvent());
}
use of org.obiba.mica.dataset.domain.HarmonizationDataset in project mica2 by obiba.
the class DatasetDtos method fromDto.
private Dataset fromDto(@NotNull Mica.HarmonizedDatasetDto dto) {
Assert.notNull(dto, "HarmonizationDataset dt cannot be null.");
HarmonizationDataset harmonizationDataset = new HarmonizationDataset();
if (dto.getStudyTablesCount() > 0) {
dto.getStudyTablesList().forEach(tableDto -> harmonizationDataset.addStudyTable(fromDto(tableDto)));
}
if (dto.getHarmonizationTablesCount() > 0) {
dto.getHarmonizationTablesList().forEach(tableDto -> harmonizationDataset.addHarmonizationTable(fromDto(tableDto)));
}
if (dto.hasHarmonizationTable()) {
HarmonizationStudyTable harmonizationLink = new HarmonizationStudyTable();
harmonizationLink.setProject(dto.getHarmonizationTable().getProject());
harmonizationLink.setTable(dto.getHarmonizationTable().getTable());
harmonizationLink.setStudyId(dto.getHarmonizationTable().getStudyId());
harmonizationLink.setPopulationId(dto.getHarmonizationTable().getPopulationId());
harmonizationDataset.setHarmonizationTable(harmonizationLink);
}
return harmonizationDataset;
}
Aggregations