Skip to content

Commit

Permalink
rework the rest of the audits
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-va committed Feb 7, 2025
1 parent 0eabaf5 commit 61fb0dc
Showing 1 changed file with 46 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -193,16 +192,13 @@ private void loadConceptsRealTime(

if (CollectionUtils.isEmpty(allConcepts)) {
logger.warn("Unable to load. No concepts found!");
Audit audit =
new Audit(
"Warning",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"loadConceptsRealTime",
"No concepts found!",
"warning");
LoaderServiceImpl.addAudit(audit);
Audit.addAudit(
operationsService,
"No concepts found",
"loadConceptsRealTime",
terminology.getTerminology(),
"No concepts found!",
"warning");
return;
}

Expand Down Expand Up @@ -249,17 +245,14 @@ private void loadConceptsRealTime(
handleHistory(terminology, c);
} catch (Exception e) {
logger.error("Error handling history for concept " + c.getCode(), e);
Audit audit =
new Audit(
"Exception",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"loadConceptsRealTime",
"Error handling history for concept " + c.getCode(),
"error");
try {
LoaderServiceImpl.addAudit(audit);
Audit.addAudit(
operationsService,
"Exception",
"loadConceptsRealTime",
terminology.getTerminology(),
"Error handling history for concept " + c.getCode(),
"error");
} catch (Exception e1) {
logger.error(e1.getMessage(), e1);
}
Expand Down Expand Up @@ -339,16 +332,13 @@ private void loadConceptsRealTime(
ElasticOperationsService.MAPPINGS_INDEX);
} catch (NoSuchIndexException e) {
logger.warn("UNABLE TO DELETE INDEX: " + NCIT_MAPS_TO + mapset.getKey() + " NOT FOUND!");
Audit audit =
new Audit(
"NoSuchIndexException",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"loadConceptsRealTime",
"UNABLE TO DELETE INDEX: " + NCIT_MAPS_TO + mapset.getKey() + " NOT FOUND!",
"warning");
LoaderServiceImpl.addAudit(audit);
Audit.addAudit(
operationsService,
"NoSuchIndexException",
"loadConceptsRealTime",
terminology.getTerminology(),
"UNABLE TO DELETE INDEX: " + NCIT_MAPS_TO + mapset.getKey() + " NOT FOUND!",
"warning");
}
Collections.sort(
mapset.getValue().getMaps(),
Expand Down Expand Up @@ -549,16 +539,13 @@ public void addExtraSubsets(List<Concept> existingSubsets, Terminology terminolo
.orElseThrow();
} catch (NoSuchElementException e) {
logger.warn("Subset " + subsetCode + " not found as a concept, skipping.");
Audit audit =
new Audit(
"NoSuchElementException",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"addExtraSubsets",
"Subset " + subsetCode + " not found as a concept, skipping.",
"warning");
LoaderServiceImpl.addAudit(audit);
Audit.addAudit(
operationsService,
"NoSuchElementException",
"addExtraSubsets",
terminology.getTerminology(),
"Subset " + subsetCode + " not found as a concept, skipping.",
"warning");
continue;
}

Expand All @@ -580,20 +567,17 @@ public void addExtraSubsets(List<Concept> existingSubsets, Terminology terminolo
+ ": "
+ newSubsets.get(subsetCode)
+ " not found, skipping.");
Audit audit =
new Audit(
"NoSuchElementException",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"addExtraSubsets",
"Parent Subset of "
+ subsetCode
+ ": "
+ newSubsets.get(subsetCode)
+ " not found, skipping.",
"warning");
LoaderServiceImpl.addAudit(audit);
Audit.addAudit(
operationsService,
"NoSuchElementException",
"addExtraSubsets",
terminology.getTerminology(),
"Parent Subset of "
+ subsetCode
+ ": "
+ newSubsets.get(subsetCode)
+ " not found, skipping.",
"warning");
continue;
}

Expand Down Expand Up @@ -643,15 +627,13 @@ public void addExtraSubsets(List<Concept> existingSubsets, Terminology terminolo
// index subsetConcept
operationsService.index(subsetConcept, terminology.getIndexName(), Concept.class);
}
Audit audit =
new Audit(
"MissingConcepts",
terminology.getTerminology(),
terminology.getVersion(),
new Date(),
"addExtraSubsets",
"Concepts " + missingConcepts + " not found for new subset " + subsetCode + ".",
"warning");
Audit.addAudit(
operationsService,
"Missing Subset Concepts",
"addExtraSubsets",
terminology.getTerminology(),
"Concepts " + missingConcepts + " not found for new subset " + subsetCode + ".",
"warning");
// explicitly set leaf since it defaults to false
newSubsetEntry.setLeaf(!newSubsets.containsValue(newSubsetEntry.getCode()));
// add extra relevant properties to new subset
Expand Down

0 comments on commit 61fb0dc

Please sign in to comment.