Validation Package invenio

ARC; data publication

v1.0.0 released on 06/21/2024

by Oliver Maus

518 Downloads

Validates if the ARC contains the necessary metadata to be publishable via Invenio.


Install with arc-validate

 arc-validate package install invenio --version 1.0.0

Include in a PLANTDataHUB CQC pipeline

validation_packages:
  - name: invenio
    version: 1.0.0

Description

Validates if the ARC contains the necessary metadata to be publishable via Invenio.

The following metadata is required:

- Investigation has title and description

- All persons in Investigation Contacts must have a name, last name, affiliation and valid email


Release notes

Initial release


Browse code (v1.0.0)
(*
---
Name: invenio
Summary: Validates if the ARC contains the necessary metadata to be publishable via Invenio.
Description: |
    Validates if the ARC contains the necessary metadata to be publishable via Invenio.
    The following metadata is required:
        - Investigation has title and description
        - All persons in Investigation Contacts must have a name, last name, affiliation and valid email
MajorVersion: 1
MinorVersion: 0
PatchVersion: 0
Publish: true
Authors:
    - FullName: Oliver Maus
      Affiliation: DataPLANT
Tags:
    - Name: ARC
    - Name: data publication
ReleaseNotes: "Initial release"
---
*)

#r "nuget: ARCExpect, 1.0.1"

open ARCExpect
open ARCTokenization
open ARCTokenization.StructuralOntology
open ControlledVocabulary
open Expecto
open System.IO


// Input:

let arcDir = Directory.GetCurrentDirectory()

// Values:

let absoluteDirectoryPaths = FileSystem.parseAbsoluteDirectoryPaths arcDir
let absoluteFilePaths = FileSystem.parseAbsoluteFilePaths arcDir

let invFileTokens = 
    Investigation.parseMetadataSheetsFromTokens() absoluteFilePaths 
    |> List.concat
    |> ARCGraph.fillTokenList Terms.InvestigationMetadata.ontology
    |> Seq.concat
    |> Seq.concat
    |> Seq.map snd

let invFileTokensNoMdSecKeys =
    invFileTokens
    |> Seq.filter (Param.getValue >> (<>) Terms.StructuralTerms.metadataSectionKey.Name) 

let contactsFns =
    invFileTokensNoMdSecKeys
    |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``)

let contactsLns =
    invFileTokensNoMdSecKeys
    |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``)

let contactsAffs =
    invFileTokensNoMdSecKeys
    |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``)

let contactsEmails =
    invFileTokensNoMdSecKeys
    |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``)
 

// Validation Cases:

let cases = 
    testList INVMSO.``Investigation Metadata``.INVESTIGATION.key.Name [
        // Investigation has title
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``.Name) {
            invFileTokensNoMdSecKeys
            |> Validate.ParamCollection.ContainsParamWithTerm
                INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title``
        }
        // Investigation has description
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) {
            invFileTokensNoMdSecKeys
            |> Validate.ParamCollection.ContainsParamWithTerm
                INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``
        }
        // All Investigation contacts have a name
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name) {
            contactsFns
            |> Seq.iter Validate.Param.ValueIsNotEmpty
        }
        // All Investigation contacts have a last name
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name) {
            contactsLns
            |> Seq.iter Validate.Param.ValueIsNotEmpty
        }
        // All Investigation contacts have an affiliation
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name) {
            contactsAffs
            |> Seq.iter Validate.Param.ValueIsNotEmpty
        }
        // All Investigation contacts have a valid email
        ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name) {
            contactsEmails
            |> Seq.iter (Validate.Param.ValueMatchesRegex StringValidationPattern.email)
        }
    ]


// Execution:

cases
|> Execute.ValidationPipeline(
    basePath = arcDir,
    packageName = "invenio"
)

Available versions
Version Released on
2.1.0 08/08/2024
2.0.1 06/21/2024
2.0.0 06/21/2024
1.0.0 06/21/2024