Skip to content

Commit 24773b0

Browse files
fixed for subjectheadings and works
1 parent 4faaafb commit 24773b0

3 files changed

Lines changed: 36 additions & 22 deletions

File tree

src/updater/gndUpdater.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,18 @@ main = (payload) => {
9999
let requests = [];
100100

101101
URIList.forEach((uri) => {
102-
var gndURIParts = uri.split('/');
103-
let gndID = gndURIParts.pop();
104-
let dataRequestUrl = `https://uri.gbv.de/terminology/entityfacts/${gndID}?format=json`
105-
let dataRequest = fetch(dataRequestUrl);
106-
requests.push({
107-
url: dataRequestUrl,
108-
uri: uri,
109-
request: dataRequest
110-
});
111-
requestUrls.push(dataRequest);
102+
if(uri) {
103+
var gndURIParts = uri.split('/');
104+
let gndID = gndURIParts.pop();
105+
let dataRequestUrl = `https://uri.gbv.de/terminology/entityfacts/${gndID}?format=json`
106+
let dataRequest = fetch(dataRequestUrl);
107+
requests.push({
108+
url: dataRequestUrl,
109+
uri: uri,
110+
request: dataRequest
111+
});
112+
requestUrls.push(dataRequest);
113+
}
112114
});
113115

114116
Promise.all(requestUrls).then(function (responses) {
@@ -168,8 +170,8 @@ main = (payload) => {
168170
// get desired language for preflabel. This is frontendlanguage from original data...
169171
let desiredLanguage = originalCdata.frontendLanguage;
170172
// lock in save data
171-
newCdata.conceptURI = data['@id'];
172-
newCdata.conceptName = data.preferredName;
173+
newCdata.conceptURI = data['@id'] ?? originalCdata.conceptURI;
174+
newCdata.conceptName = data.preferredName ?? originalCdata.conceptName;
173175

174176
// if no frontendLanguage exists in originalData: add
175177
if (!originalCdata?.frontendLanguage?.length == 2) {
@@ -188,7 +190,7 @@ main = (payload) => {
188190
}
189191

190192
newCdata._fulltext = {}
191-
newCdata._fulltext.text = GNDUtil.getFullTextFromEntityFactsJSON(data, info?.config?.plugin?.['custom-data-type-gnd']?.config);
193+
newCdata._fulltext.text = GNDUtil.getFullTextFromEntityFactsJSON(data, newCdata, info?.config?.plugin?.['custom-data-type-gnd']?.config);
192194

193195

194196
if (hasChanges(payload.objects[index].data, newCdata)) {

src/webfrontend/CustomDataTypeGND.coffee

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,12 @@ class CustomDataTypeGND extends CustomDataTypeWithCommonsAsPlugin
315315
extendedInfo_xhr = new (CUI.XHR)(url: xurl)
316316
extendedInfo_xhr.start()
317317
.done((data, status, statusText) ->
318+
# note: subjectheadings and works are not part of entityfacts yet
319+
# --> data will be empty, which is handled by falling back to cdata-defaults from autocomplete
320+
318321
pluginConfig = ez5.session.getBaseConfig("plugin", "custom-data-type-gnd")
319322

320-
cdata.conceptURI = data['@id']
323+
cdata.conceptURI = data['@id'] ? cdata.conceptURI
321324

322325
databaseLanguages = that.getDatabaseLanguages()
323326

@@ -330,7 +333,7 @@ class CustomDataTypeGND extends CustomDataTypeWithCommonsAsPlugin
330333
cdata.conceptGeoJSON = geoJSON
331334

332335
cdata._fulltext =
333-
text: GNDUtil.getFullTextFromEntityFactsJSON(data, pluginConfig)
336+
text: GNDUtil.getFullTextFromEntityFactsJSON(data, cdata, pluginConfig)
334337
)
335338

336339
.always(() ->

src/webfrontend/GNDUtil.coffee

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,33 @@ class GNDUtil
4848
return false
4949

5050

51-
@getFullTextFromEntityFactsJSON: (efJSON, pluginConfig) ->
51+
@getFullTextFromEntityFactsJSON: (efJSON, cdata, pluginConfig) ->
5252
_fulltext = ''
5353

5454
if not pluginConfig?.fulltext_gnd
5555
return _fulltext
5656
fulltextConfig = pluginConfig.fulltext_gnd
5757

5858
# changed: lobid used 'id', entityfacts uses '@id'
59-
if efJSON['@id'] and fulltextConfig?.id
60-
_fulltext += efJSON['@id'] + ' '
59+
if fulltextConfig?.id
60+
if efJSON['@id'] and
61+
_fulltext += efJSON['@id'] + ' '
62+
else
63+
_fulltext += cdata.conceptURI + ' '
6164

6265
# missing in entityfacts: gndIdentifier, replace with derivative of @id
63-
if efJSON['@id'] and fulltextConfig?.gndIdentifier
64-
_fulltext += efJSON['@id'].split('/').at(-1) + ' '
66+
if fulltextConfig?.gndIdentifier
67+
if efJSON['@id']
68+
_fulltext += efJSON['@id'].split('/').at(-1) + ' '
69+
else
70+
_fulltext += cdata.conceptURI.split('/').at(-1) + ' '
6571

6672
# same in both: preferredName
67-
if efJSON?.preferredName and fulltextConfig?.preferredName
68-
_fulltext += efJSON.preferredName + ' '
73+
if fulltextConfig?.preferredName
74+
if efJSON?.preferredName and
75+
_fulltext += efJSON.preferredName + ' '
76+
else
77+
_fulltext += cdata.conceptName + ' '
6978

7079
# same in both: variantName
7180
if efJSON?.variantName and fulltextConfig?.variantName

0 commit comments

Comments
 (0)