Search in sources :

Example 11 with HarmonizationDataset

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();
}
Also used : Dataset(org.obiba.mica.dataset.domain.Dataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Timed(com.codahale.metrics.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 12 with HarmonizationDataset

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();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) BaseStudyTable(org.obiba.mica.core.domain.BaseStudyTable) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Example 13 with HarmonizationDataset

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();
}
Also used : Dataset(org.obiba.mica.dataset.domain.Dataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) Path(javax.ws.rs.Path) RequiresPermissions(org.apache.shiro.authz.annotation.RequiresPermissions) POST(javax.ws.rs.POST) Timed(com.codahale.metrics.annotation.Timed)

Example 14 with HarmonizationDataset

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());
}
Also used : StudyTable(org.obiba.mica.core.domain.StudyTable) IndexDatasetsEvent(org.obiba.mica.dataset.event.IndexDatasetsEvent) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Example 15 with HarmonizationDataset

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;
}
Also used : HarmonizationStudyTable(org.obiba.mica.core.domain.HarmonizationStudyTable) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset)

Aggregations

HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)28 Path (javax.ws.rs.Path)10 NoSuchVariableException (org.obiba.magma.NoSuchVariableException)9 GET (javax.ws.rs.GET)8 NoSuchValueTableException (org.obiba.magma.NoSuchValueTableException)8 Timed (com.codahale.metrics.annotation.Timed)7 ImmutableList (com.google.common.collect.ImmutableList)7 IOException (java.io.IOException)4 List (java.util.List)4 BaseStudyTable (org.obiba.mica.core.domain.BaseStudyTable)4 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)4 Mica (org.obiba.mica.web.model.Mica)4 Lists (com.google.common.collect.Lists)3 Inject (javax.inject.Inject)3 HarmonizationStudyTable (org.obiba.mica.core.domain.HarmonizationStudyTable)3 StudyTable (org.obiba.mica.core.domain.StudyTable)3 Dataset (org.obiba.mica.dataset.domain.Dataset)3 Strings (com.google.common.base.Strings)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Collection (java.util.Collection)2