Skip to content

Commit

Permalink
Merge pull request #456 from nfdi4plants/Feature_Template_EnableMetad…
Browse files Browse the repository at this point in the history
…ataSheetNameCheck

Enable check for metadata sheetname and is meta data sheet for arc template
  • Loading branch information
HLWeil authored Oct 21, 2024
2 parents 76e9b62 + cb87cba commit 35ee4ae
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/Spreadsheet/Template.fs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,16 @@ module Template =
(ResizeArray tags)
lastUpdated

let isMetadataSheetName (name : string) =
name = metaDataSheetName || name = obsoletemetaDataSheetName

let isMetadataSheet (sheet : FsWorksheet) =
isMetadataSheetName sheet.Name

let tryGetMetadataSheet (doc : FsWorkbook) =
doc.GetWorksheets()
|> Seq.tryFind isMetadataSheet

let toMetadataSheet (template : Template) : FsWorksheet =
let sheet = FsWorksheet(metaDataSheetName)
Template.toRows template
Expand All @@ -261,19 +271,15 @@ module Template =

/// Reads an assay from a spreadsheet
let fromFsWorkbook (doc : FsWorkbook) =
// Reading the "Assay" metadata sheet. Here metadata
let templateInfo, ers, tags, authors =

match doc.TryGetWorksheetByName metaDataSheetName with
// Reading the "Template" metadata sheet. Here metadata
let templateInfo, ers, tags, authors =
match tryGetMetadataSheet doc with
| Option.Some sheet ->
fromMetadataSheet sheet
| None ->
match doc.TryGetWorksheetByName obsoletemetaDataSheetName with
| Option.Some sheet ->
fromMetadataSheet sheet
| None ->
Metadata.Template.TemplateInfo.empty, [], [], []

| None ->
printfn "Could not find metadata sheet with sheetname \"isa_template\" or deprecated sheetname \"Template\""
Metadata.Template.TemplateInfo.empty, [], [], []

let tryTableNameMatches (ws : FsWorksheet) =
if ws.Tables |> Seq.exists (fun t -> t.Name = templateInfo.Table) then Some ws else None

Expand Down

0 comments on commit 35ee4ae

Please sign in to comment.