diff --git a/oan-rest/src/main/java/org/jax/oan/repository/DiseaseRepository.java b/oan-rest/src/main/java/org/jax/oan/repository/DiseaseRepository.java index 4f33d20..bcf6047 100644 --- a/oan-rest/src/main/java/org/jax/oan/repository/DiseaseRepository.java +++ b/oan-rest/src/main/java/org/jax/oan/repository/DiseaseRepository.java @@ -39,6 +39,9 @@ public Optional findDiseaseById(TermId termId){ } return Optional.empty(); } + catch (Exception e){ + return Optional.empty(); + } } /** @@ -57,6 +60,9 @@ public Collection findDiseases(String query) { diseases.add(disease); } } + catch (Exception e){ + return Collections.emptyList(); + } return diseases.stream().sorted(Comparator.comparing((Disease d) -> !d.getName().toLowerCase() .startsWith(query.toLowerCase()))).toList(); } @@ -76,6 +82,9 @@ public Collection findGenesByDisease(TermId termId) { genes.add(gene); } } + catch (Exception e){ + return Collections.emptyList(); + } return genes; } @@ -97,6 +106,9 @@ public Collection findPhenotypesByDisease(TermId termId){ phenotypes.add(phenotype); } } + catch (Exception e){ + return Collections.emptyList(); + } return phenotypes; } @@ -130,6 +142,9 @@ public Collection findMedicalActionsByDisease(TermI actions.add(new MedicalActionTargetExtended(TermId.of(m.get("id").asString()), m.get("name").asString(), relations, targets )); } } + catch (Exception e){ + return Collections.emptyList(); + } return actions; } } diff --git a/oan-rest/src/main/java/org/jax/oan/repository/GeneRepository.java b/oan-rest/src/main/java/org/jax/oan/repository/GeneRepository.java index 6a0f1c0..ab04b77 100644 --- a/oan-rest/src/main/java/org/jax/oan/repository/GeneRepository.java +++ b/oan-rest/src/main/java/org/jax/oan/repository/GeneRepository.java @@ -10,10 +10,7 @@ import org.neo4j.driver.Transaction; import org.neo4j.driver.Value; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.List; +import java.util.*; import static org.neo4j.driver.Values.parameters; @@ -41,7 +38,10 @@ public Collection findGenes(String query){ Gene gene = new Gene(TermId.of(value.get("id").asString()), value.get("name").asString()); genes.add(gene); } - } + } + catch (Exception e){ + return Collections.emptyList(); + } return genes.stream().sorted(Comparator.comparing((Gene g) -> !g.getName().toLowerCase() .startsWith(query.toLowerCase()))).toList(); } @@ -60,6 +60,8 @@ public Collection findPhenotypesByGene(TermId termId){ Phenotype phenotype = new Phenotype(TermId.of(value.get("id").asString()), value.get("name").asString()); phenotypes.add(phenotype); } + } catch (Exception e){ + return Collections.emptyList(); } return phenotypes; } @@ -80,6 +82,9 @@ public Collection findDiseasesByGene(TermId termId) { diseases.add(disease); } } + catch (Exception e){ + return Collections.emptyList(); + } return diseases; } } diff --git a/oan-rest/src/main/java/org/jax/oan/repository/PhenotypeRepository.java b/oan-rest/src/main/java/org/jax/oan/repository/PhenotypeRepository.java index 08c9729..bc68624 100644 --- a/oan-rest/src/main/java/org/jax/oan/repository/PhenotypeRepository.java +++ b/oan-rest/src/main/java/org/jax/oan/repository/PhenotypeRepository.java @@ -36,6 +36,9 @@ public Collection findDiseasesByTerm(TermId termId){ diseases.add(disease); } } + catch (Exception e){ + return Collections.emptyList(); + } return diseases; } @@ -56,6 +59,9 @@ public Collection findGenesByTerm(TermId termId) { genes.add(gene); } } + catch (Exception e){ + return Collections.emptyList(); + } return genes; } @@ -75,6 +81,9 @@ public Collection findAssaysByTerm(TermId termId){ assays.add(assay); } } + catch (Exception e){ + return Collections.emptyList(); + } return assays; } @@ -101,6 +110,9 @@ public Collection findMedicalActionsByTerm(TermId t medicalActions.add(new MedicalActionSourceExtended(TermId.of(subject.get("id").asString()), subject.get("name").asString(), relations, sources)); } } + catch (Exception e){ + return Collections.emptyList(); + } return medicalActions; } }