From 78c699e06cb90de171595a984df97f9fbaaddcb1 Mon Sep 17 00:00:00 2001 From: jloux-brapi Date: Fri, 14 Mar 2025 14:21:45 -0400 Subject: [PATCH 1/4] [BI-2579] Forgo cache refresh on response from server during germ import chunks --- .../org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index 75226babf..65a8a49c8 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -296,11 +296,9 @@ public List createBrAPIGermplasm(List postBrAPIG var program = programDAO.fetchOneById(programId); try { if (!postBrAPIGermplasmList.isEmpty()) { - Callable> postFunction = () -> { List postResponse = brAPIDAOUtil.post(postBrAPIGermplasmList, upload, api::germplasmPost, importDAO::update); - return processGermplasmForDisplay(postResponse, program.getKey()); - }; - return programGermplasmCache.post(programId, postFunction); + processGermplasmForDisplay(postResponse, program.getKey()); + return postResponse; } return new ArrayList<>(); } catch (Exception e) { From fa32de4b89ced730771a1e5f682c1565c66ad9fe Mon Sep 17 00:00:00 2001 From: jloux-brapi Date: Thu, 20 Mar 2025 14:20:57 -0400 Subject: [PATCH 2/4] Fully populate program germplasm cache when upload completes --- .../org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java | 4 ++++ .../importer/services/processors/GermplasmProcessor.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index 2f756ba26..c4090ef8e 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -162,6 +162,10 @@ private Map fetchProgramGermplasm(UUID programId) throws } } + public void repopulateGermplasmCacheForProgram(UUID programId) { + programGermplasmCache.populate(programId); + } + /** * Process germplasm into a format for display * @param programGermplasm diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java index 0d514ee72..74d6a6066 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/GermplasmProcessor.java @@ -630,6 +630,8 @@ public void postBrapiData(Map mappedBrAPIImport, Program try { // Create germplasm list brAPIListDAO.createBrAPILists(List.of(importList), program.getId(), upload); + // Now that we have finished uploading, fetch all the data posted to BrAPI to the cache so it is up-to-date. + brAPIGermplasmDAO.repopulateGermplasmCacheForProgram(program.getId()); } catch (ApiException e) { throw new InternalServerException(e.toString(), e); } From dcfd786532103b4a8a624af81e1aa26c7764349c Mon Sep 17 00:00:00 2001 From: jloux-brapi Date: Mon, 31 Mar 2025 12:30:36 -0400 Subject: [PATCH 3/4] Add properties added to test server properties file --- .../brapi/properties/application.properties | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/resources/brapi/properties/application.properties b/src/main/resources/brapi/properties/application.properties index 3733fcd37..5ee3656c5 100644 --- a/src/main/resources/brapi/properties/application.properties +++ b/src/main/resources/brapi/properties/application.properties @@ -25,13 +25,25 @@ spring.datasource.password=${BRAPI_DB_PASSWORD} spring.datasource.driver-class-name=org.postgresql.Driver +# This property when set to true makes it so that a DB transaction is open through the body of a request, nullifying the use of @Transactional. +# It is generally recommended that this be set to false, and methods are properly annotated and release the transactions when complete. +# However, many of the endpoints already rely on this kind of connection infrastructure and changing is more trouble than it's worth. +spring.jpa.open-in-view=true + +spring.jpa.properties.hibernate.jdbc.batch_size=50 +spring.jpa.properties.hibernate.order_inserts=true +spring.jpa.properties.hibernate.order_updates=true +spring.jpa.hibernate.ddl-auto=validate + +# Use these to help debug queries. +# The stats will tell you how long hibernate transactions are taking, how many queries occur, how many entities are being flushed/accessed, etc. +spring.jpa.show-sql=false +spring.jpa.properties.hibernate.generate_statistics=false + spring.flyway.locations=classpath:db/migration,classpath:db/sql,classpath:org/brapi/test/BrAPITestServer/db/migration spring.flyway.schemas=public spring.flyway.baselineOnMigrate=true -spring.jpa.hibernate.ddl-auto=validate -spring.jpa.show-sql=false - spring.mvc.dispatch-options-request=true security.oidc_discovery_url=https://example.com/auth/.well-known/openid-configuration From 5fe02f2359a9e68ce147941563f8bf34822f34be Mon Sep 17 00:00:00 2001 From: jloux-brapi Date: Mon, 31 Mar 2025 16:24:03 -0400 Subject: [PATCH 4/4] Restore functionality of using post return values --- .../org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java index c4090ef8e..478c99bcf 100644 --- a/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java +++ b/src/main/java/org/breedinginsight/brapi/v2/dao/BrAPIGermplasmDAO.java @@ -315,8 +315,7 @@ public List createBrAPIGermplasm(List postBrAPIG try { if (!postBrAPIGermplasmList.isEmpty()) { List postResponse = brAPIDAOUtil.post(postBrAPIGermplasmList, upload, api::germplasmPost, importDAO::update); - processGermplasmForDisplay(postResponse, program.getKey()); - return postResponse; + return new ArrayList<>(processGermplasmForDisplay(postResponse, program.getKey()).values()); } return new ArrayList<>(); } catch (Exception e) {