From 87645a2eeeb6580b8591dd275de69d352527d6c6 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 6 Dec 2024 14:10:28 -0500 Subject: [PATCH 1/5] Hub ready for stage testing --- .../edit/fields/helpers/ActionButton.vue | 7 +- .../panels/edit/modals/HubStubCreateModal.vue | 48 ++++++++++-- .../panels/sidebar_preview_opac/Opac.vue | 2 +- src/lib/utils_export.js | 78 ++----------------- src/lib/utils_parse.js | 51 ++++++++++-- src/stores/config.js | 4 +- src/stores/profile.js | 2 +- src/views/Load.vue | 30 +++++-- 8 files changed, 124 insertions(+), 98 deletions(-) diff --git a/src/components/panels/edit/fields/helpers/ActionButton.vue b/src/components/panels/edit/fields/helpers/ActionButton.vue index 136f2cab..c51274ca 100644 --- a/src/components/panels/edit/fields/helpers/ActionButton.vue +++ b/src/components/panels/edit/fields/helpers/ActionButton.vue @@ -242,14 +242,19 @@ showBuildHubStub(){ + console.log("this.propertyPath",this.propertyPath) if (!this.propertyPath) return false; if (this.propertyPath && this.propertyPath.length==0) return false; - + let pt = this.profileStore.returnStructureByComponentGuid(this.guid) if (pt && pt.propertyURI && pt.propertyURI == "http://id.loc.gov/ontologies/bibframe/relation"){ return true } + if (pt && pt.propertyURI && pt.propertyURI == "http://id.loc.gov/ontologies/bibframe/expressionOf"){ + return true + } + return false diff --git a/src/components/panels/edit/modals/HubStubCreateModal.vue b/src/components/panels/edit/modals/HubStubCreateModal.vue index dd07cf17..e4ce1eee 100644 --- a/src/components/panels/edit/modals/HubStubCreateModal.vue +++ b/src/components/panels/edit/modals/HubStubCreateModal.vue @@ -43,6 +43,9 @@ displayModal:false, + postStatus: 'unposted', + + newHubUrl: null, @@ -155,7 +158,7 @@ - console.log(this.hubCreator) + }, @@ -175,11 +178,21 @@ async buildHub(){ - + this.postStatus='posting' let results = await this.profileStore.buildPostHubStub(this.hubCreator,this.hubTitle,this.hubLang,this.preferenceStore.catCode) + if (results && results.postLocation){ + this.profileStore.setValueComplex(this.activeHubStubComponent.guid, null, this.activeHubStubComponent.propertyPath, results.postLocation, this.hubTitle, null, {}, null) - // this.profileStore.setValueComplex(this.guid, null, this.propertyPath, contextValue.uri, contextValue.title, contextValue.typeFull, contextValue.nodeMap, contextValue.marcKey) + this.newHubUrl=results.postLocation + this.postStatus='posted' + + }else{ + alert("Error posting!") + this.postStatus='error' + } + + console.log(results) @@ -190,6 +203,14 @@ }, + + close(){ + this.activeHubStubComponent = {} + this.activeHubStubData = {} + this.showHubStubCreateModal=false + this.postStatus=='unposed' + + } @@ -262,7 +283,7 @@

Create Quick Hub

@@ -277,7 +298,7 @@
- +
[No Hub Creator] {{hubCreator.label }} @@ -298,15 +319,26 @@
-
+
Fill out the above information to create a Hub Stub. You would create a Hub for resources that you would not normally create a MARC Authority record for. Once you click create you will be provided a link to further edit the Hub if you wish.
-
+
-
+
+
+
+
Posting... Please wait...
+
+
+
The Hub was created! If you would like to edit it further please click the link, it will open in new tab:
+ +
+
+
+
diff --git a/src/components/panels/sidebar_preview_opac/Opac.vue b/src/components/panels/sidebar_preview_opac/Opac.vue index 5ef276ac..cf953093 100644 --- a/src/components/panels/sidebar_preview_opac/Opac.vue +++ b/src/components/panels/sidebar_preview_opac/Opac.vue @@ -210,7 +210,7 @@ - + {{$t("message.wordWork")}} diff --git a/src/lib/utils_export.js b/src/lib/utils_export.js index ceaed948..97987ffc 100644 --- a/src/lib/utils_export.js +++ b/src/lib/utils_export.js @@ -1397,7 +1397,7 @@ const utilsExport = { let theHub = (new XMLSerializer()).serializeToString(rdfBasic) - theHub = parser.parseFromString(theHub, "text/xml").children[0]; + theHub = xmlParser.parseFromString(theHub, "text/xml").children[0]; rdf = theHub } @@ -1885,12 +1885,12 @@ const utilsExport = { elAdminAgentCode1.innerHTML='DLC' let elAdminAgentCode2 = document.createElementNS(this.namespace.rdfs ,'bf:code') - elAdminAgentCode1.setAttributeNS(this.namespace.rdf, 'rdf:datatype', 'http://id.loc.gov/datatypes/orgs/normalized') - elAdminAgentCode1.innerHTML='dlc' + elAdminAgentCode2.setAttributeNS(this.namespace.rdf, 'rdf:datatype', 'http://id.loc.gov/datatypes/orgs/normalized') + elAdminAgentCode2.innerHTML='dlc' let elAdminAgentCode3 = document.createElementNS(this.namespace.rdfs ,'bf:code') - elAdminAgentCode1.setAttributeNS(this.namespace.rdf, 'rdf:datatype', 'http://id.loc.gov/datatypes/orgs/iso15511') - elAdminAgentCode1.innerHTML='US-dlc' + elAdminAgentCode3.setAttributeNS(this.namespace.rdf, 'rdf:datatype', 'http://id.loc.gov/datatypes/orgs/iso15511') + elAdminAgentCode3.innerHTML='US-dlc' elAdminAgentClass.appendChild(elAdminAgentCode1) elAdminAgentClass.appendChild(elAdminAgentCode2) @@ -1915,76 +1915,8 @@ const utilsExport = { elHub.appendChild(elAdminProperty) - - -// -// -// -// -// new -// n -// -// -// 1996-05-16 -// -// -// -// United States, Library of Congress -// DLC -// dlc -// US-dlc -// -// -// -// - - - - - rdf.appendChild(elHub) - - - - - // - // Filosofia e scienza nell'età moderna - // filosofiaescienzanell'etàmoderna - // - // - // - // Filosofia e scienza nell'età moderna - // 1 - // Studi - // - // - // 440 0$aFilosofia e scienza nell'età moderna.$n1,$pStudi ;$v68 - // - - -{/* - - - - - -Twain, Mark, 1835-1910 -1001 $aTwain, Mark,$d1835-1910 - - - - -contributor -ctb - - - - */} - - - - console.log(aap) console.log(aapHash) console.log(hubUri) diff --git a/src/lib/utils_parse.js b/src/lib/utils_parse.js index 0991972f..c2b8af38 100644 --- a/src/lib/utils_parse.js +++ b/src/lib/utils_parse.js @@ -336,7 +336,26 @@ const utilsParse = { return xml }, - + /** + * For our hub profile we broke out the different title types, sniff for which profile to use + * + * @param {Node} xml - the XML payload + * @return {Node} + */ + sniffTitleType(xml){ + for (let child of xml.children){ + if (child.tagName == 'bf:title'){ + if ( child.innerHTML.indexOf("bf:VariantTitle")>-1){ + child.setAttribute('local:pthint', 'lc:RT:bf2:Title:VarTitle') + }if ( child.innerHTML.indexOf("bf:TransliteratedTitle")>-1){ + child.setAttribute('local:pthint', 'lc:RT:bflc:TranscribedTitle') + }else{ + // leave blank? + } + } + } + return xml + }, specialTransforms: { @@ -382,9 +401,12 @@ const utilsParse = { profile.rtOrder.push(useInstanceRtName + '_'+(i+1)) }); + let rtsToRemove = [] + for (const pkey in profile.rt) { let tle = "" + let isHub = false if (pkey.includes(':Work')){ tle = "bf:Work" }else if (pkey.includes(':Instance')){ @@ -393,7 +415,9 @@ const utilsParse = { tle = "bf:Item" }else if (pkey.endsWith(':Hub')){ tle = "bf:Hub" - }else{ + isHub=true + }else{ + rtsToRemove.push(pkey) // don't mess with anything other than top level entities in the profile, remove them from the profile continue } @@ -411,12 +435,9 @@ const utilsParse = { if (xml === false && tle == 'bf:Hub'){ tle = "bf:Work" + isHub=true console.warn('No bf:Hub found, looking for bf:Work') - if (testRun){ - xml = this.testDom.getElementsByTagName(tle) - }else{ - xml = this.activeDom.getElementsByTagName(tle) - } + xml = this.activeDom.getElementsByTagName(tle) xml = this.returnOneWhereParentIs(xml, "rdf:RDF") } @@ -529,6 +550,11 @@ const utilsParse = { xml = this.sniffNoteType(xml) } + if (isHub){ + xml = this.sniffTitleType(xml) + + } + let sucessfulProperties = [] @@ -1900,6 +1926,17 @@ const utilsParse = { for (let x of toDeleteNoData){ profile.rt[x].noData=true } + + for (let rt of rtsToRemove){ + delete profile.rt[rt] + let index = profile.rtOrder.indexOf(rt); + if (index !== -1) { + profile.rtOrder.splice(index, 1); + } + + + } + console.log("profileprofileprofileprofile",JSON.parse(JSON.stringify(profile))) return profile diff --git a/src/stores/config.js b/src/stores/config.js index 546ff211..04387c55 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -6,8 +6,8 @@ export const useConfigStore = defineStore('config', { state: () => ({ versionMajor: 0, - versionMinor: 16, - versionPatch: 11, + versionMinor: 17, + versionPatch: 0, regionUrls: { diff --git a/src/stores/profile.js b/src/stores/profile.js index 7bb5bd5f..c856f214 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -4409,7 +4409,7 @@ export const useProfileStore = defineStore('profile', { alert("There was an error creating your Hub. Please report this issue.") } - // pubResuts = {'location': 'http://id.loc.gov/resources/hubs/1111-111-111-111'} + // pubResuts = {'postLocation': 'https://id.loc.gov/resources/hubs/a07eefde-6522-9b99-e760-5c92f7d396eb'} return pubResuts diff --git a/src/views/Load.vue b/src/views/Load.vue index 3ba010d2..9bc8a017 100644 --- a/src/views/Load.vue +++ b/src/views/Load.vue @@ -113,10 +113,11 @@

Load with profile:

+
- +

@@ -295,6 +296,9 @@ } + points.push( { "name": "HUB", "work": null, "instance": "lc:RT:bf2:HubBasic:Hub", "item": null },) + + console.log(points) return points } @@ -442,12 +446,14 @@ // find the right profile to use from the instance profile name used let useProfile = null + console.log("this.profiles",this.profiles) + console.log("useInstanceProfile",useInstanceProfile) for (let key in this.profiles){ if (this.profiles[key].rtOrder.indexOf(useInstanceProfile)>-1){ useProfile = JSON.parse(JSON.stringify(this.profiles[key])) } } - + // check if the input field is empty if (this.urlToLoad == "" && useProfile===null){ alert("Please enter the URL or Identifier of the record you want to load.") @@ -605,16 +611,30 @@ this.refreshSavedRecords() // this is checking to see if the route is available to load the passed URL to it - let inerval = window.setInterval(()=>{ + let intervalLoadUrl = window.setInterval(()=>{ if (this.$route && this.$route.query && this.$route.query.url){ this.urlToLoad = this.$route.query.url this.urlToLoadIsHttp=true - window.clearInterval(inerval) + window.clearInterval(intervalLoadUrl) + + } - } },500) + let intervalLoadProfile = window.setInterval(()=>{ + if (this.$route && this.$route.query && this.$route.query.profile && this.startingPointsFiltered && this.startingPointsFiltered.length>0){ + console.log("Weerrr looookiinnn at the profile!", this.$route.query.profile) + let possibleInstanceProfiles = this.startingPointsFiltered.map((v)=>v.instance) + if (possibleInstanceProfiles.indexOf(this.$route.query.profile) >-1){ + this.loadUrl(this.$route.query.profile) + } + window.clearInterval(intervalLoadProfile) + // loadUrl + } + + },600) + } } From a3b8ab7d9f04432d7d90bcd5c49f285c7ee3c87d Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 6 Dec 2024 14:19:45 -0500 Subject: [PATCH 2/5] error debug --- src/stores/profile.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/stores/profile.js b/src/stores/profile.js index b725bb64..4dcf60f9 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -4479,7 +4479,8 @@ export const useProfileStore = defineStore('profile', { console.log(pubResuts) pubResuts = await pubResuts.json() console.log(pubResuts) - }catch{ + }catch (error){ + console.log(error) alert("There was an error creating your Hub. Please report this issue.") } From a12c90e0854318b31d7b1c833c34c323fa4b12d6 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 6 Dec 2024 14:24:14 -0500 Subject: [PATCH 3/5] change post to propery use postLocation --- src/lib/utils_network.js | 4 ++-- src/stores/profile.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib/utils_network.js b/src/lib/utils_network.js index d750f771..430adb4d 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -2602,12 +2602,12 @@ const utilsNetwork = { if (content && content.publish && content.publish.status && content.publish.status == 'published'){ - return {status:true} + return {status:true, postLocation: (content.postLocation) ? content.postLocation : null } }else{ // alert("Did not post, please report this error--" + JSON.stringify(content.publish,null,2)) - return {status:false, msg: JSON.stringify(content.publish,null,2)} + return {status:false, postLocation: (content.postLocation) ? content.postLocation : null, msg: JSON.stringify(content.publish,null,2)} } }, diff --git a/src/stores/profile.js b/src/stores/profile.js index 4dcf60f9..2557da74 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -4476,9 +4476,9 @@ export const useProfileStore = defineStore('profile', { let pubResuts try{ pubResuts = await utilsNetwork.publish(xml, eid, {id: 'Hub'}) - console.log(pubResuts) - pubResuts = await pubResuts.json() - console.log(pubResuts) + + + }catch (error){ console.log(error) alert("There was an error creating your Hub. Please report this issue.") From 76cd00d9672baa3687faffa61ff85a7f2b1d2ce5 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Fri, 6 Dec 2024 14:29:29 -0500 Subject: [PATCH 4/5] stage should use stage profiles --- src/components/panels/edit/modals/HubStubCreateModal.vue | 1 + src/stores/config.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/panels/edit/modals/HubStubCreateModal.vue b/src/components/panels/edit/modals/HubStubCreateModal.vue index e4ce1eee..897b3c79 100644 --- a/src/components/panels/edit/modals/HubStubCreateModal.vue +++ b/src/components/panels/edit/modals/HubStubCreateModal.vue @@ -182,6 +182,7 @@ let results = await this.profileStore.buildPostHubStub(this.hubCreator,this.hubTitle,this.hubLang,this.preferenceStore.catCode) if (results && results.postLocation){ + results.postLocation = results.postLocation.replace("http://",'https://') this.profileStore.setValueComplex(this.activeHubStubComponent.guid, null, this.activeHubStubComponent.propertyPath, results.postLocation, this.hubTitle, null, {}, null) this.newHubUrl=results.postLocation diff --git a/src/stores/config.js b/src/stores/config.js index 2e2e2865..ce2ae63c 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -51,8 +51,8 @@ export const useConfigStore = defineStore('config', { shelfListing: 'https://preprod-8230.id.loc.gov/', // bfdb : 'https://preprod-8210.id.loc.gov/', bfdb : 'https://preprod-8300.id.loc.gov/', - // profiles : '/bfe2/util/profiles/profile/stage', - profiles : '/bfe2/util/profiles/profile/prod', + profiles : '/bfe2/util/profiles/profile/stage', + // profiles : '/bfe2/util/profiles/profile/prod', // profiles: 'https://preprod-3001.id.loc.gov/api/listconfigs?where=index.resourceType:profile', starting : '/bfe2/util/profiles/starting/stage', id: 'https://preprod-8288.id.loc.gov/', From ae921a50c9c3b75faa1e3e101f0c18b7091b3119 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 9 Dec 2024 13:04:43 -0500 Subject: [PATCH 5/5] posting hub from main editor --- src/stores/config.js | 4 ++-- src/stores/profile.js | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/stores/config.js b/src/stores/config.js index ce2ae63c..3e9b17ab 100644 --- a/src/stores/config.js +++ b/src/stores/config.js @@ -26,8 +26,8 @@ export const useConfigStore = defineStore('config', { profiles : 'http://localhost:9401/util/profiles/profile/prod', starting: 'http://localhost:9401/util/profiles/starting/prod', - profiles: 'https://raw.githubusercontent.com/lcnetdev/bfe-profiles/main/profile-prod/data.json', - // profiles: 'https://raw.githubusercontent.com/lcnetdev/bfe-profiles/main/profile-stage/data.json', + // profiles: 'https://raw.githubusercontent.com/lcnetdev/bfe-profiles/main/profile-prod/data.json', + profiles: 'https://raw.githubusercontent.com/lcnetdev/bfe-profiles/main/profile-stage/data.json', starting: 'https://raw.githubusercontent.com/lcnetdev/bfe-profiles/main/starting-prod/data.json', diff --git a/src/stores/profile.js b/src/stores/profile.js index 2557da74..2c18cbe2 100644 --- a/src/stores/profile.js +++ b/src/stores/profile.js @@ -2639,12 +2639,30 @@ export const useProfileStore = defineStore('profile', { * @return {obj} - response from posting action */ publishRecord: async function(eid, profile){ + + + + let postingHub = false + if (this.activeProfile && this.activeProfile.id && this.activeProfile.id.indexOf(':Hub')>-1){ + // ITS A HUB! + // do other things if its a hub + postingHub=true + } + let xml = await utilsExport.buildXML(this.activeProfile) - let pubResuts = await utilsNetwork.publish(xml.xlmStringBasic, this.activeProfile.eId, this.activeProfile) - pubResuts.resourceLinks=[] - // if it was accepted by the system send it to the marva backend to store as posted + + let pubResuts + + if (postingHub){ + pubResuts = await utilsNetwork.publish(xml.xlmStringBasic, this.activeProfile.eId, {id: 'Hub'}) + }else{ + pubResuts = await utilsNetwork.publish(xml.xlmStringBasic, this.activeProfile.eId, this.activeProfile) + } + + pubResuts.resourceLinks=[] + // if it was accepted by the system send it to the marva backend to store as posted if (pubResuts.status){ this.activeProfile.status = 'published'