Skip to content

Commit

Permalink
distribute template across appropriate projects
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Mar 26, 2024
1 parent 8af7487 commit 5f6c65b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 29 deletions.
4 changes: 1 addition & 3 deletions src/ARCtrl/ARCtrl.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
<Compile Include="Contracts\Contracts.ArcTypes.fs" />
<Compile Include="Contracts\Contracts.Git.fs" />
<Compile Include="Contracts\Contracts.ARCtrl.fs" />
<Compile Include="Templates\Templates.fs" />
<Compile Include="Templates\Template.Spreadsheet.fs" />
<Compile Include="Templates\Template.Web.fs" />
<Compile Include="Template.Web.fs" />
<Compile Include="ARC.fs" />
<Compile Include="Json.fs" />
<None Include="README.md" />
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/Core/ARCtrl.Core.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<Compile Include="Table\ArcTables.fs" />
<Compile Include="ArcTypes.fs" />
<Compile Include="Template.fs" />
<Compile Include="Templates.fs" />
<Compile Include="Conversion.fs" />
<Compile Include="IdentifierSetters.fs" />
</ItemGroup>
Expand Down
35 changes: 18 additions & 17 deletions src/ARCtrl/Templates/Templates.fs → src/Core/Templates.fs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -28,15 +29,15 @@ module TemplatesAux =
[<AttachMembers>]
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

/// <summary>
/// Returns all **distinct** `template.Tags` and `template.EndpointRepositories`
/// </summary>
/// <param name="templates"></param>
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

/// <summary>
/// Returns all **distinct** `template.Tags` and `template.EndpointRepositories`
Expand All @@ -56,8 +57,8 @@ type Templates =
/// </summary>
/// <param name="queryTags">The ontology annotation to filter by.</param>
/// <param name="matchAll">Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template.</param>
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

Expand All @@ -66,8 +67,8 @@ type Templates =
/// </summary>
/// <param name="queryTags">The ontology annotation to filter by.</param>
/// <param name="matchAll">Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template.</param>
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

Expand All @@ -76,16 +77,16 @@ type Templates =
/// </summary>
/// <param name="queryTags">The ontology annotation to filter by.</param>
/// <param name="matchAll">Default: false. If true all `queryTags` must be contained in template, if false only 1 tags must be contained in template.</param>
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

/// <summary>
/// Filters templates by template.Organisation = `Organisation.DataPLANT`/`"DataPLANT"`.
/// </summary>
/// <param name="templates"></param>
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())

4 changes: 4 additions & 0 deletions src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@
<Compile Include="ArcAssay.fs" />
<Compile Include="ArcStudy.fs" />
<Compile Include="ArcInvestigation.fs" />
<Compile Include="Template.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FsSpreadsheet" Version="5.1.3" />
</ItemGroup>
<ItemGroup>
<Content Include="*.fsproj; **\*.fs; **\*.fsi" PackagePath="fable\" />
</ItemGroup>
<ItemGroup>
<Content Remove="Template.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Core\ARCtrl.Core.fsproj" />
<ProjectReference Include="..\FileSystem\ARCtrl.FileSystem.fsproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}


Expand All @@ -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 =
Expand Down

0 comments on commit 5f6c65b

Please sign in to comment.