Skip to content

Commit

Permalink
render adminmetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
thisismattmiller committed Jul 8, 2024
1 parent 6bf0ca4 commit 0bd5f73
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 9 deletions.
59 changes: 52 additions & 7 deletions src/lib/utils_parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const utilsParse = {
// select the right part of the profile
let pt = profile.rt[pkey].pt
let xml = this.activeDom.getElementsByTagName(tle)

console.log("profile.rt[pkey]",profile.rt[pkey])
// store this here for easy access to the error report
profile.xmlSource = this.xmlSource

Expand Down Expand Up @@ -314,13 +314,58 @@ const utilsParse = {
}
}

// is there admin metdata in the data? If so we need to insert that profile template into the pt

let adminMetadataCount = xml.getElementsByTagName('bf:adminMetadata').length

if (adminMetadataCount>0){

let parent
let parentId
// find a sibling and grab their parent id so we can use it for this new property
for (let k of Object.keys(pt)){
if (pt[k].parent){
parent = pt[k].parent
parentId = pt[k].parentId
break
}
}


// adminMetadataCount
pt['id_loc_gov_ontologies_bibframe_adminmetadata'] = {
"mandatory": false,
"parent": parent,
"parentId": parentId,
"id": 'id_loc_gov_ontologies_bibframe_adminmetadata',
"propertyLabel": "Admin Metadata",
"propertyURI": "http://id.loc.gov/ontologies/bibframe/adminMetadata",
"repeatable": true,
"resourceTemplates": [],
'@guid': short.generate(),
"type": "resource",
"userValue": {"@root":"http://id.loc.gov/ontologies/bibframe/adminMetadata"},
"valueConstraint": {
"defaults": [],
"useValuesFrom": [],
"valueDataType": {},
"valueTemplateRefs": ['lc:RT:bf2:AdminMetadata:BFDB']
}
}

profile.rt[pkey].ptOrder.push('id_loc_gov_ontologies_bibframe_adminmetadata')

}


let sucessfulProperties = []
let sucessfulElements = []

// at this point we have the main piece of the xml tree that has all our data
// loop through properties we are looking for and build out the the profile
for (let k in pt){



let ptk = JSON.parse(JSON.stringify(pt[k]))
// make sure each new one has a unique guid
ptk['@guid'] = short.generate()
Expand Down Expand Up @@ -411,7 +456,6 @@ const utilsParse = {
// does it have a rdf type of that
for (let typeEl of e.getElementsByTagName('rdf:type')){
if (typeEl.attributes['rdf:resource']){
console.log(typeEl.attributes['rdf:resource'])
}
if (typeEl.attributes['rdf:resource'] && typeEl.attributes['rdf:resource'].value == 'http://id.loc.gov/ontologies/bflc/PrimaryContribution'){
isPrimaryContribXML = true
Expand Down Expand Up @@ -481,7 +525,7 @@ const utilsParse = {
let eProperty = this.UriNamespace(e.tagName)

// could be a first level bnode with no children
console.log(e.tagName,this.isClass(e.tagName))

if (this.isClass(e.tagName)){

userValue['@type'] = this.UriNamespace(e.tagName)
Expand Down Expand Up @@ -1151,8 +1195,8 @@ const utilsParse = {
// need to make a new one and add it to the resource template list
// since each piece of data in the property is its own resource template

if (counter === 0){
pt[k] = populateData
if (counter === 0){
pt[k] = populateData
}else{

let newKey = `${k}_${counter}`
Expand All @@ -1161,7 +1205,6 @@ const utilsParse = {
populateData.id = newKey
pt[newKey] = populateData


}

counter++
Expand Down Expand Up @@ -1191,6 +1234,8 @@ const utilsParse = {
}

// store the unused xml


profile.rt[pkey].unusedXml = xml.outerHTML;
if (xml.children.length == 0){
profile.rt[pkey].unusedXml = false
Expand Down
3 changes: 1 addition & 2 deletions src/lib/utils_profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ const utilsProfile = {
// we may or maynot need to create a @type for this level, depending on what type of property it is,
// so test first the property info in the profile
let type = utilsRDF.suggestTypeProfile(p,pt)
console.log("suggestTypeProfile is type",type)
if (type === false){
// did not find it in the profile, look to the network
type = await utilsRDF.suggestTypeNetwork(p)
Expand Down Expand Up @@ -474,7 +473,7 @@ const utilsProfile = {
useProfile.user = meta.user
useProfile.status = meta.status


console.log('useProfileuseProfileuseProfileuseProfile',useProfile)

let transformResults = await utilsParse.transformRts(useProfile)

Expand Down

0 comments on commit 0bd5f73

Please sign in to comment.