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();
}
}
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;
}
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"));
}
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();
}
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;
}
Aggregations