Skip to content

Commit

Permalink
Migrate API to use AVPRIndex lib, add custom migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Feb 29, 2024
1 parent 592dd65 commit ee0ee58
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 18 deletions.
16 changes: 16 additions & 0 deletions src/AVPRIndex/AVPRIndex.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<PropertyGroup>
<Authors>Kevin Schneider</Authors>
<Description>Type system for the indexing backend of avpr.nfdi4plants.org</Description>
<Summary>Type system for the indexing backend of avpr.nfdi4plants.org</Summary>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>C# F# ARC annotated-research-context rdm research-data-management validation</PackageTags>
<PackageProjectUrl>https://github.com/nfdi4plants/arc-validate-package-registry</PackageProjectUrl>
<RepositoryUrl>https://github.com/nfdi4plants/arc-validate-package-registry</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/RELEASE_NOTES.md"))</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageVersion>0.0.1</PackageVersion>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\"/>
<None Include="RELEASE_NOTES.md" />
<Compile Include="Globals.fs" />
<Compile Include="Domain.fs" />
<Compile Include="Utils.fs" />
Expand Down
33 changes: 32 additions & 1 deletion src/AVPRIndex/Domain.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,51 @@ 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
member val PatchVersion = 0 with get,set
// optional fields
member val Publish = false with get,set
member val Authors: Author [] = Array.empty<Author> with get,set
member val Tags: string [] = Array.empty<string> with get,set
member val Tags: OntologyAnnotation [] = Array.empty<OntologyAnnotation> with get,set
member val ReleaseNotes = "" with get,set

override this.GetHashCode() =
hash (
this.Name,
this.Summary,
this.Description,
this.MajorVersion,
this.MinorVersion,
Expand All @@ -70,6 +99,7 @@ module Domain =
| :? ValidationPackageMetadata as vpm ->
(
this.Name,
this.Summary,
this.Description,
this.MajorVersion,
this.MinorVersion,
Expand All @@ -80,6 +110,7 @@ module Domain =
this.ReleaseNotes
) = (
vpm.Name,
vpm.Summary,
vpm.Description,
vpm.MajorVersion,
vpm.MinorVersion,
Expand Down
5 changes: 5 additions & 0 deletions src/AVPRIndex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# AVPR Index

Type system for the indexing backend of https://avpr.nfdi4plants.org.

This lib exposes the type system and utilities needed to parse and index arc validation packages with yaml frontmatter.
3 changes: 3 additions & 0 deletions src/AVPRIndex/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## v0.0.1

- Initial release for AVPR API v1
5 changes: 3 additions & 2 deletions src/PackageRegistryService/Data/DataInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
using static AVPRIndex.Frontmatter;

namespace PackageRegistryService.Data

{
public class DataInitializer
{
public static List<ValidationPackageIndex> ReadIndex()
{
var json = File.ReadAllText(@"Data/arc-validate-package-index.json");
var index = JsonSerializer.Deserialize<List<ValidationPackageIndex>>(json);
return index;
return index ?? [];
}
public static void SeedData(ValidationPackageDb context)
{
Expand All @@ -39,6 +39,7 @@ public static void SeedData(ValidationPackageDb context)
return new ValidationPackage
{
Name = i.Metadata.Name,
Summary = i.Metadata.Summary,
Description = i.Metadata.Description,
MajorVersion = i.Metadata.MajorVersion,
MinorVersion = i.Metadata.MinorVersion,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"RepoPath": "src/PackageRegistryService/StagingArea/invenio/invenio@1.0.0.fsx",
"FileName": "invenio@1.0.0.fsx",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"LastUpdated": "2024-02-29T14:45:24+01:00",
"ContentHash": "864458DA6C7B0F08A546210CFD3CCA4A",
"Metadata": {
"Name": "invenio",
Expand Down Expand Up @@ -74,7 +74,7 @@
{
"RepoPath": "src/PackageRegistryService/StagingArea/test/test@2.0.0.fsx",
"FileName": "test@2.0.0.fsx",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"LastUpdated": "2024-02-29T14:45:24+01:00",
"ContentHash": "40729E451689807AEFF17F5932843A4C",
"Metadata": {
"Name": "test",
Expand Down Expand Up @@ -121,7 +121,7 @@
{
"RepoPath": "src/PackageRegistryService/StagingArea/test/test@3.0.0.fsx",
"FileName": "test@3.0.0.fsx",
"LastUpdated": "2024-02-29T14:45:26+01:00",
"LastUpdated": "2024-02-29T14:45:24+01:00",
"ContentHash": "0537642158095CE84F4FA8363225831E",
"Metadata": {
"Name": "test",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ee0ee58

Please sign in to comment.