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

Corrected (staging area) match count facet to give the total number of #225

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -3,7 +3,6 @@
import gsrs.config.EntityContextLookup;
import gsrs.imports.GsrsImportAdapterFactoryFactory;
import gsrs.stagingarea.model.ImportMetadata;
import gsrs.stagingarea.model.MatchedKeyValue;
import gsrs.stagingarea.model.MatchedRecordSummary;
import gsrs.stagingarea.repository.ImportDataRepository;
import gsrs.stagingarea.service.StagingAreaService;
Expand All @@ -13,7 +12,6 @@
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
import java.util.function.Consumer;

@Slf4j
Expand Down Expand Up @@ -53,13 +51,16 @@ public void createIndexableValues(ImportMetadata importMetadata, Consumer<Indexa
String instanceData= importDataRepository.retrieveByInstanceID(importMetadata.getInstanceId());
MatchedRecordSummary matchedRecordSummary = stagingAreaService.findMatchesForJson(importMetadata.getEntityClassName(), instanceData,
importMetadata.getRecordId().toString());
long matchCount= matchedRecordSummary.getMatches().stream()
.map(MatchedKeyValue::getMatchingRecords)
.flatMap(Collection::stream)
.filter(m->m. getSourceName().equals(USED_SOURCE))

long matchCount=matchedRecordSummary.getMatches().stream()
.flatMap(m->m.getMatchingRecords().stream())
.filter(r->r.getSourceName().equals(USED_SOURCE))
.map(r->r.getRecordId())
.distinct()
.count();
consumer.accept(IndexableValue.simpleFacetStringValue(IMPORT_METADATA_MATCH_COUNT_FACET, Long.toString(matchCount)));
log.trace("created string facet {} with value {}", IMPORT_METADATA_MATCH_COUNT_FACET, matchCount);

matchedRecordSummary.getMatches().stream()
.filter(m->m.getMatchingRecords().stream().anyMatch(r->r.getSourceName().equals(USED_SOURCE)))
.forEach(r->r.getMatchingRecords()
Expand Down