update to latest shacl-vue #5
8 changed files with 664 additions and 13 deletions
|
|
@ -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
|
||||
|
|
|
|||
39
Makefile
39
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
|
||||
|
|
|
|||
66
config.yaml
66
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
|
||||
|
|
|
|||
261
plugins/doi/DOIFetcher.vue
Normal file
261
plugins/doi/DOIFetcher.vue
Normal file
|
|
@ -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>
|
||||
201
plugins/doi/index.js
Normal file
201
plugins/doi/index.js
Normal file
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7ba3ebd0ed8d83538e920bb29761dff93c89e10e
|
||||
Subproject commit f3b7c5957ba32bf5aae6ce95a3db017859b95f52
|
||||
49
templates/DOIImportWizardTemplate.nunjucks.ttl
Normal file
49
templates/DOIImportWizardTemplate.nunjucks.ttl
Normal file
|
|
@ -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 -%}
|
||||
49
templates/add-record.nunjucks.ttl
Normal file
49
templates/add-record.nunjucks.ttl
Normal file
|
|
@ -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 }}.
|
||||
Loading…
Reference in a new issue