Skip to content

Commit

Permalink
map subjects for ffi
Browse files Browse the repository at this point in the history
  • Loading branch information
truhacevkir committed Jan 10, 2025
1 parent b94daa8 commit 672ffb2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/no/sikt/nva/scrapers/SubjectScraper.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import no.sikt.nva.model.dublincore.DublinCore;
import no.sikt.nva.model.dublincore.Qualifier;
import nva.commons.core.JacocoGenerated;
import nva.commons.core.StringUtils;

public final class SubjectScraper {

Expand Down Expand Up @@ -37,6 +38,7 @@ public static List<String> extractTags(DublinCore dublinCore) {
.filter(SubjectScraper::isSubjectAndNotSpecificallyIgnored)
.map(DcValue::scrapeValueAndSetToScraped)
.filter(Objects::nonNull)
.map(value -> value.replace("TermSet Emneord::", StringUtils.EMPTY_STRING))
.distinct()
.collect(Collectors.toList());
}
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/no/sikt/nva/scrapers/DublinCoreScraperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,20 @@ var record = dcScraper.validateAndParseDublinCore(dublinCore, new BrageLocation(
assertThat(appender.getMessages(), not(containsString(SUBJECT_WARNING.toString())));
}

@Test
void shouldScrapeSubjectAndRemoveTermsetEmneordFromItsValue() {
var value = "TermSet Emneord::Kommunikasjon";
var normalTagWithQualifierNone = new DcValue(Element.SUBJECT, null, value);
var dublinCore = DublinCoreFactory.createDublinCoreWithDcValues(
List.of(normalTagWithQualifierNone, toDcType("Journal Article")));
var record = dcScraper.validateAndParseDublinCore(dublinCore, new BrageLocation(null), SOME_CUSTOMER);

var expectedTag = "Kommunikasjon";

assertEquals(expectedTag, record.getEntityDescription().getTags().get(0));
}


@Test
void shouldScrapeUnrecognizedSubjectsAndWarnAboutUnrecognizedSubject() {
var tag = randomString();
Expand Down

0 comments on commit 672ffb2

Please sign in to comment.