From 5f6c65be8b50804b2f62b93545c82966719326ea Mon Sep 17 00:00:00 2001 From: HLWeil Date: Tue, 26 Mar 2024 10:49:41 +0100 Subject: [PATCH] distribute template across appropriate projects --- src/ARCtrl/ARCtrl.fsproj | 4 +-- src/ARCtrl/{Templates => }/Template.Web.fs | 0 src/Core/ARCtrl.Core.fsproj | 1 + src/{ARCtrl/Templates => Core}/Templates.fs | 35 ++++++++++--------- src/Spreadsheet/ARCtrl.Spreadsheet.fsproj | 4 +++ .../Template.fs} | 18 +++++----- 6 files changed, 33 insertions(+), 29 deletions(-) rename src/ARCtrl/{Templates => }/Template.Web.fs (100%) rename src/{ARCtrl/Templates => Core}/Templates.fs (73%) rename src/{ARCtrl/Templates/Template.Spreadsheet.fs => Spreadsheet/Template.fs} (97%) diff --git a/src/ARCtrl/ARCtrl.fsproj b/src/ARCtrl/ARCtrl.fsproj index 3b9d56ff..bf82d63a 100644 --- a/src/ARCtrl/ARCtrl.fsproj +++ b/src/ARCtrl/ARCtrl.fsproj @@ -24,9 +24,7 @@ - - - + diff --git a/src/ARCtrl/Templates/Template.Web.fs b/src/ARCtrl/Template.Web.fs similarity index 100% rename from src/ARCtrl/Templates/Template.Web.fs rename to src/ARCtrl/Template.Web.fs diff --git a/src/Core/ARCtrl.Core.fsproj b/src/Core/ARCtrl.Core.fsproj index 4573322a..27606f94 100644 --- a/src/Core/ARCtrl.Core.fsproj +++ b/src/Core/ARCtrl.Core.fsproj @@ -55,6 +55,7 @@ + diff --git a/src/ARCtrl/Templates/Templates.fs b/src/Core/Templates.fs similarity index 73% rename from src/ARCtrl/Templates/Templates.fs rename to src/Core/Templates.fs index ce96bd58..5f68ca63 100644 --- a/src/ARCtrl/Templates/Templates.fs +++ b/src/Core/Templates.fs @@ -1,6 +1,7 @@ -namespace ARCtrl.Template +namespace ARCtrl open ARCtrl +open ARCtrl.Helper open Fable.Core /// This module contains unchecked helper functions for templates @@ -12,13 +13,13 @@ module TemplatesAux = let comparer = if matchAll then (&&) else (||) comparer - let filterOnTags (tagGetter: Template -> OntologyAnnotation []) (queryTags: OntologyAnnotation []) (comparer: bool -> bool -> bool) (templates: Template []) = + let filterOnTags (tagGetter: Template -> OntologyAnnotation ResizeArray) (queryTags: OntologyAnnotation ResizeArray) (comparer: bool -> bool -> bool) (templates: Template ResizeArray) = templates - |> Array.filter(fun t -> + |> ResizeArray.filter(fun t -> let templateTags = tagGetter t let mutable isValid = None for qt in queryTags do - let contains = templateTags |> Array.contains qt + let contains = templateTags |> Seq.contains qt match isValid, contains with | None, any -> isValid <- Some any | Some maybe, any -> isValid <- Some (comparer maybe any) @@ -28,15 +29,15 @@ module TemplatesAux = [] type Templates = - static member getDistinctTags (templates: Template []) = - templates |> Array.collect (fun t -> t.Tags) |> Array.distinct + static member getDistinctTags (templates: Template ResizeArray) = + templates |> ResizeArray.collect (fun t -> t.Tags) |> ResizeArray.distinct /// /// Returns all **distinct** `template.Tags` and `template.EndpointRepositories` /// /// - static member getDistinctEndpointRepositories (templates: Template []) = - templates |> Array.collect (fun t -> t.EndpointRepositories) |> Array.distinct + static member getDistinctEndpointRepositories (templates: Template ResizeArray) = + templates |> ResizeArray.collect (fun t -> t.EndpointRepositories) |> ResizeArray.distinct /// /// Returns all **distinct** `template.Tags` and `template.EndpointRepositories` @@ -56,8 +57,8 @@ type Templates = /// /// The ontology annotation to filter by. /// Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template. - static member filterByTags(queryTags: OntologyAnnotation [], ?matchAll: bool) = - fun (templates: Template []) -> + static member filterByTags(queryTags: OntologyAnnotation ResizeArray, ?matchAll: bool) = + fun (templates: Template ResizeArray) -> let comparer = TemplatesAux.getComparer matchAll TemplatesAux.filterOnTags (fun t -> t.Tags) queryTags comparer templates @@ -66,8 +67,8 @@ type Templates = /// /// The ontology annotation to filter by. /// Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template. - static member filterByEndpointRepositories(queryTags: OntologyAnnotation [], ?matchAll: bool) = - fun (templates: Template []) -> + static member filterByEndpointRepositories(queryTags: OntologyAnnotation ResizeArray, ?matchAll: bool) = + fun (templates: Template ResizeArray) -> let comparer = TemplatesAux.getComparer matchAll TemplatesAux.filterOnTags (fun t -> t.EndpointRepositories) queryTags comparer templates @@ -76,16 +77,16 @@ type Templates = /// /// The ontology annotation to filter by. /// Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template. - static member filterByOntologyAnnotation(queryTags: OntologyAnnotation [], ?matchAll: bool) = - fun (templates: Template []) -> + static member filterByOntologyAnnotation(queryTags: OntologyAnnotation ResizeArray, ?matchAll: bool) = + fun (templates: Template ResizeArray) -> let comparer = TemplatesAux.getComparer matchAll - TemplatesAux.filterOnTags (fun t -> Array.append t.Tags t.EndpointRepositories) queryTags comparer templates + TemplatesAux.filterOnTags (fun t -> ResizeArray.append t.Tags t.EndpointRepositories) queryTags comparer templates /// /// Filters templates by template.Organisation = `Organisation.DataPLANT`/`"DataPLANT"`. /// /// - static member filterByDataPLANT (templates: Template []) = + static member filterByDataPLANT (templates: Template ResizeArray) = templates - |> Array.filter (fun t -> t.Organisation.IsOfficial()) + |> ResizeArray.filter (fun t -> t.Organisation.IsOfficial()) \ No newline at end of file diff --git a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj index 79f996d4..d5a6f817 100644 --- a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj +++ b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj @@ -26,6 +26,7 @@ + @@ -33,6 +34,9 @@ + + + diff --git a/src/ARCtrl/Templates/Template.Spreadsheet.fs b/src/Spreadsheet/Template.fs similarity index 97% rename from src/ARCtrl/Templates/Template.Spreadsheet.fs rename to src/Spreadsheet/Template.fs index a1cc2b65..c0d6154e 100644 --- a/src/ARCtrl/Templates/Template.Spreadsheet.fs +++ b/src/Spreadsheet/Template.fs @@ -1,7 +1,7 @@ -module ARCtrl.Template.Spreadsheet +namespace ARCtrl.Spreadsheet open FsSpreadsheet -open ARCtrl.Aux +open ARCtrl.Helper open ARCtrl.Spreadsheet open ARCtrl open System.Collections.Generic @@ -155,7 +155,7 @@ module Metadata = | v when v = obsoleteErLabel -> k,erLabel | v when v = obsoleteTagsLabel -> k,tagsLabel - | v when v = Authors.obsoleteORCIDLabel -> k,$"Comment[{Person.orcidKey}]" + | v when v = Authors.obsoleteORCIDLabel -> k,$"Comment[{ARCtrl.Process.Conversion.Person.orcidKey}]" | v when v = "Authors Last Name" -> k,"Author Last Name" | v when v = "Authors First Name" -> k,"Author First Name" @@ -208,13 +208,13 @@ module Metadata = yield! TemplateInfo.toRows template yield SparseRow.fromValues [erLabel] - yield! ER.toRows (None) (template.EndpointRepositories |> Array.toList) + yield! ER.toRows (None) (template.EndpointRepositories |> Seq.toList) yield SparseRow.fromValues [tagsLabel] - yield! Tags.toRows (None) (template.Tags |> Array.toList) + yield! Tags.toRows (None) (template.Tags |> Seq.toList) yield SparseRow.fromValues [authorsLabel] - yield! Contacts.toRows (Some authorsLabelPrefix) (List.ofArray template.Authors) + yield! Contacts.toRows (Some authorsLabelPrefix) (List.ofSeq template.Authors) } @@ -235,9 +235,9 @@ module Template = (templateInfo.Description) (Organisation.ofString templateInfo.Organisation) (templateInfo.Version) - (Array.ofList authors) - (Array.ofList ers) - (Array.ofList tags) + (ResizeArray authors) + (ResizeArray ers) + (ResizeArray tags) (lastUpdated) let toMetadataSheet (template : Template) : FsWorksheet =