Skip to content

Commit

Permalink
Added normalization function to map subject source by code
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanLavrov committed Oct 7, 2024
1 parent cc6f6f0 commit 46f6e6c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions ramls/settings/subjectSource.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"description": "label for the subject source",
"type": "string"
},
"code": {
"description": "label for the subject source code",
"type": "string"
},
"source": {
"type": "string",
"description": "label indicating where the subject source entry originates from, i.e. 'folio' or 'local'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,24 @@ public String apply(RuleExecutionContext context) {
}
},

SET_SUBJECT_SOURCE_ID_BY_CODE() {
@Override
public String apply(RuleExecutionContext context) {
List<SubjectSource> subjectSources = context.getMappingParameters().getSubjectSources();
String sourceCode = context.getSubFieldValue();

if (sourceCode == null || subjectSources == null) {
return StringUtils.EMPTY;
}

return subjectSources.stream()
.filter(subjectSource -> subjectSource.getCode() != null && subjectSource.getCode().equalsIgnoreCase(sourceCode))
.findFirst()
.map(SubjectSource::getId)
.orElse(StringUtils.EMPTY);
}
},

SET_SUBJECT_TYPE_ID() {
private static final String NAME_PARAMETER = "name";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
[ {
[
{
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d40",
"name" : "Library of Congress Subject Headings",
"code" : "lcsh",
"source" : "folio"
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d41",
"name" : "Library of Congress Children's and Young Adults' Subject Headings",
"code" : "cyac",
"source" : "folio"
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d42",
"name" : "Medical Subject Headings",
"code" : "mesh",
"source" : "folio"
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d43",
Expand All @@ -21,13 +25,12 @@
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d45",
"name" : "Canadian Subject Headings",
"code" : "cash",
"source" : "folio"
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d46",
"name" : "Répertoire de vedettes-matière",
"code" : "rvm",
"source" : "folio"
}, {
"id" : "e894d0dc-621d-4b1d-98f6-6f7120eb0d47",
"name" : "Source specified in subfield $2",
"source" : "folio"
} ]
}
]

0 comments on commit 46f6e6c

Please sign in to comment.