Skip to content

Commit

Permalink
Set MultiVolumeBook only if the record contains #36 sbd (RPB-28)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsteeg committed Jun 29, 2023
1 parent b0cf60b commit fe1d365
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion app/rpb/Decode.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public final class Decode extends DefaultObjectPipe<String, StreamReceiver> {
private String recordId;
private String recordTitle;
private boolean inMultiVolumeRecord;
private String currentRecord;

@Override
public void process(final String obj) {
currentRecord = obj;
LOG.debug("Process record: " + obj);
final String[] vals = obj.split("\\[/\\]");
recordId = getId(obj, vals);
Expand Down Expand Up @@ -47,7 +49,7 @@ private void processFields(final String[] vals) {
if("#36 ".equals(k) && "sm".equals(v)) {
inMultiVolumeRecord = true;
} else if(inMultiVolumeRecord && "#01 ".equals(k)) {
if(volumeCounter == 0) {
if(volumeCounter == 0 && currentRecord.contains("#36 sbd")) { // s. RPB-28
// we're still in the main (multi volume) record, so we mark that here:
getReceiver().literal(fieldName("#36t"), "MultiVolumeBook");
}
Expand Down
7 changes: 4 additions & 3 deletions test/rpb/DecodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public void processRecord() {

@Test
public void processRecordWithMultipleVolumes() {
// 'sm' in '#01 ' -> treat as multiple volumes with their own titles
// 'sm' & 'sbd' in '#36 ' -> treat as multiple volumes with their own titles
test("[/]#00 929t124030[/]#20 Deutsche Binnenwasserstraßen[/]#36 sm[/]"
+ "#01 6/2022[/]#20 Der Rhein - Rheinfelden bis Koblenz[/]"
+ "#01 6/2022[/]#36 sbd[/]#20 Der Rhein - Rheinfelden bis Koblenz[/]"
+ "#01 7. Band 2022[/]#20 Der Rhein - Koblenz bis Tolkamer[/]"
+ "#01 Nachgewiesen 2007 -[/]#20 [/]"
+ "#01 Nachgewiesen 2008 -[/]",
Expand All @@ -82,6 +82,7 @@ public void processRecordWithMultipleVolumes() {
ordered.verify(receiver).literal("f00_", "929t124030b1");
ordered.verify(receiver).literal("f20ü", "Deutsche Binnenwasserstraßen");
ordered.verify(receiver).literal("f01_", "6/2022");
ordered.verify(receiver).literal("f36_", "sbd");
ordered.verify(receiver).literal("f20_", "Der Rhein - Rheinfelden bis Koblenz");
ordered.verify(receiver).endRecord();
ordered.verify(receiver).startRecord("929t124030b2");
Expand All @@ -107,7 +108,7 @@ public void processRecordWithMultipleVolumes() {

@Test
public void processRecordWithMultipleTitles() {
// No 'sm' in '#01 ' -> treat as multiple titles of single volume
// No 'sm' in '#36 ' -> treat as multiple titles of single volume
test("[/]#00 929t124030[/]#20 Deutsche Binnenwasserstraßen[/]#36 TEST[/]"
+ "#01 6[/]#20 Der Rhein - Rheinfelden bis Koblenz[/]"
+ "#01 7[/]#20 Der Rhein - Koblenz bis Tolkamer[/]", () -> {
Expand Down

0 comments on commit fe1d365

Please sign in to comment.