@Override public QueryResult<Panel> get(String studyStr, String entryStr, QueryOptions options, String sessionId) throws CatalogException { if (StringUtils.isNotEmpty(studyStr) && INSTALLATION_PANELS.equals(studyStr)) { Panel installationPanel = getInstallationPanel(entryStr); return new QueryResult<>(entryStr, -1, 1, 1, "", "", Collections.singletonList(installationPanel)); } else { return super.get(studyStr, entryStr, options, sessionId); } }
/** * Obtains the resource java beans containing the requested entries. * * @param entryStr Entry id in string format. * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param sessionId Session id of the user logged. * @return the resource java beans containing the requested entries. * @throws CatalogException when more than one entry is found. */ public AbstractManager.MyResources<R> getUids(String entryStr, @Nullable String studyStr, String sessionId) throws CatalogException { return getUids(Arrays.asList(entryStr.split(",")), studyStr, sessionId); }
/** * Groups the matching entries by some fields. * * @param studyStr study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param query Query object. * @param fields A field or a comma separated list of fields by which the results will be grouped in. * @param options QueryOptions object. * @param sessionId Session id of the user logged in. * @return A QueryResult object containing the results of the query grouped by the fields. * @throws CatalogException CatalogException */ public QueryResult groupBy(@Nullable String studyStr, Query query, String fields, QueryOptions options, String sessionId) throws CatalogException { if (StringUtils.isEmpty(fields)) { throw new CatalogException("Empty fields parameter."); } return groupBy(studyStr, query, Arrays.asList(fields.split(",")), options, sessionId); }
/** * Fetch the R object. * * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param entryStr Entry id to be fetched. * @param options QueryOptions object, like "include", "exclude", "limit" and "skip". * @param sessionId sessionId * @return All matching elements. * @throws CatalogException CatalogException. */ public QueryResult<R> get(String studyStr, String entryStr, QueryOptions options, String sessionId) throws CatalogException { Query query = new Query(); MyResource resources = getUid(entryStr, studyStr, sessionId); query.put("uid", resources.getResource().getUid()); return get(studyStr, query, options, sessionId); }
/** * Fetch all the R objects matching the query. * * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param entryList Comma separated list of entries to be fetched. * @param query Query object. * @param options QueryOptions object, like "include", "exclude", "limit" and "skip". * @param sessionId sessionId * @return All matching elements. * @throws CatalogException CatalogException. */ public List<QueryResult<R>> get(String studyStr, List<String> entryList, Query query, QueryOptions options, String sessionId) throws CatalogException { List<QueryResult<R>> resultList = new ArrayList<>(entryList.size()); query = ParamUtils.defaultObject(query, Query::new); MyResources<R> resource = getUids(entryList, studyStr, sessionId); List<Long> resourceIds = resource.getResourceList().stream().map(R::getUid).collect(Collectors.toList()); for (int i = 0; i < resourceIds.size(); i++) { Long entityId = resourceIds.get(i); Query queryCopy = new Query(query); queryCopy.put("uid", entityId); QueryResult<R> rQueryResult = get(studyStr, queryCopy, options, sessionId); rQueryResult.setId(entryList.get(i)); resultList.add(rQueryResult); } return resultList; }
/** * Obtains the resource java beans containing the requested entries. * * @param entryList List of entry ids in string format. * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param sessionId Session id of the user logged. * @return the resource java beans containing the requested entries. * @throws CatalogException when more than one entry is found. */ public AbstractManager.MyResources<R> getUids(List<String> entryList, @Nullable String studyStr, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); List<R> finalEntryList = new ArrayList<>(entryList.size()); for (String entryStr : entryList) { R entry = smartResolutor(study.getUid(), entryStr, userId); finalEntryList.add(entry); } return new MyResources<>(userId, study, finalEntryList); }
public List<QueryResult<R>> get(String studyStr, List<String> entryList, Query query, QueryOptions options, boolean silent, String sessionId) throws CatalogException { List<QueryResult<R>> resultList = new ArrayList<>(entryList.size()); query = ParamUtils.defaultObject(query, Query::new); for (String entry : entryList) { Query queryCopy = new Query(query); try { MyResource<R> resource = getUid(entry, studyStr, sessionId); queryCopy.put("uid", resource.getResource().getUid()); QueryResult<R> rQueryResult = get(resource.getStudy().getFqn(), queryCopy, options, sessionId); rQueryResult.setId(entry); resultList.add(rQueryResult); } catch (CatalogException e) { if (silent) { resultList.add(new QueryResult<>(entry, 0, 0, 0, "", e.toString(), new ArrayList<>(0))); } else { throw e; } } } return resultList; }
/** * Obtains the resource java bean containing the requested entries. * * @param entryStr Entry id in string format. * @param studyStr Study id in string format. Could be one of [id|user@aliasProject:aliasStudy|aliasProject:aliasStudy|aliasStudy]. * @param sessionId Session id of the user logged. * @return the resource java bean containing the requested entries. * @throws CatalogException when more than one entry is found. */ public AbstractManager.MyResource<R> getUid(String entryStr, @Nullable String studyStr, String sessionId) throws CatalogException { ParamUtils.checkObj(entryStr, "id"); String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); if (entryStr.contains(",")) { throw new CatalogException("More than one entry found"); } R entry = smartResolutor(study.getUid(), entryStr, userId); return new MyResource<>(userId, study, entry); }
protected final <T extends PrivateStudyUid> List<String> validate(String defaultStudyStr, List<String> values, Integer release, VariantQueryParam param, ResourceManager<T> manager, Function<T, String> getId, Function<T, Integer> getRelease, Consumer<T> valueValidator, String sessionId) throws CatalogException { List<QueryResult<T>> queryResults = manager.get(defaultStudyStr, values, null, RELEASE_OPTIONS, sessionId); List<String> validatedValues = new ArrayList<>(values.size()); for (QueryResult<T> queryResult : queryResults) { T value = queryResult.first(); if (valueValidator != null) { valueValidator.accept(value); } String id = getId.apply(value); validatedValues.add(id); checkRelease(release, getRelease.apply(value), param, id); } return validatedValues; } }