KPMP-6538: added code to return the ontology id to cell type mapping#205
KPMP-6538: added code to return the ontology id to cell type mapping#205
Conversation
WalkthroughIntroduces Hubmap cell type mapping feature with new JPA entity, repository, and service for building ID-to-cell-type maps. Extends QueryController to expose GraphQL query endpoint. Updates build configuration and removes unused imports. Changes
Sequence DiagramsequenceDiagram
actor Client
participant GraphQL as GraphQL API
participant QueryController
participant HubmapCellTypeMappingService
participant HubmapOnotologyCellTypeRepository
participant Database
Client->>GraphQL: getHubmapTermMap()
GraphQL->>QueryController: getHubmapTermMap()
QueryController->>HubmapCellTypeMappingService: buildHubmapIdToCellTypeMap()
HubmapCellTypeMappingService->>HubmapOnotologyCellTypeRepository: findAll()
HubmapOnotologyCellTypeRepository->>Database: SELECT * FROM humbapOntology_celltype_v
Database-->>HubmapOnotologyCellTypeRepository: HubmapOntologyCellType list
HubmapOnotologyCellTypeRepository-->>HubmapCellTypeMappingService: cached result
HubmapCellTypeMappingService->>HubmapCellTypeMappingService: build Map<hubmapOntologyId, cell_type>
HubmapCellTypeMappingService-->>QueryController: Map<String, String>
QueryController-->>GraphQL: Map<String, String>
GraphQL-->>Client: JSON response
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/main/java/org/kpmp/cellType/HubmapOnotologyCellTypeRepository.java (1)
11-11: Rename repository type to fix spelling (Onotology→Ontology).The current type name is misspelled and will propagate across service/tests. Please rename to
HubmapOntologyCellTypeRepositoryfor maintainability.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (13)
.classpath.java-versionsrc/main/java/org/kpmp/QueryController.javasrc/main/java/org/kpmp/cellType/HubmapCellTypeMappingService.javasrc/main/java/org/kpmp/cellType/HubmapOnotologyCellTypeRepository.javasrc/main/java/org/kpmp/cellType/HubmapOntologyCellType.javasrc/main/java/org/kpmp/cellTypeSummary/ClusterHiearchyRepository.javasrc/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.javasrc/main/java/org/kpmp/umap/SNMetadataRepository2025.javasrc/main/resources/graphql/knowledge_environment.graphqlssrc/test/java/org/kpmp/QueryControllerTest.javasrc/test/java/org/kpmp/cellType/HubmapCellTypeMappingServiceTest.javasrc/test/java/org/kpmp/cellType/HubmapOntologyCellTypeTest.java
💤 Files with no reviewable changes (3)
- src/main/java/org/kpmp/cellTypeSummary/ClusterHierarchy.java
- src/main/java/org/kpmp/umap/SNMetadataRepository2025.java
- src/main/java/org/kpmp/cellTypeSummary/ClusterHiearchyRepository.java
| import jakarta.persistence.Table; | ||
|
|
||
| @Entity | ||
| @Table(name = "humbapOntology_celltype_v") |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "humbapOntology_celltype_v|hubmapOntology_celltype_v|hubmap_ontology_celltype_v|humbap|hubmap" --type-list | head -20Repository: KPMP/pegasus-data
Length of output: 450
🏁 Script executed:
# Check for SQL migrations, schema files, or database definitions
fd -e sql -e ddl -e schema | head -20Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Search for other `@Table` annotations to understand naming conventions
rg -n "@Table" -A 1 | head -40Repository: KPMP/pegasus-data
Length of output: 3356
🏁 Script executed:
rg "humbap|hubmap" -nRepository: KPMP/pegasus-data
Length of output: 1750
🏁 Script executed:
# Check the specific file mentioned in the review
cat -n src/main/java/org/kpmp/cellType/HubmapOntologyCellType.java | head -30Repository: KPMP/pegasus-data
Length of output: 927
🏁 Script executed:
# Search for SQL files or migrations that define tables
find . -type f \( -name "*.sql" -o -name "*.migration" -o -name "*schema*" \) | head -20Repository: KPMP/pegasus-data
Length of output: 43
Fix @Table name annotation: typo "humbap" should be "hubmap".
The table name humbapOntology_celltype_v contains a typo. The class name, field names, methods, service names, and cache key all consistently use hubmap, not humbap. This mismatch will cause JPA to fail mapping the entity to the database table at runtime.
| @@ -1,3 +1,5 @@ | |||
| scalar JSON | |||
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
rg -n "ExtendedScalars\\.Json|GraphQLScalarType|RuntimeWiringConfigurer|scalar\s+JSON|@SchemaMapping|GraphQLQueryResolver" --type graphql --type java --type kotlinRepository: KPMP/pegasus-data
Length of output: 92
🏁 Script executed:
# Also look for GraphQL configuration files and beans
fd -e java -e kt | xargs rg -l "Scalar|graphql.*config|GraphQLSchema" | head -20Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Search for scalar wiring patterns more broadly
rg -n "withScalar|addScalar|scalar.*Json|JSON.*Scalar" --type java --type ktRepository: KPMP/pegasus-data
Length of output: 87
🏁 Script executed:
# Search without file type restrictions
rg "ExtendedScalars|GraphQLScalarType|RuntimeWiringConfigurer|withScalar|addScalar" -iRepository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Find all GraphQL-related files and Java configuration files
fd -e graphqls -o -e java | grep -E "(config|scalar|graphql)" -iRepository: KPMP/pegasus-data
Length of output: 177
🏁 Script executed:
# Look at the directory structure
tree src/main/resources/graphql -L 2 2>/dev/null || find src/main/resources/graphql -type fRepository: KPMP/pegasus-data
Length of output: 143
🏁 Script executed:
# Search for GraphQL schema provider or wiring configuration
rg "GraphQL|Scalar|Schema" --type java -l | head -10Repository: KPMP/pegasus-data
Length of output: 236
🏁 Script executed:
# Search for GraphQL configuration classes and beans
rg "@Configuration|@Bean.*GraphQL|@Bean.*Scalar" -A 2Repository: KPMP/pegasus-data
Length of output: 235
🏁 Script executed:
# Look for GraphQL Java dependencies and setup
rg "graphql|GraphQL" -i | grep -E "(import|package|config|scalar)" | head -20Repository: KPMP/pegasus-data
Length of output: 628
🏁 Script executed:
# Examine the QueryController file
cat -n src/main/java/org/kpmp/QueryController.javaRepository: KPMP/pegasus-data
Length of output: 12114
🏁 Script executed:
# Search for pom.xml or gradle files to see GraphQL dependencies
find . -name "pom.xml" -o -name "build.gradle" -o -name "build.gradle.kts" | head -5Repository: KPMP/pegasus-data
Length of output: 75
🏁 Script executed:
# Read Application.java for GraphQL configuration
cat -n src/main/java/org/kpmp/Application.javaRepository: KPMP/pegasus-data
Length of output: 1275
🏁 Script executed:
# Read build.gradle for GraphQL dependencies
cat -n build.gradleRepository: KPMP/pegasus-data
Length of output: 3416
🏁 Script executed:
# Search for any GraphQL schema provider or wiring configuration
rg "SchemaProvider|RuntimeWiring|graphql.*config" -i -A 3Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Look for application properties/yml files
find . -name "application*.properties" -o -name "application*.yml" -o -name "application*.yaml"Repository: KPMP/pegasus-data
Length of output: 104
🏁 Script executed:
# Search for any schema loading configuration
rg "location.*graphql|graphql.*location|schema.*location" -iRepository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Check if there's a GraphQL configuration file elsewhere
find . -type f -name "*config*" -o -name "*graphql*" | grep -v node_modules | grep -v build | head -20Repository: KPMP/pegasus-data
Length of output: 163
🏁 Script executed:
# Look for CustomScalar or scalar registration patterns
rg "CustomScalar|Scalar.*String|@Scalar" -i -A 2Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Read application.properties
cat -n src/main/resources/application.propertiesRepository: KPMP/pegasus-data
Length of output: 1241
🏁 Script executed:
# Check if there's any GraphQL configuration in properties/yml
rg "graphql" -i src/main/resources/Repository: KPMP/pegasus-data
Length of output: 230
🏁 Script executed:
# Search for RuntimeWiring, SchemaProvider, or any Bean that might provide scalars
rg "RuntimeWiring|SchemaProvider|GraphQLSchema" -A 5Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Look for any files that might contain scalar configuration
find src -name "*.java" | xargs rg -l "Scalar|scalar" -iRepository: KPMP/pegasus-data
Length of output: 45
🏁 Script executed:
# Check if graphql-java-tools or spring-graphql auto-configures scalars
rg "JSON.*scalar|scalar.*JSON" -iRepository: KPMP/pegasus-data
Length of output: 130
🏁 Script executed:
# Search more broadly for any schema provider or configuration that might be loading/wiring scalars
rg -A 10 "extends.*SchemaProvider|implements.*SchemaProvider|SchemaFactory"Repository: KPMP/pegasus-data
Length of output: 43
🏁 Script executed:
# Check for any bean definitions or factory methods related to GraphQL schema
rg "@Bean|@Component|public.*GraphQL" -A 3 src/main/javaRepository: KPMP/pegasus-data
Length of output: 3631
🏁 Script executed:
# Look for any TypeDefinitionRegistry or SDL-to-schema conversion
rg "TypeDefinitionRegistry|SDLValidation|GraphQLSchema\\.newSchema"Repository: KPMP/pegasus-data
Length of output: 43
Add JSON scalar wiring to resolve schema at runtime.
The scalar JSON declaration requires explicit wiring to function. GraphQL Java does not auto-register custom scalars, and no scalar configuration was found in the codebase (no ExtendedScalars, GraphQLScalarType, or RuntimeWiringConfigurer). Without wiring, query execution will fail with scalar serialization errors.
Register the JSON scalar in your GraphQL schema provider or configuration bean using ExtendedScalars.Json or a custom GraphQLScalarType.
| getAtlasMessages: [AtlasMessages] | ||
| getExperimentalStrategyCountsByParticipant(redcapId: String!): [ParticipantRepoDataTypeInformation] | ||
| getParticipantClinicalDataset(redcapId: String!): ParticipantClinicalDataset | ||
| getHubmapTermMap(): JSON |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
GraphQL SDL field definition empty argument list () syntax specification
💡 Result:
In GraphQL SDL, a field’s argument definitions cannot use an empty parentheses list ().
Per the spec grammar:
FieldDefinition : ... Name ArgumentsDefinition? : Type ...(spec.graphql.org)ArgumentsDefinition : ( InputValueDefinition list )(spec.graphql.org)Symbol listmeans one or more occurrences (not zero). (spec.graphql.org)
So field(): String is invalid SDL; omit the parentheses instead: field: String.
Citations:
- 1: https://spec.graphql.org/June2018/
- 2: https://spec.graphql.org/June2018/
- 3: https://spec.graphql.org/June2018/
🏁 Script executed:
# Locate and read the GraphQL schema file
find . -name "knowledge_environment.graphqls" -type f | head -5Repository: KPMP/pegasus-data
Length of output: 120
🏁 Script executed:
# Read the GraphQL file to see the context around line 26
cat -n ./src/main/resources/graphql/knowledge_environment.graphqls | head -35Repository: KPMP/pegasus-data
Length of output: 2254
Remove empty argument list from GraphQL field definition.
getHubmapTermMap(): JSON violates GraphQL SDL specification. Per the spec, ArgumentsDefinition requires one or more arguments when parentheses are present; no-argument fields must omit the parentheses entirely.
Fix
- getHubmapTermMap(): JSON
+ getHubmapTermMap: JSON📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| getHubmapTermMap(): JSON | |
| getHubmapTermMap: JSON |
Summary by CodeRabbit
New Features
Chores