Skip to content

Commit

Permalink
LBS statt SRU
Browse files Browse the repository at this point in the history
  • Loading branch information
knepper committed Nov 30, 2022
1 parent ff91610 commit 54ca951
Show file tree
Hide file tree
Showing 6 changed files with 708 additions and 808 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { net } = require('electron')
const parser = require('xml2json')
// const Shelfmark = require('../shelfmark.js')
// const Modes = require('./Modes.js')
// const config = remote.getGlobal('config')

class DataFromSRU {
class DataFromLBS {
/*
----- Class getter and setter -----
*/
Expand Down Expand Up @@ -44,10 +43,8 @@ class DataFromSRU {
allData += chunk
})
response.on('end', () => {
let options = {
object: true
}
data = parser.toJson(allData, options)

data = allData

resolve(data)
})
Expand All @@ -57,4 +54,4 @@ class DataFromSRU {
}
}

module.exports = DataFromSRU
module.exports = DataFromLBS
105 changes: 105 additions & 0 deletions signaturenDruck/js/classes/ShelfmarksFromLBSData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
const { remote } = require('electron')
const _ = require('lodash')
const Shelfmark = require('../shelfmark.js')
const Modes = require('./Modes.js')
const config = remote.getGlobal('config')
const Formats = require('../classes/Formats')
const FormatLinesByMode = require('../classes/FormatLinesByMode')
const LocationCheck = require('../classes/LocationCheck')

class ShelfmarksFromLBSData {
/*
----- Class getter and setter -----
*/
get data () {
return this._data
}

/*
----- End Class getter and setter -----
*/

/*
----- Constructor -----
*/
constructor () {
this._data = ''
}
/*
----- End Constructor -----
*/

getShelfmark (xml, key, dataMode) {
let sig = new Shelfmark()
let mode = new Modes()
let formats = new Formats()
let formatArray = formats.formats
sig.error = getError(xml, key, dataMode)

if (sig.error === '') {
let occ = '00'
sig.id = 99 // gets overwritten at a later stage
if (dataMode === 'PPN') {
sig.ppn = 'PPN'
} else {
sig.ppn = 'EPN'
}
sig.date = '01-01-20'
sig.txtOneLine = xml
sig.exNr = ''
sig.location = ''
sig.loanIndication = ''
let allSubModeData = mode.modes[config.get('mode.defaultMode')].subModes
_.forEach(allSubModeData, function (value) {
let data = {
'format': '',
'lines': ''
}
data.format = value.format
if (config.get('filterByLoc') && !LocationCheck.locDoesMatch(value.locRegEx, sig.location)) {
data.lines = null
} else {
if (value.useRegEx) {
let regex = new RegExp(value.regEx)
if (regex.test(sig.txtOneLine) && sig.defaultSubMode === '') {
sig.defaultSubMode = value.id
}
let lines = sig.txtOneLine.match(regex)
if (lines !== null) {
lines.shift()
}
data.lines = lines
if (data.lines !== null) {
data.lines = FormatLinesByMode.formatLines(sig.location, data.lines, value.result)
}
} else {
data.lines = sig.txtOneLine.split(value.delimiter)
if (sig.defaultSubMode === '') {
sig.defaultSubMode = value.id
}
if (data.lines !== null) {
data.lines = FormatLinesByMode.formatLines(sig.location, data.lines, value.result, formatArray[value.format].lines)
}
}
}
sig.subModes.push(data)
})
}

return sig.shelfmark
}
}

function getError (object, key, mode) {
try {
if (object !== '') {
return ''
} else {
return mode + ': <b>' + key + '</b> wurde nicht gefunden.'
}
} catch (e) {
return e.message
}
}

module.exports = ShelfmarksFromLBSData
202 changes: 0 additions & 202 deletions signaturenDruck/js/classes/ShelfmarksFromSRUData.js

This file was deleted.

4 changes: 2 additions & 2 deletions signaturenDruck/js/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const _ = require('lodash')

const T = require('./classes/Table')
const P = require('./classes/Print')
const ShelfmarksFromSRUData = require('./classes/ShelfmarksFromSRUData')
const ShelfmarksFromLBSData = require('./classes/ShelfmarksFromLBSData')

let objSRU = {
all: []
Expand Down Expand Up @@ -101,7 +101,7 @@ ipcRenderer.on('removeManualSignatures', function (event) {

// ipc listener to add provided data to the SRU obj
ipcRenderer.on('addSRUdata', function (event, xml, barcode, mode) {
let data = new ShelfmarksFromSRUData()
let data = new ShelfmarksFromLBSData()
let shelfmark = data.getShelfmark(xml, barcode, mode)
if (shelfmark.error !== '') {
swal.fire('Achtung', shelfmark.error, 'error')
Expand Down
18 changes: 9 additions & 9 deletions signaturenDruck/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ const configNew = {
modalTxt: 'Die ausgewählten Signaturen wurden gedruckt.'
},
SRU: {
useSRU: false,
printImmediately: false,
SRUAddress: 'http://sru.k10plus.de/opac-de-27',
QueryPart1: '?version=1.1&operation=searchRetrieve&query=pica.bar=',
QueryPart1EPN: '?version=1.1&operation=searchRetrieve&query=pica.epn=',
QueryPart2: '&maximumRecords=1&recordSchema=picaxml'
useSRU: true,
printImmediately: true,
SRUAddress: 'https://lokalsystem-test.ub.uni-mainz.de/bar2sig',
QueryPart1: '?',
QueryPart1EPN: '?',
QueryPart2: ''
},
print: {
printCoverLabel: true
Expand Down Expand Up @@ -96,8 +96,8 @@ const menu = Menu.buildFromTemplate(template)
// name of signature storage json
const sigJSONFile = 'signaturen.json'

const DataFromSRU = require('./js/classes/DataFromSRU.js')
let sruData = new DataFromSRU()
const DataFromLBS = require('./js/classes/DataFromLBS.js')
let sruData = new DataFromLBS()

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
Expand Down Expand Up @@ -251,7 +251,7 @@ function createWindow () {
Menu.setApplicationMenu(menu)
}
// set the mainwindow title (name + version from package.json)
mainWindow.setTitle('Signaturendruck v' + app.getVersion())
mainWindow.setTitle('Signaturendruck/LBS-Hack für Mainz v' + app.getVersion())
// and load the index.html of the app.
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, '/html/index.html'),
Expand Down
Loading

0 comments on commit 54ca951

Please sign in to comment.