Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-6446 - Implement quotas management #2537

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ public OpenCGAResult<RgaKnockoutByGene> geneQuery(String studyStr, Query query,
.append(ACL_PARAM, userId + ":" + SamplePermissions.VIEW_VARIANTS)
.append(SampleDBAdaptor.QueryParams.INTERNAL_RGA_STATUS.key(), RgaIndex.Status.INDEXED)
.append(SampleDBAdaptor.QueryParams.ID.key(), includeIndividuals);
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
includeSampleIds = new HashSet<>((List<String>) authorisedSampleIdResult.getResults());
} else {
Expand All @@ -720,7 +720,7 @@ public OpenCGAResult<RgaKnockoutByGene> geneQuery(String studyStr, Query query,
// 3. Get list of sample ids for which the user has permissions
Query sampleQuery = new Query(ACL_PARAM, userId + ":" + SamplePermissions.VIEW_VARIANTS)
.append(SampleDBAdaptor.QueryParams.ID.key(), sampleIds);
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
// TODO: The number of samples to include could be really high
includeSampleIds = new HashSet<>((List<String>) authorisedSampleIdResult.getResults());
Expand All @@ -737,7 +737,7 @@ public OpenCGAResult<RgaKnockoutByGene> geneQuery(String studyStr, Query query,
logger.warn("Include only the samples that are actually necessary");
}

OpenCGAResult<?> sampleResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> sampleResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
includeSampleIds = new HashSet<>((List<String>) sampleResult.getResults());
}
Expand Down Expand Up @@ -831,7 +831,7 @@ public OpenCGAResult<KnockoutByVariant> variantQuery(String studyStr, Query quer
.append(ACL_PARAM, userId + ":" + SamplePermissions.VIEW_VARIANTS)
.append(SampleDBAdaptor.QueryParams.INTERNAL_RGA_STATUS.key(), RgaIndex.Status.INDEXED)
.append(SampleDBAdaptor.QueryParams.INDIVIDUAL_ID.key(), includeIndividuals);
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
includeSampleIds = new HashSet<>((List<String>) authorisedSampleIdResult.getResults());
} else {
Expand All @@ -850,7 +850,7 @@ public OpenCGAResult<KnockoutByVariant> variantQuery(String studyStr, Query quer
Query sampleQuery = new Query()
.append(ACL_PARAM, userId + ":" + SamplePermissions.VIEW_VARIANTS)
.append(SampleDBAdaptor.QueryParams.ID.key(), sampleIds);
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
includeSampleIds = new HashSet<>((List<String>) authorisedSampleIdResult.getResults());
}
Expand All @@ -865,7 +865,7 @@ public OpenCGAResult<KnockoutByVariant> variantQuery(String studyStr, Query quer
logger.warn("Include only the samples that are actually necessary");
}

OpenCGAResult<?> sampleResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> sampleResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
includeSampleIds = new HashSet<>((List<String>) sampleResult.getResults());
}
Expand Down Expand Up @@ -1773,7 +1773,7 @@ private Set<String> getAuthorisedSamples(String organizationId, String study, Se
query.put(ACL_PARAM, userId + ":" + StringUtils.join(otherPermissions, ","));
}

OpenCGAResult<?> distinct = catalogManager.getSampleManager().distinct(organizationId, study, SampleDBAdaptor.QueryParams.ID.key(),
OpenCGAResult<?> distinct = catalogManager.getSampleManager().distinct(study, SampleDBAdaptor.QueryParams.ID.key(),
query, token);
return distinct.getResults().stream().map(String::valueOf).collect(Collectors.toSet());
}
Expand Down Expand Up @@ -1874,7 +1874,7 @@ private Preprocess individualQueryPreprocess(String organizationId, Study study,
List<String> tmpValues = values.subList(currentBatch, Math.min(values.size(), batchSize + currentBatch));

sampleQuery.put(sampleQueryField, tmpValues);
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(organizationId, study.getFqn(),
OpenCGAResult<?> authorisedSampleIdResult = catalogManager.getSampleManager().distinct(study.getFqn(),
SampleDBAdaptor.QueryParams.ID.key(), sampleQuery, token);
authorisedSamples.addAll((Collection<? extends String>) authorisedSampleIdResult.getResults());

Expand Down
Loading
Loading