Skip to content

Commit

Permalink
MAINT-2596 Send componentId & and additionalFields to aag
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcgihtsdo authored and QuyenLy87 committed Jul 17, 2024
1 parent 0545865 commit 1e2c11f
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

@Service
public class MRCMValidationService {
Expand Down Expand Up @@ -156,25 +152,21 @@ private void checkWhitelistItems(ValidationRun report) throws RestClientExceptio

private void checkWhitelistItemAgainstEachAssertion(Assertion assertion) throws RestClientException {
// checking whitelist
List<ConceptResult> currentViolatedConcepts = assertion.getCurrentViolatedConcepts();
if (!assertion.getCurrentViolatedConceptIds().isEmpty()) {
List<Long> newViolatedConceptIds = new ArrayList<>();
for (List<Long> batch : Iterables.partition(assertion.getCurrentViolatedConceptIds(), whitelistBatchSize)) {
for (List<ConceptResult> batch : Iterables.partition(currentViolatedConcepts, whitelistBatchSize)) {
// Convert to WhitelistItem
List<WhitelistItem> whitelistItems = batch.stream()
.map(conceptId -> new WhitelistItem(assertion.getUuid().toString(), "", String.valueOf(conceptId), ""))
.collect(Collectors.toList());
List<WhitelistItem> whitelistItems = batch.stream().map(conceptResult -> new WhitelistItem(assertion.getUuid().toString(), conceptResult.getId(), conceptResult.getId(), getAdditionalFields(conceptResult))).toList();

// Send to Authoring acceptance gateway
LOGGER.info("Checking {} whitelist items in batch", whitelistItems.size());
List<WhitelistItem> whitelistedItems = whitelistService.checkComponentFailuresAgainstWhitelist(whitelistItems);
LOGGER.info("{} whitelisted items found", whitelistedItems.size());

// Find the failures which are not in the whitelisted item
newViolatedConceptIds.addAll(batch.stream().filter(conceptId ->
whitelistedItems.stream().noneMatch(whitelistedItem -> String.valueOf(conceptId).equals(whitelistedItem.getConceptId()))
).toList());
newViolatedConceptIds.addAll(batch.stream().filter(conceptResult -> whitelistedItems.stream().noneMatch(whitelistedItem -> String.valueOf(conceptResult.getId()).equals(whitelistedItem.getConceptId()))).map(conceptResult -> Long.parseLong(conceptResult.getId())).toList());
}
List<ConceptResult> newViolatedConcepts = new ArrayList<>(assertion.getCurrentViolatedConcepts().stream().filter(concept -> newViolatedConceptIds.contains(Long.valueOf(concept.getId()))).toList());
List<ConceptResult> newViolatedConcepts = new ArrayList<>(currentViolatedConcepts.stream().filter(concept -> newViolatedConceptIds.contains(Long.valueOf(concept.getId()))).toList());
assertion.setCurrentViolatedConceptIds(newViolatedConceptIds);
assertion.setCurrentViolatedConcepts(newViolatedConcepts);
}
Expand Down

0 comments on commit 1e2c11f

Please sign in to comment.