Skip to content

Commit

Permalink
Merge pull request #124 from lcnetdev/bfp-272-name-updates
Browse files Browse the repository at this point in the history
[BFP 272] ComplexValues
  • Loading branch information
f-osorio authored Nov 15, 2024
2 parents 5e67c02 + 48faf4b commit b5be0fd
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 98 deletions.
13 changes: 9 additions & 4 deletions src/components/panels/edit/fields/LookupComplex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +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(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 []
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/components/panels/edit/fields/Ref.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/stores/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useConfigStore = defineStore('config', {

versionMajor: 0,
versionMinor: 16,
versionPatch: 6,
versionPatch: 7,



Expand Down
174 changes: 86 additions & 88 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1839,104 +1839,103 @@ 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


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] && v[lP][0][lP]){
label = v[lP][0][lP]
break
}
}
for (let lP of LABEL_PREDICATES){
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] && 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){
for (let lP2 of LABEL_PREDICATES){
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 []
Expand All @@ -1959,6 +1958,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') })
Expand All @@ -1967,6 +1967,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
Expand All @@ -1993,12 +1994,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
Expand Down Expand Up @@ -2043,9 +2047,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"] = [
Expand All @@ -2057,8 +2058,6 @@ export const useProfileStore = defineStore('profile', {
]
}



if (!Array.isArray(marcKey)){
marcKey = [marcKey]
}
Expand All @@ -2074,7 +2073,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']
Expand Down Expand Up @@ -2133,7 +2132,6 @@ export const useProfileStore = defineStore('profile', {
console.error('setValueComplex: Cannot locate the component by guid', componentGuid, this.activeProfile)
}


console.log("pt is ",pt)
},

Expand Down

0 comments on commit b5be0fd

Please sign in to comment.