forked from gbv/SignaturenDruck
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
708 additions
and
808 deletions.
There are no files selected for viewing
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
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
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 |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.