Search in sources :

Example 1 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class PublishedCollectedDatasetVariableResource method getVariableAggregations.

@GET
@Path("/aggregation")
@Timed
public Mica.DatasetVariableAggregationDto getVariableAggregations() {
    StudyDataset dataset = getDataset(StudyDataset.class, datasetId);
    StudyTable studyTable = dataset.getSafeStudyTable();
    Mica.DatasetVariableAggregationDto.Builder aggDto = // 
    Mica.DatasetVariableAggregationDto.newBuilder().setStudyTable(dtos.asDto(studyTable));
    try {
        return dtos.asDto(studyTable, datasetService.getVariableSummary(dataset, variableName).getWrappedDto()).build();
    } catch (Exception e) {
        log.warn("Unable to retrieve statistics: " + e.getMessage(), e);
        return dtos.asDto(studyTable, null).build();
    }
}
Also used : StudyTable(org.obiba.mica.core.domain.StudyTable) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) BadRequestException(javax.ws.rs.BadRequestException) IOException(java.io.IOException) Path(javax.ws.rs.Path) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET)

Example 2 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DatasetDtosTest method createStudyDataset.

private StudyDataset createStudyDataset() {
    StudyDataset studyDataset = new StudyDataset();
    studyDataset.setId("123");
    return studyDataset;
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 3 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DatasetDtosTest method test_study_dataset_dto.

@Test
public void test_study_dataset_dto() throws Exception {
    StudyDataset studyDataset = createStudyDataset();
    Mica.DatasetDto dto = datasetDtos.asDto(studyDataset);
    assertThat(dto.getId(), is("123"));
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Test(org.junit.Test)

Example 4 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DraftCollectedDatasetResource method updateModel.

@PUT
@Path("/model")
@Consumes(MediaType.APPLICATION_JSON)
public Response updateModel(String body) {
    checkPermission("/draft/collected-dataset", "EDIT");
    StudyDataset dataset = getDataset();
    dataset.setModel(Strings.isNullOrEmpty(body) ? new HashMap<>() : JSONUtils.toMap(body));
    datasetService.save(dataset);
    return Response.ok().build();
}
Also used : HashMap(java.util.HashMap) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset)

Example 5 with StudyDataset

use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.

the class DatasetDtos method fromDto.

@NotNull
public Dataset fromDto(Mica.DatasetDtoOrBuilder dto) {
    Dataset dataset = dto.hasExtension(Mica.HarmonizedDatasetDto.type) ? fromDto(dto.getExtension(Mica.HarmonizedDatasetDto.type)) : dto.hasExtension(Mica.CollectedDatasetDto.type) ? fromDto(dto.getExtension(Mica.CollectedDatasetDto.type)) : new StudyDataset();
    if (dto.hasId())
        dataset.setId(dto.getId());
    dataset.setAcronym(localizedStringDtos.fromDto(dto.getAcronymList()));
    dataset.setName(localizedStringDtos.fromDto(dto.getNameList()));
    dataset.setDescription(localizedStringDtos.fromDto(dto.getDescriptionList()));
    dataset.setEntityType(dto.getEntityType());
    dataset.setPublished(dto.getPublished());
    if (dto.getAttributesCount() > 0) {
        dto.getAttributesList().forEach(attributeDto -> dataset.addAttribute(attributeDtos.fromDto(attributeDto)));
    }
    if (dto.hasContent()) {
        dataset.setModel(JSONUtils.toMap(dto.getContent()));
    }
    return dataset;
}
Also used : StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) Dataset(org.obiba.mica.dataset.domain.Dataset) HarmonizationDataset(org.obiba.mica.dataset.domain.HarmonizationDataset) StudyDataset(org.obiba.mica.dataset.domain.StudyDataset) NotNull(javax.validation.constraints.NotNull)

Aggregations

StudyDataset (org.obiba.mica.dataset.domain.StudyDataset)27 Dataset (org.obiba.mica.dataset.domain.Dataset)10 StudyTable (org.obiba.mica.core.domain.StudyTable)6 HarmonizationDataset (org.obiba.mica.dataset.domain.HarmonizationDataset)6 Timed (com.codahale.metrics.annotation.Timed)5 DatasetVariable (org.obiba.mica.dataset.domain.DatasetVariable)5 Lists (com.google.common.collect.Lists)4 IOException (java.io.IOException)4 Inject (javax.inject.Inject)4 DatasetUpdatedEvent (org.obiba.mica.dataset.event.DatasetUpdatedEvent)4 Component (org.springframework.stereotype.Component)4 Strings (com.google.common.base.Strings)3 Collectors (java.util.stream.Collectors)3 Collectors.toList (java.util.stream.Collectors.toList)3 Path (javax.ws.rs.Path)3 Sets (com.google.common.collect.Sets)2 EventBus (com.google.common.eventbus.EventBus)2 java.util (java.util)2 HashMap (java.util.HashMap)2 List (java.util.List)2