Skip to content

Commit

Permalink
Merge pull request #176 from nfdi4plants/hotfix_protocolHandling
Browse files Browse the repository at this point in the history
Hotfix protocol handling
  • Loading branch information
HLWeil authored Aug 17, 2023
2 parents 3d666dc + a3f2ed5 commit 21f56b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/ISA/ISA/ArcTypes/ArcTable.fs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ type ArcTable =
/// The table will have at most one row, with the protocol information and the component values
static member fromProtocol (p : Protocol) : ArcTable =

let t = ArcTable.init (p.Name |> Option.defaultValue "")
let t = ArcTable.init (p.Name |> Option.defaultValue (Identifier.createMissingIdentifier()))

for pp in p.Parameters |> Option.defaultValue [] do

Expand Down Expand Up @@ -506,13 +506,13 @@ type ArcTable =
let c = Component.create(ComponentType = oa)
Protocol.addComponent c p
| _ -> p
) Protocol.empty
) (Protocol.create(Name = this.Name))
|> List.singleton
else
List.init this.RowCount (fun i ->
this.GetRow(i)
|> Seq.zip this.Headers
|> CompositeRow.toProtocol
|> CompositeRow.toProtocol this.Name
)
|> List.distinct

Expand Down
4 changes: 2 additions & 2 deletions src/ISA/ISA/ArcTypes/CompositeRow.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module ARCtrl.ISA.CompositeRow

let toProtocol (row : (CompositeHeader*CompositeCell) seq) =
let toProtocol (tableName : string) (row : (CompositeHeader*CompositeCell) seq) =
row
|> Seq.fold (fun p hc ->
match hc with
Expand All @@ -20,4 +20,4 @@ let toProtocol (row : (CompositeHeader*CompositeCell) seq) =
let c = Component.create(ComponentType = oa, Value = Value.Ontology t)
Protocol.addComponent c p
| _ -> p
) Protocol.empty
) (Protocol.create(Name = tableName))
6 changes: 6 additions & 0 deletions tests/ISA/ISA.Tests/ArcJsonConversionTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ let private tests_protocolTransformation =
let t = p |> ArcTable.fromProtocol

Expect.equal t.ColumnCount 0 "ColumnCount should be 0"
Expect.isTrue (Identifier.isMissingIdentifier t.Name) $"Name should be missing identifier, not \"{t.Name}\""
)
testCase "FromProtocol SingleParameter" (fun () ->
let p = Protocol.create(Parameters = [pParam1])
Expand Down Expand Up @@ -580,7 +581,12 @@ let private tests_protocolTransformation =
let c = c.Value
Expect.equal c expected "Cell value does not match"
)
testCase "GetProtocols NoName" (fun () ->
let t = ArcTable.init "TestTable"
let expected = [Protocol.create(Name = "TestTable")]

TestingUtils.mySequenceEqual (t.GetProtocols()) expected "Protocol Name should be ArcTable name."
)
testCase "GetProtocols SingleName" (fun () ->
let t = ArcTable.init "TestTable"
let name = "Name"
Expand Down

0 comments on commit 21f56b2

Please sign in to comment.