From 3881a98479dd34f137076e4adceeddee0a6a3d24 Mon Sep 17 00:00:00 2001 From: Newatia Date: Thu, 11 Jan 2024 16:20:47 -0500 Subject: [PATCH] added log print statments --- .../products/product/models/ProductIngredient.java | 7 ++++++- .../product/services/SubstanceApiService.java | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/models/ProductIngredient.java b/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/models/ProductIngredient.java index 8f878a0..eece29a 100644 --- a/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/models/ProductIngredient.java +++ b/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/models/ProductIngredient.java @@ -135,18 +135,23 @@ private void resolveSubstance() { try { if (substanceApiService == null) { + log.info("***** in resolveSubstance(): substanceApiService == null"); AutowireHelper.getInstance().autowire(this); } // Get SubstanceKeyType from backend config + log.info("***** in resolveSubstance(): before getting config); String substanceKeyTypeFromConfig = substanceApiService.getSubstanceKeyTypeFromConfig(); - + log.info("***** in resolveSubstance(): SUBSTANCE KEY FROM CONFIG: " + substanceKeyTypeFromConfig); if (substanceKeyTypeFromConfig != null) { // if JSON Substance Key Type is not null + log.info("***** in resolveSubstance(): SUBSTANCE KEY FROM CONFIG NOT NULL: " + substanceKeyTypeFromConfig); if (this.substanceKeyType != null) { + log.info("***** in resolveSubstance(): SUBSTANCE KEY NOT NULL: " + this.substanceKeyType); // Substance Key Type in (backend config) and in (JSON) are NOT same if (!substanceKeyTypeFromConfig.equalsIgnoreCase(this.substanceKeyType)) { + log.info("***** in resolveSubstance(): SUBSTANCE KEY CONF AND SUB KEY NOT EQUAL: " + substanceKeyTypeFromConfig + " + this.substanceKeyType); /* IMPORTANT NOTE: ONLY save the substance key and subtsance key Type into the database, which is in the BACKEND CONFIG. diff --git a/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/services/SubstanceApiService.java b/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/services/SubstanceApiService.java index 3e99235..63a4194 100644 --- a/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/services/SubstanceApiService.java +++ b/gsrs-module-products-spring-boot-autoconfigure/src/main/java/gov/hhs/gsrs/products/product/services/SubstanceApiService.java @@ -112,7 +112,7 @@ public Optional getEntityManagerSubstanceBySubstanceKeyResolver(Strin // Substance API, Substance Key Resolver public Optional getSubstanceBySubstanceKeyResolver(String substanceKey, String substanceKeyType) { - + log.info("**** INSIDE getSubstanceBySubstanceKeyResolver()"); if ((substanceKey == null) && (substanceKeyType == null)) { return null; } @@ -121,17 +121,21 @@ public Optional getSubstanceBySubstanceKeyResolver(String substanc Optional substanceDTO = null; try { + log.info("**** INSIDE getSubstanceBySubstanceKeyResolver(): before calling Sub API resolveSubstance"); // Substance API resolver by Substance Key and substanceKeyType (UUID, APPROVAL_ID, BDNUM) substanceDTO = substanceRestApi.resolveSubstance(substanceKey, substanceKeyType); + log.info("**** INSIDE getSubstanceBySubstanceKeyResolver(): After calling Sub API resolveSubstance"); } catch (Exception e) { e.printStackTrace(); } if (substanceDTO == null || !substanceDTO.isPresent()) { + log.info("**** INSIDE getSubstanceBySubstanceKeyResolver(): NOT Found substance"); return null; } if (substanceDTO.get().getUuid() != null) { + log.info("**** INSIDE getSubstanceBySubstanceKeyResolver(): Found substance"); return substanceDTO; } else { log.debug("The SubstanceDTO is not null, but could not retrieve substance uuid"); @@ -199,6 +203,7 @@ public Optional> getCodesOfSubstance(String anyKindOfSubstanceId) // Convert Substance Key and Substance Key Type by Substance Key Resolver public SubstanceKeyPair convertSubstanceKeyBySubstanceKeyResolver(String substanceKey, String substanceKeyType) { + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver()"); if ((substanceKey == null) && (substanceKeyType == null)) { return null; } @@ -211,11 +216,16 @@ public SubstanceKeyPair convertSubstanceKeyBySubstanceKeyResolver(String substan if ((substanceKeyTypeFromConfig.equalsIgnoreCase(SUBSTANCE_KEY_TYPE_UUID)) || (substanceKeyTypeFromConfig.equalsIgnoreCase(SUBSTANCE_KEY_TYPE_APPROVAL_ID))) { + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): INSIDE key matching with constant"); // Get Substance by Substance Key Resolver Optional substance = getSubstanceBySubstanceKeyResolver(substanceKey, substanceKeyType); + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): after calling getSubstanceBySubstanceKeyResolver"); if (substance.isPresent()) { + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): substance is present"); + if (substanceKeyTypeFromConfig.equalsIgnoreCase(SUBSTANCE_KEY_TYPE_UUID)) { + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): substance UUID"); if (substance.get().getUuid() != null) { subKey.substanceKey = substance.get().getUuid().toString(); } else { @@ -231,6 +241,7 @@ public SubstanceKeyPair convertSubstanceKeyBySubstanceKeyResolver(String substan } } else if (substanceKeyTypeFromConfig.equalsIgnoreCase(SUBSTANCE_KEY_TYPE_BDNUM)) { + log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): substance BDNUM"); Optional> codes = getCodesOfSubstance(substanceKey); if (codes.isPresent()) { codes.get().forEach(codeObj -> {