Skip to content

Commit

Permalink
Merge pull request #22 from ncats/removeEndpoints
Browse files Browse the repository at this point in the history
added log print statements for debugging
  • Loading branch information
ChemMitch authored Jan 11, 2024
2 parents 9467ac1 + eb016b6 commit ffde783
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
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

0 comments on commit ffde783

Please sign in to comment.