diff --git a/StagingArea/invenio/invenio@2.1.0.fsx b/StagingArea/invenio/invenio@2.1.0.fsx new file mode 100644 index 0000000..4854527 --- /dev/null +++ b/StagingArea/invenio/invenio@2.1.0.fsx @@ -0,0 +1,121 @@ +let []PACKAGE_METADATA = """(* +--- +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: 2 +MinorVersion: 1 +PatchVersion: 0 +Publish: true +Authors: + - FullName: Oliver Maus + Affiliation: DataPLANT + - FullName: Christopher Lux + Email: lux@csbiology.de + Affiliation: RPTU Kaiserslautern + AffiliationLink: http://rptu.de/startseite + - FullName: Lukas Weil + Email: weil@rptu.de + Affiliation: DataPLANT +Tags: + - Name: ARC + - Name: data publication +ReleaseNotes: | + - Fix package passing validation against Investigation file containing only section keys +--- +*)""" + +#r "nuget: ARCExpect, 4.0.1" + +open ControlledVocabulary +open Expecto +open ARCExpect +open ARCTokenization +open ARCTokenization.StructuralOntology +open System.IO + +// Input: +let arcDir = Directory.GetCurrentDirectory() + +// Values: +let absoluteDirectoryPaths = FileSystem.parseARCFileSystem arcDir + +let investigationMetadata = + absoluteDirectoryPaths + |> Investigation.parseMetadataSheetsFromTokens() arcDir + |> List.concat + + +// 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) { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Title`` + } + // Investigation has description + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description``.Name) { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm + INVMSO.``Investigation Metadata``.INVESTIGATION.``Investigation Description`` + } + // Investigation has contacts with name, last name, affiliation and email + // Investigation Person First Name + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person First Name``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Last Name + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Last Name``) + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Affiliation + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation`` + } + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``.Name} is not empty") { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Affiliation``) + |> Seq.filter (Param.getValueAsString >> (<>) "Metadata Section Key") + |> Seq.iter Validate.Param.ValueIsNotEmpty + } + // Investigation Person Email + ARCExpect.validationCase (TestID.Name $"{INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name} exists") { + investigationMetadata + |> Validate.ParamCollection.ContainsNonKeyParamWithTerm INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email`` + } + ARCExpect.validationCase (TestID.Name INVMSO.``Investigation Metadata``. ``INVESTIGATION CONTACTS``.``Investigation Person Email``.Name) { + investigationMetadata + |> Seq.filter (Param.getTerm >> (=) INVMSO.``Investigation Metadata``.``INVESTIGATION CONTACTS``.``Investigation Person Email``) + |> Seq.filter (Param.getValueAsString >> (<>) "Metadata Section Key") + |> Seq.iter (Validate.Param.ValueMatchesRegex StringValidationPattern.email) + } + ] + +// Execution: + +Setup.ValidationPackage( + metadata = Setup.Metadata(PACKAGE_METADATA), + CriticalValidationCases = [cases] +) +|> Execute.ValidationPipeline( + basePath = arcDir +) \ No newline at end of file