Skip to content

Commit

Permalink
update more code to work with java21
Browse files Browse the repository at this point in the history
  • Loading branch information
Dert1129 committed Jul 24, 2024
1 parent 59c6769 commit 373f9cd
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-gradle-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 21 additions & 19 deletions src/main/java/org/kpmp/Query.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,7 +72,7 @@ public Query(AutocompleteService autocompleteService, CellTypeService cellTypeSe
}

@QueryMapping
public List<AutocompleteResult> autocomplete(String searchTerm) throws IOException, Exception {
public List<AutocompleteResult> autocomplete(@Argument String searchTerm) throws IOException, Exception {
return autocompleteService.query(searchTerm);
}

Expand All @@ -81,8 +82,8 @@ public CellTypeHierarchy cellTypeHierarchy() throws IOException {
}

@QueryMapping
public List<? extends GeneExpressionSummary> geneExpressionSummary(String dataType, String geneSymbol,
String cellType, String tissueType) throws IOException {
public List<? extends GeneExpressionSummary> geneExpressionSummary(@Argument String dataType, @Argument String geneSymbol,
@Argument String cellType, @Argument String tissueType) throws IOException {
List<? extends GeneExpressionSummary> results = new ArrayList<>();
if (cellType.isEmpty()) {
results = geneExpressionSummaryService.getByDataTypeTissueTypeAndGene(dataType, geneSymbol, tissueType);
Expand All @@ -94,12 +95,12 @@ public List<? extends GeneExpressionSummary> geneExpressionSummary(String dataTy
}

@QueryMapping
public List<ClusterHierarchy> getClusterHieararchies(String cellType) throws IOException {
public List<ClusterHierarchy> 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) {
Expand Down Expand Up @@ -129,7 +130,7 @@ public List<DataTypeSummary> getSummaryData() throws Exception {
}

@QueryMapping
public List<String> dataTypesForConcept(String geneSymbol, String clusterName) throws Exception {
public List<String> dataTypesForConcept(@Argument String geneSymbol, @Argument String clusterName) throws Exception {
if (geneSymbol != null && !geneSymbol.isEmpty()) {
return geneExpressionSummaryService.findDataTypesByGene(geneSymbol);
} else if (clusterName != null && !clusterName.isEmpty()) {
Expand All @@ -140,7 +141,7 @@ public List<String> 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);
Expand All @@ -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) {
Expand All @@ -161,7 +162,7 @@ public RPExpressionByTissueType getRPGeneExpressionByTissueAndProtein(String gen
}

@QueryMapping
public List<? extends RTExpressionData> getRTGeneExpressionByStructure(String structure) throws Exception {
public List<? extends RTExpressionData> getRTGeneExpressionByStructure(@Argument String structure) throws Exception {
try {
return rtExpressionDataService.getByStructure(structure);
} catch (Exception e) {
Expand All @@ -171,7 +172,7 @@ public List<? extends RTExpressionData> getRTGeneExpressionByStructure(String st
}

@QueryMapping
public List<RPExpressionData> getRPGeneExpressionByStructure(String structure) throws Exception {
public List<RPExpressionData> getRPGeneExpressionByStructure(@Argument String structure) throws Exception {
try {
return rpExpressionDataService.getByStructure(structure);
} catch (Exception e) {
Expand All @@ -181,7 +182,7 @@ public List<RPExpressionData> getRPGeneExpressionByStructure(String structure) t
}

@QueryMapping
public List<RPAccessionGroup> getRPGeneExpressionByTissue(String geneSymbol)
public List<RPAccessionGroup> getRPGeneExpressionByTissue(@Argument String geneSymbol)
throws Exception {
try {
return rpExpressionDataService.getByGeneSymbolPerTissue(geneSymbol);
Expand All @@ -192,32 +193,33 @@ public List<RPAccessionGroup> 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;
Expand Down Expand Up @@ -255,7 +257,7 @@ public List<AtlasMessage> getAtlasMessages() throws Exception {
}

@QueryMapping
public List<ParticipantRepoDataTypeInformation> getExperimentalStrategyCountsByParticipant(String redcapId) {
public List<ParticipantRepoDataTypeInformation> getExperimentalStrategyCountsByParticipant(@Argument String redcapId) {
return participantService.getExperimentalStrategyCountsByParticipant(redcapId);
}
}
54 changes: 31 additions & 23 deletions src/main/java/org/kpmp/autocomplete/AutocompleteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,41 @@ public List<AutocompleteResult> convertCellTypesToAutocompleteResults(List<CellT
List<AutocompleteResult> autocompleteResults = new ArrayList<>();
List<Integer> 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<String> 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<String> 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<AutocompleteResult>() {
@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kpmp/cellType/CellTypeRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
public interface CellTypeRepository extends CrudRepository<CellType, Integer> {

@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<CellType> findByCellTypeContainingOrSynonymContaining(@Param("searchTerm") String searchTerm);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kpmp/participant/ParticipantService.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public ParticipantService(DataSummaryRepository dataSummaryRepo, SpatialViewerTy
}

public ParticipantSummaryDataset getParticipantSummaryDataset(String redcapId) {
logger.info(participantSummaryDatasetRepository.findByRedcapId(redcapId).toString());
return participantSummaryDatasetRepository.findByRedcapId(redcapId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
public interface ParticipantSummaryDatasetRepository extends CrudRepository<ParticipantSummaryDataset, Long> {

@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)
Expand Down

0 comments on commit 373f9cd

Please sign in to comment.