-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag594.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package de.gwdg.metadataqa.marc.definition.tags.bltags; | ||
|
||
import de.gwdg.metadataqa.marc.definition.Cardinality; | ||
import de.gwdg.metadataqa.marc.definition.DataFieldDefinition; | ||
import de.gwdg.metadataqa.marc.definition.Indicator; | ||
import de.gwdg.metadataqa.marc.definition.general.validator.RegexValidator; | ||
|
||
/** | ||
* National Bibliography Issue Number | ||
*/ | ||
public class Tag594 extends DataFieldDefinition { | ||
|
||
private static Tag594 uniqueInstance; | ||
|
||
private Tag594() { | ||
initialize(); | ||
postCreation(); | ||
} | ||
|
||
public static Tag594 getInstance() { | ||
if (uniqueInstance == null) | ||
uniqueInstance = new Tag594(); | ||
return uniqueInstance; | ||
} | ||
|
||
private void initialize() { | ||
|
||
tag = "594"; | ||
label = "Reference to Items in Printed Catalogues"; | ||
mqTag = "referenceToItemsInPrintedCatalogues"; | ||
cardinality = Cardinality.Repeatable; | ||
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html"; | ||
// setCompilanceLevels("O"); | ||
|
||
ind1 = new Indicator(); | ||
ind2 = new Indicator(); | ||
|
||
setSubfieldsWithCardinality( | ||
"a", "Note of earliest British Library edition", "NR", | ||
"b", "Reference to items in printed catalogues", "NR" | ||
); | ||
|
||
getSubfield("a") | ||
.setValidator(new RegexValidator("^.*\\.$")) | ||
.setMqTag("note"); | ||
|
||
getSubfield("b") | ||
.setValidator(new RegexValidator("^.*\\.$")) | ||
.setMqTag("reference"); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/test/java/de/gwdg/metadataqa/marc/definition/tags/bltags/Tag594Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package de.gwdg.metadataqa.marc.definition.tags.bltags; | ||
|
||
import de.gwdg.metadataqa.marc.DataField; | ||
import de.gwdg.metadataqa.marc.MarcRecord; | ||
import de.gwdg.metadataqa.marc.definition.MarcVersion; | ||
import org.junit.Test; | ||
|
||
import static junit.framework.TestCase.assertFalse; | ||
import static junit.framework.TestCase.assertTrue; | ||
|
||
public class Tag594Test { | ||
|
||
@Test | ||
public void testValidFields() { | ||
validField("a", "First BL ed."); | ||
validField("b", "114."); | ||
validField("b", "tys."); | ||
} | ||
|
||
@Test | ||
public void testInvalidFields() { | ||
invalidField("c", "NLS copy dimensions: 16 cm."); | ||
invalidField("1", "a", "NLS copy dimensions: 16 cm."); | ||
} | ||
|
||
public void validField(String subfield, String value) { | ||
DataField field = new DataField(Tag594.getInstance(), " ", " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertFalse( | ||
String.format("594$%s=%s should be invalid in normal case", subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertTrue( | ||
String.format("594$%s=%s should be valid in normal case", subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
|
||
public void invalidField(String subfield, String value) { | ||
invalidField(" ", subfield, value); | ||
} | ||
|
||
public void invalidField(String ind1, String subfield, String value) { | ||
DataField field = new DataField(Tag594.getInstance(), ind1, " ", subfield, value); | ||
|
||
MarcRecord record = new MarcRecord("test"); | ||
field.setRecord(record); | ||
|
||
assertFalse( | ||
String.format("594$%s=%s should be invalid in normal case", subfield, value), | ||
field.validate(MarcVersion.MARC21)); | ||
assertFalse( | ||
String.format("594$%s=%s should be invalid in BL", subfield, value), | ||
field.validate(MarcVersion.BL)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters