@Override protected List<String> validate(String defaultStudyStr, List<String> values, Integer release, VariantQueryParam param, String sessionId) throws CatalogException { if (release == null) { AbstractManager.MyResources<Sample> uids = catalogManager.getSampleManager().getUids(values, defaultStudyStr, sessionId); return uids.getResourceList().stream().map(Sample::getId).collect(Collectors.toList()); } else { return validate(defaultStudyStr, values, release, param, catalogManager.getSampleManager(), Sample::getId, Sample::getRelease, null, 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; }
@Override protected List<String> validate(String defaultStudyStr, List<String> values, Integer release, VariantQueryParam param, String sessionId) throws CatalogException { if (release == null) { AbstractManager.MyResources<Cohort> uids = catalogManager.getCohortManager().getUids(values, defaultStudyStr, sessionId); return uids.getResourceList().stream().map(Cohort::getId).collect(Collectors.toList()); } else { return validate(defaultStudyStr, values, release, param, catalogManager.getCohortManager(), Cohort::getId, Cohort::getRelease, null, sessionId); } } }
Arrays.asList(StringUtils.split(fileAclParams.getSample(), ",")), studyStr, sessionId); Query query = new Query(FileDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid) .collect(Collectors.toList())); QueryOptions options = new QueryOptions(QueryOptions.INCLUDE, FileDBAdaptor.QueryParams.UID.key()); .map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(File::getUid) .collect(Collectors.toList()), members, permissions, allFilePermissions, Entity.FILE); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(File::getUid) .collect(Collectors.toList()), members, permissions, Entity.FILE); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream().map(File::getUid).collect(Collectors.toList()), members, permissions, Entity.FILE); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream().map(File::getUid).collect(Collectors.toList()), members, null, Entity.FILE); default:
Set<Long> sampleIdsSet = sampleResource.getResourceList().stream().map(Sample::getUid).collect(Collectors.toSet());
.map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream() .map(ClinicalAnalysis::getUid) .collect(Collectors.toList()), members, permissions, allClinicalPermissions, Entity.CLINICAL_ANALYSIS); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream() .map(ClinicalAnalysis::getUid) .collect(Collectors.toList()), members, permissions, Entity.CLINICAL_ANALYSIS); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream() .map(ClinicalAnalysis::getUid).collect(Collectors.toList()), members, permissions, Entity.CLINICAL_ANALYSIS); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream() .map(ClinicalAnalysis::getUid).collect(Collectors.toList()), members, null, Entity.CLINICAL_ANALYSIS);
} else { AbstractManager.MyResources<File> resource = catalogManager.getFileManager().getUids(fileIdStrs, studyIdStr, sessionId); files = resource.getResourceList(); study = resource.getStudy();
.map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Job::getUid) .collect(Collectors.toList()), members, permissions, allJobPermissions, Entity.JOB); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Job::getUid) .collect(Collectors.toList()), members, permissions, Entity.JOB); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Job::getUid).collect(Collectors.toList()), members, permissions, Entity.JOB); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Job::getUid).collect(Collectors.toList()), members, null, Entity.JOB); default:
.map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Cohort::getUid) .collect(Collectors.toList()), members, permissions, allCohortPermissions, Entity.COHORT); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Cohort::getUid) .collect(Collectors.toList()), members, permissions, Entity.COHORT); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Cohort::getUid).collect(Collectors.toList()), members, permissions, Entity.COHORT); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Cohort::getUid).collect(Collectors.toList()), members, null, Entity.COHORT); default:
.map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Family::getUid) .collect(Collectors.toList()), members, permissions, allFamilyPermissions, Entity.FAMILY); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream().map(Family::getUid) .collect(Collectors.toList()), members, permissions, Entity.FAMILY); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Family::getUid).collect(Collectors.toList()), members, permissions, Entity.FAMILY); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Family::getUid).collect(Collectors.toList()), members, null, Entity.FAMILY); default:
.map(String::valueOf) .collect(Collectors.toList()); return authorizationManager.setAcls(resource.getStudy().getUid(), resource.getResourceList().stream() .map(Panel::getUid) .collect(Collectors.toList()), members, permissions, allPanelPermissions, Entity.PANEL); case ADD: return authorizationManager.addAcls(resource.getStudy().getUid(), resource.getResourceList().stream() .map(Panel::getUid) .collect(Collectors.toList()), members, permissions, Entity.PANEL); case REMOVE: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Panel::getUid) .collect(Collectors.toList()), members, permissions, Entity.PANEL); case RESET: return authorizationManager.removeAcls(resource.getResourceList().stream().map(Panel::getUid) .collect(Collectors.toList()), members, null, Entity.PANEL); default:
MyResources<Individual> resource = catalogManager.getIndividualManager().getUids( query.getAsStringList(FamilyDBAdaptor.QueryParams.MEMBERS.key()), study.getFqn(), sessionId); query.put(FamilyDBAdaptor.QueryParams.MEMBER_UID.key(), resource.getResourceList().stream().map(Individual::getUid) .collect(Collectors.toList())); } catch (CatalogException e) {
fileList.addAll(resource.getResourceList()); uidFileSet.addAll(resource.getResourceList().stream().map(File::getUid).collect(Collectors.toSet())); for (File file : resource.getResourceList()) { if (file.getType().equals(File.Type.DIRECTORY)) { pathList.add("~^" + file.getPath());
@Override protected List<String> validate(String defaultStudyStr, List<String> values, Integer release, VariantQueryParam param, String sessionId) throws CatalogException { if (release == null) { AbstractManager.MyResources<File> uids = catalogManager.getFileManager().getUids(values, defaultStudyStr, sessionId); return uids.getResourceList().stream().map(File::getName).collect(Collectors.toList()); } else { return validate(defaultStudyStr, values, release, param, catalogManager.getFileManager(), File::getName, file -> ((int) file.getIndex().getRelease()), file -> { if (file.getIndex() == null || file.getIndex().getStatus() == null || file.getIndex().getStatus().getName() == null || !file.getIndex().getStatus().getName().equals(Status.READY)) { throw new VariantQueryException("File '" + file.getName() + "' is not indexed"); } }, sessionId); } } }
private void fixQuery(Study study, Query query, String sessionId) throws CatalogException { if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()))) { MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.FATHER.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.FATHER.key()); query.append(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), resource.getResource().getUid()); } if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()))) { MyResource resource = getUid(query.getString(IndividualDBAdaptor.QueryParams.MOTHER.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.MOTHER.key()); query.append(IndividualDBAdaptor.QueryParams.MOTHER_UID.key(), resource.getResource().getUid()); } if (StringUtils.isNotEmpty(query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()))) { MyResources<Sample> resource = catalogManager.getSampleManager().getUids( query.getString(IndividualDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId); query.remove(IndividualDBAdaptor.QueryParams.SAMPLES.key()); query.append(IndividualDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid) .collect(Collectors.toList())); } }
private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException { if (query.containsKey("inputFiles")) { MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("inputFiles"), study.getFqn(), sessionId); query.put(JobDBAdaptor.QueryParams.INPUT_UID.key(), resource.getResourceList().stream().map(File::getUid) .collect(Collectors.toList())); query.remove("inputFiles"); } if (query.containsKey("outputFiles")) { MyResources<File> resource = catalogManager.getFileManager().getUids(query.getAsStringList("outputFiles"), study.getFqn(), sessionId); query.put(JobDBAdaptor.QueryParams.OUTPUT_UID.key(), resource.getResourceList().stream().map(File::getUid) .collect(Collectors.toList())); query.remove("outputFiles"); } }
void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException { if (StringUtils.isNotEmpty(query.getString(FileDBAdaptor.QueryParams.ID.key()))) { MyResources<File> uids = getUids(query.getAsStringList(FileDBAdaptor.QueryParams.ID.key()), study.getFqn(), sessionId); query.remove(FileDBAdaptor.QueryParams.ID.key()); query.put(FileDBAdaptor.QueryParams.UID.key(), uids.getResourceList().stream().map(File::getUid).collect(Collectors.toList())); } // The samples introduced could be either ids or names. As so, we should use the smart resolutor to do this. if (StringUtils.isNotEmpty(query.getString(FileDBAdaptor.QueryParams.SAMPLES.key()))) { MyResources<Sample> resource = catalogManager.getSampleManager().getUids( query.getAsStringList(FileDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId); query.put(FileDBAdaptor.QueryParams.SAMPLE_UIDS.key(), resource.getResourceList().stream().map(Sample::getUid) .collect(Collectors.toList())); query.remove(FileDBAdaptor.QueryParams.SAMPLES.key()); } }
private List<String> getSamplesFromIndividuals(MyResources<Individual> resource) throws CatalogDBException { // Look for all the samples belonging to the individual Query query = new Query() .append(IndividualDBAdaptor.QueryParams.STUDY_UID.key(), resource.getStudy().getUid()) .append(IndividualDBAdaptor.QueryParams.UID.key(), resource.getResourceList().stream().map(Individual::getUid) .collect(Collectors.toList())); QueryResult<Individual> individualQueryResult = individualDBAdaptor.get(query, new QueryOptions(QueryOptions.INCLUDE, IndividualDBAdaptor.QueryParams.SAMPLES.key())); List<String> sampleIds = new ArrayList<>(); for (Individual individual : individualQueryResult.getResult()) { sampleIds.addAll(individual.getSamples().stream().map(Sample::getId).collect(Collectors.toList())); } return sampleIds; }
private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException { if (query.containsKey(CohortDBAdaptor.QueryParams.SAMPLES.key())) { // First look for the sample ids. MyResources<Sample> samples = catalogManager.getSampleManager() .getUids(query.getAsStringList(CohortDBAdaptor.QueryParams.SAMPLES.key()), study.getFqn(), sessionId); query.remove(CohortDBAdaptor.QueryParams.SAMPLES.key()); query.append(CohortDBAdaptor.QueryParams.SAMPLE_UIDS.key(), samples.getResourceList().stream().map(Sample::getUid) .collect(Collectors.toList())); } }
private void fixQueryObject(Study study, Query query, String sessionId) throws CatalogException { // The individuals introduced could be either ids or names. As so, we should use the smart resolutor to do this. if (StringUtils.isNotEmpty(query.getString(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()))) { MyResources<Individual> resource = catalogManager.getIndividualManager().getUids( query.getAsStringList(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()), study.getFqn(), sessionId); query.put(SampleDBAdaptor.QueryParams.INDIVIDUAL_UID.key(), resource.getResourceList().stream().map(Individual::getUid) .collect(Collectors.toList())); query.remove(SampleDBAdaptor.QueryParams.INDIVIDUAL.key()); } }