diff --git a/.github/workflows/build-gradle-project.yml b/.github/workflows/build-gradle-project.yml index 44877ec..d0db8b0 100644 --- a/.github/workflows/build-gradle-project.yml +++ b/.github/workflows/build-gradle-project.yml @@ -21,12 +21,12 @@ jobs: uses: actions/checkout@v3 - uses: actions/setup-java@v3 with: - java-version: '8' + java-version: '21' distribution: 'temurin' - name: Setup Gradle uses: gradle/gradle-build-action@v2 with: - gradle-version: 7.4 + gradle-version: 8.5 - name: Login to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a diff --git a/src/main/java/org/kpmp/Query.java b/src/main/java/org/kpmp/Query.java index fe496fb..a2f6bf7 100755 --- a/src/main/java/org/kpmp/Query.java +++ b/src/main/java/org/kpmp/Query.java @@ -29,6 +29,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.QueryMapping; import org.springframework.stereotype.Component; import org.springframework.stereotype.Controller; @@ -71,7 +72,7 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe } @QueryMapping - public List autocomplete(String searchTerm) throws IOException, Exception { + public List autocomplete(@Argument String searchTerm) throws IOException, Exception { return autocompleteService.query(searchTerm); } @@ -81,8 +82,8 @@ public CellTypeHierarchy cellTypeHierarchy() throws IOException { } @QueryMapping - public List geneExpressionSummary(String dataType, String geneSymbol, - String cellType, String tissueType) throws IOException { + public List geneExpressionSummary(@Argument String dataType, @Argument String geneSymbol, + @Argument String cellType, @Argument String tissueType) throws IOException { List results = new ArrayList<>(); if (cellType.isEmpty()) { results = geneExpressionSummaryService.getByDataTypeTissueTypeAndGene(dataType, geneSymbol, tissueType); @@ -94,12 +95,12 @@ public List geneExpressionSummary(String dataTy } @QueryMapping - public List getClusterHieararchies(String cellType) throws IOException { + public List getClusterHieararchies(@Argument String cellType) throws IOException { return clusterHierarchyService.findClustersByCellType(cellType); } @QueryMapping - public PlotData getUmapPlotData(String dataType, String geneSymbol, String tissueType) throws Exception { + public PlotData getUmapPlotData(@Argument String dataType, @Argument String geneSymbol, @Argument String tissueType) throws Exception { try { return umapService.getPlotData(dataType, geneSymbol, tissueType); } catch (Exception e) { @@ -129,7 +130,7 @@ public List getSummaryData() throws Exception { } @QueryMapping - public List dataTypesForConcept(String geneSymbol, String clusterName) throws Exception { + public List dataTypesForConcept(@Argument String geneSymbol, @Argument String clusterName) throws Exception { if (geneSymbol != null && !geneSymbol.isEmpty()) { return geneExpressionSummaryService.findDataTypesByGene(geneSymbol); } else if (clusterName != null && !clusterName.isEmpty()) { @@ -140,7 +141,7 @@ public List dataTypesForConcept(String geneSymbol, String clusterName) t } @QueryMapping - public RTExpressionByTissueType getRTGeneExpressionByTissue(String comparisonType, String geneSymbol) + public RTExpressionByTissueType getRTGeneExpressionByTissue(@Argument String comparisonType, @Argument String geneSymbol) throws Exception { try { return rtExpressionDataService.getByComparisonTypeAndGeneSymbolPerTissue(comparisonType, geneSymbol); @@ -151,7 +152,7 @@ public RTExpressionByTissueType getRTGeneExpressionByTissue(String comparisonTyp } @QueryMapping - public RPExpressionByTissueType getRPGeneExpressionByTissueAndProtein(String geneSymbol, String protein) throws Exception { + public RPExpressionByTissueType getRPGeneExpressionByTissueAndProtein(@Argument String geneSymbol, @Argument String protein) throws Exception { try { return rpExpressionDataService.getByGeneSymbolAndProteinPerTissue(geneSymbol, protein); } catch (Exception e) { @@ -161,7 +162,7 @@ public RPExpressionByTissueType getRPGeneExpressionByTissueAndProtein(String gen } @QueryMapping - public List getRTGeneExpressionByStructure(String structure) throws Exception { + public List getRTGeneExpressionByStructure(@Argument String structure) throws Exception { try { return rtExpressionDataService.getByStructure(structure); } catch (Exception e) { @@ -171,7 +172,7 @@ public List getRTGeneExpressionByStructure(String st } @QueryMapping - public List getRPGeneExpressionByStructure(String structure) throws Exception { + public List getRPGeneExpressionByStructure(@Argument String structure) throws Exception { try { return rpExpressionDataService.getByStructure(structure); } catch (Exception e) { @@ -181,7 +182,7 @@ public List getRPGeneExpressionByStructure(String structure) t } @QueryMapping - public List getRPGeneExpressionByTissue(String geneSymbol) + public List getRPGeneExpressionByTissue(@Argument String geneSymbol) throws Exception { try { return rpExpressionDataService.getByGeneSymbolPerTissue(geneSymbol); @@ -192,32 +193,33 @@ public List getRPGeneExpressionByTissue(String geneSymbol) } @QueryMapping - public ParticipantDataTypeSummary getDataTypeInformationByParticipant(String redcapId) { + public ParticipantDataTypeSummary getDataTypeInformationByParticipant(@Argument String redcapId) { return participantService.getExperimentCounts(redcapId); } @QueryMapping - public ParticipantRepoDataTypeSummary getRepoDataTypeInformationByParticipant(String redcapId) { + public ParticipantRepoDataTypeSummary getRepoDataTypeInformationByParticipant(@Argument String redcapId) { return participantService.getDataTypeCounts(redcapId); } @QueryMapping - public ParticipantSummaryDataset participantSummaryDataset(String redcap_id) throws Exception { + public ParticipantSummaryDataset participantSummaryDataset(@Argument String redcapId) throws Exception { + logger.info(redcapId); try { - return participantService.getParticipantSummaryDataset(redcap_id); + return participantService.getParticipantSummaryDataset(redcapId); } catch (Exception e) { logger.error(e.getMessage()); ParticipantSummaryDataset emptyResult = new ParticipantSummaryDataset(); - emptyResult.setRedcapId(redcap_id); + emptyResult.setRedcapId(redcapId); return emptyResult; } } @QueryMapping - public ParticipantRepoDataTypeInformation getTotalParticipantFilesCount(String redcap_id) throws Exception { + public ParticipantRepoDataTypeInformation getTotalParticipantFilesCount(@Argument String redcapId) throws Exception { try { - return this.participantService.getTotalFilesCount(redcap_id); + return this.participantService.getTotalFilesCount(redcapId); } catch (Exception e) { logger.error(e.getMessage()); throw e; @@ -255,7 +257,7 @@ public List getAtlasMessages() throws Exception { } @QueryMapping - public List getExperimentalStrategyCountsByParticipant(String redcapId) { + public List getExperimentalStrategyCountsByParticipant(@Argument String redcapId) { return participantService.getExperimentalStrategyCountsByParticipant(redcapId); } } \ No newline at end of file diff --git a/src/main/java/org/kpmp/autocomplete/AutocompleteService.java b/src/main/java/org/kpmp/autocomplete/AutocompleteService.java index f0d65e6..75f840c 100755 --- a/src/main/java/org/kpmp/autocomplete/AutocompleteService.java +++ b/src/main/java/org/kpmp/autocomplete/AutocompleteService.java @@ -59,33 +59,41 @@ public List convertCellTypesToAutocompleteResults(List autocompleteResults = new ArrayList<>(); List idsAdded = new ArrayList<>(); - for (CellType cellType : cellTypeListNoDupes) { - autocompleteResults.add(new AutocompleteResult(cellType.getCellType(), null, - Integer.toString(cellType.getCellTypeId()), TYPE_CELL_TYPE, cellType.getSynonymStringList())); - idsAdded.add(cellType.getCellTypeId()); - } + if (cellTypeListNoDupes != null){ + for (CellType cellType : cellTypeListNoDupes) { + autocompleteResults.add(new AutocompleteResult(cellType.getCellType(), null, + Integer.toString(cellType.getCellTypeId()), TYPE_CELL_TYPE, cellType.getSynonymStringList())); + idsAdded.add(cellType.getCellTypeId()); + } + } List subregionHits = new ArrayList<>(); - for (CellType subregion : subregions) { - - if (!(subregionHits.contains(subregion.getStructureSubregion()) - || idsAdded.contains(subregion.getCellTypeId()))) { - autocompleteResults.add(new AutocompleteResult(subregion.getStructureSubregion(), null, - Integer.toString(subregion.getCellTypeId()), TYPE_CELL_TYPE, null)); - subregionHits.add(subregion.getStructureSubregion()); - idsAdded.add(subregion.getCellTypeId()); - } - } + if (subregions != null){ + for (CellType subregion : subregions) { + + if (!(subregionHits.contains(subregion.getStructureSubregion()) + || idsAdded.contains(subregion.getCellTypeId()))) { + autocompleteResults.add(new AutocompleteResult(subregion.getStructureSubregion(), null, + Integer.toString(subregion.getCellTypeId()), TYPE_CELL_TYPE, null)); + subregionHits.add(subregion.getStructureSubregion()); + idsAdded.add(subregion.getCellTypeId()); + } + } + } + List regionHits = new ArrayList<>(); - for (CellType region : regions) { - if (!(regionHits.contains(region.getStructureRegion()) || idsAdded.contains(region.getCellTypeId()))) { - autocompleteResults.add(new AutocompleteResult(region.getStructureRegion(), null, - Integer.toString(region.getCellTypeId()), TYPE_CELL_TYPE, null)); - regionHits.add(region.getStructureRegion()); - idsAdded.add(region.getCellTypeId()); - } - } + if(regions != null){ + for (CellType region : regions) { + if (!(regionHits.contains(region.getStructureRegion()) || idsAdded.contains(region.getCellTypeId()))) { + autocompleteResults.add(new AutocompleteResult(region.getStructureRegion(), null, + Integer.toString(region.getCellTypeId()), TYPE_CELL_TYPE, null)); + regionHits.add(region.getStructureRegion()); + idsAdded.add(region.getCellTypeId()); + } + } + } + autocompleteResults.sort(new Comparator() { @Override diff --git a/src/main/java/org/kpmp/cellType/CellTypeRepository.java b/src/main/java/org/kpmp/cellType/CellTypeRepository.java index 0fc449b..81668fa 100755 --- a/src/main/java/org/kpmp/cellType/CellTypeRepository.java +++ b/src/main/java/org/kpmp/cellType/CellTypeRepository.java @@ -12,9 +12,9 @@ public interface CellTypeRepository extends CrudRepository { @Cacheable("cellTypeContainingOrSynonymContaining") - @Query(value = "SELECT ct.*, cs.* " + " FROM cell_type ct " + @Query(value = "SELECT ct.cell_type_id, ct.structure_region, ct.structure_subregion, ct.cell_type, ct.release_ver, ct.release_sunset, ct.cell_type_order, cs.cell_type_synonym " + " FROM cell_type ct " + " JOIN celltype_synonym cs ON (ct.cell_type_id = cs.cell_type_id AND cs.cell_type_synonym LIKE %:searchTerm%) " - + " UNION " + " SELECT ct.*, cs.* " + " FROM cell_type ct " + + " UNION " + " SELECT ct.cell_type_id, ct.structure_region, ct.structure_subregion, ct.cell_type, ct.release_ver, ct.release_sunset, ct.cell_type_order, cs.cell_type_synonym " + " FROM cell_type ct " + " LEFT JOIN celltype_synonym cs ON ct.cell_type_id = cs.cell_type_id " + " WHERE ct.cell_type LIKE %:searchTerm% ", nativeQuery = true) List findByCellTypeContainingOrSynonymContaining(@Param("searchTerm") String searchTerm); diff --git a/src/main/java/org/kpmp/participant/ParticipantService.java b/src/main/java/org/kpmp/participant/ParticipantService.java index 137dd8b..62a6e31 100755 --- a/src/main/java/org/kpmp/participant/ParticipantService.java +++ b/src/main/java/org/kpmp/participant/ParticipantService.java @@ -59,6 +59,7 @@ public ParticipantService(DataSummaryRepository dataSummaryRepo, SpatialViewerTy } public ParticipantSummaryDataset getParticipantSummaryDataset(String redcapId) { + logger.info(participantSummaryDatasetRepository.findByRedcapId(redcapId).toString()); return participantSummaryDatasetRepository.findByRedcapId(redcapId); } diff --git a/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java b/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java index 6862bf6..fab74f2 100755 --- a/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java +++ b/src/main/java/org/kpmp/participant/ParticipantSummaryDatasetRepository.java @@ -10,7 +10,8 @@ public interface ParticipantSummaryDatasetRepository extends CrudRepository { @Cacheable("participantByRedcap") - ParticipantSummaryDataset findByRedcapId(@Param("redcap_id") String redcapId); + @Query(value = "select * from participant where redcap_id= :redcapId", nativeQuery = true) + ParticipantSummaryDataset findByRedcapId(@Param("redcapId") String redcapId); @Cacheable("partipantByTissueType") @Query(value = "select count(*) from participant where tissue_type= :tissue_type", nativeQuery = true)