Export in PICA+ ausgelagert
This commit is contained in:
parent
1ecfe74b83
commit
e7274cbd7c
|
@ -0,0 +1,82 @@
|
||||||
|
# Generierung PICA+ aus CSV-Exporten
|
||||||
|
|
||||||
|
# ================================== CONFIG ================================== #
|
||||||
|
|
||||||
|
# TODO: Zusammenführung mit Alephino
|
||||||
|
zip -j "${workspace}/ba-sachsen.zip" \
|
||||||
|
"${workspace}/bibliotheca.csv"
|
||||||
|
|
||||||
|
projects["ba-sachsen"]="${workspace}/ba-sachsen.zip"
|
||||||
|
|
||||||
|
# ================================= STARTUP ================================== #
|
||||||
|
|
||||||
|
refine_start; echo
|
||||||
|
|
||||||
|
# ================================== IMPORT ================================== #
|
||||||
|
|
||||||
|
# Neues Projekt erstellen aus Zip-Archiv
|
||||||
|
|
||||||
|
p="ba-sachsen"
|
||||||
|
echo "import file" "${projects[$p]}" "..."
|
||||||
|
if curl -fs --write-out "%{redirect_url}\n" \
|
||||||
|
--form project-file="@${projects[$p]}" \
|
||||||
|
--form project-name="${p}" \
|
||||||
|
--form format="text/line-based/*sv" \
|
||||||
|
--form options='{
|
||||||
|
"encoding": "UTF-8",
|
||||||
|
"includeFileSources": "false",
|
||||||
|
"separator": ","
|
||||||
|
}' \
|
||||||
|
"${endpoint}/command/core/create-project-from-upload$(refine_csrf)" \
|
||||||
|
> "${workspace}/${p}.id"
|
||||||
|
then
|
||||||
|
log "imported ${projects[$p]} as ${p}"
|
||||||
|
else
|
||||||
|
error "import of ${projects[$p]} failed!"
|
||||||
|
fi
|
||||||
|
refine_store "${p}" "${workspace}/${p}.id" || error "import of ${p} failed!"
|
||||||
|
echo
|
||||||
|
|
||||||
|
# ================================ TRANSFORM ================================= #
|
||||||
|
|
||||||
|
# --------------------------- 01 Exemplare clustern -------------------------- #
|
||||||
|
|
||||||
|
# TODO
|
||||||
|
# spec_Z_07
|
||||||
|
|
||||||
|
# ================================== EXPORT ================================== #
|
||||||
|
|
||||||
|
# Export in PICA+
|
||||||
|
format="pic"
|
||||||
|
echo "export ${p} to pica+ file using template..."
|
||||||
|
IFS= read -r -d '' template << "TEMPLATE"
|
||||||
|
{{
|
||||||
|
if(row.index - row.record.fromRowIndex == 0, '' + '\n', '')
|
||||||
|
}}{{
|
||||||
|
forNonBlank(cells['0100'].value, v, '003@' + ' 0' + v + '\n', '')
|
||||||
|
}}{{
|
||||||
|
forNonBlank(cells['2199'].value, v, '006Y' + ' 0' + v + '\n', '')
|
||||||
|
}}{{
|
||||||
|
if(isNonBlank(cells['7100f'].value), '209A/' + with(rowIndex - row.record.fromRowIndex + 1, i, '00'[0,2-i.length()] + i) + ' B' + cells['7100B'].value + 'f' + cells['7100f'].value + forNonBlank(cells['209Aa'].value, v, 'a' + v, '') + 'x00' + '\n', '')
|
||||||
|
}}
|
||||||
|
TEMPLATE
|
||||||
|
if echo "${template}" | head -c -2 | curl -fs \
|
||||||
|
--data project="${projects[$p]}" \
|
||||||
|
--data format="template" \
|
||||||
|
--data prefix="" \
|
||||||
|
--data suffix="" \
|
||||||
|
--data separator="" \
|
||||||
|
--data engine='{"facets":[],"mode":"row-based"}' \
|
||||||
|
--data-urlencode template@- \
|
||||||
|
"${endpoint}/command/core/export-rows" \
|
||||||
|
> "${workspace}/${p}.${format}"
|
||||||
|
then
|
||||||
|
log "exported ${p} (${projects[$p]}) to ${workspace}/${p}.${format}"
|
||||||
|
else
|
||||||
|
error "export of ${p} (${projects[$p]}) failed!"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# ================================== FINISH ================================== #
|
||||||
|
|
||||||
|
refine_stop; echo
|
|
@ -1,7 +1,7 @@
|
||||||
# Bibliotheca Hauptverarbeitung
|
# Bibliotheca Hauptverarbeitung
|
||||||
# - Datenbereinigungen
|
# - Datenbereinigungen
|
||||||
# - Für PICA+ umformen
|
# - Mapping auf PICA3
|
||||||
# - TSV und PICA+ (via Template) generieren
|
# - PICA3-Spalten als CSV (via Template) exportieren
|
||||||
|
|
||||||
# ================================== CONFIG ================================== #
|
# ================================== CONFIG ================================== #
|
||||||
|
|
||||||
|
@ -365,38 +365,130 @@ else
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# ================================== EXPORT ================================== #
|
# --------------------------------- 07 7100f --------------------------------- #
|
||||||
|
|
||||||
# ------------------------------------ TSV ----------------------------------- #
|
# spec_B_E_13
|
||||||
|
echo "Zweigstelle 7100f..."
|
||||||
format="tsv"
|
|
||||||
echo "export ${p} to ${format} file..."
|
|
||||||
if curl -fs \
|
if curl -fs \
|
||||||
--data project="${projects[$p]}" \
|
--data project="${projects[$p]}" \
|
||||||
--data format="${format}" \
|
--data-urlencode "operations@-" \
|
||||||
--data engine='{"facets":[],"mode":"row-based"}' \
|
"${endpoint}/command/core/apply-operations$(refine_csrf)" > /dev/null \
|
||||||
"${endpoint}/command/core/export-rows" \
|
<< "JSON"
|
||||||
> "${workspace}/${p}.${format}"
|
[
|
||||||
|
{
|
||||||
|
"op": "core/column-addition",
|
||||||
|
"engineConfig": {
|
||||||
|
"facets": [],
|
||||||
|
"mode": "row-based"
|
||||||
|
},
|
||||||
|
"baseColumnName": "E|ZWGST",
|
||||||
|
"expression": "grel:value",
|
||||||
|
"onError": "set-to-blank",
|
||||||
|
"newColumnName": "7100f",
|
||||||
|
"columnInsertIndex": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
JSON
|
||||||
then
|
then
|
||||||
log "exported ${p} (${projects[$p]}) to ${workspace}/${p}.${format}"
|
log "transformed ${p} (${projects[$p]})"
|
||||||
else
|
else
|
||||||
error "export of ${p} (${projects[$p]}) failed!"
|
error "transform ${p} (${projects[$p]}) failed!"
|
||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# ----------------------------------- PICA+ ---------------------------------- #
|
# --------------------------------- 07 209Aa --------------------------------- #
|
||||||
|
|
||||||
format="pic"
|
# spec_B_E_07
|
||||||
echo "export ${p} to pica+ file using template..."
|
echo "Standort 209Aa..."
|
||||||
|
if curl -fs \
|
||||||
|
--data project="${projects[$p]}" \
|
||||||
|
--data-urlencode "operations@-" \
|
||||||
|
"${endpoint}/command/core/apply-operations$(refine_csrf)" > /dev/null \
|
||||||
|
<< "JSON"
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"op": "core/column-addition",
|
||||||
|
"engineConfig": {
|
||||||
|
"facets": [],
|
||||||
|
"mode": "row-based"
|
||||||
|
},
|
||||||
|
"baseColumnName": "E|STA1",
|
||||||
|
"expression": "grel:value",
|
||||||
|
"onError": "set-to-blank",
|
||||||
|
"newColumnName": "209Aa",
|
||||||
|
"columnInsertIndex": 3
|
||||||
|
}
|
||||||
|
]
|
||||||
|
JSON
|
||||||
|
then
|
||||||
|
log "transformed ${p} (${projects[$p]})"
|
||||||
|
else
|
||||||
|
error "transform ${p} (${projects[$p]}) failed!"
|
||||||
|
fi
|
||||||
|
echo
|
||||||
|
|
||||||
|
# ================================== EXPORT ================================== #
|
||||||
|
|
||||||
|
# Export der PICA3-Spalten als CSV
|
||||||
|
format="csv"
|
||||||
|
echo "export ${p} to ${format} file using template..."
|
||||||
IFS= read -r -d '' template << "TEMPLATE"
|
IFS= read -r -d '' template << "TEMPLATE"
|
||||||
{{
|
{{
|
||||||
if(row.index - row.record.fromRowIndex == 0, '' + '\n', '')
|
with(
|
||||||
}}{{
|
[
|
||||||
forNonBlank(cells['0100'].value, v, '003@' + ' 0' + v + '\n', '')
|
'2199',
|
||||||
}}{{
|
'0100',
|
||||||
forNonBlank(cells['2199'].value, v, '006Y' + ' 0' + v + '\n', '')
|
'7100B',
|
||||||
}}{{
|
'7100f',
|
||||||
if(isNonBlank(cells['E|EXNR'].value), '209A/' + with(rowIndex - row.record.fromRowIndex + 1, i, '00'[0,2-i.length()] + i) + ' B' + cells['7100B'].value + 'f' + cells['E|ZWGST'].value + forNonBlank(cells['E|STA1'].value, v, 'a' + v, '') + 'x00' + '\n', '')
|
'209Aa'
|
||||||
|
],
|
||||||
|
columns,
|
||||||
|
if(
|
||||||
|
row.index == 0,
|
||||||
|
forEach(
|
||||||
|
columns,
|
||||||
|
cn,
|
||||||
|
cn.escape('csv')
|
||||||
|
).join(',')
|
||||||
|
+ '\n'
|
||||||
|
+ with(
|
||||||
|
forEach(
|
||||||
|
columns,
|
||||||
|
cn,
|
||||||
|
forNonBlank(
|
||||||
|
cells[cn].value,
|
||||||
|
v,
|
||||||
|
v.escape('csv'),
|
||||||
|
'␀'
|
||||||
|
)
|
||||||
|
).join(',').replace('␀',''),
|
||||||
|
r,
|
||||||
|
if(
|
||||||
|
isNonBlank(r.split(',').join(',')),
|
||||||
|
r + '\n',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
),
|
||||||
|
with(
|
||||||
|
forEach(
|
||||||
|
columns,
|
||||||
|
cn,
|
||||||
|
forNonBlank(
|
||||||
|
cells[cn].value,
|
||||||
|
v,
|
||||||
|
v.escape('csv'),
|
||||||
|
'␀'
|
||||||
|
)
|
||||||
|
).join(',').replace('␀',''),
|
||||||
|
r,
|
||||||
|
if(
|
||||||
|
isNonBlank(r.split(',').join(',')),
|
||||||
|
r + '\n',
|
||||||
|
''
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
}}
|
}}
|
||||||
TEMPLATE
|
TEMPLATE
|
||||||
if echo "${template}" | head -c -2 | curl -fs \
|
if echo "${template}" | head -c -2 | curl -fs \
|
||||||
|
|
Loading…
Reference in New Issue