From 6a02bb6ad2732315cfac6a5340b3128300e5cf9a Mon Sep 17 00:00:00 2001 From: f-osorio Date: Fri, 15 Nov 2024 07:20:55 -0500 Subject: [PATCH 1/5] Fix `aMarcKey is null` error --- src/stores/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/profile.js b/src/stores/profile.js index 6d78830f..7e2029ce 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -2074,7 +2074,7 @@ export const useProfileStore = defineStore('profile', { 'http://id.loc.gov/ontologies/bflc/marcKey' : aMarcKeyNode } ) - }else if (aMarcKeyNode['@value']){ + }else if (aMarcKeyNode && aMarcKeyNode['@value']){ let aNode = { '@guid': short.generate(), 'http://id.loc.gov/ontologies/bflc/marcKey' : aMarcKeyNode['@value'] From 5d0690535ee89754085c98687beba6441d3aaa14 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Fri, 15 Nov 2024 09:05:41 -0500 Subject: [PATCH 2/5] Clean complexValue of existing data when setting data The complex values were maintaining existing values when they were updated. --- .../panels/edit/fields/LookupComplex.vue | 15 ++++++--- src/components/panels/edit/fields/Ref.vue | 10 +++--- src/stores/profile.js | 31 +++++++++---------- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/components/panels/edit/fields/LookupComplex.vue b/src/components/panels/edit/fields/LookupComplex.vue index 4826c7eb..5070d414 100644 --- a/src/components/panels/edit/fields/LookupComplex.vue +++ b/src/components/panels/edit/fields/LookupComplex.vue @@ -328,10 +328,16 @@ export default { complexLookupValues(){ - - - let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) - return values + + let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) + return values + + // try{ + // let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) + // return values + // } catch { + // return false + // } }, @@ -526,6 +532,7 @@ export default { * @return {object} profile */ setComplexValue: function(contextValue){ + console.info("contextValue: ", contextValue) delete contextValue.typeFull this.profileStore.setValueComplex(this.guid, null, this.propertyPath, contextValue.uri, contextValue.title, contextValue.typeFull, contextValue.nodeMap, contextValue.marcKey) this.searchValue='' diff --git a/src/components/panels/edit/fields/Ref.vue b/src/components/panels/edit/fields/Ref.vue index a73ec325..e4e44fd8 100644 --- a/src/components/panels/edit/fields/Ref.vue +++ b/src/components/panels/edit/fields/Ref.vue @@ -284,11 +284,11 @@ export default { let template = this.structure.valueConstraint.valueTemplateRefs[idx] if (parentUserValue && parentUserValue["@root"] == "http://id.loc.gov/ontologies/bibframe/contribution" && parentUserValue["http://id.loc.gov/ontologies/bibframe/contribution"]){ let target = parentUserValue["http://id.loc.gov/ontologies/bibframe/contribution"][0]["http://id.loc.gov/ontologies/bibframe/agent"] - if (target){ - let type = target[0]["@type"] - if (type && this.rtLookup[template].resourceURI === type){ - useId = template - } + if (target){ + let type = target[0]["@type"] + if (type && this.rtLookup[template].resourceURI === type){ + useId = template + } } } } diff --git a/src/stores/profile.js b/src/stores/profile.js index 7e2029ce..56bf0209 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -1839,16 +1839,15 @@ export const useProfileStore = defineStore('profile', { // console.log("propertyPath=",propertyPath) - let pt = utilsProfile.returnPt(this.activeProfile,componentGuid) let valueLocation = utilsProfile.returnValueFromPropertyPath(pt,propertyPath) let deepestLevelURI = propertyPath[propertyPath.length-1].propertyURI + if (valueLocation){ let values = [] - + for (let v of valueLocation){ - let URI = null let label = null @@ -1859,17 +1858,17 @@ export const useProfileStore = defineStore('profile', { for (let lP of LABEL_PREDICATES){ - if (v[lP] && v[lP][0][lP]){ - label = v[lP][0][lP] - break - } + if (v[lP][0] && v[lP] != null && v[lP] && v[lP][0][lP]){ + label = v[lP][0][lP] + break + } } // look for bf:title -> bf:mainTitle if (!label){ for (let lP1 of LABEL_PREDICATES){ for (let lP2 of LABEL_PREDICATES){ - if (v[lP1] && v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ + if (v[lP1][0] && v[lP1] && v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ label = v[lP1][0][lP2][0][lP2] break } @@ -1934,6 +1933,7 @@ export const useProfileStore = defineStore('profile', { } } + return values } @@ -1959,6 +1959,7 @@ export const useProfileStore = defineStore('profile', { * @return {void} */ setValueComplex: async function(componentGuid, fieldGuid, propertyPath, URI, label, type, nodeMap=null, marcKey=null ){ + // TODO: reconcile this to how the profiles are built, or dont.. // remove the sameAs from this property path, which will be the last one, we don't need it propertyPath = propertyPath.filter((v)=> { return (v.propertyURI!=='http://www.w3.org/2002/07/owl#sameAs') }) @@ -1967,6 +1968,7 @@ export const useProfileStore = defineStore('profile', { let lastProperty = propertyPath.at(-1).propertyURI // locate the correct pt to work on in the activeProfile let pt = utilsProfile.returnPt(this.activeProfile,componentGuid) + if (!type && URI && !lastProperty.includes("intendedAudience")){ // I regretfully inform you we will need to look this up @@ -1993,12 +1995,15 @@ export const useProfileStore = defineStore('profile', { if (blankNode === false){ // create the path to the blank node let buildBlankNodeResult = await utilsProfile.buildBlanknode(pt,propertyPath) - console.log('buildBlankNodeResult',buildBlankNodeResult) - pt = buildBlankNodeResult[0] // now we can make a link to the parent of where the literal value should live blankNode = utilsProfile.returnGuidLocation(pt.userValue,buildBlankNodeResult[1]) + + //empty out the blankNode's existing data so it only has the new data + for (let key of Object.keys(blankNode).filter((k) => !k.startsWith("@"))){ + blankNode[key] = [] + } // set the URI // if its null then we are adding a literal @@ -2043,9 +2048,6 @@ export const useProfileStore = defineStore('profile', { } } - - - //Add gacs code to user data if (nodeMap["GAC(s)"]){ blankNode["http://www.loc.gov/mads/rdf/v1#code"] = [ @@ -2057,8 +2059,6 @@ export const useProfileStore = defineStore('profile', { ] } - - if (!Array.isArray(marcKey)){ marcKey = [marcKey] } @@ -2133,7 +2133,6 @@ export const useProfileStore = defineStore('profile', { console.error('setValueComplex: Cannot locate the component by guid', componentGuid, this.activeProfile) } - console.log("pt is ",pt) }, From 9173b2ef21903bb132746e4635ee1a661201ae11 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Fri, 15 Nov 2024 09:26:13 -0500 Subject: [PATCH 3/5] Catch error in `complexLookupValues()` The error occured when populating an empty complexValue. The function tries to data from an empty component. This mostly didn't seem to cause an issue, but might have been causing some freeze with the cutter tool. Also, why not catch the error. --- .../panels/edit/fields/LookupComplex.vue | 18 +- src/stores/profile.js | 160 +++++++++--------- 2 files changed, 91 insertions(+), 87 deletions(-) diff --git a/src/components/panels/edit/fields/LookupComplex.vue b/src/components/panels/edit/fields/LookupComplex.vue index 5070d414..32b0e3b1 100644 --- a/src/components/panels/edit/fields/LookupComplex.vue +++ b/src/components/panels/edit/fields/LookupComplex.vue @@ -328,16 +328,15 @@ export default { complexLookupValues(){ - - let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) - return values - // try{ - // let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) - // return values - // } catch { - // return false - // } + try{ + let values = this.profileStore.returnComplexLookupValueFromProfile(this.guid,this.propertyPath) + return values + } catch(err) { + // this can run into an error when populating an empty complexValue field + // It mostly doesn't seem to matter, but might as well catch + return [] + } }, @@ -532,7 +531,6 @@ export default { * @return {object} profile */ setComplexValue: function(contextValue){ - console.info("contextValue: ", contextValue) delete contextValue.typeFull this.profileStore.setValueComplex(this.guid, null, this.propertyPath, contextValue.uri, contextValue.title, contextValue.typeFull, contextValue.nodeMap, contextValue.marcKey) this.searchValue='' diff --git a/src/stores/profile.js b/src/stores/profile.js index 56bf0209..4a59ba27 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -1843,100 +1843,106 @@ export const useProfileStore = defineStore('profile', { let valueLocation = utilsProfile.returnValueFromPropertyPath(pt,propertyPath) let deepestLevelURI = propertyPath[propertyPath.length-1].propertyURI + console.info("pt", JSON.parse(JSON.stringify(pt))) + console.info("valueLocation", valueLocation) + console.info("deepestLevelURI", deepestLevelURI) + if (valueLocation){ let values = [] for (let v of valueLocation){ - let URI = null - let label = null - - if (v['@id']){ - URI = v['@id'] - } + let URI = null + let label = null + if (v['@id']){ + URI = v['@id'] + } - for (let lP of LABEL_PREDICATES){ - if (v[lP][0] && v[lP] != null && v[lP] && v[lP][0][lP]){ - label = v[lP][0][lP] - break - } - } + for (let lP of LABEL_PREDICATES){ + console.info("lP", lP) + if (v[lP] && v[lP][0][lP]){ + label = v[lP][0][lP] + break + } + } - // look for bf:title -> bf:mainTitle - if (!label){ - for (let lP1 of LABEL_PREDICATES){ - for (let lP2 of LABEL_PREDICATES){ - if (v[lP1][0] && v[lP1] && v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ - label = v[lP1][0][lP2][0][lP2] - break + // look for bf:title -> bf:mainTitle + if (!label){ + for (let lP1 of LABEL_PREDICATES){ + console.info("lP1", lP1) + for (let lP2 of LABEL_PREDICATES){ + console.info("lP2", lP2) + if (v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ + label = v[lP1][0][lP2][0][lP2] + break + } + } } } - } - } - - let source = null - if (URI && URI.indexOf('/fast/') >1){ - source = 'FAST' - } - let uneditable = false - - // if we don't have a URI for a work don't let them edit it - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Work'){ - uneditable = true - } - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bflc/Uncontrolled'){ - uneditable = true - } - if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Uncontrolled'){ - uneditable = true - } - // if it is deepHierarchy then then we are copy pasting what came into the system and they cann change it anyway. - if (pt.deepHierarchy){uneditable=true} + let source = null + if (URI && URI.indexOf('/fast/') >1){ + source = 'FAST' + } + let uneditable = false - if (URI && label){ - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: false, - isLiteral: false, - uneditable: uneditable, - type:v['@type'] - }) - }else if (URI && !label){ - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: true, - isLiteral: false, - uneditable: uneditable, - type:v['@type'] - }) - }else if (!URI && label){ + // if we don't have a URI for a work don't let them edit it + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Work'){ + uneditable = true + } + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bflc/Uncontrolled'){ + uneditable = true + } + if (!URI && label && v['@type'] && v['@type'] == 'http://id.loc.gov/ontologies/bibframe/Uncontrolled'){ + uneditable = true + } - values.push({ - '@guid':v['@guid'], - URI: URI, - label: label, - source: source, - needsDereference: false, - uneditable: uneditable, - isLiteral: true, - type:v['@type'] - }) - } + // if it is deepHierarchy then then we are copy pasting what came into the system and they cann change it anyway. + if (pt.deepHierarchy){uneditable=true} + + if (URI && label){ + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: false, + isLiteral: false, + uneditable: uneditable, + type:v['@type'] + }) + }else if (URI && !label){ + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: true, + isLiteral: false, + uneditable: uneditable, + type:v['@type'] + }) + }else if (!URI && label){ + + values.push({ + '@guid':v['@guid'], + URI: URI, + label: label, + source: source, + needsDereference: false, + uneditable: uneditable, + isLiteral: true, + type:v['@type'] + }) + } + } + + return values } - - return values - } // if valueLocation is false then it did not find anytihng meaning its empty, return empty array return [] From c1d9c913e7dc9a9f72b9ef99585151c61c8faee6 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Fri, 15 Nov 2024 09:46:51 -0500 Subject: [PATCH 4/5] Clean console --- src/stores/profile.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/stores/profile.js b/src/stores/profile.js index 4a59ba27..97c40ea1 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -1843,10 +1843,6 @@ export const useProfileStore = defineStore('profile', { let valueLocation = utilsProfile.returnValueFromPropertyPath(pt,propertyPath) let deepestLevelURI = propertyPath[propertyPath.length-1].propertyURI - console.info("pt", JSON.parse(JSON.stringify(pt))) - console.info("valueLocation", valueLocation) - console.info("deepestLevelURI", deepestLevelURI) - if (valueLocation){ let values = [] @@ -1861,7 +1857,6 @@ export const useProfileStore = defineStore('profile', { } for (let lP of LABEL_PREDICATES){ - console.info("lP", lP) if (v[lP] && v[lP][0][lP]){ label = v[lP][0][lP] break @@ -1871,9 +1866,7 @@ export const useProfileStore = defineStore('profile', { // look for bf:title -> bf:mainTitle if (!label){ for (let lP1 of LABEL_PREDICATES){ - console.info("lP1", lP1) for (let lP2 of LABEL_PREDICATES){ - console.info("lP2", lP2) if (v[lP1][0][lP2] && v[lP1][0][lP2][0][lP2]){ label = v[lP1][0][lP2][0][lP2] break From 48faf4bca21fe46b1da57835994b492c46573568 Mon Sep 17 00:00:00 2001 From: f-osorio Date: Fri, 15 Nov 2024 10:00:09 -0500 Subject: [PATCH 5/5] version++ --- src/stores/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/config.js b/src/stores/config.js index b6d113ca..bf0ef786 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -7,7 +7,7 @@ export const useConfigStore = defineStore('config', { versionMajor: 0, versionMinor: 16, - versionPatch: 6, + versionPatch: 7,