Skip to content

Commit 6da588d

Browse files
Merge pull request #719 from lcnetdev/subject-finder-crash
Subject finder crash
2 parents aa2f58b + 24fc82e commit 6da588d

8 files changed

Lines changed: 62 additions & 46 deletions

File tree

public/test_files/2023548750.xml

Lines changed: 2 additions & 0 deletions
Large diffs are not rendered by default.

src/components/panels/edit/modals/YoshinoSubjectsModal.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,7 @@
846846
847847
insertClassification: function(c) {
848848
this.profileStore.yoshinoInsertClassification(c)
849+
console.log(c)
849850
this.profileStore.logEvent('SUBJECT_FINDER_INSERT_CLASSIFICATION', { metadata: [c.portion] })
850851
this.insertedClassifications.add(c.key)
851852
this.insertedClassifications = new Set(this.insertedClassifications)

src/lib/utils_export.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,15 @@ const utilsExport = {
283283
*/
284284
hasUserValue: function(userValue){
285285
for (let key in userValue){
286-
if (key == '@id' || key.includes('http://') || key.includes('https://')){
286+
if (key == '@id'){
287+
return true
288+
}
289+
if (key.includes('http://') || key.includes('https://')){
290+
let v = userValue[key]
291+
// an empty array means this is a placeholder pt with no real data — keep looking
292+
if (Array.isArray(v) && v.length === 0){
293+
continue
294+
}
287295
return true
288296
}
289297
}
@@ -423,7 +431,7 @@ const utilsExport = {
423431
***End Source***
424432
`
425433

426-
utilsNetwork.sendErrorReportLog(errorReport,filename,profileAsJson)
434+
// utilsNetwork.sendErrorReportLog(errorReport,filename,profileAsJson)
427435

428436

429437

src/lib/utils_network.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3594,27 +3594,27 @@ const utilsNetwork = {
35943594

35953595
},
35963596

3597-
sendErrorReportLog: function(log,filename,profileAsJson){
3598-
3599-
let url = useConfigStore().returnUrls.util + 'errorlog/'
3600-
3601-
3602-
fetch(url, {
3603-
method: 'POST',
3604-
headers: {
3605-
'Accept': 'application/json',
3606-
'Content-Type': 'application/json',
3607-
...getAuthHeaders()
3608-
},
3609-
body: JSON.stringify({
3610-
log: log,
3611-
filename:filename,
3612-
profile: profileAsJson
3613-
})
3614-
});
3615-
3616-
3617-
},
3597+
// sendErrorReportLog: function(log,filename,profileAsJson){
3598+
//
3599+
// let url = useConfigStore().returnUrls.util + 'errorlog/'
3600+
//
3601+
//
3602+
// fetch(url, {
3603+
// method: 'POST',
3604+
// headers: {
3605+
// 'Accept': 'application/json',
3606+
// 'Content-Type': 'application/json',
3607+
// ...getAuthHeaders()
3608+
// },
3609+
// body: JSON.stringify({
3610+
// log: log,
3611+
// filename:filename,
3612+
// profile: profileAsJson
3613+
// })
3614+
// });
3615+
//
3616+
//
3617+
// },
36183618

36193619

36203620

@@ -4006,21 +4006,23 @@ const utilsNetwork = {
40064006
async linkedDataLCSHContributorsExtract(data){
40074007
// TODO: Implement extraction logic
40084008
if (data){
4009-
console.log("linkedDataLCSHContributorsExtract data:",data)
4009+
// console.log("linkedDataLCSHContributorsExtract data:",data)
40104010

40114011
for (let lccnUri of Object.keys(data)){
40124012

4013+
if (!data[lccnUri] || !data[lccnUri].results) continue
4014+
40134015
let workUrls = data[lccnUri].results.map(work => work.uri.replace("http://","https://") + '.json');
40144016

40154017
let workPromises = workUrls.map(url => fetch(url).then(response => response.json()));
40164018

40174019
try {
40184020
let workResults = await Promise.all(workPromises);
4019-
console.log("workResults", workResults);
4021+
// console.log("workResults", workResults);
40204022
// Now process each workResult
40214023
for (let workData of workResults) {
40224024
// Process workData
4023-
console.log("Processing workData:", workData);
4025+
// console.log("Processing workData:", workData);
40244026

40254027
let lookup = {}
40264028
let lcshList = []
@@ -4111,7 +4113,7 @@ const utilsNetwork = {
41114113

41124114
if (g['@type'] && g['@type'].indexOf('http://www.loc.gov/mads/rdf/v1#ComplexSubject') > -1) {
41134115

4114-
console.log("Complex Subject:", g);
4116+
// console.log("Complex Subject:", g);
41154117

41164118

41174119

@@ -4120,7 +4122,7 @@ const utilsNetwork = {
41204122
let components = g['http://www.loc.gov/mads/rdf/v1#componentList'][0]['@list'];
41214123
for (let component of components) {
41224124
// now find this in the graph...
4123-
console.log("component:", component);
4125+
// console.log("component:", component);
41244126
let userValueComponent = {
41254127
"@guid": short.generate(),
41264128
"@type": null,
@@ -4136,7 +4138,7 @@ const utilsNetwork = {
41364138
}
41374139
for (let g2 of workData) {
41384140
if (g2['@id'] === component['@id']) {
4139-
console.log("component g2:", g2);
4141+
// console.log("component g2:", g2);
41404142
if (g2['@id']) {
41414143
userValueComponent['@id'] = g2['@id']
41424144
}
@@ -4154,7 +4156,7 @@ const utilsNetwork = {
41544156
}
41554157
}
41564158
}
4157-
console.log("userValueComponent:", userValueComponent);
4159+
// console.log("userValueComponent:", userValueComponent);
41584160
userData['http://id.loc.gov/ontologies/bibframe/subject'][0]['http://www.loc.gov/mads/rdf/v1#componentList'].push(userValueComponent);
41594161
}
41604162
}
@@ -4176,8 +4178,8 @@ const utilsNetwork = {
41764178

41774179
}
41784180

4179-
console.log("lcshList:", lcshList);
4180-
console.log("lookup:", lookup);
4181+
// console.log("lcshList:", lcshList);
4182+
// console.log("lookup:", lookup);
41814183

41824184

41834185

src/lib/utils_parse.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2133,11 +2133,11 @@ const utilsParse = {
21332133
// now look into the rt of this propertiy to see what properties we have sucuessfully mapped and things we did not map
21342134
let allUris = [profile.rt[pkey].pt[key].propertyURI]
21352135
profile.rt[pkey].pt[key].valueConstraint.valueTemplateRefs.forEach((rtName)=>{
2136-
console.log('----')
2137-
console.log(profile.rt[pkey].pt[key])
2138-
console.log(pkey,key)
2139-
console.log(profile.rt[pkey].pt[key].valueConstraint.valueTemplateRefs)
2140-
console.log(rtName)
2136+
// console.log('----')
2137+
// console.log(profile.rt[pkey].pt[key])
2138+
// console.log(pkey,key)
2139+
// console.log(profile.rt[pkey].pt[key].valueConstraint.valueTemplateRefs)
2140+
// console.log(rtName)
21412141

21422142
useProfileStore().rtLookup[rtName].propertyTemplates.forEach((ptObj)=>{
21432143
if (allUris.indexOf(ptObj.propertyURI)==-1){

src/lib/yoshino.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,12 @@ function yoshinoParseRdf(xmlText) {
145145
let compLabel = child.getElementsByTagNameNS(NS.madsrdf, 'authoritativeLabel')[0]?.textContent?.trim()
146146
|| child.getElementsByTagNameNS(NS.rdfs, 'label')[0]?.textContent?.trim()
147147
|| null
148-
// Determine type from element local name (Topic, Geographic, Temporal, GenreForm, etc.)
148+
// Determine type from element local name (Topic, Geographic, Temporal, GenreForm, Hub, etc.)
149149
const compType = child.namespaceURI === NS.madsrdf
150150
? 'http://www.loc.gov/mads/rdf/v1#' + child.localName
151-
: child.localName
151+
: child.namespaceURI === NS.bf
152+
? 'http://id.loc.gov/ontologies/bibframe/' + child.localName
153+
: child.localName
152154
const marcKeyEl = child.getElementsByTagNameNS(NS.bflc, 'marcKey')[0]
153155
const compMarcKey = marcKeyEl?.textContent?.trim() || null
154156

src/stores/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,7 @@ export const useConfigStore = defineStore('config', {
452452
{lccn:'2023478519',label:"bf:relation test", idUrl:'https://id.loc.gov/resources/instances/2023478519.html', profile:'Monograph',profileId:'lc:RT:bf2:Monograph:Instance'},
453453
{lccn:'2025443360',label:"NAR Tests", idUrl:'https://id.loc.gov/resources/instances/2025443360.html', profile:'Monograph',profileId:'lc:RT:bf2:Monograph:Instance'},
454454

455+
{lccn:'2023548750',label:"Subject Test", idUrl:'https://id.loc.gov/resources/instances/2023548750.html', profile:'Monograph',profileId:'lc:RT:bf2:Monograph:Instance'},
455456

456457

457458

src/stores/profile.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6842,7 +6842,7 @@ export const useProfileStore = defineStore('profile', {
68426842
let workRt = null
68436843
let emptySubjectPt = null
68446844
let lastSubjectPt = null
6845-
6845+
console.log("label, source, components, uri, marcKey", label, source, components, uri, marcKey)
68466846
// Find the Work RT
68476847
for (let rt of activeProfile.rtOrder) {
68486848
if (rt.indexOf(':Work') > -1) {
@@ -7991,15 +7991,15 @@ export const useProfileStore = defineStore('profile', {
79917991
contributors: utilsProfile.returnContributorUris(this.activeProfile),
79927992
isbn: (this.activeProfile.linkedData && this.activeProfile.linkedData.isbn) ? this.activeProfile.linkedData.isbn : [],
79937993
}
7994-
console.log(":linkedDatalinkedData",linkedData)
7994+
// console.log(":linkedDatalinkedData",linkedData)
79957995

79967996
for (let isbn of linkedData.isbn){
79977997

79987998
let baseData = await utilsNetwork.linkedDataBaseRelated(isbn)
7999-
console.log("baseData",baseData)
7999+
// console.log("baseData",baseData)
80008000

80018001
let oclcMarcData = utilsNetwork.linkedDataExtractOclcMarc(baseData.results)
8002-
console.log("oclcMarcData",oclcMarcData)
8002+
// console.log("oclcMarcData",oclcMarcData)
80038003
linkedData.subtitle = linkedData.subtitle.concat(oclcMarcData.filter((v) => (v.dataType == 'subtitle')));
80048004
linkedData.noteContent = linkedData.noteContent.concat(oclcMarcData.filter((v) => (v.dataType == 'description')));
80058005
linkedData.noteTOC = linkedData.noteTOC.concat(oclcMarcData.filter((v) => (v.dataType == 'toc')));
@@ -8022,7 +8022,7 @@ export const useProfileStore = defineStore('profile', {
80228022
if (baseData.results.isbns && baseData.results.isbns.length > 0){
80238023
let googleBookData = await utilsNetwork.linkedDataAllGoogleBooksByIsbns(baseData.results.isbns)
80248024
googleBookData = utilsNetwork.linkedDataExtractGoogleBooks(googleBookData)
8025-
console.log("googleBookData",googleBookData)
8025+
// console.log("googleBookData",googleBookData)
80268026

80278027
googleBookData.filter((v) => (v.dataType == 'toc'))
80288028

@@ -8090,12 +8090,12 @@ export const useProfileStore = defineStore('profile', {
80908090
// console.log("lcshContributors",lcshContributors)
80918091
// kick this off but don't wait for it to finish
80928092
utilsNetwork.linkedDataLCSHContributorsExtract(lcshContributors).then((colabResults)=>{
8093-
console.log("colabResults",colabResults)
8093+
// console.log("colabResults",colabResults)
80948094
})
80958095
// if (lcshContributors && lcshContributors.length > 0){
80968096
}
80978097

8098-
console.log("linkedData",linkedData)
8098+
// console.log("linkedData",linkedData)
80998099
this.linkedData = linkedData
81008100
this.linkedData.done = true
81018101
this.linkedData.eId = this.activeProfile && this.activeProfile.eId

0 commit comments

Comments
 (0)