use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.
the class VariableSetService method toOpalTableFullName.
private List<String> toOpalTableFullName(Dataset dataset) {
if (dataset instanceof StudyDataset) {
OpalTable opalTable = ((StudyDataset) dataset).getSafeStudyTable();
return Lists.newArrayList(opalTable.getProject() + "." + opalTable.getTable());
} else {
HarmonizationDataset harmoDataset = (HarmonizationDataset) dataset;
// one for each study and harmo tables
List<String> tableNames = Lists.newArrayList();
tableNames.addAll(harmoDataset.getStudyTables().stream().map(st -> st.getProject() + "." + st.getTable()).collect(Collectors.toList()));
tableNames.addAll(harmoDataset.getHarmonizationTables().stream().map(ht -> ht.getProject() + "." + ht.getTable()).collect(Collectors.toList()));
return tableNames;
}
}
use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.
the class CollectedDatasetServiceTest method buildStudyDataset.
private StudyDataset buildStudyDataset() {
StudyDataset ds = new StudyDataset();
StudyTable st = new StudyTable();
st.setProject("proj");
st.setTable("tab");
ds.setStudyTable(st);
ds.setName(new LocalizedString(Locale.CANADA, "test"));
return ds;
}
use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.
the class DraftCollectedDatasetsResource method list.
/**
* Get all {@link org.obiba.mica.dataset.domain.StudyDataset}, optionally filtered by study.
*
* @param studyId can be null, in which case all datasets are returned
* @return
*/
@GET
@Path("/collected-datasets")
@Timed
public List<Mica.DatasetDto> list(@QueryParam("study") String studyId, @QueryParam("query") String query, @QueryParam("from") @DefaultValue("0") Integer from, @QueryParam("limit") Integer limit, @QueryParam("sort") @DefaultValue("id") String sort, @QueryParam("order") @DefaultValue("asc") String order, @QueryParam("filter") @DefaultValue("ALL") String filter, @Context HttpServletResponse response) {
long totalCount;
EntityStateFilter entityStateFilter = EntityStateFilter.valueOf(filter);
List<String> filteredIds = datasetService.getIdsByStateFilter(entityStateFilter);
Searcher.IdFilter accessibleIdFilter = AccessibleIdFilterBuilder.newBuilder().aclService(subjectAclService).resources(Lists.newArrayList("/draft/collected-dataset")).ids(filteredIds).build();
if (limit == null)
limit = MAX_LIMIT;
if (limit < 0)
throw new IllegalArgumentException("limit cannot be negative");
DocumentService.Documents<StudyDataset> datasets = draftCollectedDatasetService.find(from, limit, sort, order, studyId, query, null, null, accessibleIdFilter);
totalCount = datasets.getTotal();
response.addHeader("X-Total-Count", Long.toString(totalCount));
return datasets.getList().stream().map(dataset -> dtos.asDto(dataset, true)).collect(toList());
}
use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.
the class PublishedDatasetResource method alternativeStudyDataset.
private StudyDataset alternativeStudyDataset(String id, String project, String table) {
Dataset dataset = getDataset(id);
if (!(dataset instanceof StudyDataset))
throw NoSuchDatasetException.withId(id);
StudyDataset asStudyDataset = (StudyDataset) dataset;
asStudyDataset.getStudyTable().setProject(project);
asStudyDataset.getStudyTable().setTable(table);
return asStudyDataset;
}
use of org.obiba.mica.dataset.domain.StudyDataset in project mica2 by obiba.
the class DraftCollectedDatasetResource method update.
@PUT
public Response update(Mica.DatasetDto datasetDto, @Context UriInfo uriInfo, @Nullable @QueryParam("comment") String comment) {
checkPermission("/draft/collected-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 StudyDataset))
throw new IllegalArgumentException("A study dataset is expected");
datasetService.save((StudyDataset) dataset, comment);
return Response.noContent().build();
}
Aggregations