update to latest shacl-vue #5

Merged
adina merged 3 commits from update-shacl into main 2026-06-03 09:40:41 +00:00
Member

@jsheunis do you know from the top of your head whether I need to do any more adjustments to update this deployment? I put it up as a PR, because I have no good overview whether config changes are necessary, and no environment to test-deploy locally

@jsheunis do you know from the top of your head whether I need to do any more adjustments to update this deployment? I put it up as a PR, because I have no good overview whether config changes are necessary, and no environment to test-deploy locally
Member

Seems like several changes can be made, if desired for the UI. What I did just now is to look at the previous submodule commit (7ba3ebd0ed8d83538e920bb29761dff93c89e10e) in the shacl-vue commit history, orinoco/shacl-vue@7ba3ebd0ed, saw it was on 4 March. Then looked around that same date for the submodule update in the Psyinf pool repo: www/pool.psychoinformatics.de-ui@5b6f05702c. Then look at the diff in that repo from that commit until now. Looks like a lot of changes.

Commit summary:

35cdaa2 (HEAD -> main, origin/main, origin/HEAD) Let public upload repo appear first in file upload wizard
9387d53 change kickstarter subdirectory to 'kickstarter'
8daa739 Update to shacl-vue that fetches a single record specified in URL query parameters
f7ca499 do recursive copy directly from dist directory; print dist directory files after build
f7063e3 do not also move interim 'app' directory
6d9cd3b Support for new shacl-vue starter feature
5cfe3d3 update to shacl-vue state supporting starter functionality
49d1ff2 chore: use latest shacl-vue
d27b5b2 special buttons for source code and documentation
f508023 Fetch more upfront
3c851ff add missing config for person depiction upload wizard
01e7613 add person depiction upload wizard and template
f189016 Update to shacl-vue nunjucks to handle multiline ttl rendering and more character escaping
09db7ff Updates and bug fixes to DOI plugin
8efe252 author role should be a named node
6de6a8f fix template name
9f2186c DOIImportWizard support
c1f0f48 bring in support for plugins and improved wizardeditor
80ea5d5 External config should point to latest in main
5b6f057 rdfs:label and rdfs:comment fixes

actual diff:

>> git diff 5b6f057..HEAD > patch.diff
diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml
index e4daa4a..c2bdc93 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/pool.psychoinformatics.de-new && (test -d && mv /www/pool.psychoinformatics.de /www/pool.psychoinformatics.de-old || true); mv /www/pool.psychoinformatics.de-new /www/pool.psychoinformatics.de; rm -rf /www/pool.psychoinformatics.de-old
+        run: cp -r dist /www/pool.psychoinformatics.de-new && (test -d && mv /www/pool.psychoinformatics.de /www/pool.psychoinformatics.de-old || true); mv /www/pool.psychoinformatics.de-new /www/pool.psychoinformatics.de; rm -rf /www/pool.psychoinformatics.de-old
diff --git a/Makefile b/Makefile
index c277817..c62e970 100644
--- a/Makefile
+++ b/Makefile
@@ -1,26 +1,48 @@
 # 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)
-	cp config.* $(DIST_DIR)/
-	cp favicon.ico $(DIST_DIR)/favicon.ico
-	cp *logo* $(DIST_DIR)/
-	cp -r templates $(DIST_DIR)/
+	mkdir -p ./$(DIST_DIR_UI)
+	mv $(VUE_APP_DIR)/dist/app/* ./$(DIST_DIR_UI)
+	cp config.* $(DIST_DIR_UI)/
+	cp favicon.ico $(DIST_DIR_UI)/favicon.ico
+	cp *logo* $(DIST_DIR_UI)/
+	cp -r templates $(DIST_DIR_UI)/
+
+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)
+	rm -rf dist
+
+clean-ui:
+	rm -rf $(DIST_DIR_UI)
+
+clean-starter:
+	rm -rf $(DIST_DIR_STARTER)
 
-.PHONY: install build clean deploy
+.PHONY: install build-ui build-starter clean-ui clean-starter deploy
diff --git a/config.yaml b/config.yaml
index 27c34d0..521846a 100644
--- a/config.yaml
+++ b/config.yaml
@@ -2,8 +2,9 @@
 # General app settings
 # --------------------
 app_name: PsyInf Knowledge Pooling Tool
+app_name_starter: PsyInf Knowledge Kickstarter
 documentation_url: ''
-external_config_url: https://hub.psychoinformatics.de/orinoco/assets/raw/branch/psyinf-config/shacl-vue/config_default_xyzri.yaml
+external_config_url: https://hub.psychoinformatics.de/orinoco/assets/raw/branch/main/shacl-vue/config_default_xyzri.yaml
 page_title: PsyInf Knowledge
 source_code_url: https://hub.psychoinformatics.de/www/pool.psychoinformatics.de-ui
 
@@ -11,8 +12,14 @@ source_code_url: https://hub.psychoinformatics.de/www/pool.psychoinformatics.de-
 # Content
 # -------
 content:
+  add-record:
+    url: templates/add-record.nunjucks.ttl
+  person-depiction-upload:
+    url: templates/person-depiction-upload.nunjucks.ttl
   DocumentUploadTemplate:
     url: templates/DocumentUploadTemplate.ttl
+  DOIImportWizardTemplate:
+    url: templates/DOIImportWizardTemplate.nunjucks.ttl
   DOIWizardTemplate:
     url: templates/DOIWizardTemplate.ttl
   DOIlogo:
@@ -96,6 +103,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:
@@ -116,6 +145,35 @@ priority_classes:
     title: All
     include_subclasses: true
 wizard_editors:
+  AddRecordWizard:
+    name: Quick-Add New Record
+    tooltip: Quick Add
+    icon: mdi-plus-box
+    description: Add the display name and description and then hit *Save*
+    inputs:
+      - prop: name
+        name: Display name
+        description: The display name of the new record
+        type: text
+        placeholder: 'My record title'
+        required: true
+      - prop: description
+        name: Description
+        description: The description of the new record
+        type: text-paragraph
+        placeholder: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod...'
+    template: content:add-record
+  DepictionUploadWizard:
+    name: Depiction Upload Wizard
+    tooltip: Upload a depiction
+    icon: mdi-account-box-outline
+    description: Upload an image of the person and hit *Save*
+    inputs:
+      - prop: file
+        name: File
+        type: upload
+        required: true
+    template: content:person-depiction-upload
   DOIWizard:
     name: DOI Wizard
     tooltip: Add a Digital Object Identifier
@@ -131,6 +189,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
@@ -143,7 +235,14 @@ wizard_editors:
         required: true
     template: content:file-upload-template
 wizard_editor_selection:
+  _classes:
+    - AddRecordWizard
+  xyzri:XYZPerson:
+    _record:
+      - DepictionUploadWizard
   xyzri:XYZPublication:
+    _class:
+      - DOIImportWizard
     _record:
       - DOIWizard
   _slots:
@@ -165,9 +264,14 @@ use_service: true
 use_token: true
 service_fetch_before:
   get-records:
+    - xyzri:XYZActivity
     - xyzri:XYZAgentRole
+    - xyzri:XYZBibliographicType
+    - xyzri:XYZCompetitionType
     - xyzri:XYZDepictionType
+    - xyzri:XYZInstrumentType
     - xyzri:XYZPerson
+    - xyzri:XYZTopic
 
 # ----------------
 # Special features
@@ -184,7 +288,7 @@ gitannex_p2phttp_config_wizard:
     - name: Psychoinformatics Hub
       base_url: https://hub.psychoinformatics.de/git-annex-p2phttp/git-annex
       repositories:
-        - name: Private uploads
-          annex_uuid: f1a8ef1c-6d8a-40e3-970f-4634390d961f
         - name: Public uploads
           annex_uuid: cedde37c-416a-41fd-87e0-4ac100df4bf7
+        - name: Private uploads
+          annex_uuid: f1a8ef1c-6d8a-40e3-970f-4634390d961f
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 @@
+<template>
+
+    <v-row align="stretch">
+        <v-col cols="10">
+            <v-text-field v-model="doiText" label="DOI" variant="outlined" density="compact"></v-text-field>
+            <v-card v-if="showError" flat style="margin-top: 0">
+                <v-card-text>
+                    <v-icon color="error">mdi-alert</v-icon> <em>{{ errorTitle }}:</em> {{ errorMessage }}
+                    <v-btn @click="clearError" density="compact">Ok</v-btn>
+                </v-card-text>
+            </v-card>
+        </v-col>
+        <v-col>
+            <v-btn @click="checkThenImportMetadata">Import</v-btn>
+        </v-col>
+    </v-row>
+
+    <v-card flat variant="text" v-if="modelVals['title'] && modelVals['authors']">
+        <h2>Imported metadata</h2>
+        <br>
+        <h3>Title</h3>
+        <v-text-field
+            variant="outlined"
+            v-model="modelVals['title']" 
+            density="compact">
+        </v-text-field>
+        <h3>Abstract</h3>
+        <v-textarea
+            variant="outlined"
+            v-model="modelVals['abstract']" 
+            density="compact">
+        </v-textarea>
+        <h3>Authors</h3>
+        <v-card-text>
+            <span v-if="modelVals['authors'].length">
+                <v-row>
+                    <v-col cols="2"><strong>Given Name</strong></v-col>
+                    <v-col cols="2"><strong>Family Name</strong></v-col>
+                    <v-col cols="3"><strong>Role</strong></v-col>
+                    <v-col cols="3" class="d-flex justify-center align-center"><strong>Linked Record</strong></v-col>
+                    <v-col cols="1" class="d-flex justify-center align-center"><strong>Type</strong></v-col>
+                    <v-col></v-col>
+                </v-row>
+                <v-divider opacity=".7" thickness="1" style="margin-top: 1em; margin-bottom: 1em"></v-divider>
+                <v-row
+                    no-gutters align="center" class="author-row"
+                    v-for="(a, idx) in modelVals['authors']" 
+                    :disabled="a.type == 'matched'"
+                    :class="a.type == 'matched' ? 'author-matched': ''"
+                    :key="a.row_key"
+                >
+                    <v-col cols="2">
+                        <v-text-field
+                            variant="outlined"
+                            v-model="a.given_name" 
+                            density="compact"
+                            hide-details="auto"
+                            :disabled="a.type == 'matched'"
+                        />
+                    </v-col>
+                    <v-col cols="2">
+                        <v-text-field
+                            variant="outlined"
+                            v-model="a.family_name" 
+                            density="compact"
+                            hide-details="auto"
+                            :disabled="a.type == 'matched'"
+                        />
+                    </v-col>
+                    <v-col cols="3">
+                        <InstancesSelectEditor4Wiz
+                            v-model="a.role"
+                            :property_shape="prop_shape_role"
+                            :allow_add="false"
+                            :disabled="a.type == 'matched'"
+                        />
+                    </v-col>
+                    <v-col cols="3">
+                        <InstancesSelectEditor4Wiz
+                            v-model="a.pid"
+                            :property_shape="prop_shape_person"
+                            :allow_add="false"
+                            :disabled="a.type == 'matched'"
+                        />
+                    </v-col>
+                    <v-col cols="1" class="d-flex justify-center align-center">
+                        <span v-if="a.type == 'matched'">
+                            <v-tooltip text="Matched">
+                                <template v-slot:activator="{ props }">
+                                    <v-icon v-bind="props" color="success">mdi-check-all</v-icon>
+                                </template>
+                            </v-tooltip>
+                        </span>
+                        <span v-else-if="a.type == 'new' && a.pid">
+                            <v-tooltip text="Selected">
+                                <template v-slot:activator="{ props }">
+                                    <v-icon v-bind="props">mdi-account-check</v-icon>
+                                </template>
+                            </v-tooltip>
+                        </span>
+                        <span v-else>
+                            <v-tooltip text="New">
+                                <template v-slot:activator="{ props }">
+                                    <v-icon v-bind="props">mdi-account</v-icon>
+                                </template>
+                            </v-tooltip>
+                        </span>
+                    </v-col>
+                    <v-col>
+                        <v-btn variant="text" icon="mdi-trash-can" @click="removeAuthor(idx)"></v-btn>
+                    </v-col>
+                </v-row>
+                <br>
+
+                <v-btn
+                @click="addAuthor()"
+                prepend-icon="mdi-plus"
+                density="compact"
+                >Add author</v-btn>
+            </span>
+        </v-card-text>
+    </v-card>    
+</template>
+
+<script setup>
+import { ref, inject, toRaw, onMounted, watch} from 'vue'
+import { SHACL } from '@/modules/namespaces';
+import InstancesSelectEditor4Wiz from '@/components/InstancesSelectEditor4Wiz.vue';
+import { namespace } from 'shacl-tulip';
+const XYZRI = namespace('https://concepts.datalad.org/s/demo-research-information/unreleased/');
+
+const props = defineProps({
+    config: Object,
+    disabled: Boolean,
+});
+
+const modelVals = defineModel('modelVals')
+const emit = defineEmits(['uploadComplete', 'init-form'])
+const plugins = inject('runtimePlugins')
+const fetchFromService = inject('fetchFromService')
+const allPrefixes = inject('allPrefixes')
+
+const rdfDS = inject('rdfDS')
+const doiText = ref('')
+const prop_shape_person = {
+    [SHACL.class.value]: XYZRI.XYZPerson.value,
+    [SHACL.nodeKind.value]: SHACL.IRI.value,
+    [SHACL.path.value]:'',
+    [SHACL.description.value]:'',
+}
+const prop_shape_role = {
+    [SHACL.class.value]: XYZRI.XYZAgentRole.value,
+    [SHACL.nodeKind.value]: SHACL.IRI.value,
+    [SHACL.path.value]:'',
+    [SHACL.description.value]:'',
+}
+const showError = ref(false);
+const errorTitle = ref('');
+const errorMessage = ref('');
+onMounted(() => {
+
+})
+
+function clearError() {
+    showError.value = false;
+    errorTitle.value = '';
+    errorMessage.value = '';
+}
+
+function loadError(title, message) {
+    showError.value = true;
+    errorTitle.value = title;
+    errorMessage.value = message;
+}
+
+function addAuthor() {
+    modelVals.value['authors'].push(
+        {
+            pid: null,
+            given_name: null,
+            family_name: null,
+            role: null,
+            row_key: crypto.randomUUID(),
+        }
+    )
+}
+
+function removeAuthor(idx) {
+    modelVals.value['authors'].splice(idx,1)
+}
+
+async function checkThenImportMetadata() {
+    // First check if a publication with the doi is already in the pool
+    // if so: instruct user to rather edit the existing record
+
+    // First do a constrained fetch for all publication records referencing the doi
+    const result = await fetchFromService(
+        'get-paginated-records-constrained',
+        XYZRI.XYZPublication.value,
+        allPrefixes,
+        doiText.value
+    );
+    if (result.status === null) {
+        console.error(result.error);
+    }
+    // Now we find a publication with said DOI, either in identifiers or as pid
+    let pub = await plugins['doi'].api.findPublicationWithDOI(doiText.value, rdfDS)
+    if (pub) {
+        let title = 'Known DOI'
+        let message = `A publication record with the specified DOI (${doiText.value}) already exists in the knowledge base. Please edit the existing record rather than importing a new one.`
+        loadError(title, message)
+        return
+    }
+    // Otherwise we continue
+    importMetadata()
+}
+
+// Validate file type and read it
+const importMetadata = async () => {
+    clearError()
+    emit('init-form')
+    try {
+        let result = await plugins['doi'].api.importMetadata(
+            {
+                doi: doiText.value,
+                rdfDS: rdfDS,
+            }
+        )
+        modelVals.value['authors'] = result.authors;
+        modelVals.value['title'] = result.title;
+        modelVals.value['abstract'] = result.abstract;
+        modelVals.value['doi'] = doiText.value;
+        for (const a of modelVals.value['authors']) {
+            if (a.pid) {
+                 a.type = 'matched';
+            } else {
+                 a.type = 'new';
+            }
+            a.row_key = a.given_name+a.family_name;
+        }
+    } catch (error) {
+        let title = 'DOI Fetch Error'
+        let message = error
+        loadError(title, message)
+        console.error(error)
+    }
+}
+
+
+</script>
+
+<style scoped>
+
+.author-row:hover {
+    background-color: #7f7d7de5;
+    align-items: center;
+}
+.author-matched {
+    background-color: #7f7d7de5;
+}
+</style>
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: <https://concepts.datalad.org/s/demo-research-information/ns/>.
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
+@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/>.
+@prefix dlthings: <https://concepts.datalad.org/s/things/v2/>.
+@prefix obo: <http://purl.obolibrary.org/obo/>.
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#>.
+@prefix sio: <http://semanticscience.org/resource/>.
+@prefix dcterms: <http://purl.org/dc/terms/>.
+@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
+@prefix orcid: <https://orcid.org/>.
+
+{% 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: <http://purl.org/dc/terms/> .
+@prefix dlthings: <https://concepts.datalad.org/s/things/v2/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
+@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/> .
+@prefix xyzrins: <https://concepts.datalad.org/s/demo-research-information/ns/>.
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+{% 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 }}.
diff --git a/templates/person-depiction-upload.nunjucks.ttl b/templates/person-depiction-upload.nunjucks.ttl
new file mode 100644
index 0000000..92edd0f
--- /dev/null
+++ b/templates/person-depiction-upload.nunjucks.ttl
@@ -0,0 +1,30 @@
+@prefix dcat: <http://www.w3.org/ns/dcat#> .
+@prefix dcterms: <http://purl.org/dc/terms/> .
+@prefix dldi: <https://pid.datalad.org/distributions/> .
+@prefix dlthings: <https://concepts.datalad.org/s/things/v2/> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
+@prefix spdx: <http://spdx.org/rdf/terms#> .
+@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/> .
+@prefix xyzrins: <https://concepts.datalad.org/s/demo-research-information/ns/>.
+@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
+
+{% set depictionId = _randomUUID() -%}
+{% set depictionURI = "https://concepts.datalad.org/s/demo-research-information/ns/depictions/" + depictionId -%}
+dldi:{{ file.annexKey }} a xyzri:XYZFile;
+    skos:prefLabel {{ file.name | ttl }}^^xsd:string;
+    dlthings:distribution_of <{{ depictionURI }}>;
+    dlthings:byte_size {{ file.size | ttl }}^^xsd:nonNegativeInteger;
+    dlthings:characterized_by _:n0-1.
+_:n0-1 a dlthings:Statement;
+    rdf:object <{{ file.downloadUrl }}>;
+    rdf:predicate dcat:downloadUrl.
+dldi:{{ file.annexKey }} dlthings:checksums _:n0-2.
+_:n0-2 a dlthings:Checksum;
+    skos:notation {{ file.hash | ttl }}^^xsd:hexBinary;
+    dcterms:creator spdx:checksumAlgorithm_sha256.
+<{{ depictionURI }}> a xyzri:XYZDepiction;
+    dcterms:subject <{{ pid }}>;
+    dcterms:type <https://concepts.datalad.org/s/demo-research-information/ns/depiction-types/e9a34f7d-d05e-4591-bb45-f8a0c499e07b>;
+    dlthings:distributions dldi:{{ file.annexKey }}.
+<{{ pid }}> dlthings:depiction <{{ depictionURI }}>.
\ No newline at end of file
Seems like several changes can be made, if desired for the UI. What I did just now is to look at the previous submodule commit (`7ba3ebd0ed8d83538e920bb29761dff93c89e10e`) in the `shacl-vue` commit history, https://hub.psychoinformatics.de/orinoco/shacl-vue/commit/7ba3ebd0ed8d83538e920bb29761dff93c89e10e, saw it was on 4 March. Then looked around that same date for the submodule update in the Psyinf pool repo: https://hub.psychoinformatics.de/www/pool.psychoinformatics.de-ui/commit/5b6f05702c2ba3ca7d72526d3c74387e849be088. Then look at the diff in that repo from that commit until now. Looks like a lot of changes. Commit summary: ``` 35cdaa2 (HEAD -> main, origin/main, origin/HEAD) Let public upload repo appear first in file upload wizard 9387d53 change kickstarter subdirectory to 'kickstarter' 8daa739 Update to shacl-vue that fetches a single record specified in URL query parameters f7ca499 do recursive copy directly from dist directory; print dist directory files after build f7063e3 do not also move interim 'app' directory 6d9cd3b Support for new shacl-vue starter feature 5cfe3d3 update to shacl-vue state supporting starter functionality 49d1ff2 chore: use latest shacl-vue d27b5b2 special buttons for source code and documentation f508023 Fetch more upfront 3c851ff add missing config for person depiction upload wizard 01e7613 add person depiction upload wizard and template f189016 Update to shacl-vue nunjucks to handle multiline ttl rendering and more character escaping 09db7ff Updates and bug fixes to DOI plugin 8efe252 author role should be a named node 6de6a8f fix template name 9f2186c DOIImportWizard support c1f0f48 bring in support for plugins and improved wizardeditor 80ea5d5 External config should point to latest in main 5b6f057 rdfs:label and rdfs:comment fixes ``` actual diff: ``` >> git diff 5b6f057..HEAD > patch.diff ``` ```diff diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index e4daa4a..c2bdc93 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/pool.psychoinformatics.de-new && (test -d && mv /www/pool.psychoinformatics.de /www/pool.psychoinformatics.de-old || true); mv /www/pool.psychoinformatics.de-new /www/pool.psychoinformatics.de; rm -rf /www/pool.psychoinformatics.de-old + run: cp -r dist /www/pool.psychoinformatics.de-new && (test -d && mv /www/pool.psychoinformatics.de /www/pool.psychoinformatics.de-old || true); mv /www/pool.psychoinformatics.de-new /www/pool.psychoinformatics.de; rm -rf /www/pool.psychoinformatics.de-old diff --git a/Makefile b/Makefile index c277817..c62e970 100644 --- a/Makefile +++ b/Makefile @@ -1,26 +1,48 @@ # 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) - cp config.* $(DIST_DIR)/ - cp favicon.ico $(DIST_DIR)/favicon.ico - cp *logo* $(DIST_DIR)/ - cp -r templates $(DIST_DIR)/ + mkdir -p ./$(DIST_DIR_UI) + mv $(VUE_APP_DIR)/dist/app/* ./$(DIST_DIR_UI) + cp config.* $(DIST_DIR_UI)/ + cp favicon.ico $(DIST_DIR_UI)/favicon.ico + cp *logo* $(DIST_DIR_UI)/ + cp -r templates $(DIST_DIR_UI)/ + +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) + rm -rf dist + +clean-ui: + rm -rf $(DIST_DIR_UI) + +clean-starter: + rm -rf $(DIST_DIR_STARTER) -.PHONY: install build clean deploy +.PHONY: install build-ui build-starter clean-ui clean-starter deploy diff --git a/config.yaml b/config.yaml index 27c34d0..521846a 100644 --- a/config.yaml +++ b/config.yaml @@ -2,8 +2,9 @@ # General app settings # -------------------- app_name: PsyInf Knowledge Pooling Tool +app_name_starter: PsyInf Knowledge Kickstarter documentation_url: '' -external_config_url: https://hub.psychoinformatics.de/orinoco/assets/raw/branch/psyinf-config/shacl-vue/config_default_xyzri.yaml +external_config_url: https://hub.psychoinformatics.de/orinoco/assets/raw/branch/main/shacl-vue/config_default_xyzri.yaml page_title: PsyInf Knowledge source_code_url: https://hub.psychoinformatics.de/www/pool.psychoinformatics.de-ui @@ -11,8 +12,14 @@ source_code_url: https://hub.psychoinformatics.de/www/pool.psychoinformatics.de- # Content # ------- content: + add-record: + url: templates/add-record.nunjucks.ttl + person-depiction-upload: + url: templates/person-depiction-upload.nunjucks.ttl DocumentUploadTemplate: url: templates/DocumentUploadTemplate.ttl + DOIImportWizardTemplate: + url: templates/DOIImportWizardTemplate.nunjucks.ttl DOIWizardTemplate: url: templates/DOIWizardTemplate.ttl DOIlogo: @@ -96,6 +103,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: @@ -116,6 +145,35 @@ priority_classes: title: All include_subclasses: true wizard_editors: + AddRecordWizard: + name: Quick-Add New Record + tooltip: Quick Add + icon: mdi-plus-box + description: Add the display name and description and then hit *Save* + inputs: + - prop: name + name: Display name + description: The display name of the new record + type: text + placeholder: 'My record title' + required: true + - prop: description + name: Description + description: The description of the new record + type: text-paragraph + placeholder: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod...' + template: content:add-record + DepictionUploadWizard: + name: Depiction Upload Wizard + tooltip: Upload a depiction + icon: mdi-account-box-outline + description: Upload an image of the person and hit *Save* + inputs: + - prop: file + name: File + type: upload + required: true + template: content:person-depiction-upload DOIWizard: name: DOI Wizard tooltip: Add a Digital Object Identifier @@ -131,6 +189,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 @@ -143,7 +235,14 @@ wizard_editors: required: true template: content:file-upload-template wizard_editor_selection: + _classes: + - AddRecordWizard + xyzri:XYZPerson: + _record: + - DepictionUploadWizard xyzri:XYZPublication: + _class: + - DOIImportWizard _record: - DOIWizard _slots: @@ -165,9 +264,14 @@ use_service: true use_token: true service_fetch_before: get-records: + - xyzri:XYZActivity - xyzri:XYZAgentRole + - xyzri:XYZBibliographicType + - xyzri:XYZCompetitionType - xyzri:XYZDepictionType + - xyzri:XYZInstrumentType - xyzri:XYZPerson + - xyzri:XYZTopic # ---------------- # Special features @@ -184,7 +288,7 @@ gitannex_p2phttp_config_wizard: - name: Psychoinformatics Hub base_url: https://hub.psychoinformatics.de/git-annex-p2phttp/git-annex repositories: - - name: Private uploads - annex_uuid: f1a8ef1c-6d8a-40e3-970f-4634390d961f - name: Public uploads annex_uuid: cedde37c-416a-41fd-87e0-4ac100df4bf7 + - name: Private uploads + annex_uuid: f1a8ef1c-6d8a-40e3-970f-4634390d961f 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 @@ +<template> + + <v-row align="stretch"> + <v-col cols="10"> + <v-text-field v-model="doiText" label="DOI" variant="outlined" density="compact"></v-text-field> + <v-card v-if="showError" flat style="margin-top: 0"> + <v-card-text> + <v-icon color="error">mdi-alert</v-icon> <em>{{ errorTitle }}:</em> {{ errorMessage }} + <v-btn @click="clearError" density="compact">Ok</v-btn> + </v-card-text> + </v-card> + </v-col> + <v-col> + <v-btn @click="checkThenImportMetadata">Import</v-btn> + </v-col> + </v-row> + + <v-card flat variant="text" v-if="modelVals['title'] && modelVals['authors']"> + <h2>Imported metadata</h2> + <br> + <h3>Title</h3> + <v-text-field + variant="outlined" + v-model="modelVals['title']" + density="compact"> + </v-text-field> + <h3>Abstract</h3> + <v-textarea + variant="outlined" + v-model="modelVals['abstract']" + density="compact"> + </v-textarea> + <h3>Authors</h3> + <v-card-text> + <span v-if="modelVals['authors'].length"> + <v-row> + <v-col cols="2"><strong>Given Name</strong></v-col> + <v-col cols="2"><strong>Family Name</strong></v-col> + <v-col cols="3"><strong>Role</strong></v-col> + <v-col cols="3" class="d-flex justify-center align-center"><strong>Linked Record</strong></v-col> + <v-col cols="1" class="d-flex justify-center align-center"><strong>Type</strong></v-col> + <v-col></v-col> + </v-row> + <v-divider opacity=".7" thickness="1" style="margin-top: 1em; margin-bottom: 1em"></v-divider> + <v-row + no-gutters align="center" class="author-row" + v-for="(a, idx) in modelVals['authors']" + :disabled="a.type == 'matched'" + :class="a.type == 'matched' ? 'author-matched': ''" + :key="a.row_key" + > + <v-col cols="2"> + <v-text-field + variant="outlined" + v-model="a.given_name" + density="compact" + hide-details="auto" + :disabled="a.type == 'matched'" + /> + </v-col> + <v-col cols="2"> + <v-text-field + variant="outlined" + v-model="a.family_name" + density="compact" + hide-details="auto" + :disabled="a.type == 'matched'" + /> + </v-col> + <v-col cols="3"> + <InstancesSelectEditor4Wiz + v-model="a.role" + :property_shape="prop_shape_role" + :allow_add="false" + :disabled="a.type == 'matched'" + /> + </v-col> + <v-col cols="3"> + <InstancesSelectEditor4Wiz + v-model="a.pid" + :property_shape="prop_shape_person" + :allow_add="false" + :disabled="a.type == 'matched'" + /> + </v-col> + <v-col cols="1" class="d-flex justify-center align-center"> + <span v-if="a.type == 'matched'"> + <v-tooltip text="Matched"> + <template v-slot:activator="{ props }"> + <v-icon v-bind="props" color="success">mdi-check-all</v-icon> + </template> + </v-tooltip> + </span> + <span v-else-if="a.type == 'new' && a.pid"> + <v-tooltip text="Selected"> + <template v-slot:activator="{ props }"> + <v-icon v-bind="props">mdi-account-check</v-icon> + </template> + </v-tooltip> + </span> + <span v-else> + <v-tooltip text="New"> + <template v-slot:activator="{ props }"> + <v-icon v-bind="props">mdi-account</v-icon> + </template> + </v-tooltip> + </span> + </v-col> + <v-col> + <v-btn variant="text" icon="mdi-trash-can" @click="removeAuthor(idx)"></v-btn> + </v-col> + </v-row> + <br> + + <v-btn + @click="addAuthor()" + prepend-icon="mdi-plus" + density="compact" + >Add author</v-btn> + </span> + </v-card-text> + </v-card> +</template> + +<script setup> +import { ref, inject, toRaw, onMounted, watch} from 'vue' +import { SHACL } from '@/modules/namespaces'; +import InstancesSelectEditor4Wiz from '@/components/InstancesSelectEditor4Wiz.vue'; +import { namespace } from 'shacl-tulip'; +const XYZRI = namespace('https://concepts.datalad.org/s/demo-research-information/unreleased/'); + +const props = defineProps({ + config: Object, + disabled: Boolean, +}); + +const modelVals = defineModel('modelVals') +const emit = defineEmits(['uploadComplete', 'init-form']) +const plugins = inject('runtimePlugins') +const fetchFromService = inject('fetchFromService') +const allPrefixes = inject('allPrefixes') + +const rdfDS = inject('rdfDS') +const doiText = ref('') +const prop_shape_person = { + [SHACL.class.value]: XYZRI.XYZPerson.value, + [SHACL.nodeKind.value]: SHACL.IRI.value, + [SHACL.path.value]:'', + [SHACL.description.value]:'', +} +const prop_shape_role = { + [SHACL.class.value]: XYZRI.XYZAgentRole.value, + [SHACL.nodeKind.value]: SHACL.IRI.value, + [SHACL.path.value]:'', + [SHACL.description.value]:'', +} +const showError = ref(false); +const errorTitle = ref(''); +const errorMessage = ref(''); +onMounted(() => { + +}) + +function clearError() { + showError.value = false; + errorTitle.value = ''; + errorMessage.value = ''; +} + +function loadError(title, message) { + showError.value = true; + errorTitle.value = title; + errorMessage.value = message; +} + +function addAuthor() { + modelVals.value['authors'].push( + { + pid: null, + given_name: null, + family_name: null, + role: null, + row_key: crypto.randomUUID(), + } + ) +} + +function removeAuthor(idx) { + modelVals.value['authors'].splice(idx,1) +} + +async function checkThenImportMetadata() { + // First check if a publication with the doi is already in the pool + // if so: instruct user to rather edit the existing record + + // First do a constrained fetch for all publication records referencing the doi + const result = await fetchFromService( + 'get-paginated-records-constrained', + XYZRI.XYZPublication.value, + allPrefixes, + doiText.value + ); + if (result.status === null) { + console.error(result.error); + } + // Now we find a publication with said DOI, either in identifiers or as pid + let pub = await plugins['doi'].api.findPublicationWithDOI(doiText.value, rdfDS) + if (pub) { + let title = 'Known DOI' + let message = `A publication record with the specified DOI (${doiText.value}) already exists in the knowledge base. Please edit the existing record rather than importing a new one.` + loadError(title, message) + return + } + // Otherwise we continue + importMetadata() +} + +// Validate file type and read it +const importMetadata = async () => { + clearError() + emit('init-form') + try { + let result = await plugins['doi'].api.importMetadata( + { + doi: doiText.value, + rdfDS: rdfDS, + } + ) + modelVals.value['authors'] = result.authors; + modelVals.value['title'] = result.title; + modelVals.value['abstract'] = result.abstract; + modelVals.value['doi'] = doiText.value; + for (const a of modelVals.value['authors']) { + if (a.pid) { + a.type = 'matched'; + } else { + a.type = 'new'; + } + a.row_key = a.given_name+a.family_name; + } + } catch (error) { + let title = 'DOI Fetch Error' + let message = error + loadError(title, message) + console.error(error) + } +} + + +</script> + +<style scoped> + +.author-row:hover { + background-color: #7f7d7de5; + align-items: center; +} +.author-matched { + background-color: #7f7d7de5; +} +</style> 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: <https://concepts.datalad.org/s/demo-research-information/ns/>. +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. +@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/>. +@prefix dlthings: <https://concepts.datalad.org/s/things/v2/>. +@prefix obo: <http://purl.obolibrary.org/obo/>. +@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. +@prefix sio: <http://semanticscience.org/resource/>. +@prefix dcterms: <http://purl.org/dc/terms/>. +@prefix skos: <http://www.w3.org/2004/02/skos/core#>. +@prefix orcid: <https://orcid.org/>. + +{% 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: <http://purl.org/dc/terms/> . +@prefix dlthings: <https://concepts.datalad.org/s/things/v2/> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix skos: <http://www.w3.org/2004/02/skos/core#> . +@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/> . +@prefix xyzrins: <https://concepts.datalad.org/s/demo-research-information/ns/>. +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +{% 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 }}. diff --git a/templates/person-depiction-upload.nunjucks.ttl b/templates/person-depiction-upload.nunjucks.ttl new file mode 100644 index 0000000..92edd0f --- /dev/null +++ b/templates/person-depiction-upload.nunjucks.ttl @@ -0,0 +1,30 @@ +@prefix dcat: <http://www.w3.org/ns/dcat#> . +@prefix dcterms: <http://purl.org/dc/terms/> . +@prefix dldi: <https://pid.datalad.org/distributions/> . +@prefix dlthings: <https://concepts.datalad.org/s/things/v2/> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix skos: <http://www.w3.org/2004/02/skos/core#> . +@prefix spdx: <http://spdx.org/rdf/terms#> . +@prefix xyzri: <https://concepts.datalad.org/s/demo-research-information/unreleased/> . +@prefix xyzrins: <https://concepts.datalad.org/s/demo-research-information/ns/>. +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . + +{% set depictionId = _randomUUID() -%} +{% set depictionURI = "https://concepts.datalad.org/s/demo-research-information/ns/depictions/" + depictionId -%} +dldi:{{ file.annexKey }} a xyzri:XYZFile; + skos:prefLabel {{ file.name | ttl }}^^xsd:string; + dlthings:distribution_of <{{ depictionURI }}>; + dlthings:byte_size {{ file.size | ttl }}^^xsd:nonNegativeInteger; + dlthings:characterized_by _:n0-1. +_:n0-1 a dlthings:Statement; + rdf:object <{{ file.downloadUrl }}>; + rdf:predicate dcat:downloadUrl. +dldi:{{ file.annexKey }} dlthings:checksums _:n0-2. +_:n0-2 a dlthings:Checksum; + skos:notation {{ file.hash | ttl }}^^xsd:hexBinary; + dcterms:creator spdx:checksumAlgorithm_sha256. +<{{ depictionURI }}> a xyzri:XYZDepiction; + dcterms:subject <{{ pid }}>; + dcterms:type <https://concepts.datalad.org/s/demo-research-information/ns/depiction-types/e9a34f7d-d05e-4591-bb45-f8a0c499e07b>; + dlthings:distributions dldi:{{ file.annexKey }}. +<{{ pid }}> dlthings:depiction <{{ depictionURI }}>. \ No newline at end of file ```
adina force-pushed update-shacl from 27c47c0c7c to 8fae8d7094 2026-06-03 07:37:31 +00:00 Compare
adina force-pushed update-shacl from 8fae8d7094 to fd5c2d92ca 2026-06-03 07:44:14 +00:00 Compare
adina force-pushed update-shacl from fd5c2d92ca to b1f1835e5c 2026-06-03 08:57:58 +00:00 Compare
Author
Member

I think this is ready. I'll hit merge in a short bit

I think this is ready. I'll hit merge in a short bit
adina merged commit 0ddef3f4bb into main 2026-06-03 09:40:41 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
www/kiste.abcd-j.de-ui!5
No description provided.