Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

fuzhaoyuan
Copy link
Contributor

@fuzhaoyuan fuzhaoyuan commented Feb 27, 2025

Fix #11384

Migrate clinical-data to Clean Architecture with ClickHouse Support

Overview

This PR refactors clinical data endpoints from legacy architecture to clean architecture with ClickHouse support, as part of the broader backend migration to ClickHouse and clean architecture patterns.

Architecture Changes

Domain Layer - Record-Based Models

  • ClinicalData Record: Immutable record with multiple constructor overloads for different projection levels (ID, SUMMARY, DETAILED)
  • ClinicalAttribute Record: Nested domain object for clinical attribute metadata

Use Case Layer

  • GetClinicalDataUseCase: Main business logic with projection-based routing
  • GetClinicalDataMetaUseCase: Dedicated metadata/count operations

Repository Layer - Projection-Based Queries

New repository methods supporting different data retrieval levels:

  • getClinicalDataId() - Basic identifiers only
  • getClinicalDataSummary() - Identifiers + attribute values
  • getClinicalDataDetailed() - Complete data with clinical attribute metadata
  • getClinicalDataMeta() - Count operations only

MyBatis Layer - Constructor Mapping

  • Replaced <result> + <association> patterns with <constructor> mapping for Records
  • Separate ResultMaps and queries for each projection level
  • Fixed package name issue: clinical_dataclinical_attributes

REST Layer

  • ColumnarStoreClinicalDataController: New @Profile("clickhouse") controller supporting multiple projection types
  • DTO Layer: Response DTOs with MapStruct transformation including computed fields

MapStruct Integration

  • ClinicalDataMapper: Main mapper with computed uniqueKey fields
  • ClinicalAttributeMapper: Nested object transformation
  • Automatic nested mapping via uses = ClinicalAttributeMapper.class

Files Changed

Core New Architecture

  • domain/clinical_data/ClinicalData.java
  • domain/clinical_attributes/ClinicalAttribute.java
  • domain/clinical_data/repository/ClinicalDataRepository.java
  • domain/clinical_data/usecase/GetClinicalDataUseCase.java
  • domain/clinical_data/usecase/GetClinicalDataMetaUseCase.java
  • application/rest/vcolumnstore/ColumnarStoreClinicalDataController.java
  • application/rest/response/ClinicalDataDTO.java
  • application/rest/response/ClinicalAttributeDTO.java
  • application/rest/mapper/ClinicalDataMapper.java
  • application/rest/mapper/ClinicalAttributeMapper.java
  • MyBatis XML mapper (complete ResultMap and query restructuring)

Compatibility Updates

  • domain/clinical_data/usecase/ClinicalDataUseCases.java
  • domain/clinical_data/usecase/GetPatientClinicalDataUseCase.java
  • domain/clinical_data/usecase/GetSampleClinicalDataUseCase.java
  • domain/clinical_data/usecase/GetClinicalDataForXyPlotUseCase.java
  • domain/clinical_data/ClinicalDataType.java
  • application/rest/vcolumnstore/ColumnarStoreStudyViewController.java

Testing

Added comprehensive integration tests in ClickhouseClinicalDataMapperTest:

  • testDataCountConsistency(): Verifies data retrieval counts match metadata counts across different filters
  • testEmptyAndNullConditions(): Tests edge cases with non-existent IDs and attributes
  • testProjectionTypesConsistency(): Validates that different projection levels return consistent record counts while providing appropriate field sets

Migration Notes

  • New endpoints are isolated under @Profile("clickhouse")
  • Legacy endpoints remain unchanged
  • No breaking changes - new API returns consistent data format with existing endpoints
  • Part of broader ClickHouse and clean architecture migration

@fuzhaoyuan fuzhaoyuan self-assigned this Feb 27, 2025
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from 4758f70 to 3ef5db7 Compare February 27, 2025 19:00
@sonarqubecloud
Copy link

@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from 62abff3 to c9d7a32 Compare April 3, 2025 20:03
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from df74892 to 392691d Compare April 16, 2025 20:24
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch 5 times, most recently from 2e4a73d to abb7772 Compare May 19, 2025 19:00
@sonarqubecloud
Copy link

@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch 2 times, most recently from 5027914 to de9f107 Compare July 2, 2025 18:33
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from 956625b to 65409a8 Compare July 10, 2025 19:42
@fuzhaoyuan fuzhaoyuan marked this pull request as ready for review July 10, 2025 19:43
@fuzhaoyuan fuzhaoyuan requested review from alisman and haynescd July 10, 2025 20:26
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch 3 times, most recently from c5fb8db to f4f4630 Compare July 14, 2025 14:45
@sonarqubecloud
Copy link

@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from e349697 to ec29084 Compare July 15, 2025 19:20
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch 2 times, most recently from 8b255eb to 2f7aa88 Compare August 4, 2025 14:48
@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch 4 times, most recently from e615615 to e903864 Compare August 6, 2025 18:00
Copy link
Collaborator

@haynescd haynescd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!! Great job @fuzhaoyuan

just had a few comments

@fuzhaoyuan fuzhaoyuan force-pushed the master-clean-arch-clinical-data branch from c788637 to b407d4d Compare August 18, 2025 19:10
@alisman alisman merged commit e70d600 into cBioPortal:master Aug 20, 2025
20 of 21 checks passed
i-am-leslie pushed a commit to i-am-leslie/cbioportal that referenced this pull request Sep 1, 2025
…e support (cBioPortal#11425)

* Implement clinical-data in clean arch with ClickHouse support

* Add integration tests

* Fix ResultMap

* Rectify naming

* Address comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clickhouse-ify clinical-data endpoint

4 participants