Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added log print statements for debugging #22

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public Optional<Substance> getEntityManagerSubstanceBySubstanceKeyResolver(Strin

// Substance API, Substance Key Resolver
public Optional<SubstanceDTO> getSubstanceBySubstanceKeyResolver(String substanceKey, String substanceKeyType) {

log.info("**** INSIDE getSubstanceBySubstanceKeyResolver()");
if ((substanceKey == null) && (substanceKeyType == null)) {
return null;
}
Expand All @@ -121,17 +121,21 @@ public Optional<SubstanceDTO> getSubstanceBySubstanceKeyResolver(String substanc
Optional<SubstanceDTO> 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");
Expand Down Expand Up @@ -199,6 +203,7 @@ public Optional<List<CodeDTO>> 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;
}
Expand All @@ -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<SubstanceDTO> 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 {
Expand All @@ -231,6 +241,7 @@ public SubstanceKeyPair convertSubstanceKeyBySubstanceKeyResolver(String substan
}

} else if (substanceKeyTypeFromConfig.equalsIgnoreCase(SUBSTANCE_KEY_TYPE_BDNUM)) {
log.info("**** IN convertSubstanceKeyBySubstanceKeyResolver(): substance BDNUM");
Optional<List<CodeDTO>> codes = getCodesOfSubstance(substanceKey);
if (codes.isPresent()) {
codes.get().forEach(codeObj -> {
Expand Down
Loading