Skip to content

Commit

Permalink
fix problem with blank subjects (#2674)
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-butcher authored Jul 1, 2024
1 parent 0404dc8 commit 21fef70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ trait MarcSubject extends MarcFieldTransformer with MarcHasRecordControlNumber {
): Output = getSubjectConcepts(field) match {
case Success(Nil) => None
case Success(entities) =>
Some(
Subject(
label = getLabel(field).get,
concepts = entities.toList,
id = getIdState(field)
)
getLabel(field).map(
label =>
Subject(
label = label,
concepts = entities.toList,
id = getIdState(field)
)
)
case Failure(exception) =>
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,28 @@ class MarcSubjectsTest
MarcSubjects(
MarcTestRecord(fields =
Seq(
// with no subfields
MarcField(
marcTag = "610",
subfields = Nil
),
// with blank or blank-like subfields
MarcField(
marcTag = "600",
marcTag = "650",
indicator2 = "0",
subfields = Seq(
MarcSubfield(tag = "a", content = " "),
MarcSubfield(tag = "b", content = ""),
MarcSubfield(tag = "c", content = " ")
)
),
// with a dodgy second indicator
MarcField(
marcTag = "650",
indicator2 = "x",
subfields = Seq(
MarcSubfield(tag = "a", content = "Hello, World!")
)
)
)
)
Expand Down

0 comments on commit 21fef70

Please sign in to comment.