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..897b3c79 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,22 @@ async buildHub(){ - + this.postStatus='posting' 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.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 +204,14 @@ }, + + close(){ + this.activeHubStubComponent = {} + this.activeHubStubData = {} + this.showHubStubCreateModal=false + this.postStatus=='unposed' + + } @@ -262,7 +284,7 @@

Create Quick Hub

@@ -277,7 +299,7 @@
- +
[No Hub Creator] {{hubCreator.label }} @@ -298,15 +320,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 e7475840..a25f8ea4 100644 --- a/src/lib/utils_export.js +++ b/src/lib/utils_export.js @@ -1406,7 +1406,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 } @@ -1894,12 +1894,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) @@ -1924,74 +1924,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_network.js b/src/lib/utils_network.js index 2414f1da..2f1ab89c 100644 --- a/src/lib/utils_network.js +++ b/src/lib/utils_network.js @@ -2620,12 +2620,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/lib/utils_parse.js b/src/lib/utils_parse.js index 5ba85ec3..b29bcda8 100644 --- a/src/lib/utils_parse.js +++ b/src/lib/utils_parse.js @@ -338,7 +338,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: { @@ -384,9 +403,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')){ @@ -395,7 +417,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 } @@ -413,12 +437,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") } @@ -531,6 +552,11 @@ const utilsParse = { xml = this.sniffNoteType(xml) } + if (isHub){ + xml = this.sniffTitleType(xml) + + } + let sucessfulProperties = [] @@ -1933,6 +1959,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 1309141c..d9385bac 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: 29, + versionMinor: 17, + versionPatch: 1, regionUrls: { @@ -25,8 +25,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', @@ -50,8 +50,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/', diff --git a/src/stores/profile.js b/src/stores/profile.js index 1cee4bcf..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' @@ -4476,14 +4494,16 @@ 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{ + + + + }catch (error){ + console.log(error) 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) + } }