Skip to content

Commit

Permalink
fix study and assay xlsx write error
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Jul 19, 2022
1 parent 99e3ebb commit 7385792
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ISADotNet.QueryModel/Row.fs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type QRow =
(characteristics |> List.map Characteristic)
@ (parameters |> List.map Parameter)
@ (factors |> List.map Factor)
|> List.sortBy (fun v -> v.ValueIndex)
|> List.sortBy (fun v -> v.TryValueIndex |> Option.defaultValue System.Int32.MaxValue)

{
Input = Input |> Option.defaultValue ""
Expand Down
15 changes: 12 additions & 3 deletions src/ISADotNet.QueryModel/Value.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,16 @@ type ISAValue =
| Factor f -> f.ValueWithUnitText

member this.ValueIndex =
try
match this with
| Parameter p -> p.GetValueIndex()
| Characteristic c -> c.GetValueIndex()
| Factor f -> f.GetValueIndex()
with
| _ -> failwithf $"Value index could not be retrieved for value {this.NameText}"

member this.TryValueIndex =
match this with
| Parameter p -> p.GetValueIndex()
| Characteristic c -> c.GetValueIndex()
| Factor f -> f.GetValueIndex()
| Parameter p -> p.TryGetValueIndex()
| Characteristic c -> c.TryGetValueIndex()
| Factor f -> f.TryGetValueIndex()
24 changes: 24 additions & 0 deletions src/ISADotnet/ValueIndex.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,20 @@ module ValueIndexExtensions =

member this.GetValueIndex() = ValueIndex.tryGetFactorIndex this |> Option.get

static member tryGetValueIndex(f) = ValueIndex.tryGetFactorIndex f

member this.TryGetValueIndex() = ValueIndex.tryGetFactorIndex this

type FactorValue with

static member getValueIndex(f) = ValueIndex.tryGetFactorValueIndex f |> Option.get

member this.GetValueIndex() = ValueIndex.tryGetFactorValueIndex this |> Option.get

static member tryGetValueIndex(f) = ValueIndex.tryGetFactorValueIndex f

member this.TryGetValueIndex() = ValueIndex.tryGetFactorValueIndex this

type MaterialAttribute with

/// Create a ISAJson characteristic from ISATab string entries
Expand All @@ -86,12 +94,20 @@ module ValueIndexExtensions =

member this.GetValueIndex() = ValueIndex.tryGetCharacteristicIndex this |> Option.get

static member tryGetValueIndex(m) = ValueIndex.tryGetCharacteristicIndex m

member this.TryGetValueIndex() = ValueIndex.tryGetCharacteristicIndex this

type MaterialAttributeValue with

static member getValueIndex(m) = ValueIndex.tryGetCharacteristicValueIndex m |> Option.get

member this.GetValueIndex() = ValueIndex.tryGetCharacteristicValueIndex this |> Option.get

static member tryGetValueIndex(m) = ValueIndex.tryGetCharacteristicValueIndex m

member this.TryGetValueIndex() = ValueIndex.tryGetCharacteristicValueIndex this

type ProtocolParameter with

/// Create a ISAJson parameter from ISATab string entries
Expand All @@ -106,8 +122,16 @@ module ValueIndexExtensions =

member this.GetValueIndex() = ValueIndex.tryGetParameterIndex this |> Option.get

static member tryGetValueIndex(p) = ValueIndex.tryGetParameterIndex p

member this.TryGetValueIndex() = ValueIndex.tryGetParameterIndex this

type ProcessParameterValue with

static member getValueIndex(p) = ValueIndex.tryGetParameterValueIndex p |> Option.get

member this.GetValueIndex() = ValueIndex.tryGetParameterValueIndex this |> Option.get

static member tryGetValueIndex(p) = ValueIndex.tryGetParameterValueIndex p

member this.TryGetValueIndex() = ValueIndex.tryGetParameterValueIndex this

0 comments on commit 7385792

Please sign in to comment.