-
-
Notifications
You must be signed in to change notification settings - Fork 748
Clickhouse only db #11704
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
Open
alisman
wants to merge
32
commits into
master
Choose a base branch
from
demo-clickhouse-only-db
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Clickhouse only db #11704
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
85b47c2
Update initial Mappers to fix Patient View Page
haynescd fd83576
Fix queries to support cbioportal with clickhouse only
haynescd 32f527c
Fix mybatis xml
haynescd 611aa91
Remove GeneMemoizer call
haynescd de029ad
Optimize PatientMapper IN clauses for ClickHouse JDBC performance (#1…
alisman 000498c
improve molecular data query (#11669)
onursumer c284181
add back clinical data mapper queries for clinical table (#11700)
gblaih 3fd4662
Optimize ClinicalAttributeMapper sample ID queries for ClickHouse JDB…
alisman 688a552
Comprehensive ArrayTypeHandler optimization for ClickHouse JDBC perfo…
alisman 94aaee9
Fix capitalization of field names in sql
alisman 6189f4f
make sure treatment mapper string comparisons are case-insensitive (#…
onursumer e5fdccf
fix broken resource data endpoints (#11719)
onursumer c90509b
improve generic_assay_data sql performance (#11706)
onursumer 528230a
Refactor GenePanelServiceImpl to use batch repository call
alisman 16ade59
Refactor getMutationsInMultipleMolecularProfiles to use single query
alisman 9768d62
Refactor fetchStructuralVariants to use single query
alisman 2503494
Fix spotless issues
alisman aa133a8
fix broken getPatientClinicalDataFromStudyViewFilter mapping (#11710)
onursumer 4fb4d04
fix high security vulnerabilities (#11717)
gblaih 2e5d568
Refactor Clickhouse enrichments endpoint to avoid redundant counting …
alisman 72583b3
Optimize discrete copy number queries by reordering JOINs (#11740)
alisman b764fe6
Add studyExists method and fix ClickHouse GROUP BY issue (#11746)
alisman d89e0f0
truncate genetic alteration values for molecular data queries (#11734)
onursumer bfd1299
In the molecular data truncation SQL, add case for zero values (#11751)
alisman c2e4117
Fix column store study endpoint (#11747)
haynescd 9387415
Fix sample list error (clickhouse-only) (#11753)
dippindots 2ba9202
Fix legacy core tests after changes to legacy mapper for clickhouse-o…
onursumer 95cb175
Use mutation_derived table in mutation mapper to avoid joins (#11786)
alisman 84a22ab
Merge remote-tracking branch 'upstream/master' into demo-clickhouse-o…
alisman 2164b45
Fix upper case column issues in merged code
alisman d2e6aa4
fix a potential null pointer exception with the VariantCountMyBatisRe…
onursumer 536b22f
Rename combineStudyAndPatientIds to combineStudyAndEntityIds (#11780)
alisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
379 changes: 209 additions & 170 deletions
379
src/main/java/org/cbioportal/application/security/CancerStudyPermissionEvaluator.java
Large diffs are not rendered by default.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
src/main/java/org/cbioportal/application/security/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # 🛡️ Study Permission Evaluator | ||
|
|
||
| This class is an implementation of the **Spring Security `PermissionEvaluator`** interface. Its purpose is to enforce fine-grained access control across the application's data model, ensuring that authenticated users have the required `AccessLevel` to interact with specific cancer research entities. | ||
|
|
||
| Access control is centrally determined at the **`CancerStudy`** level. All other related entities (profiles, lists, patients) inherit their access policy from their associated study. | ||
|
|
||
| *** | ||
|
|
||
| ## Core Functionality | ||
|
|
||
| The evaluator implements two primary permission checking methods: | ||
|
|
||
| ### 1. Object-Based Permission Check | ||
|
|
||
| | Method | `hasPermission(Authentication, Object targetDomainObject, Object permission)` | | ||
| | :--- | :--- | | ||
| | **Purpose** | Checks permission on a **single, loaded domain object instance** (e.g., a `MolecularProfile` object). | | ||
| | **Process** | It uses `extractCancerStudy()` to resolve the target object back to its parent `CancerStudy` and delegates the final access check to a business logic method (`hasAccessToCancerStudy`). | | ||
|
|
||
| ### 2. ID-Based Permission Check | ||
|
|
||
| | Method | `hasPermission(Authentication, Serializable targetId, String targetType, Object permission)` | | ||
| | :--- | :--- | | ||
| | **Purpose** | Checks permission on resources identified by an **ID, a collection of IDs, or a filter object**. | | ||
| | **Process** | It resolves the IDs/filter into a collection of unique `CancerStudy` objects. It then enforces an **all-or-nothing** policy: access is granted only if the user has permission to **every single** associated `CancerStudy`. | | ||
|
|
||
| *** | ||
|
|
||
| ## Supported Target Types | ||
|
|
||
| The evaluator is designed to handle access checks for objects and identifiers spanning the core data model: | ||
|
|
||
| | Target Object/ID Type | Description | | ||
| | :--- | :--- | | ||
| | `CancerStudy` | Direct object or ID. The root entity for access control. | | ||
| | `MolecularProfile` | Object or ID. Access is determined by its parent study. | | ||
| | `SampleList` | Object or ID. Access is determined by its parent study. | | ||
| | `Patient` | Direct object. Access is determined by its parent study. | | ||
| | `Collection<...Ids>` | A bulk check on a collection of any supported ID type. | | ||
| | `*Filter` Objects | Various application-specific filter classes (e.g., `SampleFilter`, `StudyViewFilter`) that implicitly reference a set of `CancerStudy` IDs. | | ||
|
|
||
| *** | ||
|
|
||
| ## Dependencies | ||
|
|
||
| * **`Authentication`**: The standard Spring Security principal representing the logged-in user. | ||
| * **`cacheMapUtil`**: A utility used for high-performance retrieval of domain objects (like `CancerStudy`, `MolecularProfile`) by their string identifiers, crucial for efficient ID-based permission checks. | ||
| * **`AccessLevel`**: An external enumeration (cast from the `permission` object) defining the specific level of access requested (e.g., `READ`, `WRITE`). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,11 +23,8 @@ | |
|
|
||
| package org.cbioportal.legacy.persistence.mybatis; | ||
|
|
||
| import static java.util.Arrays.asList; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.stream.Collectors; | ||
| import org.cbioportal.legacy.model.GeneFilterQuery; | ||
| import org.cbioportal.legacy.model.StructuralVariant; | ||
| import org.cbioportal.legacy.model.StructuralVariantFilterQuery; | ||
|
|
@@ -52,20 +49,8 @@ public List<StructuralVariant> fetchStructuralVariants( | |
| if (molecularProfileIds == null || molecularProfileIds.isEmpty()) { | ||
| return new ArrayList<>(); | ||
| } | ||
| return molecularProfileCaseIdentifierUtil | ||
| .getGroupedCasesByMolecularProfileId(molecularProfileIds, sampleIds) | ||
| .entrySet() | ||
| .stream() | ||
| .flatMap( | ||
| entry -> | ||
| structuralVariantMapper | ||
| .fetchStructuralVariants( | ||
| asList(entry.getKey()), | ||
| new ArrayList<>(entry.getValue()), | ||
| entrezGeneIds, | ||
| structuralVariantQueries) | ||
| .stream()) | ||
| .collect(Collectors.toList()); | ||
| return structuralVariantMapper.fetchStructuralVariants( | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change was made because fetching all profiles at once is much more performant. it is always true that sampleId collection and molecular profile collection will be of equal length |
||
| molecularProfileIds, sampleIds, entrezGeneIds, structuralVariantQueries); | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
44 changes: 44 additions & 0 deletions
44
src/main/java/org/cbioportal/legacy/persistence/mybatis/util/SqlUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package org.cbioportal.legacy.persistence.mybatis.util; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** Utility class for SQL operations in MyBatis mappers */ | ||
| public class SqlUtils { | ||
|
|
||
| /** | ||
| * Combines study IDs and patient/sample IDs into unique keys for efficient array parameter usage. | ||
| * This helps optimize ClickHouse JDBC performance by reducing the number of prepared statement | ||
| * parameters. | ||
| * | ||
| * @param studyIds List of study identifiers | ||
| * @param entityIds List of patient or sample identifiers (corresponding to studyIds by index) | ||
| * @return Array of combined unique keys in format "studyId:entityId" | ||
| */ | ||
| public static String[] combineStudyAndEntityIds(List<String> studyIds, List<String> entityIds) { | ||
| if (studyIds == null || entityIds == null || studyIds.size() != entityIds.size()) { | ||
| throw new IllegalArgumentException( | ||
| "studyIds and entityIds must be non-null and have the same size"); | ||
| } | ||
|
|
||
| String[] combinedKeys = new String[studyIds.size()]; | ||
| for (int i = 0; i < studyIds.size(); i++) { | ||
| combinedKeys[i] = studyIds.get(i) + ":" + entityIds.get(i); | ||
| } | ||
|
|
||
| return combinedKeys; | ||
| } | ||
|
|
||
| /** | ||
| * Converts a List of strings to a String array for use with ArrayTypeHandler. ArrayTypeHandler | ||
| * requires Java arrays, not ArrayList objects. | ||
| * | ||
| * @param list List of strings to convert | ||
| * @return Array of strings | ||
| */ | ||
| public static String[] listToArray(List<String> list) { | ||
| if (list == null) { | ||
| return null; | ||
| } | ||
| return list.toArray(new String[0]); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this empty file?