Skip to content

Commit

Permalink
issue #75: add tag ONX
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Dec 18, 2020
1 parent 4a9e9c6 commit 160d944
Show file tree
Hide file tree
Showing 5 changed files with 131 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, ONS
MIS, MNI, MPX, NEG, NID, OBJ, OHC, ONS, ONX

13 changes: 13 additions & 0 deletions src/main/java/de/gwdg/metadataqa/marc/MarcSubfield.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,19 @@ public boolean validate(MarcVersion marcVersion) {
: referencePath + "->" + definition.getPath());
addError(path, ValidationErrorType.SUBFIELD_INVALID_VALUE, message);
isValid = false;
/*
} else if (definition.getCodeList() != null &&
!definition.getCodeList().isValid(value)) {
String message = value;
if (referencePath != null) {
message += String.format(" (the field is embedded in %s)", referencePath);
}
String path = (referencePath == null
? definition.getPath()
: referencePath + "->" + definition.getPath());
addError(path, ValidationErrorType.SUBFIELD_INVALID_VALUE, message);
isValid = false;
*/
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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.codelist.CountryCodes;
import de.gwdg.metadataqa.marc.definition.general.codelist.LanguageCodes;

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

private static TagONX uniqueInstance;

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

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

private void initialize() {

tag = "ONX";
label = "ONIX Un-Mapped Data";
mqTag = "OnixUnmappedData";
cardinality = Cardinality.Nonrepeatable;
// descriptionUrl = "https://www.loc.gov/marc/bibliographic/bd037.html";
// setCompilanceLevels("O");

ind1 = new Indicator();

ind2 = new Indicator();

setSubfieldsWithCardinality(
"a", "Country of publication code", "NR",
"b", "Language code", "NR",
"c", "Edition type code", "NR"
);

// TODO: the example use capital letters, the country code list contains small letters
getSubfield("a")
// .setCodeList(CountryCodes.getInstance())
.setMqTag("country");

getSubfield("b")
.setCodeList(LanguageCodes.getInstance())
.setMqTag("language");

// https://www.medra.org/stdoc/onix-codelist-21.htm
getSubfield("c")
.setCodes(
"ABR", "Abridged",
"ADP", "Adapted",
"ALT", "Alternate",
"ANN", "Annotated",
"BLL", "Bilingual edition",
"BRL", "Braille edition",
"CMB", "Combined volume",
"CRI", "Critical",
"CSP", "Coursepack",
"DGO", "Digital original",
"ENL", "Enlarged",
"EXP", "Expurgated",
"FAC", "Facsimile",
"FST", "Festschrift",
"ILL", "Illustrated",
"LTE", "Large type / large print",
"MCP", "Microprint",
"MDT", "Media tie-in",
"MLL", "Multilingual edition",
"NED", "New edition",
"NUM", "Edition with numbered copies",
"PRB", "Prebound edition",
"REV", "Revised",
"SCH", "School edition",
"SMP", "Simplified language edition",
"SPE", "Special edition",
"STU", "Student edition",
"TCH", "Teacher’s edition",
"UBR", "Unabridged",
"ULP", "Ultra large print",
"UXP", "Unexpurgated",
"VAR", "Variorum"
)
.setMqTag("editionType");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.gwdg.metadataqa.marc.definition.tags.bltags;

import org.junit.Test;

public class TagONXTest extends BLTagTest {

public TagONXTest() {
super(TagONX.getInstance());
}

@Test
public void testValidFields() {
validField("a", "AU", "c", "NED");
}

@Test
public void testInvalidFields() {
invalidField("1", "a", "1");
// invalidField("a", "1.");
// invalidField("b", "1");
invalidField("d", "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(390, tags.size());
assertEquals(391, 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 160d944

Please sign in to comment.