@Override
public QueryResult<Interpretation> get(String studyStr, Query query, QueryOptions options, String sessionId) throws CatalogException {
query = ParamUtils.defaultObject(query, Query::new);
options = ParamUtils.defaultObject(options, QueryOptions::new);
String userId = catalogManager.getUserManager().getUserId(sessionId);
Study study = catalogManager.getStudyManager().resolveId(studyStr, userId);
query.append(InterpretationDBAdaptor.QueryParams.STUDY_UID.key(), study.getUid());
QueryResult<Interpretation> queryResult = interpretationDBAdaptor.get(query, options, userId);
List<Interpretation> results = new ArrayList<>(queryResult.getResult().size());
for (Interpretation interpretation : queryResult.getResult()) {
if (StringUtils.isNotEmpty(interpretation.getInterpretation().getClinicalAnalysisId())) {
try {
catalogManager.getClinicalAnalysisManager().smartResolutor(study.getUid(),
interpretation.getInterpretation().getClinicalAnalysisId(), userId);
results.add(interpretation);
} catch (CatalogException e) {
logger.debug("Removing interpretation " + interpretation.getUuid() + " from results. User " + userId + " does not have "
+ "proper permissions");
}
}
}
queryResult.setResult(results);
queryResult.setNumTotalResults(results.size());
queryResult.setNumResults(results.size());
return queryResult;
}