Last active
August 27, 2021 12:33
-
-
Save cKlee/493a504c278b47ab170ebfd0ce41b500 to your computer and use it in GitHub Desktop.
ZDB Import und Änderungsfunktionen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Datei: zdb_scripte_perUser.js | |
// Autor: | |
// Datei fuer nutzerspezifische Standarskripts | |
//-------------------------------------------------------------------------------------------------------- | |
//name: __zeigeEigenschaften | |
//replaces: zeigeEigenschaften | |
//description: listing a objects properties | |
//user: developers | |
//input: the object | |
//return: messageBox with all properties | |
//author: Carsten Klee | |
//date: 2011-06-24 | |
//version: 1.0.0.1 | |
//-------------------------------------------------------------------------------------------------------- | |
function __zeigeEigenschaften(object){ | |
var Namen = new Array(); | |
var namen = ""; | |
var type; | |
// make a properties list for the prompter | |
//for(var name in object) namen += name + "\n"; | |
for(var name in object) Namen.push(name); | |
// get out if objects count zero prperties | |
if (Namen.length == 0) | |
{ | |
application.messageBox("Länge des Objekts", "Das Objekt hat " + Namen.length + " Eigenschaften.", false); | |
return; | |
} | |
Namen.sort(); | |
namen = Namen.join("\n"); | |
// initialize the prompter | |
var thePrompter = utility.newPrompter(); | |
thePrompter.setDebug(false); // only for debugging | |
// get the selection as string | |
var theAnswer = thePrompter.select("Eigenschaften von " + typeof object, "Zeige Eigenschaften von", namen); | |
// return if nothing have been selected | |
if (!theAnswer) { | |
return; | |
} else { | |
// eval the answer as an object | |
/*for(var n in object) { | |
if(n == theAnswer) | |
__zdbError(object[theAnswer]); | |
}*/ | |
//var newObject = eval(object[theAnswer]); | |
var newObject = object[theAnswer]; | |
type = typeof newObject; | |
application.messageBox("Typ des Objects", type, false); | |
if(type == "object"){ | |
__zeigeEigenschaften(newObject); | |
} | |
else { | |
try { | |
if(type == "function") | |
{ | |
application.messageBox("Eigenschaften",newObject.toString() + "\nWeitere Eigenschaften anzeigen?",false); | |
__zeigeEigenschaften(newObject); | |
return; | |
} | |
else // strings, integers | |
{ | |
application.messageBox("Eigenschaften", newObject.toString(), false); | |
} | |
} | |
catch(exception) | |
{ | |
application.messageBox("Fehler",exception,false); | |
} | |
finally | |
{ | |
return; | |
} | |
} | |
} | |
} | |
function isilGeoUpload() { | |
var csv = new CSV(); | |
csv.csvFilename = "out20160303_mus_opencage2.csv"; | |
csv.startLine = 1; | |
csv.delimiter = ";"; | |
csv.__osm = function () { | |
var lat, lon, anschrift; | |
var updatetxt = "neugeo 11-5-16"; | |
// set gloabal variable _rec | |
__zdbJSON(); | |
if ("I" == _rec["035E"][0]['a']) return; | |
application.activeWindow.command("k", false); | |
// 032P $k = Länge, 032P $l = Breite | |
for (var i in _rec["032P"]) { | |
if ("S" == _rec["032P"][i]['2']) { | |
if (!_rec["032P"][i]['k']) { | |
break; | |
} else { | |
return csv.__csvSaveBuffer(false, "Koordinaten vorhanden fuer ISIL " + csv.line['isil']); | |
} | |
} | |
} | |
lon = csv.line['lon'].toString(); | |
lon = lon.match(/(^.*\.\d{5,5})/)[1]; | |
lat = csv.line['lat'].toString(); | |
lat = lat.match(/(^.*\.\d{5,5})/)[1]; | |
for (var s in _rec["032P"][i]) { | |
if (s > 'k') { | |
break; | |
} | |
} | |
anschrift = application.activeWindow.title.findTag("371", i, true, true, false); | |
var re = new RegExp("(^.*)(\\$" + s + ".*$)"); | |
var replacementpattern = "$1$k" + lon + "$l" + lat + "$2"; | |
var result = anschrift.replace(re, replacementpattern); | |
application.activeWindow.title.deleteLine(1); | |
application.activeWindow.title.insertText(result + "\n"); | |
if (!_rec['050D']) { | |
application.activeWindow.title.insertText("\n680 " + updatetxt + "\n"); | |
} else { | |
application.activeWindow.title.findTag("680", 0, false, true, false); | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText("; " + updatetxt + "\n"); | |
} | |
return csv.__csvSaveBuffer(true, "ISIL " + csv.line['isil'] + " mit " + lon + ";" + lat); | |
}; | |
csv.__csvSetProperties(csv.__osm, ["idn", "isil", "lat", "lon"], 'idn', 'idn', false, "LOG_out20160303_mus_opencage2.csv"); | |
try { | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function test42XX() { | |
// set global variable _rec | |
__zdbJSON(); | |
var felder = __zdbFeld424XGet(); | |
__zeigeEigenschaften(felder); | |
} | |
function setBearbeiten() { | |
//__testLogger('LOG_test'); | |
//__fernleih_karlsruhe('LOG_flk2.tsv', 'd', '1026734010'); | |
//__fernleih_lmu('LOG_fllmu.csv', 'd', '00902350X'); | |
//__cup_nl('','d','992837243'); | |
//__addProduktsigel('LOG_fuenta_academica.csv', 'd', 'ZDB-4-FAP'); | |
} | |
function __fromFile(fileName, callback, logFileName, eigene_bibliothek, format, start, delimiter, csvHeader, id_key, searchindex, withbib) { | |
var csv = new CSV(); | |
csv.csvFilename = fileName; | |
csv.startLine = start = typeof start !== 'undefined' ? start : 1; | |
csv.delimiter = delimiter = typeof delimiter !== 'undefined' ? delimiter : ";"; | |
csv.eigene_bibliothek = eigene_bibliothek; | |
csv.__callback = function () { | |
callback(csv, logFileName, format, eigene_bibliothek); | |
} | |
csv.__csvSetProperties( | |
csv.__callback, | |
csvHeader, id_key, searchindex, withbib, logFileName | |
); | |
try { | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function test_7120() { | |
var cb = function (csv, logFileName, format, eigene_bibliothek) { | |
var f8032 = "8032 " + csv.line['bestand']; | |
var f7120 = __feld7120(false, false, f8032); | |
csv.__csvSaveBuffer(false, "" + csv.line['zdb'] + "\t" + csv.line['bestand'] + "\t" + f7120); | |
} | |
__fromFile('geisenheim.txt', cb, 'LOG_7120.txt', '020591519', 'd', 2, ';', ['zdb', 'sig', 'bestand'], 'zdb', 'zdb', false); | |
} | |
function fuente_urls() { | |
var cb = function (csv, logFileName, format, eigene_bibliothek) { | |
application.activeWindow.command('k', false); | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText('\n4085 =u ' + csv.line['url'] + '=x G'); | |
csv.__csvSaveBuffer(true, "" + csv.line['url']); | |
} | |
__fromFile('fuente_urls.csv', cb, 'LOG_fuente_urls.txt', null, 'd', 2, ';', ['zdb', 'url'], 'zdb', 'zdb', false); | |
} | |
function __fernleih_karlsruhe(logFileName, format, eigene_bibliothek) { | |
var set = new SET(logFileName, format, eigene_bibliothek), | |
i, e; | |
while (i = set.nextTit()) { | |
__zdbJSON(); | |
while (e = set.nextEx()) { | |
var numbering = set.current_ex + 1; | |
if (!_rec['209A/0' + numbering]) { | |
ex.endOfBuffer(false); | |
ex.insertText('7100 % k'); | |
set.save(true, set.exNum + "\tFeld 7100 mit FL-Code k hinzugefuegt"); | |
continue; | |
} | |
else if (!_rec['209A/0' + numbering][0]['l']) { | |
ex.findTag2('7100', 0, true, true, false); | |
ex.endOfField(false); | |
ex.insertText(' % k'); | |
set.save(true, set.exNum + "\tFL-Code k hinzugefuegt"); | |
continue; | |
} | |
set.save(true, set.exNum + "\tFL-Code war schon vorhanden"); | |
} | |
} | |
} | |
function __fernleih_lmu(logFileName, format, eigene_bibliothek) { | |
var set = new SET(logFileName, format, eigene_bibliothek), | |
i, e, | |
std = new RegExp('\!\!(0207|1100|1101|1705|1900|2001|2005|2007|2009)\!\!'), | |
flex = new RegExp('\% [ln]'), | |
flc, | |
nwfl; | |
while (i = set.nextTit()) { | |
while (e = set.nextEx()) { | |
e.findTag('4800', 0, false, true, false); | |
if (e.selection.indexOf(eigene_bibliothek) == -1) { | |
set.save(false); | |
continue; | |
} | |
e.findTag('7109', 0, false, true, false); | |
if (!std.test(ex.selection)) { | |
set.save(false); | |
continue; | |
} | |
e.findTag('7100', 0, false, true, false); | |
flc = flex.exec(ex.selection); | |
if (!flc) { | |
set.save(false); | |
continue; | |
} | |
nwfl = ex.selection.replace(flc[0], '% k'); | |
e.insertText(nwfl); | |
set.save(true, "FL-Code " + flc[0] + " wurde gegen % k ersetzt"); | |
} | |
} | |
} | |
function __nrw(i, csv, edit, save) { | |
var tit = edit(csv, 'd', i); | |
var text = "Digitalisierung Landesprojekt Nordrhein-Westfalen 2017-2019"; | |
if ("" != (tit.findTag2('4701', 0, true, true, false))) { | |
tit.endOfField(false); | |
tit.insertText('.-' + text); | |
save("Feld ergaenzt"); | |
return; | |
} | |
tit.endOfBuffer(false); | |
tit.insertText('4701 ' + text); | |
save("Feld neu hinzugefuegt"); | |
} // end of method | |
function __lokaldatenLoeschen(i, csv, edit, save, edit_e) { | |
application.activeWindow.command("s " + i, false); | |
var ex, | |
exNr, | |
alleExe = __exemplareAnzahl(), | |
currentField, | |
newfield; | |
if (!alleExe) { | |
return; | |
} | |
for (var e = 0; e < alleExe.length; e += 1) { | |
exNr = alleExe[e].substring(3, 5); | |
ex = edit_e(exNr, 'd', csv, edit); | |
if (false == ex) { | |
continue; | |
} | |
application.activeWindow.title.findTag2('70', 0, true, true, false); | |
currentField = application.activeWindow.title.currentField; | |
newfield = currentField.replace(/: [xau].{0,2}/, ': l'); | |
application.activeWindow.title.endOfField(true); | |
// inert new field content | |
application.activeWindow.title.insertText(newfield); | |
save(exNr + "\tErsetzt: " + currentField + " gegen " + newfield + " in Zeile " + application.activeWindow.title.currentLineNumber); | |
} | |
} // end of method | |
function __zdbGetXML(url) { | |
var req = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(); | |
req.open('GET', url, false); | |
req.send(null); | |
return req.responseXML; | |
} | |
function postIt() { | |
open_xul_dialog("chrome://ibw/content/xul/ZDB_postIt.xul", null); | |
} | |
function toJSON() { | |
__zdbJSON(); | |
var string = __objToString(_rec); | |
__zdbError(string); | |
} | |
function __objToString(obj) { | |
var str = '{'; | |
if (typeof obj == 'object') { | |
for (var p in obj) { | |
if (obj.hasOwnProperty(p)) { | |
str += p + ':' + __objToString(obj[p]) + ','; | |
} | |
} | |
} | |
else { | |
if (typeof obj == 'string') { | |
return '"' + obj + '"'; | |
} | |
else { | |
return obj + ''; | |
} | |
} | |
return str.substring(0, str.length - 1) + "}"; | |
} | |
function __fid_korrektur(logFileName, format) { | |
var set = new SET(logFileName, format), | |
i, e, t; | |
while (i = set.nextTit()) { | |
t = set.edit(i); | |
var fid = t.findTag2('5056', 0, false, true, false), | |
split; | |
if (/;/.test(fid)) { | |
split = fid.split(';'); | |
} else { | |
split[0] = fid; | |
} | |
t.deleteLine(1); // deletes the current field 5056 | |
if (split.length > 1) { | |
set.save(false); | |
} | |
set.save(true, set.exNum + "\tFL-Code war schon vorhanden"); | |
} | |
} | |
function __cup_nl(logFileName, format, eigeneBibliothek) { | |
var set = new SET(logFileName, format, eigeneBibliothek), | |
i, e, mw, | |
patt = new RegExp('Die Freischaltung der Inhalte des Vorjahres erfolgt im Juli') | |
while (i = set.nextTit()) { | |
while (e = set.nextEx()) { | |
if (e.findTag('7140', 0, false, true, false)) { | |
mw = e.selection.replace('-Y002', '-Y001'); | |
e.insertText(mw); | |
if (e.findTag('8034', 0, false, true, false)) { | |
if (patt.test(e.selection) == false) { | |
e.endOfField(false); | |
e.insertText('. Die Freischaltung der Inhalte des Vorjahres erfolgt im Juli.'); | |
} | |
} | |
} | |
set.save(true); | |
} | |
} | |
} | |
function __addProduktsigel(logFileName, format, ISIL) { | |
var set = new SET(logFileName, format), | |
i, e, t, feld_0601, feld_0601_alt; | |
while (i = set.nextTit()) { | |
t = set.edit(i); | |
if ('' == (feld_0601 = t.findTag('0601', 0, false, true, false))) { | |
t.endOfBuffer(false); | |
t.insertText('0601 ' + ISIL); | |
feld_0601_alt = ''; | |
} else { | |
feld_0601_alt = feld_0601; | |
var isilList = feld_0601.split(';'), | |
indexOfIsil = -1; | |
for (var a = 0; a < isilList.length; a += 1) { | |
if (ISIL == isilList[a]) { | |
indexOfIsil = a; | |
} | |
} | |
if (-1 == indexOfIsil) { | |
isilList.push(ISIL); | |
feld_0601 = isilList.join(';'); | |
t.insertText(feld_0601); | |
} | |
} | |
set.save(true, feld_0601_alt + ';' + ISIL); | |
} | |
} | |
function csvImportDhiw() { | |
// initiiere das CSV-Objekt | |
var csv = new CSV(); | |
// diese csv muss im Unterverzeichnis 'csv' des Anwendungsprofils liegen. | |
csv.csvFilename = "dhiw-all.csv"; | |
// start ab Zeile | |
csv.startLine = 2; | |
// werte getrennt mit | |
csv.delimiter = ";"; | |
csv.__csvSetEigeneBibliothek("1130280020"); | |
// erweitere nun die Klasse CSV durch deine eigene Methode | |
csv.meineMethode = function () { | |
var best7120, | |
f7120 = '', | |
f7135 = '', | |
f8034 = '', | |
f8032 = csv.line['bestand'].toString().replace(/^\s|\s$/, ''), | |
f8598 = '8598 ' + csv.line['dhiw'].toString().replace(/^\s|\s$/, ''); | |
if (f8032 != '') { | |
f8032 = '8032 ' + f8032; | |
best7120 = __feld7120(false, false, f8032); | |
if (best7120) { | |
f7120 = "7120 " + best7120; | |
} | |
} else { | |
f8032 = '8032 #1#'; | |
} | |
var f8031 = csv.line['8031'].toString().replace(/^\s|\s$/, ''); | |
if (f8031 != '') { | |
f8031 = '8031 ' + f8031; | |
} | |
var f7100 = csv.line['sig'].toString().replace(/^\s|\s$/, ''); | |
if (f7100 != '') { | |
if (f7100 == 'e-only') { | |
var arrUrl = csv.line['url'].toString().replace(/^\s|\s$/, '').split(";"); | |
f7135 = '7135 =u ' + arrUrl[0].replace(/^\s|\s$/, ''); | |
if (arrUrl[1] !== void 0) { | |
f8034 = '8034 ' + arrUrl[1].replace(/^\s|\s$/, ''); | |
} | |
f7100 = ''; | |
} else { | |
f7100 = '7100 ' + f7100; | |
} | |
} | |
var ex = __zdbExemplarNummer(); | |
var content = "4800 " + csv.eigene_bibliothek + "\n" + f7100 + "\n" + f7120 + "\n" + f7135 + "\n" + f8031 + "\n" + f8032 + "\n" + f8034 + "\n" + f8598 + "\n"; | |
__zdbExemplarErfassen(ex, content); | |
csv.__csvSaveBuffer(true, "Exemplar erstellt |" + f8032 + "|" + f7120); | |
} | |
// setze deine eigenen Eigenschaften | |
// der erste Parameter ist die Callback Funktion, die Du zuvor erstellt hast | |
csv.__csvSetProperties(csv.meineMethode, ["dhiw", "sig", "url", "8031", "bestand", "ZDB-ID"], 'ZDB-ID', 'zdb', false, "LOG_dhiw_prod.txt"); | |
// initiiere das Konfigurations-Interface | |
// fange dabei eventuelle Fehler ab | |
try { | |
// initiiere die Batchbearbeitung | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function __isilOPAC(bearbeiter) { | |
if (!__zdbCheckScreen(['8A'], 'Script OPAC')) { | |
return false; | |
} | |
// set global variable _rec | |
__zdbJSON(); | |
if ('Tw' != _rec['002@'][0]['0']) { | |
__zdbError('Das Script kann nur auf Tw-Sätze angewendet werden.'); | |
return false; | |
} | |
var isil = _rec['008H'][0]['e']; | |
_rec['OPAC_url'] = 'https://sigel.staatsbibliothek-berlin.de/suche/?isil=' + isil; | |
if (_rec['035B']) { | |
var mailTo = (_rec['035B'][0]['k']) ? _rec['035B'][0]['k'] : ""; | |
} | |
// GET the File opac_textbausteine.txt | |
var theFileInput = utility.newFileInput(); | |
//var theLine; | |
var fileName = "\\" + "opac_textbausteine.txt"; | |
if (!theFileInput.openSpecial("ProfD", fileName)) { | |
application.messageBox("Datei suchen", "Datei " + fileName + " wurde nicht gefunden.", "error-icon"); | |
return; | |
} | |
var text = theFileInput.read(theFileInput.getAvailable()); | |
// LVR | |
var lvrRegex = /###\sVAR\sBEGIN\s###([^#]+)###\sVAR\sEND\s###/m; | |
var lvrtext = text.match(lvrRegex)[1]; | |
//__zdbError(lvrtext); | |
var lvrs = eval('({' + lvrtext + '})'); | |
if (_rec['035I']) { | |
var lvr = decodeURIComponent(encodeURIComponent(lvrs[_rec['035I'][0]['a']])); | |
text = text.replace(/{LVR}/g, lvr); | |
//__zdbError(lvr); | |
// FLI | |
var flis = { | |
n: "Fernleihfähig? nein", | |
e: "Fernleihfähig? ja, nur Kopie, elektronischer Versand an Endnutzer möglich", | |
k: "Fernleihfähig? ja, nur Papierkopie an Endnutzer" | |
}; | |
var fli = decodeURIComponent(encodeURIComponent(flis[_rec['035I'][0]['e']])); | |
text = text.replace(/{FLI}/g, fli); | |
} | |
// Primärerfassung | |
if (!_rec['035E'][0]['e']) { | |
_rec['035E'][0]['e'] = 'ZDB'; | |
} | |
// Get all Vars in text | |
var getVarsRegEx = /{(....)\s\$(.)}/gm; | |
// Associate Vars with data | |
var results = {}, matches; | |
while ((matches = getVarsRegEx.exec(text)) != null) { | |
results[matches[0]] = ''; | |
if (_rec[matches[1]]) { | |
if (_rec[matches[1]][0][matches[2]]) { | |
results[matches[0]] = _rec[matches[1]][0][matches[2]]; | |
} | |
} | |
} | |
// do replace Vars with data | |
var re; | |
for (var k in results) { | |
if (results.hasOwnProperty(k)) { | |
var repl = k.replace('$', '\\$'); | |
re = new RegExp(repl, "g"); | |
if ('string' != typeof results[k]) { | |
results[k] = results[k].toString(); | |
results[k] = results[k].replace('#', '||'); | |
} | |
text = text.replace(re, results[k]); | |
} | |
} | |
// Get Mail | |
var mailRegex = '### ' + bearbeiter + ' BEGIN ###([^#]+)### ' + bearbeiter + ' END ###'; | |
//__zdbError(mailRegex); | |
mailRegex = new RegExp(mailRegex, 'm'); | |
var mail = text.match(mailRegex)[1]; | |
// Get blocks | |
//var blockRegex = /###\sTEXT(..?)\sBEGIN\s###((?:.|\n)+?)###\sTEXT..?\sEND\s###/gm; | |
var blockRegex = /###\sTEXT(..?)\sBEGIN\s###([^#]+?)###\sTEXT..?\sEND\s###/gm; | |
var blockMatch; | |
while ((blockMatch = blockRegex.exec(text)) != null) { | |
mail = mail.replace('{TEXT' + blockMatch[1] + '}', blockMatch[2]); | |
} | |
// cleaning | |
var cleanRegex = /^.+:[\t ]+\r\n/m; | |
var cleanMatch; | |
while ((cleanMatch = cleanRegex.exec(mail)) != null) { | |
mail = mail.replace(cleanMatch[0], ''); | |
} | |
mail = mail.replace('||', '#'); | |
// clipboard | |
application.activeWindow.clipboard = mailTo + "\n" + mail; | |
/*if(__zdbYesNo("Der Text wurde in die Zwischenablage kopiert. Soll eine neue Mail an " + mailTo + " erstellt werden?")) { | |
application.shellExecute('mailto:' + mailTo + '?subject=' + isil, 5, 'open',''); | |
}*/ | |
// open browser | |
application.shellExecute(_rec['OPAC_url'], 5, 'open', ''); | |
application.messageBox("ISIL OPAC", "Der Text wurde in die Zwischenablage kopiert", "message-icon"); | |
} | |
function OPAC() { | |
__isilOPAC('HE'); | |
} | |
function zdbCsvGoogle() { | |
var csv = new CSV(); | |
var digiConfig; | |
csv.csvFilename = 'bsb_google_2018_neu.csv'; | |
//csv.csvFilename = 'bsb_google_2018_test.txt'; | |
csv.startLine = 1; | |
csv.delimiter = ";"; | |
csv.__makeConfig = function (rda) { | |
var digi = {}; | |
digi[1101] = { kat: "1101 ", cont: "cr" }; | |
if (csv.line['4025'] != "") digi[4025] = { kat: "4025 ", cont: csv.line['4025'] }; | |
if(rda) { | |
digi[4030] = { kat: "4030 ", cont: csv.line['4048_2'] }; | |
digi[4201] = { kat: "4201 ", cont: 'Digitalisiert von: ' + csv.line['4048_2'] + ', 2013-2013' }; | |
} else { | |
digi[4048] = { kat: "4048 ", cont: csv.line['4048_2'] }; | |
if (csv.line['2050'] != "") digi[2050] = { kat: "2050 ", cont: csv.line['2050'] }; | |
if (csv.line['1109'] != "") digi[1109] = { kat: "1109 ", cont: csv.line['1109'] }; | |
if (csv.line['4237'] != "") digi[4237] = { kat: "4237 ", cont: csv.line['4237'] }; | |
if (csv.line['4119'] != "") digi[4119] = { kat: "4119 ", cont: csv.line['4119'] }; | |
} | |
if (csv.line['4233'] != "") digi[4233] = { kat: "4233 ", cont: csv.line['4233'] }; | |
if (csv.line['4085'] != "") digi[4085] = { kat: "4085 ", cont: "=" + csv.line['4085'] }; | |
if (csv.line['4701'] != "") digi[4701] = { kat: "4701 ", cont: csv.line['4701'] }; | |
return digi; | |
}, | |
csv.__reziprok = function (idn) { | |
var digiIDN = application.activeWindow.getVariable("P3GPP"); | |
//zielID = regExpPPN.exec(text); | |
// Kommando abschicken und Ergebnis in gleichen Fenster anzeigen | |
application.activeWindow.command("f idn " + idn, false); // <=== Kommando in demselben Fenster | |
application.activeWindow.command("k d", false); | |
application.activeWindow.title.endOfBuffer(false); | |
//application.activeWindow.title.insertText("4243 Digital. Ausg.!" + quellID + "!" + "\n"); | |
application.activeWindow.title.insertText("\n4256 Elektronische Reproduktion!" + digiIDN + "!"); | |
application.activeWindow.simulateIBWKey("FR"); | |
csv.__csvSaveBuffer(true, "Reziprok Link erstellen " + idn + " ---> " + digiIDN); | |
}, | |
csv.__merge = function (feld4243) { | |
var mergeId = feld4243.substring(feld4243.indexOf("!") + 1, feld4243.lastIndexOf("!")); | |
application.activeWindow.command("f idn " + mergeId, false); | |
var f4701 = application.activeWindow.findTagContent("4701", 0, false); | |
if(-1 != f4701.indexOf('85640SF3!Volltext')) { | |
return; | |
} | |
application.activeWindow.command("k d", false); | |
var rda = false; | |
//if(application.activeWindow.title.find("1505 $erda", false, false, false)) { | |
if (application.activeWindow.title.findTag("1505", 0, false, true, false) !== '') { | |
if(-1 != application.activeWindow.title.selection.indexOf('rda')) { | |
rda = true; | |
} else { | |
// Es werden dadurch NUR RDA-Titel bearbeitet | |
return; | |
} | |
} | |
if (application.activeWindow.title.findTag("0600", 0, true, true, false) !== "") { | |
if (!application.activeWindow.title.find("ld", 0, false, true, false)) { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText(";ld"); | |
} | |
if (!application.activeWindow.title.find("la", 0, false, true, false)) { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText(";la"); | |
} | |
} | |
else { | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n0600 ld;la\n"); | |
} | |
/* if (csv.line['4025'] != "") { | |
// pruef umfang von 4025 | |
var feld1100 = application.activeWindow.title.findTag("1100", 0, false, true, false); | |
var feld1100erstesJahr = feld1100.substr(0, 4); | |
var inhalt7120 = __feld7120(false, false, "4025 " + csv.line['4025']); | |
var matchJahr = inhalt7120.match(/\/b([0-9]{4,4})/); | |
if (matchJahr && matchJahr[1] < feld1100erstesJahr) // 4025 nur uberschreiben wenn umfangreicher als vorh. | |
{ | |
//var feld4025 = application.activeWindow.title.findTag("4025",0,false,true,false); | |
application.activeWindow.title.findTag("4025", 0, false, true, false); | |
//if(feld4025.match(/mehr nicht digital/)) | |
//{ | |
application.activeWindow.title.replace(csv.line['4025']); | |
if ("" != application.activeWindow.title.findTag("4024", 0, false, true, false)) { | |
application.activeWindow.title.deleteLine(1); | |
} | |
//application.activeWindow.title.findTag("4025",0,false,true,false); | |
__feld7120(false, true, false); | |
//} | |
} | |
} | |
// 4024 erzeugen | |
if ("" == application.activeWindow.title.findTag("4024", 0, false, true, false)) { | |
application.activeWindow.title.findTag("4025", 0, false, true, false); | |
__feld7120(false, true, false); | |
} | |
*/ | |
application.activeWindow.title.endOfBuffer(false); | |
if (csv.line['4085'] != "") application.activeWindow.title.insertText("\n4085 =" + csv.line['4085'] + "\n"); | |
if (csv.line['4701'] != "") { | |
if (application.activeWindow.title.findTag2("4701", 0, false, true, false) !== "") { | |
application.activeWindow.title.insertText(csv.line['4701'] + "###"); | |
} | |
else { | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n4701 " + csv.line['4701'] + "\n"); | |
} | |
} | |
if(rda) { | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n4201 Digitalisiert von: " + csv.line['4048_2'] + ", 2013-2013\n"); | |
application.activeWindow.title.insertText("\n4030 " + csv.line['4048_2'] + "\n"); | |
csv.__csvSaveBuffer(true, "Google-Digitalisat RDA mergen"); | |
return; | |
} | |
if (csv.line['4237'] != "") { | |
if (application.activeWindow.title.findTag("4237", 0, false, true, false) !== "") { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.charLeft(1, true); | |
if (application.activeWindow.title.selection == ".") { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText(" - "); | |
} | |
else { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText(". - "); | |
} | |
application.activeWindow.title.insertText(csv.line['4237']); | |
} | |
else { | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n4237 " + csv.line['4237'] + "\n"); | |
} | |
} | |
application.activeWindow.title.endOfBuffer(false); | |
if (csv.line['1109'] != "") application.activeWindow.title.insertText("\n1109 " + csv.line['1109'] + "\n"); | |
if (csv.line['4048_2'] != "") { | |
// doppelte Einträge verhindern | |
var occ = 0; | |
while (application.activeWindow.title.findTag("4048", occ, false, true, false) != '') { | |
if(application.activeWindow.title.selection == csv.line['4048']) { | |
application.activeWindow.title.replace(csv.line['4048_2']); | |
occ = 'repl'; | |
break; | |
} | |
occ++; | |
} | |
if('repl' != occ) { | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText("\n4048 " + csv.line['4048_2'] + "\n"); | |
} | |
} | |
if (csv.line['4233'] != "") application.activeWindow.title.insertText("\n4233 " + csv.line['4233'] + "\n"); | |
csv.__csvSaveBuffer(true, "Google-Digitalisat mergen"); | |
}, | |
csv.__bsbdigi = function () { | |
var feld4243; | |
var x = 0; | |
// Verknüpfung über 4243 | |
while ((feld4243 = application.activeWindow.findTagContent("4243", x, false)) !== "") { | |
if (feld4243.substr(1, 7) == "Digital") { | |
//csv.__merge(feld4243); | |
return; | |
} | |
x++; | |
} | |
x = 0; | |
while ((feld4243 = application.activeWindow.findTagContent("4256", x, false)) !== "") { | |
if (feld4243.substr(1, 26) == "Elektronische Reproduktion") { | |
//csv.__merge(feld4243); | |
return; | |
} | |
x++; | |
} | |
//return; | |
var f1505 = application.activeWindow.findTagContent("1505", 0, false); | |
var rda = (-1 == f1505.indexOf('rda')) ? false : true; | |
digiConfig = csv.__makeConfig(rda); | |
var idn = application.activeWindow.getVariable('P3GPP'); | |
// __digitalisierung siehe https://github.com/Zeitschriftendatenbank/ZDB-WinIBW3.6.2/blob/master/scripts/zdb_scripte_01.js | |
//__digitalisierung(digiConfig,false,"resource:/ttlcopy/zdb_titeldatenkopie_digi_bsb.ttl"); | |
__zdbOnlineRessource("resource:/ttlcopy/zdb_titeldatenkopie_digi_bsb.ttl", false, ['ld', 'la'], digiConfig); | |
if(rda) { | |
application.activeWindow.title.findTag("4030", 0, false, true, false); | |
application.activeWindow.title.replace('München : Bayerische Staatsbibliothek, Münchener Digitalisierungszentrum'); | |
application.activeWindow.title.findTag("1100", 0, false, true, false); | |
application.activeWindow.title.replace('2013$b2018$n[2013-2018]'); | |
} | |
var f4024; | |
if ("" == application.activeWindow.title.findTag("4024", 0, true, true, false)) { | |
application.activeWindow.title.findTag("4025", 0, false, true, false); | |
f4024 = __feld7120(false, false, application.activeWindow.title.currentField); | |
application.activeWindow.title.endOfField(false); | |
application.activeWindow.title.insertText("\n4024 " + f4024); | |
} | |
//application.activeWindow.title.find("4243 Druckausg", false, false, false); | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n4256 Elektronische Reproduktion von!" + idn + "!\n"); | |
if(csv.__csvSaveBuffer(true, "BSB Google Digitalisat erstellen")) { | |
//logger.log(application.activeWindow.getVariable('P3VTX')); | |
csv.__reziprok(idn); | |
} | |
} | |
//var logger = new LOGGER(); | |
//logger.setLogFile('BSB_Google_TITEL.txt'); | |
csv.__csvSetProperties(csv.__bsbdigi, ["zdb", "1101", "1109", "2050", "4025", "4048", "4085", "4119", "4233", "4237", "4701","4048_2"], 'zdb', 'zdb', false, "LOG_BSB_Google_2018_neu.txt"); | |
try { | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function myAsyncFunc() { | |
var log = new LOGGER; | |
log.setLogFile('LOG_ASNC'); | |
var myIDNs = ["1094729256", "1084639459", "1139463136", "107477292X", "1074407148", "1070221325", "106917937X", "1066329435", "1053544677", "1051633087", "1050005031", "1036771768", "1036771709", "1036771660", "1033806684", "1027556426", "1027121063", "1018730753", "99954943X", "1064864848", "1011435721", "994496354", "989316122", "987707019", "987611135", "984649522", "988135078", "983830754", "027325695", "026830558", "02662480X", "023130830", "980778778", "027195260", "024048801", "023511567", "021708096", "021409072", "027432610", "978334507", "020501420", "021222444", "020384238", "019858647", "023614080", "023496266", "022787712", "020000561", "019746466", "019741022", "021943508", "025810391", "021884862", "01976264X", "988303914", "025771752", "021714932", "019740832", "021714738", "021348065", "02050179X", "020074506", "019745818", "021352682", "020084382", "026031256", "024400653", "021352232", "019937083", "020958749", "019827431", "023727667", "020830580", "020327986", "019633505", "021818258", "020467575", "020659652", "019599188", "01959920X", "020707045", "020077602", "019551541", "025187465", "023739142", "019926375", "019747187", "020718837", "020242026", "025659782", "019633645", "01964700X", "982977700", "021186642", "020000340", "019676603", "019676174", "020121717", "020495560", "019676573", "020695756", "020553455", "019652569", "02093873X", "019717318", "026075474", "019641265", "019654448", "999486144", "01958671X", "027428206", "020670230", "020468067", "025794248", "021244979", "02049209X", "027469980", "020501315", "021318026", "019613121", "024282863", "020000391", "019764669", "020918380", "01989225X", "019840756", "019910355", "984996559", "982262396", "019840578", "019587449", "019721846", "989022846", "989022161"]; | |
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] | |
.getService(Components.interfaces.mozIJSSubScriptLoader); | |
loader.loadSubScript("chrome://ibw/content/xul/class_excelTabelle.js"); | |
//var event; | |
//var timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer); | |
for (var x = 0; x < myIDNs.length; x += 1) { | |
/*event = { | |
notify: function(timer) { | |
log.log("test \n"); | |
} | |
}; | |
timer.initWithCallback(event,0, Components.interfaces.nsITimer.TYPE_ONE_SHOT);*/ | |
async(myIDNs[x], log); | |
log.log("IDN " + x + "\n"); | |
//application.activeWindow.title.logMessage('test'); | |
} | |
} | |
function korrMuenster() { | |
var set = new SET('LOG_muenster_korr', 'd', '009006079'), | |
i, e, f7900, f700; | |
while (i = set.nextTit()) { | |
while (e = set.nextEx()) { | |
f7900 = e.findTag('7900', 0, false, true, false); | |
//__zdbMsg('test'); | |
if(-1 == f7900.indexOf('21-01-19 12')) { | |
if(-1 == f7900.indexOf('17-01-19 21')) { | |
set.save(false, 'falsches Datum'); | |
continue; | |
} | |
} | |
e.startOfBuffer(false); | |
f700 = e.findTag('700', 0, false, true, false); | |
if(e.find(': x', false, true, false)) { | |
e.replace(': l'); | |
set.save(true, 'Löschung setzten'); | |
continue; | |
} | |
set.save(false, 'test'); | |
} | |
} | |
} | |
function ezbFrontdoor() { | |
var set = new SET('LOG_ezb_frontdoor', 'd'), | |
t, i, zdb, ezb = "=u http://www.bibliothek.uni-regensburg.de/ezeit/?", frontdoor; | |
while (i = set.nextTit()) { | |
t = set.edit(i); | |
zdb = __zdbGetZDB(); | |
zdb = zdb.substring(0,zdb.lastIndexOf('-')); | |
frontdoor = ezb + zdb + "=x F"; | |
t.endOfBuffer(false); | |
t.insertText("\n4085 " + frontdoor); | |
set.save(true, frontdoor); | |
} | |
} | |
function matchBbk() { | |
var csv = new CSV(); | |
csv.csvFilename = 'AdJ_match.csv'; | |
//csv.csvFilename = 'bsb_google_2018_test.txt'; | |
csv.startLine = 1; | |
//csv.endLine = 3042; | |
csv.delimiter = ";"; | |
var log = new LOGGER; | |
log.setLogFile('LOG_AdJ_match2.txt'); | |
var f = "f bbg A* "; | |
var q; | |
var setNr = application.activeWindow.getVariable("P3GSE"); | |
csv.__bbkSearch = function(q) { | |
//__zdbError(q); | |
application.activeWindow.command(q, false); | |
if( application.activeWindow.getVariable("P3GSE") !== setNr) { | |
setNr = application.activeWindow.getVariable("P3GSE"); | |
csv.__bbkIDNs(); | |
return true; | |
} else { | |
csv.line['idns'] = ""; | |
return false; | |
} | |
}; | |
csv.__bbkIDNs = function () { | |
var size = application.activeWindow.getVariable("P3GSZ"); | |
if(10 < parseInt(size)) { | |
csv.line['idns'] = "mehr als zehn"; | |
} else { | |
var set = new SET(); | |
var idns = new Array(); | |
while (set.nextTit()) { | |
idns.push(application.activeWindow.getVariable("P3GPP")); | |
} | |
csv.line['idns'] = idns.join(" or "); | |
} | |
csv.__bbkOut(); | |
}; | |
csv.__bbkOut = function() { | |
var join = ""; | |
for(var o in csv.line) { | |
if(!csv.line.hasOwnProperty(o)) { | |
continue; | |
} | |
join += csv.line[o] + "\t"; | |
} | |
log.log(join); | |
}; | |
csv.__bbk = function() { | |
q = ""; | |
var ver, ort, ejb; | |
if((ver = csv.line['VLG'].toString()) == '') { | |
ver = ''; | |
} else { | |
ver = " and ver \"" + ver + '"'; | |
} | |
if((ejb = csv.line['EJB'].toString()) == '') { | |
ejb = ''; | |
} else { | |
ejb = " and ejb " + ejb; | |
} | |
if((ort = csv.line['VLO'].toString()) == '') { | |
ort = ''; | |
} else { | |
ort = " and vlo \"" + ort + '"'; | |
} | |
var tit = '"' + csv.line['Titel_Match'].toString() + '"'; | |
//__zdbError(csv.line['ISS']); | |
q = f + ' and tst ' + tit + ort + ver + ejb; | |
//__zdbError(q); | |
if(!csv.__bbkSearch(q)){ | |
q = f + ' and tst' + tit + ort + ejb; | |
if(!csv.__bbkSearch(q)){ | |
q = f + ' and tst' + tit + ejb; | |
if(!csv.__bbkSearch(q)){ | |
q = f + ' and tst' + tit + ort; | |
if(!csv.__bbkSearch(q)){ | |
csv.__bbkOut(); | |
} | |
} | |
} | |
} | |
}; | |
csv.__csvSetProperties(csv.__bbk, ["Titel-ID", "Titel_Match", "VLO", "VLG", "EJB"], false, false, false, "LOG_AdJ_match2.txt"); | |
try { | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function caption() { | |
var fensterId = new Array(); | |
var allCaptions = new Array(); | |
for (var i=0; i<application.windows.count; i++) { | |
fensterId[i] = application.windows.item(i).windowID; | |
allCaptions[i] = application.windows.item(i).text; | |
application.messageBox("", i + " fensterId:\n" + fensterId[i] + "\nallCaptions:\n" + allCaptions[i], ""); | |
__zeigeEigenschaften(application.windows); | |
} | |
} | |
function importCAJ() { | |
var set = new SET('LOG_CAJ3.txt', 'd'); | |
var logger = new LOGGER('LOG_CAJ3.txt'); | |
var file = "caj_rest.txt"; | |
// load file object | |
var theFileInput = utility.newFileInput(); | |
if (!theFileInput.openSpecial("ProfD", '\csv\\' + file)) { | |
__zdbError("Datei " + file + " wurde nicht gefunden."); | |
return; | |
} | |
// read the start line | |
var aLine = ""; | |
var i = 1; | |
var x = 0; | |
var message = ''; | |
var zdb_prev; | |
var zdb; | |
var status = true; | |
application.activeWindow.command('e', false); | |
while( (aLine = theFileInput.readLine()) != null) | |
{ | |
x++; | |
message = i; | |
if("|||" == aLine) { | |
set.save(true, "line " + x); | |
zdb = __zdbGetZDB(); | |
if(zdb_prev != zdb) { | |
zdb_prev = zdb; | |
status = true; | |
logger.log('t ' + message + "\t" + zdb + "\t" + "line " + x); | |
application.activeWindow.command('e e1', false); | |
} else { | |
status = false; | |
logger.log('error t ' + message + "\t" + 'line ' + x); | |
} | |
continue; | |
} | |
if('###' == aLine) { | |
set.save(true, 'e ' + i + "\t" + 'line ' + x); | |
application.activeWindow.command('e', false); | |
status = true; | |
i++; | |
continue; | |
} | |
if(status) { | |
application.activeWindow.title.insertText(aLine + "\n"); | |
continue; | |
} | |
} | |
theFileInput.close(); | |
} | |
function csvExportOCLC() { | |
// initiiere das CSV-Objekt | |
var csv = new CSV(); | |
// diese csv muss im Unterverzeichnis 'csv' des Anwendungsprofils liegen. | |
csv.csvFilename = "oclc3.csv"; | |
// start ab Zeile | |
csv.startLine = 2; | |
//csv.endLine = 10; | |
// werte getrennt mit | |
csv.delimiter = ";"; | |
csv.csvOutFile = utility.newFileOutput(); | |
var theRelativePath = "listen\\oclc3.txt"; | |
//Datei wird angelegt: | |
csv.csvOutFile.createSpecial("ProfD", theRelativePath); | |
//GBV: es soll immer eine neue Datei angelegt werden. | |
csv.csvOutFile.setTruncate(true); | |
//csv.__csvSetEigeneBibliothek("009013423"); | |
// erweitere nun die Klasse CSV durch deine eigene Methode | |
csv.meineMethode = function () { | |
var zdb; | |
if('8A' != application.activeWindow.getVariable('scr')) { | |
zdb = csv.line['zdbids'].toString(); | |
} else if('NOHITS' == application.activeWindow.status) { | |
zdb = csv.line['zdbids'].toString(); | |
} else { | |
zdb = __zdbGetZDB(); | |
} | |
csv.csvOutFile.writeLine(csv.line['_id'].toString() + '\t' + csv.line['tit'].toString() + '\t' + csv.line['ut'].toString() + '\t' + zdb); | |
application.activeWindow.command('r', false); | |
} | |
// setze deine eigenen Eigenschaften | |
// der erste Parameter ist die Callback Funktion, die Du zuvor erstellt hast | |
csv.__csvSetProperties(csv.meineMethode, ["_id","tit","ut", "idns", "zdbids"], 'tit', 'bbg O* AND icd "zdb\\-1\\-bcn" AND eaz find.galegroup.com\\/bncn? AND tst', false, "LOG_oclc.txt"); | |
// initiiere das Konfigurations-Interface | |
// fange dabei eventuelle Fehler ab | |
try { | |
// initiiere die Batchbearbeitung | |
csv.__csvAPI(); | |
csv.csvOutFile.close(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function lmuStdo() { | |
var set = new SET('LOG_LMU_STO2.txt', 'd', '00902350X'), | |
i, e, re; | |
var std = new RegExp('\!\!(1202|1203|1210)\!\!'), | |
st; | |
while (i = set.nextTit()) { | |
while (e = set.nextEx()) { | |
st = null; | |
e.findTag('7109', 0, false, true, false); | |
if (null == (st = std.exec(e.selection))) { | |
set.save(false); | |
continue; | |
} | |
re = new RegExp(st[1], 'gi'); | |
e.insertText(e.selection.replace(re, '0900')); | |
if('' !== e.findTag('8032', 0, false, true, false)) { | |
e.insertText(e.selection.replace(re, '0900')); | |
} | |
set.save(true, 'Ersetze Standort ' + st[1]); | |
} | |
} | |
} | |
function zdb_isilInactive() { | |
if(!__zdbCheckScreen(['MI'],'ISIL Löschen')) return false; | |
__zdbJSON(); | |
var datum = new Date(), | |
fy = datum.getFullYear(), | |
jahr = fy.toString(), | |
monat = datum.getMonth() + 1, | |
monat = ('0' + monat).slice(-2) , | |
feld_680 = '680 Löschung'+jahr+'-'+monat, | |
feld_900 = '900 $aÜngültig; Bibliothek/Einrichtung aufgelöst // aufgegangen in <ISIL der Zielbibliothek> // ergänzende Information zur Auflösung oder dem Verbleib', | |
feld_805 = "805 I\n", | |
feld_110 = '110 früher: ' + _rec['029A'][0]['a'][0] + "\n"; | |
feld_005 = "\n005 Tw\n", | |
feld_806 = '', | |
feld_092 = '092 ', | |
bik = '', | |
sigel = ''; | |
// sigel | |
if(_rec['008H'][0]['d']) { | |
feld_092 += '$d' + _rec['008H'][0]['d'][0]; | |
} | |
// isil | |
feld_092 += '$e' + _rec['008H'][0]['e'][0] + "\n"; | |
// bik | |
if(_rec['008H'][0]['a']) { | |
bik = _rec['008H'][0]['a'][0]; | |
feld_680 += '; BIK war ' + bik + ', ILN ' + _rec['035E'][0]['c'][0] + '; Auftragsbestätigung: ...'; | |
} | |
if(_rec['035D']) { | |
for (var i=0; i<_rec['035D'].length; i++) { | |
feld_806 += '806 '; | |
if(_rec['035D'][i]['a']) { | |
feld_806 += _rec['035D'][i]['a'][0]; | |
} | |
if(_rec['035D'][i]['b']) { | |
feld_806 += '$b' + _rec['035D'][i]['b'][0]; | |
} | |
feld_806 += "\n"; | |
} | |
} | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText(feld_005 + feld_092 + feld_110 + feld_680 + "\n" + feld_805 + feld_806 + feld_900); | |
} | |
function importPICA() { | |
var set = new SET('LOG_Shang.txt', 'd'), | |
logger = new LOGGER('LOG_Shang.txt'), | |
file = "ShangT2.txt", | |
theFileInput = utility.newFileInput(), | |
aLine = "", | |
i = 1, | |
x = 0, | |
message = '', | |
zdb_prev, | |
format = 'd', | |
zdb; | |
if (!theFileInput.openSpecial("ProfD", '\csv\\' + file)) { | |
__zdbError("Datei " + file + " wurde nicht gefunden."); | |
return; | |
} | |
application.activeWindow.command('e ' + format, false); | |
while( (aLine = theFileInput.readLine()) != null) | |
{ | |
x++; | |
message = i; | |
if("###" == aLine) { | |
set.save(true, "line " + x); | |
zdb = __zdbGetZDB(); | |
if(zdb_prev != zdb) { | |
zdb_prev = zdb; | |
logger.log('t ' + message + "\t" + zdb + "\t" + "line " + x); | |
} else { | |
logger.log('error t ' + message + "\t" + 'line ' + x); | |
} | |
i++; | |
application.activeWindow.command('e ' + format, false); | |
continue; | |
} | |
application.activeWindow.title.insertText(aLine + "\n"); | |
} | |
theFileInput.close(); | |
} | |
function loeEID() { | |
var cb = function (csv, logFileName, format, eigene_bibliothek) { | |
//__zdbError(csv.line['zdb']); | |
var exNum = __zdbExemplarNummer(); | |
var eid = "7800 " + csv.line['eid']; | |
var num = 1; | |
var sel; | |
do { | |
sel = ''; | |
application.activeWindow.command('k e' + num, false); | |
if ('ME' != application.activeWindow.getVariable('scr')) { | |
num += 1; | |
continue; | |
} | |
if (application.activeWindow.title.find(eid, true, false, false)) { | |
application.activeWindow.title.startOfBuffer(false); | |
application.activeWindow.title.find(': x', true, true, false); | |
if ((sel = application.activeWindow.title.selection) == ': x') { | |
application.activeWindow.title.insertText(sel.replace('x', 'l')); | |
} | |
csv.__csvSaveBuffer(true, "" + csv.line['eid']); | |
break; | |
} else { | |
csv.__csvSaveBuffer(false, "nicht in Liste"); | |
} | |
num += 1; | |
} while (num < exNum); | |
} | |
__fromFile('wlb_loe_21_07_20_test.csv', cb, 'LOG_loe_24.txt', '009017216', 'd', 1, ";", ['eid'], 'eid', 'eid', false); | |
} | |
function updateDOAJ() { | |
var cb = function (csv, logFileName, format, eigene_bibliothek) { | |
//__zdbError(csv.line['zdb']); | |
//var exNum = __zdbExemplarNummer(); | |
var k005A = "" + csv.line['k005A']; | |
var k006Y = "" + csv.line['k006Y']; | |
var k047V = "" + csv.line['k047V']; | |
if("" != k005A) { | |
k005A = '005A ' + k005A + "\n"; | |
} | |
if("" != k006Y) { | |
k006Y = '006Y ' + k006Y + "\n"; | |
} | |
if("" != k047V) { | |
k047V = '047V ' + k047V + "\n"; | |
} | |
application.activeWindow.command('k p', false); | |
application.activeWindow.title.endOfBuffer(false); | |
application.activeWindow.title.insertText("\n" + k005A + k006Y + k047V); | |
csv.__csvSaveBuffer(true, "" + csv.line['k006Y']); | |
} | |
__fromFile('doaj_korr.csv', cb, 'LOG_doaj_korr.txt', '', 'p', 1, ";", ['zdb', 'k005A','k006Y', 'k047V'], 'zdb', 'zdb', false); | |
} | |
function csvImportNLGale() { | |
// initiiere das CSV-Objekt | |
var csv = new CSV(); | |
// diese csv muss im Unterverzeichnis 'csv' des Anwendungsprofils liegen. | |
csv.csvFilename = "zdb-1-ncn.csv"; | |
// start ab Zeile | |
csv.startLine = 32; | |
//csv.endLine = 1; | |
// werte getrennt mit | |
csv.delimiter = ";"; | |
csv.__csvSetEigeneBibliothek("009022090"); | |
// erweitere nun die Klasse CSV durch deine eigene Methode | |
csv.meineMethode = function () { | |
var f7120 = '7120 ', | |
f7135 = '7135 =u ', | |
f8032 = '8032 #1#', | |
ejb = '', | |
eje = ''; | |
if((ejb += csv.line['EJB']) != ''){ | |
f7120 += '/b' + ejb; | |
f8032 += ejb; | |
} | |
if((eje += csv.line['EJE']) != ''){ | |
f7120 += '/E' + eje; | |
f8032 += ' - ' + eje; | |
} | |
f7135 += csv.line['URL'] + '=x Nationallizenz' | |
var ex = __zdbExemplarNummer(); | |
var content = "4800 " + csv.eigene_bibliothek + "\n" + f7120 + "\n" + f7135 + "\n8001 %8g\n" + f8032 + "\n8510 %gale" | |
__zdbExemplarErfassen(ex, content); | |
csv.__csvSaveBuffer(true, "Exemplar erstellt Nr. " + ex); | |
} | |
csv.__csvSetProperties(csv.meineMethode, ["ZDB-ID", "URL", "EJB", "EJE"], 'ZDB-ID', 'zdb', false, "LOG_zdb-1-ncn.txt"); | |
csv.__csvAPI(); | |
} | |
function csvImportTHK() { | |
var csv = new CSV(); | |
csv.csvFilename = "de-832.csv"; | |
csv.startLine = 3017; | |
//csv.endLine = 100; | |
csv.delimiter = ";"; | |
csv.__csvSetEigeneBibliothek("009010297"); | |
csv.meineMethode = function () { | |
var set = new SET(false,'d','009010297'), | |
e, | |
eid = ''; | |
while (e = set.nextEx()) { | |
eid = e.findTag('7800', 0, false, true, false); | |
if (eid !== csv.line['EID'].toString()) { | |
csv.__csvSaveBuffer(false, "Exemplar ID nicht in Liste\t" + csv.line['EID']); | |
continue; | |
} | |
e.findTag('7100', 0, false, true, false); | |
e.insertText(csv.line['SIG'] + "\n7109 !!" + csv.line['STO'] + '!!'); | |
csv.__csvSaveBuffer(true, "Exemplar bearbeitet\t" + csv.line['EID']); | |
} | |
} | |
csv.__csvSetProperties(csv.meineMethode, ["IDN", "EID", "STO", "SIG"], 'IDN', 'idn', false, "LOG_832.txt"); | |
// initiiere das Konfigurations-Interface | |
// fange dabei eventuelle Fehler ab | |
try { | |
// initiiere die Batchbearbeitung | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} | |
function zdb_match() { | |
__csvMatch({ | |
filename: 'AdJ_match.csv', // Name of the input CSV-File | |
delimit: ";", // CSV file delimiter | |
columns: ["Titel-ID", "Titel_Match", "VLO", "VLG", "EJB"], // name of coloumns of csv input file | |
start: 167, // start at line | |
end: 177, // end with line | |
logfile: 'LOG_AdJ_matchTest.txt', // name of the output file | |
bbg: 'A*', // material code for key bbg | |
idType: 'zdb', // identifier for output | |
q: { | |
mustHave: { tst: "Titel_Match" }, // minimum search words | |
options: [ // combinations of search words | |
[[ "vlo", "VLO" ], [ "ver", "VLG" ], [ "ejb", "EJB" ]], | |
[[ "vlo", "VLO" ], [ "ejb", "EJB" ]], | |
[[ "ejb", "EJB" ]], | |
[[ "vlo", "VLO" ]] | |
] | |
} | |
}); | |
} | |
function __csvMatch(cnf) { | |
var csv = new CSV(); | |
csv.csvFilename = cnf.filename; | |
csv.startLine = cnf.start || 1; | |
csv.endLine = cnf.end || false; | |
csv.delimiter = cnf.delimit || ";"; | |
var log = new LOGGER; | |
log.setLogFile(cnf.logfile); | |
var f = (cnf.bbg) ? 'f bbg ' + cnf.bbg + ' and ' : 'f '; | |
var setNr = application.activeWindow.getVariable("P3GSE"); | |
csv.__bbkSearch = function (q, test) { | |
var t = test || false; | |
application.activeWindow.command(q, false); | |
//log.log(q); // Debug output search | |
if (application.activeWindow.getVariable("P3GSE") !== setNr) { | |
setNr = application.activeWindow.getVariable("P3GSE"); | |
if(t) { | |
return csv.__bbkIDs(); | |
} | |
return csv.line['ids'] = csv.__bbkIDs(); | |
} else { | |
csv.line['ids'] = ""; | |
return false; | |
} | |
}; | |
csv.__bbkIDs = function () { | |
var size = application.activeWindow.getVariable("P3GSZ"); | |
if (10 < parseInt(size)) { | |
return "mehr als zehn"; | |
} else { | |
var set = new SET(); | |
var ids = []; | |
while (set.nextTit()) { | |
if (cnf.idType[0] == 'z') { | |
ids.push(__zdbGetZDB()); | |
} else { | |
ids.push(application.activeWindow.getVariable("P3GPP")); | |
} | |
} | |
return ids.join(" or "); | |
} | |
}; | |
csv.__bbkOut = function () { | |
var join = ""; | |
for (var o in csv.line) { | |
if (!csv.line.hasOwnProperty(o)) { | |
continue; | |
} | |
join += csv.line[o] + "\t"; | |
} | |
log.log(join); | |
}; | |
csv.__bbk = function () { | |
var q = '', valueArray, ids; | |
// mustHave test | |
if (cnf.q.mustHave) { | |
for(var key in cnf.q.mustHave) { | |
q = f + key + ' ' + csv.line[cnf.q.mustHave[key]]; | |
} | |
if (!(ids = csv.__bbkSearch(q, true))) { | |
return csv.__bbkOut(); | |
} | |
q = q + ' and '; | |
} else { | |
q = f; | |
} | |
for (var o = 0; o < cnf.q.options.length; o += 1) { | |
valueArray = []; | |
for(var v in cnf.q.options[o]) { | |
if('' == csv.line[cnf.q.options[o][v][1]]) { | |
continue; | |
} | |
valueArray.push(cnf.q.options[o][v][0] + ' ' + csv.line[cnf.q.options[o][v][1]]); | |
} | |
if (csv.__bbkSearch(q + ' ' + valueArray.join(' and '))) { | |
return csv.__bbkOut(); | |
} | |
} | |
csv.line['ids'] = ids; | |
return csv.__bbkOut(); | |
}; | |
csv.__csvSetProperties(csv.__bbk, cnf.columns, false, false, false, false); | |
try { | |
csv.__csvAPI(); | |
} | |
catch (e) { | |
csv.__csvError(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment