diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml
index 6b010ce..ee07068 100644
--- a/.forgejo/workflows/deploy.yml
+++ b/.forgejo/workflows/deploy.yml
@@ -21,13 +21,11 @@ jobs:
submodules: true
- name: Build
- run: make install build
+ run: make all
- - name: Package
+ - name: Test built files
run: |
- # we need to have the editor served from a `ui/` path
- mkdir deploy
- mv dist deploy/ui
+ find dist
- name: Deploy
- run: cp -r deploy /www/kiste.abcd-j.de-new && (test -d && mv /www/kiste.abcd-j.de /www/kiste.abcd-j.de-old || true); mv /www/kiste.abcd-j.de-new /www/kiste.abcd-j.de; rm -rf /www/kiste.abcd-j.de-old
+ run: cp -r dist /www/kiste.abcd-j.de-new && (test -d && mv /www/kiste.abcd-j.de /www/kiste.abcd-j.de-old || true); mv /www/kiste.abcd-j.de-new /www/kiste.abcd-j.de; rm -rf /www/kiste.abcd-j.de-old
diff --git a/Makefile b/Makefile
index 5fc8f47..fd8d21b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,30 +1,57 @@
# Important directories
VUE_APP_DIR = shacl-vue
DIST_DIR = dist
+DIST_DIR_UI = dist/ui
+DIST_DIR_STARTER = dist/kickstarter
+PLUGIN_DIR = plugins
+RUNTIME_PLUGIN_DIR = $(VUE_APP_DIR)/src/runtime-plugins
-all: build
+all: install build-ui build-starter
# Install vite and shacl-vue dependencies
install:
npm install vite
cd $(VUE_APP_DIR) && npm install
+# Copy runtime plugins before build
# Build shacl-vue using top-level Vite-config
# Copy shacl-vue config to dist directory
-build: clean
+build-ui: clean-ui
+ cp -r $(PLUGIN_DIR) $(RUNTIME_PLUGIN_DIR)
cd $(VUE_APP_DIR) && npm run build:app
- mv $(VUE_APP_DIR)/dist/app ./$(DIST_DIR)
+ mkdir -p ./$(DIST_DIR_UI)
+ mv $(VUE_APP_DIR)/dist/app/* ./$(DIST_DIR_UI)
cp config.* $(DIST_DIR)/
cp favicon.ico $(DIST_DIR)/favicon.ico
cp *logo* $(DIST_DIR)/
cp -r templates $(DIST_DIR)/
cp *.html $(DIST_DIR)/
+build-starter: clean-starter
+ cp -r $(PLUGIN_DIR) $(RUNTIME_PLUGIN_DIR)
+ cd $(VUE_APP_DIR) && VITE_SHACLVUE_VARIANT=starter npm run build:app
+ mkdir -p ./$(DIST_DIR_STARTER)
+ mv $(VUE_APP_DIR)/dist/app/* ./$(DIST_DIR_STARTER)
+ cp config.* $(DIST_DIR_STARTER)/
+ cp favicon.ico $(DIST_DIR_STARTER)/favicon.ico
+ cp *logo* $(DIST_DIR_STARTER)/
+ cp -r templates $(DIST_DIR_STARTER)/
+
+
# Clean output
clean:
rm -rf $(DIST_DIR)
-deploy: dist install build
- rsync -rvz --delete $ www7.itsdmz.inm7.de:/home/kiste/site_root/ui/
+clean-ui:
+ rm -rf $(DIST_DIR_UI)
-.PHONY: install build clean deploy
+clean-starter:
+ rm -rf $(DIST_DIR_STARTER)
+
+test-ui: install build-ui
+ npx serve $(DIST_DIR_UI) -l 3000
+
+test-starter: install build-starter
+ npx serve $(DIST_DIR_STARTER) -l 3000
+
+.PHONY: install build-ui build-starter clean-ui clean-starter deploy test-ui
diff --git a/config.yaml b/config.yaml
index 4b4098f..dd664db 100644
--- a/config.yaml
+++ b/config.yaml
@@ -13,6 +13,8 @@ source_code_url: https://hub.psychoinformatics.de/www/kiste.abcd-j.de-ui
content:
FrontPageHTML:
url: frontpage.html
+ DOIImportWizardTemplate:
+ url: templates/DOIImportWizardTemplate.nunjucks.ttl
DOIWizardTemplate:
url: templates/DOIWizardTemplate.ttl
DOIlogo:
@@ -96,6 +98,28 @@ component_config:
template: '{return}'
icon: mdi-home
tooltip: Homepage
+ Documentation:
+ slot: dlthings:attributes
+ match:
+ - key: rdf:type
+ val: dlthings:AttributeSpecification
+ - key: rdf:predicate
+ val: obo:NGBO_6000416
+ return: rdf:value
+ template: '{return}'
+ icon: mdi-text-box
+ tooltip: Documentation
+ SourceCodeRepo:
+ slot: dlthings:attributes
+ match:
+ - key: rdf:type
+ val: dlthings:AttributeSpecification
+ - key: rdf:predicate
+ val: obo:APOLLO_SV_00000488
+ return: rdf:value
+ template: '{return}'
+ icon: mdi-code-block-tags
+ tooltip: Source code
filter_records_by:
- dlthings:short_name
show_classes:
@@ -129,6 +153,40 @@ wizard_editors:
# pattern:
# default:
template: content:DOIWizardTemplate
+ DOIImportWizard:
+ name: DOI Import Wizard
+ tooltip: Import a publication via DOI
+ icon: mdi-import
+ description: >-
+ Enter the 'DOI' field and hit *Import* in order to import metadata.
+ This will prepopulate editable fields such as *Title* and *Authors*.
+ An attempt is made to match individual imported *Author*s with known
+ *Person* records via ORCID identifiers. These matches can be accepted
+ as is without editing. The dropdown next to each imported and unmatched
+ author can be used to manually identify the correct associated Person
+ record. Also, additional authors can be added to the list. If no Person
+ record is selected for any given author in the list, a new Person record
+ will be created with a random and unique identifier, associated with the
+ entered given and family name.
+ component: doi:DOIFetcher
+ inputs:
+ - prop: title
+ type: text
+ - prop: abstract
+ type: text-paragraph
+ - prop: authors
+ type: object
+ multi_valued: true
+ inputs:
+ - prop: pid
+ type: text
+ - prop: given_name
+ type: text
+ - prop: family_name
+ type: text
+ - prop: role
+ type: select
+ template: content:DOIImportWizardTemplate
FileUploadWizard:
name: File Upload Wizard
tooltip: Upload a file
@@ -142,6 +200,8 @@ wizard_editors:
template: content:FileUploadTemplate
wizard_editor_selection:
xyzri:XYZPublication:
+ _class:
+ - DOIImportWizard
_record:
- DOIWizard
_slots:
@@ -163,9 +223,15 @@ service_base_url:
type: read
service_fetch_before:
get-records:
+ - xyzri:XYZActivity
- xyzri:XYZAgentRole
+ - xyzri:XYZBibliographicType
+ - xyzri:XYZCompetitionType
- xyzri:XYZDepictionType
+ - xyzri:XYZInstrumentType
- xyzri:XYZPerson
+ - xyzri:XYZTopic
+
token_info: Please contact Adina Wagner at a.wagner@fz-juelich.de for credentials.
token_info_url: ''
use_service: true
diff --git a/plugins/doi/DOIFetcher.vue b/plugins/doi/DOIFetcher.vue
new file mode 100644
index 0000000..351b792
--- /dev/null
+++ b/plugins/doi/DOIFetcher.vue
@@ -0,0 +1,261 @@
+
+
+
+
+
+
+
+ mdi-alert {{ errorTitle }}: {{ errorMessage }}
+ Ok
+
+
+
+
+ Import
+
+
+
+
+ Imported metadata
+
+ Title
+
+
+ Abstract
+
+
+ Authors
+
+
+
+ Given Name
+ Family Name
+ Role
+ Linked Record
+ Type
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ mdi-check-all
+
+
+
+
+
+
+ mdi-account-check
+
+
+
+
+
+
+ mdi-account
+
+
+
+
+
+
+
+
+
+
+ Add author
+
+
+
+
+
+
+
+
diff --git a/plugins/doi/index.js b/plugins/doi/index.js
new file mode 100644
index 0000000..e5b797d
--- /dev/null
+++ b/plugins/doi/index.js
@@ -0,0 +1,201 @@
+import { DLTHINGS, RDF, SKOS } from '@/modules/namespaces';
+import { namespace } from 'shacl-tulip';
+import { DataFactory } from 'n3';
+
+const { namedNode, blankNode, literal, quad } = DataFactory;
+const DCTERMS = namespace('http://purl.org/dc/terms/');
+const OBO = namespace('http://purl.obolibrary.org/obo/');
+const MARCREL = namespace('http://id.loc.gov/vocabulary/relators/');
+const DOI_BASE = "https://doi.org/"
+const XYZRI = namespace('https://concepts.datalad.org/s/demo-research-information/unreleased/');
+
+export async function importMetadata(args) {
+ const doi = args.doi;
+ const rdfDS = args.rdfDS;
+ try {
+ let result = await fetchCSL(doi);
+ const enrichedRecord = processRecord(result, rdfDS);
+ return enrichedRecord
+ } catch (error) {
+ throw(error)
+ }
+}
+
+async function fetchCSL(doi) {
+ const endpoint = `${DOI_BASE}${doi}`
+ const response = await fetch(endpoint, {
+ headers: {
+ Accept: "application/vnd.citationstyles.csl+json"
+ }
+ })
+ if (!response.ok) {
+ throw new Error(`DOI lookup failed ${response.status}`)
+ }
+ return await response.json()
+}
+
+async function fetchCitation(doi) {
+ const endpoint = `${DOI_BASE}${doi}`
+ const response = await fetch(endpoint, {
+ headers: {
+ Accept: "text/x-bibliography; style=apa"
+ }
+ })
+ if (!response.ok) {
+ return null
+ }
+ return await response.text()
+}
+
+function getAuthors(citeprocMetadata) {
+ return citeprocMetadata.author ?? []
+}
+
+function getContributions(citeprocMetadata, rdfDS) {
+ const authors = getAuthors(citeprocMetadata)
+ const persons = [];
+ const contributions = [];
+ for (const auth of authors) {
+ // if record has ORCID, try to find known Person with that identifier
+ // if person found via ORCID, this is the pid to add to the object slot of attribution
+ // if person not found: create new person record
+ let attr = {
+ roles: [getAuthorRole(auth)],
+ }
+ let person_pid
+ let person_found_via
+ if (auth['ORCID']) {
+ person_pid = findRecordWithIdentifier(auth['ORCID'].replace('https://orcid.org/', ''), rdfDS)
+ person_found_via = 'orcid'
+ }
+ attr['object'] = person_pid;
+ contributions.push(attr)
+ persons.push({
+ pid: person_pid,
+ given_name: auth['given'] ? auth['given'] : '',
+ family_name: auth['family'] ? auth['family'] : '',
+ role: getAuthorRole(auth),
+ found_via: person_found_via,
+ })
+ }
+
+ return {
+ persons: persons,
+ contributions: contributions,
+ }
+}
+
+function findRecordWithIdentifier(notation, rdfDS) {
+
+ let identifiers = rdfDS.data.graph.getQuads(
+ null,
+ namedNode(SKOS.notation.value),
+ literal(notation),
+ null
+ ).map(q => q.subject);
+ const records = identifiers.flatMap(id =>
+ rdfDS.data.graph.getQuads(
+ null,
+ namedNode(DCTERMS.identifier.value),
+ id,
+ null
+ ).map(q => q.subject)
+ )
+ if (records.length) {
+ return records[0].value
+ }
+ return undefined
+}
+
+export function findPublicationWithDOI(doi, rdfDS) {
+ // First try and find publication records with linked identifiers
+ // Then try to find publications with DOI as PID
+ let publication = findRecordWithIdentifier(doi, rdfDS)
+ if (publication) {
+ return publication
+ } else {
+ let pubPIDs = rdfDS.data.graph.getQuads(
+ namedNode(`${DOI_BASE}${doi}`),
+ namedNode(RDF.type.value),
+ namedNode(XYZRI.XYZPublication.value),
+ null
+ ).map(q => q.subject);
+ if (pubPIDs.length) {
+ return pubPIDs[0].value;
+ }
+ }
+ return undefined
+}
+
+function findPersonWithNames(givenName, familyName, rdfDS) {
+ // persons with matching family name
+ const familyMatches = rdfDS.data.graph.getQuads(
+ null,
+ namedNode(DLTHINGS.family_name.value),
+ literal(familyName),
+ null
+ ).map(q => q.subject.value)
+ // persons with matching given name
+ const givenMatches = rdfDS.data.graph.getQuads(
+ null,
+ namedNode(DLTHINGS.given_name.value),
+ literal(givenName),
+ null
+ ).map(q => q.subject.value)
+ // intersection
+ const persons = familyMatches.filter(p => givenMatches.includes(p))
+ if (persons.length) {
+ return persons[0]
+ }
+ return undefined
+}
+
+function getAuthorRole(author) {
+ let seq = author['sequence']
+ if (seq) {
+ if (seq == 'first') {
+ return OBO.MS_1002034.value;
+ } else if (seq == 'additional') {
+ return OBO.MS_1002036.value;
+ } else {
+ return MARCREL.aut.value;
+ }
+ }
+ return MARCREL.aut.value;
+}
+
+function htmlDecode(input) {
+ var doc = new DOMParser().parseFromString(input, "text/html");
+ return doc.documentElement.textContent;
+}
+
+function getTitle(citeprocMetadata) {
+ return citeprocMetadata.title ? htmlDecode(citeprocMetadata.title) : ''
+}
+
+function getAbstract(citeprocMetadata) {
+ return citeprocMetadata.abstract ? htmlDecode(citeprocMetadata.abstract) : ''
+}
+
+function processRecord(citeprocMetadata, rdfDS) {
+ // authors => attributed_to and persons
+ // publishing activity (date / ISSN) => generated_by
+ // licenses => rules
+ const {persons, contributions} = getContributions(citeprocMetadata, rdfDS)
+ const title = getTitle(citeprocMetadata, rdfDS)
+ const abstract = getAbstract(citeprocMetadata, rdfDS)
+ const pub = {
+ attributed_to: contributions,
+ generated_by: [],
+ about: [],
+ description: "",
+ identifiers: [],
+ pid:'',
+ title:title,
+ }
+ return {
+ authors: persons,
+ title: title,
+ abstract: abstract,
+ }
+}
\ No newline at end of file
diff --git a/shacl-vue b/shacl-vue
index 7ba3ebd..f3b7c59 160000
--- a/shacl-vue
+++ b/shacl-vue
@@ -1 +1 @@
-Subproject commit 7ba3ebd0ed8d83538e920bb29761dff93c89e10e
+Subproject commit f3b7c5957ba32bf5aae6ce95a3db017859b95f52
diff --git a/templates/DOIImportWizardTemplate.nunjucks.ttl b/templates/DOIImportWizardTemplate.nunjucks.ttl
new file mode 100644
index 0000000..786e718
--- /dev/null
+++ b/templates/DOIImportWizardTemplate.nunjucks.ttl
@@ -0,0 +1,49 @@
+@prefix xyzrins: .
+@prefix rdf: .
+@prefix xyzri: .
+@prefix dlthings: .
+@prefix obo: .
+@prefix xsd: .
+@prefix sio: .
+@prefix dcterms: .
+@prefix skos: .
+@prefix orcid: .
+
+{% set pubId = _randomUUID() -%}
+{% set pubURI = "https://concepts.datalad.org/s/demo-research-information/ns/publications/" + pubId -%}
+<{{ pubURI }}> a xyzri:XYZPublication .
+{% if title -%}
+<{{ pubURI }}> dlthings:title {{ title | ttl }} .
+{%- endif %}
+{% if abstract -%}
+<{{ pubURI }}> dcterms:description {{ abstract | ttl }} .
+{%- endif %}
+
+{% if doi %}
+<{{ pubURI }}> dcterms:identifier _:doiNode .
+_:doiNode a dlthings:DOI ;
+ skos:notation {{ doi | ttl }} .
+{% endif %}
+
+{% for author in authors -%}
+{% if author.pid %}
+{% set personURI = author.pid -%}
+{% else -%}
+{% set personId = _randomUUID() -%}
+{% set personURI = "https://concepts.datalad.org/s/demo-research-information/ns/persons/" + personId -%}
+<{{ personURI }}> a xyzri:XYZPerson .
+{% if author.given_name -%}
+<{{ personURI }}> dlthings:given_name {{ author.given_name | ttl }} .
+{%- endif %}
+
+{% if author.family_name -%}
+<{{ personURI }}> dlthings:family_name {{ author.family_name | ttl }} .
+{%- endif %}
+{% endif %}
+
+<{{ pubURI }}> dlthings:attributed_to _:attr{{ loop.index }} .
+_:attr{{ loop.index }} a dlthings:Attribution ;
+ rdf:object <{{ personURI }}> ;
+ dlthings:roles <{{ author.role }}> .
+
+{% endfor -%}
\ No newline at end of file
diff --git a/templates/add-record.nunjucks.ttl b/templates/add-record.nunjucks.ttl
new file mode 100644
index 0000000..a2a7ff3
--- /dev/null
+++ b/templates/add-record.nunjucks.ttl
@@ -0,0 +1,49 @@
+@prefix dcterms: .
+@prefix dlthings: .
+@prefix rdf: .
+@prefix skos: .
+@prefix xyzri: .
+@prefix xyzrins: .
+@prefix xsd: .
+
+{% set recordId = _randomUUID() -%}
+{% set recordPrefixes = {
+ 'https://concepts.datalad.org/s/things/v2/AnnotationTag': 'annotation-tags/',
+ 'https://concepts.datalad.org/s/things/v2/Property': 'properties/',
+ 'https://concepts.datalad.org/s/things/v2/Rule': 'rules/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZAccolade': 'accolades/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZActivity': 'activities/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZActivityRole': 'activity-roles/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZAgentRole': 'agent-roles/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZBibliographicType': 'bibliographic-types/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZCompetition': 'competitions/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZCompetitionType': 'competition-types/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZConcept': 'concepts/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZConvention': 'conventions/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDataItem': 'dataitems/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDataType': 'datatypes/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDataset': 'datasets/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDepiction': 'depictions/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDepictionType': 'depiction-types/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZDocument': 'documents/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZEntityRole': 'entity-roles/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZFile': 'files/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZGrant': 'grants/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZInstrument': 'instruments/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZInstrumentType': 'instrument-types/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZObjective': 'objectives/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZOrganization': 'organizations/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZPerson': 'persons/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZProject': 'projects/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZPublication': 'publications/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZPublicationVenue': 'publication-venues/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZQuality': 'qualities/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZStudy': 'studies/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZSubject': 'subjects/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZSubjectType': 'subject-types/',
+ 'https://concepts.datalad.org/s/demo-research-information/unreleased/XYZTopic': 'topics/'} -%}
+{% set recordPre = recordPrefixes[class_uri] -%}
+{% set recordURI = 'https://concepts.datalad.org/s/demo-research-information/unreleased/' + recordPre + recordId -%}
+<{{ recordURI }}> a <{{ class_uri }}>;
+ dcterms:description {{ description | ttl}};
+ skos:prefLabel {{ name | ttl }}.