Skip to content

Commit

Permalink
issue #75: add tag LDO
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 18, 2020
1 parent 4177fa5 commit e0b0b27
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
- British Library tags: 039, 091, 509, 539, 590, 591, 592, 594, 595, 596, 597, 598, 599,
690, 692, 852$a (code list), 859, 909, 916, 917, 945, 950, 954, 955, 957, 959, 960,
961, 962, 963, 964, 966, 968, 970, 975, 976, 979, 980, 985, 990, 992, 996, 997,
A02, AQN, BGT, BUF, CFI, CNF, DGM, DRT, EST, EXP, FFP, FIN, LAS, LCS
A02, AQN, BGT, BUF, CFI, CNF, DGM, DRT, EST, EXP, FFP, FIN, LAS, LCS, LDO

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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.parser.LinkageParser;
import de.gwdg.metadataqa.marc.definition.general.validator.ISSNValidator;

import static de.gwdg.metadataqa.marc.definition.FRBRFunction.*;

/**
* LDO (Legal Deposit Office) Information
*/
public class TagLDO extends DataFieldDefinition {

private static TagLDO uniqueInstance;

private TagLDO() {
initialize();
postCreation();
}

public static TagLDO getInstance() {
if (uniqueInstance == null)
uniqueInstance = new TagLDO();
return uniqueInstance;
}

private void initialize() {

tag = "LDO";
label = "LDO (Legal Deposit Office) Information";
mqTag = "LegalDepositOfficeInformation";
cardinality = Cardinality.Repeatable;
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html";
// setCompilanceLevels("O");

ind1 = new Indicator();

ind2 = new Indicator();

setSubfieldsWithCardinality(
"a", "Source of record", "NR",
"b", "Format of item used for record", "NR",
"c", "Date at Copyright Agent", "NR",
"d", "ALDL control number", "NR"
);

getSubfield("a").setMqTag("source");
getSubfield("b").setMqTag("dormat");
getSubfield("c").setMqTag("date");
getSubfield("d").setMqTag("controlNumber");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.gwdg.metadataqa.marc.definition.tags.bltags;

import org.junit.Test;

public class TagLDOTest extends BLTagTest {

public TagLDOTest() {
super(TagLDO.getInstance());
}

@Test
public void testValidFields() {
validField("a", "CIP", "b", "hbk");
validField("a", "CIP", "b", "pbk");
validField("a", "LDO", "b", "pack", "c", "12/6/02");
validField("a", "ALDL", "b", "pbk", "c", "12/10/05", "d", "3982641");
}

@Test
public void testInvalidFields() {
invalidField("3", "a", "Y");
invalidField("e", "20050944");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ public void testListTag() {
List<Class<? extends DataFieldDefinition>> tags = MarcTagLister.listTags();
assertNotNull(tags);
assertNotEquals(0, tags.size());
assertEquals(379, tags.size());
assertEquals(380, tags.size());
assertEquals("Tag010", tags.get(0).getSimpleName());
Map<String, Integer> versionCounter = new HashMap<>();
Map<MarcVersion, Integer> versionCounter2 = new HashMap<>();

for (Class<? extends DataFieldDefinition> tag : tags) {
MarcVersion version = Utils.getVersion(tag);
DataFieldDefinition definition = TagDefinitionLoader.load(tag.getSimpleName().replace("Tag", ""), version);
DataFieldDefinition definition = TagDefinitionLoader.load(
tag.getSimpleName().replace("Tag", ""), version);
assertEquals(tag.getSimpleName() + " should have the same tag", "Tag" + definition.getTag(), tag.getSimpleName());

assertEquals(version, definition.getMarcVersion());
Utils.count(Utils.extractPackageName(definition), versionCounter);
Utils.count(definition.getMarcVersion(), versionCounter2);
Expand Down

0 comments on commit e0b0b27

Please sign in to comment.