CSU Library Website Customization

Documentation of CSU Primo and LibGuides customization

Javascript Fix for DSpace Identifier Display

Problem Description

VE combines dc.identifier dc.identifier.url dc.identifier.schema into one string and then attaches an oai to the end. This oai is generated by DSpace import profile and can't be deleted. This OAI is misleading because our DSpace system does not have this OAI. 

For example for this DSpace record,VE  default display is like the following

Default VE identifiers display for DSpace item

Initially we thought we can delete this OAI from Alma since it has MMS ID. We found out that there isn't a corresponding Alma record. If you search for this MMS ID in Alma, you won't find it. Then we thought we might be able to modify the DSpace import profile in VE, so the OAI is not generated. No we can't do that neither. The following is the answer from Exlibris' support

I'm afraid that there is no way currently to disable this or remove this value with Normalization Rules. This will therefore be considered an enhancement. The actual file harvested cannot be modified on the Primo side, only on the DSpace side. However, you cannot remove the identifier field from the header since Primo requires it to identify the record.

Goal

We want display the handle only. 

Fixed identifier display

Solution

Use Javascript to find the identifier line and strip other identifiers. 

Step 1: Identify tags to modify

1. Load a page, inspect its source code (I use Chrome)

2. Click console tab and type angular.reloadWithDebugInfo()

3. While the inspect code window is open, go back to the VE window and click the MMID, the last item under details section. This will also highlight the MMS ID element in the code inspection window. Go back to the code inspection window, scroll down to find 

<prm-service-details-after parent-ctrl="$ctrl"></prm-service-details-after>. This is the name you will use for the JS code. 

Inspect code

4. While the <prm-service-details-after parent-ctrl="$ctrl"></prm-service-details-after> is highlighted, go to console tab and type in 

angular.element($0).scope().$ctrl

You will see what's under Details section. 

Inspecting elements

Expand the _details arrow and the element with {label:identifier,  you will eventually find the identifier line, which is an array. 

Identifiers arrary

To test access this identifier line, you can type the following line (make sure change position number for different record. For example, this record's identifier is at _details[9] , values[0] and then values[0]. 

angular.element($0).scope().$ctrl._details[9].values[0].values[0]

check _details array values

Step 2: Check your DSpace's set up to for identifiers

We use handle.net for dc.identifier.url. You might use different identifiers. If you just want delete oai:your_DSpace_domain:10217/42160  You can  use split() function to separate identifers and create an new array. Then use pop() to remove the last element in that new array. Last put the array without OAI back to the _details[9].values[0].values[0]  

Step 3: Modify custom.js 

app.controller('prmServiceDetailsAfterController', ['angularLoad', function(angularLoad) { 
var i = 0;
var j = 0;
var vm = this;  
  vm.$doCheck = function(){
  var detailArray = vm.parentCtrl._details;
var len = detailArray.length;
for (i = 0; i < len; i = i + 1){
  var label1 = "identifier";
var label2 = detailArray[i].label;
       var cm = label1.localeCompare(label2);
  if( cm == 0){
var identifiersArray = detailArray[i].values[0].values;
var iLen = identifiersArray.length;
if ( iLen == 1 ){
var newIdentifiers = detailArray[i].values[0].values[0].split(';');
  var k = newIdentifiers.length; 
  for (j = 0; j < k; j = j + 1){
var testHttp = newIdentifiers[j].startsWith('http://hdl.handle.net/');
  var testHttps = newIdentifiers[j].startsWith('https://hdl.handle.net/');
if (testHttps){
detailArray[i].values[0].values[0]=newIdentifiers[j]; 
}
  else if(testHttp){
detailArray[i].values[0].values[0]=newIdentifiers[j]; 
}}}}}}
}]);
 app.component('prmServiceDetailsAfter', { 
    bindings: { 
      parentCtrl: '<' 
    }, 
    controller: 'prmServiceDetailsAfterController' 
  });

 

Note: The fix only hide other identifiers' display but the source record still contains those information

Source Record

 

URL: https://libguides.colostate.edu/web_customization | Print Page