From b0e42d2bbb7852d8fe2762b5a8dc2172d114c698 Mon Sep 17 00:00:00 2001 From: beapen Date: Sat, 24 Apr 2021 11:40:15 -0400 Subject: [PATCH 1/9] relationship attributes in progress --- .../canehealth/ckblib/graph/BaseRelationRepository.java | 7 +++++++ .../com/canehealth/ckblib/graph/BaseRelationService.java | 9 ++++++++- .../canehealth/ckblib/graph/BaseRelationServiceTest.java | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java index fbdd61b..5426924 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java @@ -16,4 +16,11 @@ public interface BaseRelationRepository extends ReactiveNeo4jRepository getRelationsByCui(String cui); + @Query("" + + "MATCH (d {cui: $dcui}) -[r]- (s {cui: $scui})\n" + + "SET r.confidence = r.confidence + $c, r.upvote = r.upvote + $u, r.downvote = r.downvote + $d \n" + + "RETURN r" + ) + Mono updateRelationshipAttributes(String dcui, String scui, int c, int u, int d); + } diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java index 65a940e..2dac6a3 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java @@ -3,6 +3,8 @@ import org.neo4j.driver.Driver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.canehealth.ckblib.graph.model.BaseRelation; +import reactor.core.publisher.Mono; @Service public class BaseRelationService { @@ -10,11 +12,16 @@ public class BaseRelationService { @Autowired Driver driver; + @Autowired + BaseRelationRepository baseRelationRepository; + public String getRelationsByCui(String cui) { String externalQuery = "MATCH (d {cui: '" + cui + "'}) -[r]- (s) RETURN d, r, s"; D3Map d3Map = new D3Map.Builder(driver).withQuery(externalQuery).build(); return d3Map.fetch(); } - + public Mono addAttributes(String dcui, String scui, int confidence, int upvote, int downvote) { + return baseRelationRepository.updateRelationshipAttributes(dcui, scui, confidence, upvote, downvote); + } } diff --git a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java index 33fad14..233e621 100644 --- a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java +++ b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java @@ -93,6 +93,7 @@ void shouldRetrieveDiseases() { assertEquals(signSymptomService.addRelation("C0041834", "C1041834", 0, 0, 0).block().getName(), "Pruritus"); assertEquals(signSymptomService.addRelation("C0041834", "C1041835", 0, 0, 0).block().getName(), "Erythema"); assertFalse(baseRelationService.getRelationsByCui("C0041834").length() < 10); + System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 3, -5).block()); } } From c72c50ca084e55ebd05793914eebefb660a44d0c Mon Sep 17 00:00:00 2001 From: beapen Date: Sat, 24 Apr 2021 13:05:10 -0400 Subject: [PATCH 2/9] create void function to update --- .../ckblib/graph/BaseRelationRepository.java | 5 ++--- .../canehealth/ckblib/graph/BaseRelationService.java | 12 ++++++++++-- .../ckblib/graph/BaseRelationServiceTest.java | 3 ++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java index 5426924..cc5aac8 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java @@ -17,10 +17,9 @@ public interface BaseRelationRepository extends ReactiveNeo4jRepository getRelationsByCui(String cui); @Query("" - + "MATCH (d {cui: $dcui}) -[r]- (s {cui: $scui})\n" + + "MATCH (d {cui: $dcui}) -[r]- (s {cui: $scui})\n" + "SET r.confidence = r.confidence + $c, r.upvote = r.upvote + $u, r.downvote = r.downvote + $d \n" - + "RETURN r" ) - Mono updateRelationshipAttributes(String dcui, String scui, int c, int u, int d); + void updateRelationshipAttributes(String dcui, String scui, int c, int u, int d); } diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java index 2dac6a3..dfe9dd2 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java @@ -21,7 +21,15 @@ public String getRelationsByCui(String cui) { return d3Map.fetch(); } - public Mono addAttributes(String dcui, String scui, int confidence, int upvote, int downvote) { - return baseRelationRepository.updateRelationshipAttributes(dcui, scui, confidence, upvote, downvote); + // Cannot use above method + // Writing in read access mode not allowed. Attempted write to internal graph 0 + // (neo4j) + public String addAttributes(String dcui, String scui, int confidence, int upvote, int downvote) { + try { + baseRelationRepository.updateRelationshipAttributes(dcui, scui, confidence, upvote, downvote); + return "Success"; + } catch (Exception e) { + return "Error" + e.getLocalizedMessage(); + } } } diff --git a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java index 233e621..f893a16 100644 --- a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java +++ b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java @@ -93,7 +93,8 @@ void shouldRetrieveDiseases() { assertEquals(signSymptomService.addRelation("C0041834", "C1041834", 0, 0, 0).block().getName(), "Pruritus"); assertEquals(signSymptomService.addRelation("C0041834", "C1041835", 0, 0, 0).block().getName(), "Erythema"); assertFalse(baseRelationService.getRelationsByCui("C0041834").length() < 10); - System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 3, -5).block()); + System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 3, -5)); + System.out.println(baseRelationService.getRelationsByCui("C0041834")); } } From c050286942f70219dad7bb90bf647ab6899fa6af Mon Sep 17 00:00:00 2001 From: Bell Eapen Date: Sat, 24 Apr 2021 15:42:43 -0400 Subject: [PATCH 3/9] debug in progress --- .../ckblib/graph/BaseRelationServiceTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java index f893a16..96385e8 100644 --- a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java +++ b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import com.canehealth.ckblib.graph.model.BaseRelation; import com.canehealth.ckblib.graph.model.DiseaseDisorderMention; @@ -93,8 +94,15 @@ void shouldRetrieveDiseases() { assertEquals(signSymptomService.addRelation("C0041834", "C1041834", 0, 0, 0).block().getName(), "Pruritus"); assertEquals(signSymptomService.addRelation("C0041834", "C1041835", 0, 0, 0).block().getName(), "Erythema"); assertFalse(baseRelationService.getRelationsByCui("C0041834").length() < 10); - System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 3, -5)); + String before = baseRelationService.getRelationsByCui("C0041834"); + System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1)); + baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); + baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); + baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); + String after = baseRelationService.getRelationsByCui("C0041834"); System.out.println(baseRelationService.getRelationsByCui("C0041834")); + assertNotEquals(before, after); + } } From 0bff013ecd02c1afd5e64be09b1e8d53e9ce6a34 Mon Sep 17 00:00:00 2001 From: Bell Eapen Date: Sat, 24 Apr 2021 15:58:42 -0400 Subject: [PATCH 4/9] working add attributes --- .../ckblib/graph/BaseRelationRepository.java | 2 +- .../canehealth/ckblib/graph/BaseRelationService.java | 12 ++++-------- .../ckblib/graph/BaseRelationServiceTest.java | 6 +----- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java index cc5aac8..9a81f23 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationRepository.java @@ -20,6 +20,6 @@ public interface BaseRelationRepository extends ReactiveNeo4jRepository updateRelationshipAttributes(String dcui, String scui, int c, int u, int d); } diff --git a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java index dfe9dd2..a916970 100644 --- a/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java +++ b/graph/src/main/java/com/canehealth/ckblib/graph/BaseRelationService.java @@ -3,7 +3,7 @@ import org.neo4j.driver.Driver; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.canehealth.ckblib.graph.model.BaseRelation; + import reactor.core.publisher.Mono; @Service @@ -24,12 +24,8 @@ public String getRelationsByCui(String cui) { // Cannot use above method // Writing in read access mode not allowed. Attempted write to internal graph 0 // (neo4j) - public String addAttributes(String dcui, String scui, int confidence, int upvote, int downvote) { - try { - baseRelationRepository.updateRelationshipAttributes(dcui, scui, confidence, upvote, downvote); - return "Success"; - } catch (Exception e) { - return "Error" + e.getLocalizedMessage(); - } + public Mono addAttributes(String dcui, String scui, int confidence, int upvote, int downvote) { + return baseRelationRepository.updateRelationshipAttributes(dcui, scui, confidence, upvote, downvote); + } } diff --git a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java index 96385e8..8c22417 100644 --- a/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java +++ b/graph/src/test/java/com/canehealth/ckblib/graph/BaseRelationServiceTest.java @@ -95,12 +95,8 @@ void shouldRetrieveDiseases() { assertEquals(signSymptomService.addRelation("C0041834", "C1041835", 0, 0, 0).block().getName(), "Erythema"); assertFalse(baseRelationService.getRelationsByCui("C0041834").length() < 10); String before = baseRelationService.getRelationsByCui("C0041834"); - System.out.println(baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1)); - baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); - baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); - baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1); + baseRelationService.addAttributes("C0041834", "C1041834",0, 1, 1).block(); String after = baseRelationService.getRelationsByCui("C0041834"); - System.out.println(baseRelationService.getRelationsByCui("C0041834")); assertNotEquals(before, after); } From b7e66323c098fc095d87c110fcc2065f42aa4bae Mon Sep 17 00:00:00 2001 From: Bell Eapen Date: Sat, 24 Apr 2021 16:01:41 -0400 Subject: [PATCH 5/9] update version 0.10.0 --- application/pom.xml | 2 +- graph/pom.xml | 2 +- library/pom.xml | 2 +- pom-deploy.xml | 2 +- pom.xml | 2 +- qtakes/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/pom.xml b/application/pom.xml index 4589e6b..453bcfd 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib ckblib-application - 0.9.0 + 0.10.0 ckblib-application Demo project for Spring Boot diff --git a/graph/pom.xml b/graph/pom.xml index 80a704e..f6cd7d5 100644 --- a/graph/pom.xml +++ b/graph/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib graph - 0.9.0 + 0.10.0 ckblib-graph Demo project for Spring Boot diff --git a/library/pom.xml b/library/pom.xml index f70b61e..54452cf 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib library - 0.9.0 + 0.10.0 ckblib-library Demo project for Spring Boot diff --git a/pom-deploy.xml b/pom-deploy.xml index cd06c9a..4078330 100644 --- a/pom-deploy.xml +++ b/pom-deploy.xml @@ -4,7 +4,7 @@ com.canehealth.ckblib cklib-core - 0.9.0 + 0.10.0 pom diff --git a/pom.xml b/pom.xml index 62b3241..d3c4721 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.canehealth.ckblib cklib-core - 0.9.0 + 0.10.0 pom diff --git a/qtakes/pom.xml b/qtakes/pom.xml index 9687de3..d591a11 100644 --- a/qtakes/pom.xml +++ b/qtakes/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib qtakes - 0.9.0 + 0.10.0 ckblib-qtakes Demo project for Spring Boot From 659ff0fe42f81c52fa06875e232f99f3eb1c1491 Mon Sep 17 00:00:00 2001 From: beapen Date: Sun, 25 Apr 2021 12:19:23 -0400 Subject: [PATCH 6/9] publish on release --- .github/workflows/publish.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 84cee1b..f20a313 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,9 +1,8 @@ name: Java Publish on: - push: - branches: - - master + release: + types: [published] jobs: build: From d9018134e316d6e2646d2d307813309184b15c7d Mon Sep 17 00:00:00 2001 From: beapen Date: Sun, 25 Apr 2021 12:35:04 -0400 Subject: [PATCH 7/9] Add getter and setter --- .../java/com/canehealth/ckblib/library/service/CkbEfetch.java | 3 +++ .../java/com/canehealth/ckblib/library/service/CkbEsearch.java | 1 + 2 files changed, 4 insertions(+) diff --git a/library/src/main/java/com/canehealth/ckblib/library/service/CkbEfetch.java b/library/src/main/java/com/canehealth/ckblib/library/service/CkbEfetch.java index 9a1cabc..e5585ba 100644 --- a/library/src/main/java/com/canehealth/ckblib/library/service/CkbEfetch.java +++ b/library/src/main/java/com/canehealth/ckblib/library/service/CkbEfetch.java @@ -17,6 +17,7 @@ import org.w3c.dom.Node; import lombok.Getter; +import lombok.Setter; import reactor.core.publisher.Mono; @Service @@ -31,10 +32,12 @@ public class CkbEfetch { private WebClient webClient; + @Setter List esearch_results = new ArrayList(); @Getter + @Setter List results = new ArrayList(); public CkbEfetch() { diff --git a/library/src/main/java/com/canehealth/ckblib/library/service/CkbEsearch.java b/library/src/main/java/com/canehealth/ckblib/library/service/CkbEsearch.java index 3f157d7..fa32d2c 100644 --- a/library/src/main/java/com/canehealth/ckblib/library/service/CkbEsearch.java +++ b/library/src/main/java/com/canehealth/ckblib/library/service/CkbEsearch.java @@ -27,6 +27,7 @@ public class CkbEsearch { private WebClient webClient; @Getter + @Setter List results = new ArrayList(); public CkbEsearch() { From 6e08b62604ca50bb9ecfbc2aabcfcd9a264b6388 Mon Sep 17 00:00:00 2001 From: beapen Date: Sun, 25 Apr 2021 12:35:15 -0400 Subject: [PATCH 8/9] Add api key --- .../java/com/canehealth/ckblib/library/model/BaseQuery.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/com/canehealth/ckblib/library/model/BaseQuery.java b/library/src/main/java/com/canehealth/ckblib/library/model/BaseQuery.java index da5f1da..0ae8339 100644 --- a/library/src/main/java/com/canehealth/ckblib/library/model/BaseQuery.java +++ b/library/src/main/java/com/canehealth/ckblib/library/model/BaseQuery.java @@ -13,6 +13,7 @@ public class BaseQuery { private int retmax = 10; private int reldate = 0; private int retstart = 0; + private String api_key = ""; public String getQuery() { String query = "?retmode=json&db=" + db + "&term=" + term + "&retmax=" + Integer.toString(retmax); @@ -22,6 +23,9 @@ public String getQuery() { if (retstart > 0) { query += "&retstart=" + Integer.toString(retstart); } + if(!"".equals(api_key)){ + query += "&api_key=" + api_key; + } return query.replace(" ", "+"); } From bfef6686218d9b921d4a28edbe53a175990d0e28 Mon Sep 17 00:00:00 2001 From: Bell Eapen Date: Sun, 25 Apr 2021 14:14:04 -0400 Subject: [PATCH 9/9] version bump to 0.11.0 --- application/pom.xml | 2 +- graph/pom.xml | 2 +- library/pom.xml | 2 +- pom-deploy.xml | 2 +- pom.xml | 2 +- qtakes/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/pom.xml b/application/pom.xml index 453bcfd..3a72fc6 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib ckblib-application - 0.10.0 + 0.11.0 ckblib-application Demo project for Spring Boot diff --git a/graph/pom.xml b/graph/pom.xml index f6cd7d5..162fcc3 100644 --- a/graph/pom.xml +++ b/graph/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib graph - 0.10.0 + 0.11.0 ckblib-graph Demo project for Spring Boot diff --git a/library/pom.xml b/library/pom.xml index 54452cf..4a593f5 100644 --- a/library/pom.xml +++ b/library/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib library - 0.10.0 + 0.11.0 ckblib-library Demo project for Spring Boot diff --git a/pom-deploy.xml b/pom-deploy.xml index 4078330..233e4cb 100644 --- a/pom-deploy.xml +++ b/pom-deploy.xml @@ -4,7 +4,7 @@ com.canehealth.ckblib cklib-core - 0.10.0 + 0.11.0 pom diff --git a/pom.xml b/pom.xml index d3c4721..669894f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.canehealth.ckblib cklib-core - 0.10.0 + 0.11.0 pom diff --git a/qtakes/pom.xml b/qtakes/pom.xml index d591a11..7cf5567 100644 --- a/qtakes/pom.xml +++ b/qtakes/pom.xml @@ -10,7 +10,7 @@ com.canehealth.ckblib qtakes - 0.10.0 + 0.11.0 ckblib-qtakes Demo project for Spring Boot