Skip to content

Commit

Permalink
issue #75: add tag ONS
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 18, 2020
1 parent ed3d53a commit 4a9e9c6
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
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, LDO, LEO, LET,
MIS, MNI, MPX, NEG, NID, OBJ, OHC
MIS, MNI, MPX, NEG, NID, OBJ, OHC, ONS

Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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;

/**
* ONIX Subjects
*/
public class TagONS extends DataFieldDefinition {

private static TagONS uniqueInstance;

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

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

private void initialize() {

tag = "ONS";
label = "ONIX Subjects";
mqTag = "OnixSubjects";
cardinality = Cardinality.Repeatable;
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html";
// setCompilanceLevels("O");

ind1 = new Indicator();

ind2 = new Indicator("Provides information on the content of subfield $a")
.setCodes(
" ", "No information provided",
"7", "Source specified in subfield $2"
)
.setMqTag("contentOfSubfield");

setSubfieldsWithCardinality(
"a", "Subject code", "NR",
"t", "Subject heading text", "NR",
"x", "Remainder of BISAC subject code", "NR",
"2", "Source of term", "NR"
);

getSubfield("a").setMqTag("code");
getSubfield("t").setMqTag("text");
getSubfield("x").setMqTag("bisac");
getSubfield("2")
.setCodes(
"bisacsh", "BISAC subject code",
"bicssc", "BIC subject code or BIC geographical qualifier, or BIC language qualifier, or BIC time period qualifier",
"Subject Keywords", "subject keywords"
)
.setMqTag("source");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package de.gwdg.metadataqa.marc.definition.tags.bltags;

import de.gwdg.metadataqa.marc.DataField;
import org.junit.Test;

public class TagONSTest extends BLTagTest {

public TagONSTest() {
super(TagONS.getInstance());
}

@Test
public void testValidFields() {
validField(new DataField(tag, " ", "7", "a", "STU", "x", "026000", "2", "bisacsh"));
validField(new DataField(tag, " ", "7", "a", "YF", "2", "bicssc"));
validField(new DataField(tag, " ", " ",
"t", "Cold War; Espionage; USSR; Soviets; John le Carré; Len Deighton; Chernobyl; Nagasaki; Hiroshima; Nuclear Explosion; M.A.D.; Mutually Assured Destruction",
"2", "Subject Keywords"));
}

@Test
public void testInvalidFields() {
invalidField("1", "a", "1");
invalidField("b", "1.");
invalidField("b", "1");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void testListTag() {
List<Class<? extends DataFieldDefinition>> tags = MarcTagLister.listTags();
assertNotNull(tags);
assertNotEquals(0, tags.size());
assertEquals(389, tags.size());
assertEquals(390, tags.size());
assertEquals("Tag010", tags.get(0).getSimpleName());
Map<String, Integer> versionCounter = new HashMap<>();
Map<MarcVersion, Integer> versionCounter2 = new HashMap<>();
Expand Down

0 comments on commit 4a9e9c6

Please sign in to comment.