Skip to content

Commit fa05f45

Browse files
committed
Add integration test for incorrect path update with multiple reserved fields. (hbz/lobid-resources#1354)
`Value.updatePathRename()` turns `subject[].$last.componentList[].$last.type[].$append` into `subject[].2.componentList[].2.type[].2`.
1 parent be327d9 commit fa05f45

File tree

9 files changed

+250
-0
lines changed

9 files changed

+250
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"subject" : [ {
3+
"componentList" : [ {
4+
"gndIdentifier" : "(DE-588)4131620-4",
5+
"id" : "(DE-588)4131620-4",
6+
"label" : "Schulhof",
7+
"source" : {
8+
"id" : "https://d-nb.info/gnd/7749153-1",
9+
"label" : "Gemeinsame Normdatei (GND)"
10+
},
11+
"type" : [ "SubjectHeading" ]
12+
}, {
13+
"gndIdentifier" : "(DE-588)4116546-9",
14+
"id" : "(DE-588)4116546-9",
15+
"label" : "Sozialraum",
16+
"source" : {
17+
"id" : "https://d-nb.info/gnd/7749153-1",
18+
"label" : "Gemeinsame Normdatei (GND)"
19+
},
20+
"type" : [ "SubjectHeading" ]
21+
}, {
22+
"gndIdentifier" : "(DE-588)4680202-2",
23+
"id" : "(DE-588)4680202-2",
24+
"label" : "Informelles Lernen",
25+
"source" : {
26+
"id" : "https://d-nb.info/gnd/7749153-1",
27+
"label" : "Gemeinsame Normdatei (GND)"
28+
},
29+
"type" : [ "SubjectHeading" ]
30+
}, {
31+
"gndIdentifier" : "(DE-588)4155947-2",
32+
"id" : "(DE-588)4155947-2",
33+
"label" : "Ganztagsschule",
34+
"source" : {
35+
"id" : "https://d-nb.info/gnd/7749153-1",
36+
"label" : "Gemeinsame Normdatei (GND)"
37+
},
38+
"type" : [ "SubjectHeading" ]
39+
}, {
40+
"gndIdentifier" : "(DE-588)4130615-6",
41+
"id" : "(DE-588)4130615-6",
42+
"label" : "Sportpädagogik",
43+
"source" : {
44+
"id" : "https://d-nb.info/gnd/7749153-1",
45+
"label" : "Gemeinsame Normdatei (GND)"
46+
},
47+
"type" : [ "SubjectHeading" ]
48+
} ],
49+
"label" : [ ],
50+
"type" : [ "ComplexSubject" ]
51+
} ]
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"subject" : [ {
3+
"componentList" : [ {
4+
"gndIdentifier" : "(DE-588)4131620-4",
5+
"id" : "(DE-588)4131620-4",
6+
"label" : "Schulhof",
7+
"source" : {
8+
"id" : "https://d-nb.info/gnd/7749153-1",
9+
"label" : "Gemeinsame Normdatei (GND)"
10+
},
11+
"type" : [ "s" ]
12+
}, {
13+
"gndIdentifier" : "(DE-588)4116546-9",
14+
"id" : "(DE-588)4116546-9",
15+
"label" : "Sozialraum",
16+
"source" : {
17+
"id" : "https://d-nb.info/gnd/7749153-1",
18+
"label" : "Gemeinsame Normdatei (GND)"
19+
},
20+
"type" : [ "s" ]
21+
}, {
22+
"gndIdentifier" : "(DE-588)4680202-2",
23+
"id" : "(DE-588)4680202-2",
24+
"label" : "Informelles Lernen",
25+
"source" : {
26+
"id" : "https://d-nb.info/gnd/7749153-1",
27+
"label" : "Gemeinsame Normdatei (GND)"
28+
},
29+
"type" : [ "s" ]
30+
}, {
31+
"gndIdentifier" : "(DE-588)4155947-2",
32+
"id" : "(DE-588)4155947-2",
33+
"label" : "Ganztagsschule",
34+
"source" : {
35+
"id" : "https://d-nb.info/gnd/7749153-1",
36+
"label" : "Gemeinsame Normdatei (GND)"
37+
},
38+
"type" : [ "s" ]
39+
}, {
40+
"gndIdentifier" : "(DE-588)4130615-6",
41+
"id" : "(DE-588)4130615-6",
42+
"label" : "Sportpädagogik",
43+
"source" : {
44+
"id" : "https://d-nb.info/gnd/7749153-1",
45+
"label" : "Gemeinsame Normdatei (GND)"
46+
},
47+
"type" : [ "s" ]
48+
} ],
49+
"label" : [ ],
50+
"type" : [ "ComplexSubject" ]
51+
} ]
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
put_map("rswk-indicator", s: "SubjectHeading")
2+
lookup("subject[].*.componentList[].*.type[].*", "rswk-indicator")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FLUX_DIR + "input.json"
2+
|open-file
3+
|as-records
4+
|decode-json
5+
|fix(FLUX_DIR + "test.fix")
6+
|encode-json(prettyPrinting="true")
7+
|write(FLUX_DIR + "output-metafix.json")
8+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"subject" : [ {
3+
"componentList" : [ {
4+
"gndIdentifier" : "(DE-588)4131620-4",
5+
"id" : "(DE-588)4131620-4",
6+
"label" : "Schulhof",
7+
"source" : {
8+
"id" : "https://d-nb.info/gnd/7749153-1",
9+
"label" : "Gemeinsame Normdatei (GND)"
10+
},
11+
"type" : [ "SubjectHeading" ]
12+
}, {
13+
"gndIdentifier" : "(DE-588)4116546-9",
14+
"id" : "(DE-588)4116546-9",
15+
"label" : "Sozialraum",
16+
"source" : {
17+
"id" : "https://d-nb.info/gnd/7749153-1",
18+
"label" : "Gemeinsame Normdatei (GND)"
19+
},
20+
"type" : [ "SubjectHeading" ]
21+
}, {
22+
"gndIdentifier" : "(DE-588)4680202-2",
23+
"id" : "(DE-588)4680202-2",
24+
"label" : "Informelles Lernen",
25+
"source" : {
26+
"id" : "https://d-nb.info/gnd/7749153-1",
27+
"label" : "Gemeinsame Normdatei (GND)"
28+
},
29+
"type" : [ "SubjectHeading" ]
30+
}, {
31+
"gndIdentifier" : "(DE-588)4155947-2",
32+
"id" : "(DE-588)4155947-2",
33+
"label" : "Ganztagsschule",
34+
"source" : {
35+
"id" : "https://d-nb.info/gnd/7749153-1",
36+
"label" : "Gemeinsame Normdatei (GND)"
37+
},
38+
"type" : [ "SubjectHeading" ]
39+
}, {
40+
"gndIdentifier" : "(DE-588)4130615-6",
41+
"id" : "(DE-588)4130615-6",
42+
"label" : "Sportpädagogik",
43+
"source" : {
44+
"id" : "https://d-nb.info/gnd/7749153-1",
45+
"label" : "Gemeinsame Normdatei (GND)"
46+
},
47+
"type" : [ "SubjectHeading" ]
48+
} ],
49+
"label" : [ ],
50+
"type" : [ "ComplexSubject" ]
51+
} ]
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0"?>
2+
<collection xmlns="http://www.loc.gov/MARC21/slim">
3+
<record>
4+
<datafield tag="689" ind1="0" ind2="0">
5+
<subfield code="a">Schulhof</subfield>
6+
<subfield code="D">s</subfield>
7+
<subfield code="0">(DE-588)4131620-4</subfield>
8+
<subfield code="0">(uri) https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn=041316207</subfield>
9+
<subfield code="0">(uri) http://viaf.org/viaf/sourceID/DNB|041316207</subfield>
10+
<subfield code="B">GND-041316207</subfield>
11+
</datafield>
12+
<datafield tag="689" ind1="0" ind2="1">
13+
<subfield code="a">Sozialraum</subfield>
14+
<subfield code="D">s</subfield>
15+
<subfield code="0">(DE-588)4116546-9</subfield>
16+
<subfield code="0">(uri) https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn=041165462</subfield>
17+
<subfield code="0">(uri) http://viaf.org/viaf/sourceID/DNB|041165462</subfield>
18+
<subfield code="B">GND-041165462</subfield>
19+
</datafield>
20+
<datafield tag="689" ind1="0" ind2="2">
21+
<subfield code="a">Informelles Lernen</subfield>
22+
<subfield code="D">s</subfield>
23+
<subfield code="0">(DE-588)4680202-2</subfield>
24+
<subfield code="0">(uri) https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn=964127970</subfield>
25+
<subfield code="0">(uri) http://viaf.org/viaf/sourceID/DNB|964127970</subfield>
26+
<subfield code="B">GND-964127970</subfield>
27+
</datafield>
28+
<datafield tag="689" ind1="0" ind2="3">
29+
<subfield code="a">Ganztagsschule</subfield>
30+
<subfield code="D">s</subfield>
31+
<subfield code="0">(DE-588)4155947-2</subfield>
32+
<subfield code="0">(uri) https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn=041559479</subfield>
33+
<subfield code="0">(uri) http://viaf.org/viaf/sourceID/DNB|041559479</subfield>
34+
<subfield code="B">GND-041559479</subfield>
35+
</datafield>
36+
<datafield tag="689" ind1="0" ind2="4">
37+
<subfield code="a">Sportp&#xE4;dagogik</subfield>
38+
<subfield code="D">s</subfield>
39+
<subfield code="0">(DE-588)4130615-6</subfield>
40+
<subfield code="0">(uri) https://portal.dnb.de/opac.htm?method=simpleSearch&amp;cqlMode=true&amp;query=idn=041306155</subfield>
41+
<subfield code="0">(uri) http://viaf.org/viaf/sourceID/DNB|041306155</subfield>
42+
<subfield code="B">GND-041306155</subfield>
43+
</datafield>
44+
</record>
45+
</collection>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
put_map("rswk-indicator", s: "SubjectHeading")
2+
3+
set_array("subject[]")
4+
5+
if exists("6890?")
6+
set_array("subject[].$append.type[]", "ComplexSubject")
7+
set_array("subject[].$last.label")
8+
set_array("subject[].$last.componentList[]")
9+
do list(path: "6890?", "var": "$i")
10+
set_array("subject[].$last.componentList[].$append.type[]")
11+
do list(path: "$i.D", "var": "$k")
12+
copy_field("$k", "subject[].$last.componentList[].$last.type[].$append")
13+
end
14+
copy_field("$i.a", "subject[].$last.componentList[].$last.label")
15+
do list(path: "$i.0", "var": "$j")
16+
if any_match("$j", "^\\(DE-588\\)(.*)$")
17+
add_field("subject[].$last.componentList[].$last.source.label", "Gemeinsame Normdatei (GND)")
18+
add_field("subject[].$last.componentList[].$last.source.id", "https://d-nb.info/gnd/7749153-1")
19+
copy_field("$j", "subject[].$last.componentList[].$last.id")
20+
replace_all("subject[].$last.componentList[].$last..id", "^\\(DE-588\\)(.*)$", "http://d-nb.info/gnd/$1")
21+
copy_field("$j", "subject[].$last.componentList[].$last.gndIdentifier")
22+
replace_all("subject[].$last.componentList[].$last..gndIdentifier", "^\\(DE-588\\)(.*)$", "$1")
23+
end
24+
end
25+
end
26+
end
27+
28+
lookup("subject[].*.componentList[].*.type[].*", "rswk-indicator")
29+
30+
retain("subject[]")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FLUX_DIR + "input.xml"
2+
|open-file
3+
|decode-xml
4+
|handle-marcxml
5+
|fix(FLUX_DIR + "test.fix")
6+
|encode-json(prettyPrinting="true")
7+
|write(FLUX_DIR + "output-metafix.json")
8+
;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See hbz/lobid-resources#1354

0 commit comments

Comments
 (0)