Skip to content

Commit de011d2

Browse files
committed
add missing json examples, move older ones to ./demo, fix typos
1 parent 214cdea commit de011d2

13 files changed

Lines changed: 196 additions & 47 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Display can also be graphical, as in displaying [Local Contexts](https://localco
3434

3535
This repository contains scripts and example materials that demonstrate how to configure Dataverse to leverage them. They are a mixture of initial proofs-of-concept, demonstrations of alternative approaches, and some that are potentially mature enough for production use (although the latter often require later versions of Dataverse which have extensions/bug fixes for the underlying mechanism. Documentation in the /examples subdirectory provides additional details for specific scripts and configuration for specific fields.
3636

37-
It also contains a [JSON Schema that can be used to validate configuration files](https://github.com/gdcc/dataverse-external-vocab-support/blob/main/examples/config/CVocConf.schema.json).
37+
It also contains a [JSON Schema that can be used to validate configuration files](https://github.com/gdcc/dataverse-external-vocab-support/blob/main/examples/config/demo/CVocConf.schema.json).
3838

3939
## Scripts in Production
4040

examples/affiliation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ The affiliation example illustrates a lookup in ROR.org for the author affiliati
22

33
Two files comprise this example:
44

5-
- examples/config/affiliation.json : the configuration file that needs to be uploaded in the :CVocConf setting
5+
- examples/config/demo/affiliation.json : the configuration file that needs to be uploaded in the :CVocConf setting
66

77
- scripts/affiliation.js : the Javascript file that modifies standard Dataverse behaviour
88

examples/authors.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
The authors example uses the external vocabularies mechanism to implement a simple lookup and copy-and-paste functionality for the authors fields (name, affiliation, indentification scheme and number). It is different from the other examples as it does not store URLs to the external vocabulary, but instead copies the data directly into the dataverse metadata fields. The link with the vocabulary URI is therefore not persisted.
1+
The authors example uses the external vocabularies mechanism to implement a simple lookup and copy-and-paste functionality for the authors fields (name, affiliation, identification scheme and number). It is different from the other examples as it does not store URLs to the external vocabulary, but instead copies the data directly into the dataverse metadata fields. The link with the vocabulary URI is therefore not persisted.
22

33
There are several reasons why we implemented it like this:
44

5-
- we did not want to expose the personel data unprotected to the public internet. By copying the data instead of the URL, we can open the vocabulary only to the IP ranges that need access to dataset metadata editing, which for our institution is esentially on-premis or via VPN. The vocabulary server is no longer needed when the dataset metadata is published and accessed publicly.
5+
- we did not want to expose the personal data unprotected to the public internet. By copying the data instead of the URL, we can open the vocabulary only to the IP ranges that need access to dataset metadata editing, which for our institution is essentially on-premis or via VPN. The vocabulary server is no longer needed when the dataset metadata is published and accessed publicly.
66

7-
- the data in the vocabulary will rarely change, it will only be expanded. The risk of author information getting outdated is very low. And even if so, it is likely that it would be better to leave the old metadata alone.
7+
- the data in the vocabulary will rarely change, it will only be expanded. The risk of author information getting out-dated is very low. And even if so, it is likely that it would be better to leave the old metadata alone.
88

9-
- we implemented it as a prototype for other metadata fields where the vocabulary data will most certainly change and we do not want these changes to percollate into the metadata of existing datasets. One such field is our faculty or department field. Departments splitting and merging do occur fairly regularly and we want the metadata to reflect the organisational entity as it was when the dataset was created. While this can be achieved in external vocabularies with deprecated entries, the extra complexity of maintaining the external vocabulary for a fairly simple list is not worth it. We will just change the list as we go and leave the existing data alone.
9+
- we implemented it as a prototype for other metadata fields where the vocabulary data will most certainly change and we do not want these changes to percolate into the metadata of existing datasets. One such field is our faculty or department field. Departments splitting and merging do occur fairly regularly and we want the metadata to reflect the organiational entity as it was when the dataset was created. While this can be achieved in external vocabularies with deprecated entries, the extra complexity of maintaining the external vocabulary for a fairly simple list is not worth it. We will just change the list as we go and leave the existing data alone.
1010

1111
To illustrate the example for our authors lookup there are 2 files provided:
1212

13-
- examples/config/authors.json : the configuration file that needs to be uploaded in the :CVocConf setting
13+
- examples/config/demo/authors.json : the configuration file that needs to be uploaded in the :CVocConf setting
1414

1515
- scripts/authors.js : the Javascript file that modifies standard Dataverse behaviour
1616

1717
The standard authors compound fields are used, so there is no need to modify the default citation metadata block.
1818

19-
Note that this is a trimmed-down version of de code that we use in production. Our production version can be found in our [github repository](https://github.com/libis/rdm-covoc_server). There you will also find the implementation of a small REST server that performs the search in the background.
19+
Note that this is a trimmed-down version of the code that we use in production. Our production version can be found in our [github repository](https://github.com/libis/rdm-covoc_server). There you will also find the implementation of a small REST server that performs the search in the background.
2020

21-
The JSON configuration file has most fields empty, but as they are all required, they need to be present in the configuration file. The `field-name` and `term-uri-field` have both been set to `authorName`. Only the field `field-name` should be set for this to work, but as I found out the hard way, the external vocabulary code insits that the `term-uri-field` also points to a valid metadata field. Theoretically, this means that the external vocabulary code that looks up values externally could be triggered if an URI is filled in in the `authorName` field, but it is fairly safe to asume that that will not be the case during normal use.
21+
The JSON configuration file has most fields empty, but as they are all required, they need to be present in the configuration file. The `field-name` and `term-uri-field` have both been set to `authorName`. Only the field `field-name` should be set for this to work, but as I found out the hard way, the external vocabulary code insists that the `term-uri-field` also points to a valid metadata field. Theoretically, this means that the external vocabulary code that looks up values externally could be triggered if an URI is filled in in the `authorName` field, but it is fairly safe to assume that that will not be the case during normal use.
2222

23-
The `js-url` field in the configuration file points to the location where the JavaScript file is located. Since we already use an Apache frontend server to enable the Shibboleth logins, we decided to reverse-proxy the JavaScript file there as well. The other fields are emtpy and have no influence on our code.
23+
The `js-url` field in the configuration file points to the location where the JavaScript file is located. Since we already use an Apache frontend server to enable the Shibboleth logins, we decided to reverse-proxy the JavaScript file there as well. The other fields are empty and have no influence on our code.
2424

2525
The JavaScript file contains three parts:
2626

2727
- first of all code that is triggered each time the page is loaded and each time an author compound field set is added or deleted. That piece of code is responsible for creating the HTML code for a modal dialog box with search box and table with results. It also puts a search button next to each authorName input field that will display the dialog box.
2828

29-
- the `authorsQuery` function performs a call to a server that will search the given string in the database and return the data for the matches found. The code asumes this to be a simeple REST server that returns JSON data. The server itself in our case uses a Solr index to query and retrieve the data. Again, for security reasons we did not want to expose the Solr server directly beyond the server itself, so a simple REST server in front of it sanitizes the queries and protects the Solr index from being abused.
29+
- the `authorsQuery` function performs a call to a server that will search the given string in the database and return the data for the matches found. The code assumes this to be a simple REST server that returns JSON data. The server itself in our case uses a Solr index to query and retrieve the data. Again, for security reasons we did not want to expose the Solr server directly beyond the server itself, so a simple REST server in front of it sanitizes the queries and protects the Solr index from being abused.
3030

31-
- the `importAuthorData` function is triggered when a user selects one of the search results and is responsible for copying the JSON data into the input fields on the dataset metadata form. Most of it is pretty straightforward code looking for the input fields in the form and setting the values, except for the part where the `identifierScheme` has to be filled in. The dropdown box consists of multiple elements that have to be changed in sync and it took a while to figure that out. This is also the weakest point in the code, as translations could modify any displayed text and thus could break the code that relies on the text `ORCID` to be present in the dropdown box. In this case that is something we have full contol of, but be warned when porting this code to other fields.
31+
- the `importAuthorData` function is triggered when a user selects one of the search results and is responsible for copying the JSON data into the input fields on the dataset metadata form. Most of it is pretty straightforward code looking for the input fields in the form and setting the values, except for the part where the `identifierScheme` has to be filled in. The dropdown box consists of multiple elements that have to be changed in sync and it took a while to figure that out. This is also the weakest point in the code, as translations could modify any displayed text and thus could break the code that relies on the text `ORCID` to be present in the dropdown box. In this case that is something we have full control of, but be warned when porting this code to other fields.
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
[
2-
{
3-
"field-name": "authorAffiliation",
4-
"term-uri-field": "authorAffiliation",
5-
"js-url": ["/cvoc/js/ror.js","/cvoc/js/cvocutils.js"],
6-
"protocol": "ror",
7-
"retrieval-uri": "https://api.ror.org/organizations/{0}",
8-
"allow-free-text": true,
9-
"prefix": "https://ror.org/",
10-
"managed-fields": {},
11-
"languages":"",
12-
"vocabs": {
13-
"rors": {
14-
"uriSpace": "https://ror.org/"
15-
}
16-
},
17-
"retrieval-filtering": {
18-
"@context": {
19-
"termName": "https://schema.org/name",
20-
"scheme": "http://www.w3.org/2004/02/skos/core#inScheme",
21-
"lang": "@language",
22-
"content": "@value"
23-
},
24-
"scheme": {
25-
"pattern": "http://www.grid.ac/ontology/"
26-
},
27-
"termName": {
28-
"pattern": "{0}",
29-
"params": ["/name"]
30-
},
31-
"@type": {
32-
"pattern": "https://schema.org/Organization"
33-
}
34-
}
35-
}
1+
[
2+
{
3+
"field-name": "authorAffiliation",
4+
"term-uri-field": "authorAffiliation",
5+
"js-url": ["/cvoc/js/ror.js","/cvoc/js/cvocutils.js"],
6+
"protocol": "ror",
7+
"retrieval-uri": "https://api.ror.org/organizations/{0}",
8+
"allow-free-text": true,
9+
"prefix": "https://ror.org/",
10+
"managed-fields": {},
11+
"languages":"",
12+
"vocabs": {
13+
"rors": {
14+
"uriSpace": "https://ror.org/"
15+
}
16+
},
17+
"retrieval-filtering": {
18+
"@context": {
19+
"termName": "https://schema.org/name",
20+
"scheme": "http://www.w3.org/2004/02/skos/core#inScheme",
21+
"lang": "@language",
22+
"content": "@value"
23+
},
24+
"scheme": {
25+
"pattern": "http://www.grid.ac/ontology/"
26+
},
27+
"termName": {
28+
"pattern": "{0}",
29+
"params": ["/name"]
30+
},
31+
"@type": {
32+
"pattern": "https://schema.org/Organization"
33+
}
34+
}
35+
}
3636
]
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)