use of org.obiba.mica.core.domain.BaseStudyTable in project mica2 by obiba.
the class RQLCriteriaOpalConverter method parseField.
private RQLFieldReferences parseField(String path) {
DatasetVariable.IdResolver resolver = DatasetVariable.IdResolver.from(path);
if (resolver.getType() == null || DatasetVariable.Type.Collected.equals(resolver.getType())) {
StudyDataset ds = collectedDatasetService.findById(resolver.getDatasetId());
BaseStudyTable studyTable = ds.getStudyTable();
BaseStudy study = studyService.findStudy(studyTable.getStudyId());
return new RQLFieldReferences(path, ds, studyTable, study, getDatasetVariableInternal(Indexer.PUBLISHED_VARIABLE_INDEX, Indexer.VARIABLE_TYPE, path));
} else if (DatasetVariable.Type.Dataschema.equals(resolver.getType())) {
HarmonizationDataset ds = harmonizedDatasetService.findById(resolver.getDatasetId());
BaseStudy study = studyService.findStudy(ds.getHarmonizationTable().getStudyId());
return new RQLFieldReferences(path, ds, ds.getBaseStudyTables(), study, getDatasetVariableInternal(Indexer.PUBLISHED_VARIABLE_INDEX, Indexer.VARIABLE_TYPE, path));
} else if (DatasetVariable.Type.Harmonized.equals(resolver.getType())) {
HarmonizationDataset ds = harmonizedDatasetService.findById(resolver.getDatasetId());
Optional<BaseStudyTable> studyTable = ds.getBaseStudyTables().stream().filter(st -> st.getStudyId().equals(resolver.getStudyId()) && st.getProject().equals(resolver.getProject()) && st.getTable().equals(resolver.getTable())).findFirst();
if (!studyTable.isPresent())
throw new IllegalArgumentException("Not a valid variable: " + path);
BaseStudy study = studyService.findStudy(studyTable.get().getStudyId());
return new RQLFieldReferences(path, ds, studyTable.get(), study, getDatasetVariableInternal(Indexer.PUBLISHED_HVARIABLE_INDEX, Indexer.HARMONIZED_VARIABLE_TYPE, path));
}
throw new IllegalArgumentException("Not a valid variable: " + path);
}
use of org.obiba.mica.core.domain.BaseStudyTable 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();
}
Aggregations