From 592dd6589e5d16197794b5b088d107e6f2b32506 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Thu, 29 Feb 2024 14:45:24 +0100 Subject: [PATCH] add new metadata --- scripts/domain.fsx | 66 +++++++++++++++++-- .../Data/arc-validate-package-index.json | 65 ++++++++++++++---- .../StagingArea/invenio/invenio@1.0.0.fsx | 4 +- .../StagingArea/test/test@2.0.0.fsx | 6 +- .../StagingArea/test/test@3.0.0.fsx | 6 +- 5 files changed, 118 insertions(+), 29 deletions(-) diff --git a/scripts/domain.fsx b/scripts/domain.fsx index b18de15..242f69d 100644 --- a/scripts/domain.fsx +++ b/scripts/domain.fsx @@ -4,10 +4,17 @@ open System open System.IO +open System.Security.Cryptography open YamlDotNet.Serialization open System.Text.Json // open ARCValidationPackages <-- use this (or ARCtrl) once the data model is stable +[] +module Constants = + + let [] STAGING_AREA_RELATIVE_PATH = "src/PackageRegistryService/StagingArea" + let [] PACKAGE_INDEX_RELATIVE_PATH = "src/PackageRegistryService/Data/arc-validate-package-index.json" + // This is the F# version of /src/PackageRegistryService/Models/ValidationPackageIndex.cs // and should be equal to the implementation in arc-validate (until there is a common codebase/domain) [] @@ -45,9 +52,37 @@ module Domain = ) | _ -> false + type OntologyAnnotation() = + + member val Name = "" with get,set + member val TermSourceREF = "" with get,set + member val TermAccessionNumber = "" with get,set + + override this.GetHashCode() = + hash ( + this.Name, + this.TermSourceREF, + this.TermAccessionNumber + ) + + override this.Equals(other) = + match other with + | :? OntologyAnnotation as oa -> + ( + this.Name, + this.TermSourceREF, + this.TermAccessionNumber + ) = ( + oa.Name, + oa.TermSourceREF, + oa.TermAccessionNumber + ) + | _ -> false + type ValidationPackageMetadata() = // mandatory fields member val Name = "" with get,set + member val Summary = "" with get,set member val Description = "" with get,set member val MajorVersion = 0 with get,set member val MinorVersion = 0 with get,set @@ -55,12 +90,13 @@ module Domain = // optional fields member val Publish = false with get,set member val Authors: Author [] = Array.empty with get,set - member val Tags: string [] = Array.empty with get,set + member val Tags: OntologyAnnotation [] = Array.empty with get,set member val ReleaseNotes = "" with get,set override this.GetHashCode() = hash ( this.Name, + this.Summary, this.Description, this.MajorVersion, this.MinorVersion, @@ -76,6 +112,7 @@ module Domain = | :? ValidationPackageMetadata as vpm -> ( this.Name, + this.Summary, this.Description, this.MajorVersion, this.MinorVersion, @@ -86,6 +123,7 @@ module Domain = this.ReleaseNotes ) = ( vpm.Name, + vpm.Summary, vpm.Description, vpm.MajorVersion, vpm.MinorVersion, @@ -125,7 +163,7 @@ module Domain = metadata: ValidationPackageMetadata ) = - let md5 = System.Security.Cryptography.MD5.Create() + let md5 = MD5.Create() ValidationPackageIndex.create( repoPath = repoPath, @@ -212,11 +250,18 @@ module Utils = System.Globalization.CultureInfo.InvariantCulture ) -module AVPRRepo = +type AVPRRepo = ///! Paths are relative to the root of the project, since the script is executed from the repo root in CI - let getStagedPackages() = - Directory.GetFiles("src/PackageRegistryService/StagingArea", "*.fsx", SearchOption.AllDirectories) + /// Path is adjustable by passing `RepoRoot` + static member getStagedPackages(?RepoRoot: string) = + + let path = + defaultArg + (RepoRoot |> Option.map (fun p -> Path.Combine(p, STAGING_AREA_RELATIVE_PATH))) + STAGING_AREA_RELATIVE_PATH + + Directory.GetFiles(path, "*.fsx", SearchOption.AllDirectories) |> Array.map (fun x -> x.Replace('\\',Path.DirectorySeparatorChar).Replace('/',Path.DirectorySeparatorChar)) |> Array.map (fun p -> ValidationPackageIndex.create( @@ -226,8 +271,15 @@ module AVPRRepo = ) ///! Paths are relative to the root of the project, since the script is executed from the repo root in CI - let getIndexedPackages() = - "src/PackageRegistryService/Data/arc-validate-package-index.json" + /// Path is adjustable by passing `RepoRoot` + static member getIndexedPackages(?RepoRoot: string) = + + let path = + defaultArg + (RepoRoot |> Option.map (fun p -> Path.Combine(p, PACKAGE_INDEX_RELATIVE_PATH))) + PACKAGE_INDEX_RELATIVE_PATH + + path |> File.ReadAllText |> JsonSerializer.Deserialize diff --git a/src/PackageRegistryService/Data/arc-validate-package-index.json b/src/PackageRegistryService/Data/arc-validate-package-index.json index 3106921..910ec9b 100644 --- a/src/PackageRegistryService/Data/arc-validate-package-index.json +++ b/src/PackageRegistryService/Data/arc-validate-package-index.json @@ -2,10 +2,11 @@ { "RepoPath": "src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx", "FileName": "invenio@1.0.0.fsx", - "LastUpdated": "2024-02-28T15:39:07+01:00", - "ContentHash": "1A3CB3CC0538782C864EA37545451FD5", + "LastUpdated": "2024-02-29T14:45:26+01:00", + "ContentHash": "864458DA6C7B0F08A546210CFD3CCA4A", "Metadata": { "Name": "invenio", + "Summary": "", "Description": "Validates if the ARC contains the necessary metadata to be publishable via Invenio.\nThe following metadata is required:\n - Investigation has title and description\n - All persons in Investigation Contacts must have a name, last name, affiliation and valid email\n", "MajorVersion": 1, "MinorVersion": 0, @@ -20,8 +21,16 @@ } ], "Tags": [ - "ARC", - "data publication" + { + "Name": "ARC", + "TermSourceREF": "", + "TermAccessionNumber": "" + }, + { + "Name": "data publication", + "TermSourceREF": "", + "TermAccessionNumber": "" + } ], "ReleaseNotes": "Initial release" } @@ -33,6 +42,7 @@ "ContentHash": "43BFF4CDCC3F3EBB3CA21B6C1F8AC5BA", "Metadata": { "Name": "test", + "Summary": "", "Description": "this package is here for testing purposes only.", "MajorVersion": 1, "MinorVersion": 0, @@ -50,6 +60,7 @@ "ContentHash": "0B9CBA89F1CECFAF5EB0BA1CE6A480FA", "Metadata": { "Name": "test", + "Summary": "", "Description": "this package is here for testing purposes only.", "MajorVersion": 1, "MinorVersion": 0, @@ -63,10 +74,11 @@ { "RepoPath": "src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx", "FileName": "test@2.0.0.fsx", - "LastUpdated": "2024-02-28T15:39:07+01:00", - "ContentHash": "F819359C06456B62F035F2587FBE1EE2", + "LastUpdated": "2024-02-29T14:45:26+01:00", + "ContentHash": "40729E451689807AEFF17F5932843A4C", "Metadata": { "Name": "test", + "Summary": "", "Description": "this package is here for testing purposes only.", "MajorVersion": 2, "MinorVersion": 0, @@ -87,9 +99,21 @@ } ], "Tags": [ - "validation", - "my-package", - "thing" + { + "Name": "validation", + "TermSourceREF": "", + "TermAccessionNumber": "" + }, + { + "Name": "my-package", + "TermSourceREF": "", + "TermAccessionNumber": "" + }, + { + "Name": "thing", + "TermSourceREF": "", + "TermAccessionNumber": "" + } ], "ReleaseNotes": "add authors and tags for further testing" } @@ -97,10 +121,11 @@ { "RepoPath": "src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx", "FileName": "test@3.0.0.fsx", - "LastUpdated": "2024-02-28T15:39:07+01:00", - "ContentHash": "9E6AB1A9C908DE02F583D9FD0E76D8FA", + "LastUpdated": "2024-02-29T14:45:26+01:00", + "ContentHash": "0537642158095CE84F4FA8363225831E", "Metadata": { "Name": "test", + "Summary": "", "Description": "this package is here for testing purposes only.", "MajorVersion": 3, "MinorVersion": 0, @@ -121,9 +146,21 @@ } ], "Tags": [ - "validation", - "my-package", - "thing" + { + "Name": "validation", + "TermSourceREF": "", + "TermAccessionNumber": "" + }, + { + "Name": "my-package", + "TermSourceREF": "", + "TermAccessionNumber": "" + }, + { + "Name": "thing", + "TermSourceREF": "", + "TermAccessionNumber": "" + } ], "ReleaseNotes": "add authors and tags for further testing" } diff --git a/src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx b/src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx index 5f70d59..39f373a 100644 --- a/src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx +++ b/src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx @@ -14,8 +14,8 @@ Authors: - FullName: Oliver Maus Affiliation: DataPLANT Tags: - - ARC - - data publication + - Name: ARC + - Name: data publication ReleaseNotes: "Initial release" --- *) diff --git a/src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx b/src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx index 40f1788..9392fda 100644 --- a/src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx +++ b/src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx @@ -16,9 +16,9 @@ Authors: Affiliation: University of Somewhere AffiliationLink: https://somewhere.edu Tags: - - validation - - my-package - - thing + - Name: validation + - Name: my-package + - Name: thing ReleaseNotes: "add authors and tags for further testing" --- *) diff --git a/src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx b/src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx index c3cac8e..85ffdbf 100644 --- a/src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx +++ b/src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx @@ -16,9 +16,9 @@ Authors: Affiliation: University of Somewhere AffiliationLink: https://somewhere.edu Tags: - - validation - - my-package - - thing + - Name: validation + - Name: my-package + - Name: thing ReleaseNotes: "add authors and tags for further testing" --- *)