Skip to content

Commit

Permalink
Merge pull request #68 from hbz/rpb-128-rppd
Browse files Browse the repository at this point in the history
Transformation updates for RPPD forms (RPB-128)
  • Loading branch information
fsteeg authored Feb 16, 2024
2 parents 621dd7f + 206f324 commit eea6777
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 73 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@ This attempts to import all data selected with the `PICK` variable to the API en
To reimport existing entries, these may need to be deleted first, e.g. for `articles/1` to `articles/5`:

```
curl --request DELETE http://test-metadaten-nrw.hbz-nrw.de:1339/api/articles/[1-5]
curl --request DELETE http://test-metadaten-nrw.hbz-nrw.de:1337/api/articles/[1-5]
```

After import they are available at e.g. http://test-metadaten-nrw.hbz-nrw.de:1339/api/articles?populate=*
After import they are available at e.g. http://test-metadaten-nrw.hbz-nrw.de:1337/api/articles?populate=*

Entries using the same path can be filtered, e.g. to get only volumes (`f36_=sbd`):

http://test-metadaten-nrw.hbz-nrw.de:1339/api/independent-works?filters[f36_][$eq]=sbd&populate=*
http://test-metadaten-nrw.hbz-nrw.de:1337/api/independent-works?filters[f36_][$eq]=sbd&populate=*

### Import SKOS data into strapi

Expand Down
96 changes: 48 additions & 48 deletions conf/output/test-output-rppd.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion conf/rpb-sw-import.flux
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default IN_FILE = "test-output-sw.json"; // pass e.g. IN_FILE=output-sw-strapi.ndjson
default HOST = "localhost"; // pass e.g. HOST=test-metadaten-nrw.hbz-nrw.de
API_URL = "http://" + HOST + ":1339/api/rpb-authorities";
API_URL = "http://" + HOST + ":1337/api/rpb-authorities";

FLUX_DIR + "output/" + IN_FILE
| open-file
Expand Down
2 changes: 1 addition & 1 deletion conf/rpb-systematik-import.flux
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default HOST = "localhost"; // pass e.g. HOST=test-metadaten-nrw.hbz-nrw.de
API_URL = "http://" + HOST + ":1339/api/" + PATH;
API_URL = "http://" + HOST + ":1337/api/" + PATH;

"https://raw.githubusercontent.com/acka47/scripts/master/skos2json/" + INPUT
| open-http
Expand Down
2 changes: 1 addition & 1 deletion conf/rpb-test-titel-import.flux
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default HOST = "localhost"; // pass e.g. test-metadaten-nrw.hbz-nrw.de
API_URL = "http://" + HOST + ":1339/api/" + PATH;
API_URL = "http://" + HOST + ":1337/api/" + PATH;

FIX = "
unless " + PICK + "
Expand Down
2 changes: 1 addition & 1 deletion conf/rpb-titel-import.flux
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default HOST = "localhost"; // pass e.g. test-metadaten-nrw.hbz-nrw.de
API_URL = "http://" + HOST + ":1339/api/" + PATH;
API_URL = "http://" + HOST + ":1337/api/" + PATH;

FIX = "
unless " + PICK + "
Expand Down
2 changes: 1 addition & 1 deletion conf/rppd-import.flux
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
default HOST = "localhost"; // pass e.g. HOST=test-metadaten-nrw.hbz-nrw.de
default IN_FILE = "test-output-rppd.json"; // pass e.g. IN_FILE=output-rppd-strapi.ndjson
API_URL = "http://" + HOST + ":1339/api/rppds";
API_URL = "http://" + HOST + ":1337/api/rppds";

FLUX_DIR + "output/" + IN_FILE
| open-file
Expand Down
5 changes: 2 additions & 3 deletions conf/rppd-to-lobid.fix
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,12 @@ copy_field("f1nu[].*.f1nu", "publication[].$append")

# -------
# #1nv (Geschlecht) -> gender
# Kommentar Doku: "mmm" (männlich) oder "www" (weiblich) eintragen,

set_array("gender[]")
if any_equal("f1nv", "mmm")
if any_equal("f1nv", "männlich")
set_field("gender[].$append.id", "https://d-nb.info/standards/vocab/gnd/gender#male")
set_field("gender[].$last.label", "Männlich")
elsif any_equal("f1nv", "www")
elsif any_equal("f1nv", "weiblich")
set_field("gender[].$append.id", "https://d-nb.info/standards/vocab/gnd/gender#female")
set_field("gender[].$last.label", "Weiblich")
else
Expand Down
6 changes: 4 additions & 2 deletions conf/rppd-to-strapi.fix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ do once()
end

call_macro("to_bool", field: "f11_")
call_macro("to_bool", field: "f12_")
call_macro("to_bool", field: "f13_")
call_macro("to_bool", field: "f14_")
call_macro("to_bool", field: "f15_")
Expand Down Expand Up @@ -63,7 +64,8 @@ end
replace_all("f82b", "(\\d+)n(\\d)", "$1-$2")
lookup("f82b", "map_gndid_to_new")

replace_all("f1nv", "w+", "www") # z.B. ww -> www
replace_all("f1nv", "m+", "mmm") # z.B. mmmm -> mmm
replace_all("f1nv", "w+", "weiblich")
replace_all("f1nv", "m+", "männlich")
replace_all("f1nv", "d+", "divers")

vacuum()
12 changes: 6 additions & 6 deletions transformAndImportFull.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ if [ -z "$@" ]; then echo "Pass host, e.g. 'localhost'"; else echo "Will import
HOST=$1

# Notationen
# curl --request DELETE "http://$HOST:1339/api/rpb-notations/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-notations/[1-5]"
sbt "runMain rpb.ETL conf/rpb-systematik-import.flux INPUT=rpb.ndjson PATH=rpb-notations HOST=$HOST"
# curl --request DELETE "http://$HOST:1339/api/rpb-spatials/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-spatials/[1-5]"
sbt "runMain rpb.ETL conf/rpb-systematik-import.flux INPUT=rpb-spatial.ndjson PATH=rpb-spatials HOST=$HOST"

# Personen
# curl --request DELETE "http://$HOST:1339/api/rppds/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rppds/[1-5]"
sbt "runMain rpb.ETL conf/rppd-to-strapi.flux IN_FILE=RPB-Export_HBZ_Bio.txt OUT_FILE=output-rppd-strapi.ndjson"
sbt "runMain rpb.ETL conf/rppd-import.flux IN_FILE=output-rppd-strapi.ndjson HOST=$HOST"

# Normdaten
# curl --request DELETE "http://$HOST:1339/api/rpb-authorities/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-authorities/[1-5]"
sbt "runMain rpb.ETL conf/rpb-sw-to-strapi.flux IN_FILE=RPB-Export_HBZ_SW.txt OUT_FILE=output-sw-strapi.ndjson"
sbt "runMain rpb.ETL conf/rpb-sw-import.flux IN_FILE=output-sw-strapi.ndjson HOST=$HOST"

# Titeldaten
sbt "runMain rpb.ETL conf/rpb-titel-to-strapi.flux"
# curl --request DELETE "http://$HOST:1339/api/articles/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/articles/[1-5]"
sbt "runMain rpb.ETL conf/rpb-titel-import.flux PICK=all_equal('f36_','u') PATH=articles HOST=$HOST"
# curl --request DELETE "http://$HOST:1339/api/independent-works/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/independent-works/[1-5]"
sbt "runMain rpb.ETL conf/rpb-titel-import.flux PICK=all_equal('f36_','Monografie') PATH=independent-works HOST=$HOST"
sbt "runMain rpb.ETL conf/rpb-titel-import.flux PICK=all_equal('f36_','Band') PATH=independent-works HOST=$HOST"
sbt "runMain rpb.ETL conf/rpb-titel-import.flux PICK=all_equal('f36t','MultiVolumeBook') PATH=independent-works HOST=$HOST"
12 changes: 6 additions & 6 deletions transformAndImportTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ if [ -z "$@" ]; then echo "Pass host, e.g. 'localhost'"; else echo "Will import
HOST=$1

# Notationen
# curl --request DELETE "http://$HOST:1339/api/rpb-notations/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-notations/[1-5]"
sbt "runMain rpb.ETL conf/rpb-systematik-import.flux INPUT=rpb.ndjson PATH=rpb-notations HOST=$HOST"
# curl --request DELETE "http://$HOST:1339/api/rpb-spatials/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-spatials/[1-5]"
sbt "runMain rpb.ETL conf/rpb-systematik-import.flux INPUT=rpb-spatial.ndjson PATH=rpb-spatials HOST=$HOST"

# Personen
# curl --request DELETE "http://$HOST:1339/api/rppds/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rppds/[1-5]"
sbt "runMain rpb.ETL conf/rppd-to-strapi.flux IN_FILE=RPB-Export_HBZ_Bio_Test.txt OUT_FILE=test-output-rppd.json"
sbt "runMain rpb.ETL conf/rppd-import.flux IN_FILE=test-output-rppd.json HOST=$HOST"

# Normdaten
# curl --request DELETE "http://$HOST:1339/api/rpb-authorities/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/rpb-authorities/[1-5]"
sbt "runMain rpb.ETL conf/rpb-sw-to-strapi.flux IN_FILE=RPB-Export_HBZ_SW_Test.txt OUT_FILE=test-output-sw.json"
sbt "runMain rpb.ETL conf/rpb-sw-import.flux IN_FILE=test-output-sw.json HOST=$HOST"

# Titeldaten
sbt "runMain rpb.ETL conf/rpb-test-titel-to-strapi.flux"
# curl --request DELETE "http://$HOST:1339/api/articles/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/articles/[1-5]"
sbt "runMain rpb.ETL conf/rpb-test-titel-import.flux PICK=all_equal('f36_','u') PATH=articles HOST=$HOST"
# curl --request DELETE "http://$HOST:1339/api/independent-works/[1-5]"
# curl --request DELETE "http://$HOST:1337/api/independent-works/[1-5]"
sbt "runMain rpb.ETL conf/rpb-test-titel-import.flux PICK=all_equal('f36_','Monografie') PATH=independent-works HOST=$HOST"
sbt "runMain rpb.ETL conf/rpb-test-titel-import.flux PICK=all_equal('f36_','Band') PATH=independent-works HOST=$HOST"
sbt "runMain rpb.ETL conf/rpb-test-titel-import.flux PICK=all_equal('f36t','MultiVolumeBook') PATH=independent-works HOST=$HOST"

0 comments on commit eea6777

Please sign in to comment.