Skip to content

Commit

Permalink
Merge pull request #23 from lcnetdev/hub-marcKey
Browse files Browse the repository at this point in the history
Hub marc key
  • Loading branch information
thisismattmiller authored Aug 28, 2024
2 parents cb75518 + 3c5e42b commit 2883c34
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 25 deletions.
20 changes: 7 additions & 13 deletions src/lib/utils_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,14 @@ const utilsNetwork = {
for (let val of data){

if (val['@id']){



if (val['@id'] == data.uri){
// this is the main graph

for (let k in val){
//add the marcKey to the nodeMap, so nothing needs to happen downstream
if (k == 'http://id.loc.gov/ontologies/bflc/marcKey'){
results.nodeMap["marcKey"] = [val[k][0]['@value']]
}
//find the title
if (k == 'http://www.w3.org/2000/01/rdf-schema#label'){
results.title = val[k][0]['@value']
Expand All @@ -594,27 +595,20 @@ const utilsNetwork = {


if (k == 'http://id.loc.gov/ontologies/bibframe/hasInstance'){


let counter = 1
for (let i of val['http://id.loc.gov/ontologies/bibframe/hasInstance']){

if (counter>4){
break
}
counter++


let url = i['@id']

if (url.includes('gpo_') ){

url = url.replace('https://id.','https://preprod-8295.id.')
url = url.replace('http://id.','http://preprod-8295.id.')

}


if (url.includes('/instances/') || url.includes('/works/') || url.includes('/hubs/')){
if (returnUrls.env === 'production'){
url = url.replace('https://id.','https://preprod-8080.id.')
Expand Down Expand Up @@ -1227,7 +1221,7 @@ const utilsNetwork = {
r.slice(0,2).toLowerCase() != '|a' &&
r.slice(0,2).toLowerCase() != '|x' &&
r.slice(0,2).toLowerCase() != '|y' &&
r.slice(0,2).toLowerCase() != '|z'
r.slice(0,2).toLowerCase() != '|z'
){
// console.log(r.slice(0,2).toLowerCase())
result.resultType = 'ERROR'
Expand Down Expand Up @@ -1789,7 +1783,7 @@ const utilsNetwork = {
if (Array.isArray(result.hit)){
// it wont be an array if its a complex heading
for (let r of result.hit){
if (!r.literal && r.uri.indexOf('id.loc.gov/authorities/names/')){
if (!r.literal && r.uri.indexOf('id.loc.gov/authorities/names/')){
let responseUri = await this.returnRDFType(r.uri + '.madsrdf_raw.jsonld')
if (responseUri){
r.heading.rdfType = responseUri
Expand Down Expand Up @@ -1883,7 +1877,7 @@ const utilsNetwork = {
*/
subjectSearch: async function(searchVal,complexVal,mode){



let namesUrl = useConfigStore().lookupConfig['http://preprod.id.loc.gov/authorities/names'].modes[0]['NAF All'].url.replace('<QUERY>',searchVal).replace('&count=25','&count=4').replace("<OFFSET>", "1")
let subjectUrlComplex = useConfigStore().lookupConfig['http://id.loc.gov/authorities/subjects'].modes[0]['LCSH All'].url.replace('<QUERY>',complexVal).replace('&count=25','&count=5').replace("<OFFSET>", "1")+'&rdftype=ComplexType'
Expand Down
23 changes: 11 additions & 12 deletions src/stores/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,6 @@ export const useProfileStore = defineStore('profile', {
let blankNode = utilsProfile.returnGuidLocation(pt.userValue,fieldGuid)
console.log("blankNode === ",blankNode, fieldGuid)
if (blankNode === false){

// create the path to the blank node
let buildBlankNodeResult = await utilsProfile.buildBlanknode(pt,propertyPath)
console.log('buildBlankNodeResult',buildBlankNodeResult)
Expand Down Expand Up @@ -2848,7 +2847,7 @@ export const useProfileStore = defineStore('profile', {
pt.userValue[baseURI] = [{}]
}
let userValue = JSON.parse(JSON.stringify(pt.userValue[baseURI][0]))

// userValue['somting'] = {'@guid':'00000','hppts:sfsdfgfdsg.com':['helllerrlooo']}

// find the default values for this template if they exist
Expand All @@ -2870,13 +2869,13 @@ export const useProfileStore = defineStore('profile', {
for (let d of p.valueConstraint.defaults){
let value = {
'@guid': short.generate(d.defaultLiteral, d.defaultURI)
}
}
// do we need to create a blank node for this value?
let useType = utilsRDF.suggestTypeProfile(p.propertyURI,pt)
if (useType === false){
// did not find it in the profile, look to the network
useType = await utilsRDF.suggestTypeNetwork(p.propertyURI)
}
}
if (useType && useType != 'http://www.w3.org/2000/01/rdf-schema#Literal'){
value['@type'] = useType
value[defaultPropertyToUse] = [{
Expand All @@ -2891,27 +2890,27 @@ export const useProfileStore = defineStore('profile', {
}else{
if ((d.defaultLiteral && !d.defaultURI) || (d.defaultLiteral != '' && d.defaultURI == '') ){
value[defaultPropertyToUse] = d.defaultLiteral
}else{
value['@id'] = d.defaultURI
}else{
value['@id'] = d.defaultURI
}
}
}
userValue[p.propertyURI].push(value)
}
}else{
console.warn("Nested default template trying to insert values but there are multiple propertyTemplates so no clue which proerpty to look into for the default value: ", this.rtLookup[p.valueConstraint.valueTemplateRefs[0]])
}
}else{
}else{
let blankNodeType = null
// we probably need to make a blank node, so find out what rdf type blank node is needed
if (p.valueConstraint && p.valueConstraint.valueDataType && p.valueConstraint.valueDataType.dataTypeURI){
blankNodeType = p.valueConstraint.valueDataType.dataTypeURI
}
// overwrite it if there is anything there already
userValue[p.propertyURI] = []
userValue[p.propertyURI] = []
for (let d of p.valueConstraint.defaults){
let value = {
'@guid': short.generate(d.defaultLiteral, d.defaultURI)
}
}
// if it just has a literal value and not a URI then don't create a blank node, just insert it using that literal property
if ((d.defaultLiteral && !d.defaultURI) || (d.defaultLiteral != '' && d.defaultURI == '') ){
value[p.propertyURI] = d.defaultLiteral
Expand All @@ -2930,7 +2929,7 @@ export const useProfileStore = defineStore('profile', {
if (blankNodeType){
value['@type'] = blankNodeType
}

}
userValue[p.propertyURI].push(value)
}
Expand Down Expand Up @@ -2972,7 +2971,7 @@ export const useProfileStore = defineStore('profile', {

if (pt !== false){


let profile
let propertyPosition
for (let r of this.activeProfile.rtOrder){
Expand Down

0 comments on commit 2883c34

Please sign in to comment.