@@ -317,6 +317,14 @@ module ProcessParsing =
317317 |> Some
318318 | _ -> None
319319
320+ let tryGetCommentGetter ( generalI : int ) ( header : CompositeHeader ) =
321+ match header with
322+ | CompositeHeader.Comment c ->
323+ fun ( matrix : System.Collections.Generic.Dictionary <( int * int ), CompositeCell >) i ->
324+ Comment( c, matrix.[ generalI, i]. AsFreeText)
325+ |> Some
326+ | _ -> None
327+
320328 /// Given the header sequence of an ArcTable, returns a function for parsing each row of the table to a process
321329 let getProcessGetter ( processNameRoot : string ) ( headers : CompositeHeader seq ) =
322330
@@ -366,6 +374,11 @@ module ProcessParsing =
366374 headers
367375 |> Seq.tryPick ( fun ( generalI , header ) -> tryGetProtocolVersionGetter generalI header)
368376
377+ let commentGetters =
378+ headers
379+ |> Seq.choose ( fun ( generalI , header ) -> tryGetCommentGetter generalI header)
380+ |> Seq.toList
381+
369382 // This is a little more complex, as data and material objects can't contain characteristics. So in the case where the input of the table is a data object but characteristics exist. An additional sample object with the same name is created to contain the characteristics.
370383 let inputGetter =
371384 match headers |> Seq.tryPick ( fun ( generalI , header ) -> tryGetInputGetter generalI header) with
@@ -418,6 +431,8 @@ module ProcessParsing =
418431 let paramvalues = parameterValueGetters |> List.map ( fun f -> f matrix i) |> Option.fromValueWithDefault []
419432 let parameters = paramvalues |> Option.map ( List.map ( fun pv -> pv.Category.Value))
420433
434+ let comments = commentGetters |> List.map ( fun f -> f matrix i) |> Option.fromValueWithDefault []
435+
421436 let protocol : Protocol option =
422437 Protocol.make
423438 None
@@ -462,7 +477,7 @@ module ProcessParsing =
462477 None
463478 ( Some inputs)
464479 ( Some outputs)
465- None
480+ comments
466481
467482 /// Groups processes by their name, or by the name of the protocol they execute
468483 ///
@@ -492,20 +507,20 @@ module ProcessParsing =
492507 processes
493508 |> List.groupBy ( fun x ->
494509 if x.Name.IsSome && ( x.Name.Value |> Process.decomposeName |> snd) .IsSome then
495- ( x.Name.Value |> Process.decomposeName |> fst), HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq
510+ ( x.Name.Value |> Process.decomposeName |> fst), HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq, x.Comments |> Option.map HashCodes.boxHashSeq
496511 elif x.ExecutesProtocol.IsSome && x.ExecutesProtocol.Value.Name.IsSome then
497- x.ExecutesProtocol.Value.Name.Value, HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq
512+ x.ExecutesProtocol.Value.Name.Value, HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq, x.Comments |> Option.map HashCodes.boxHashSeq
498513 else
499- Identifier.createMissingIdentifier(), HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq
514+ Identifier.createMissingIdentifier(), HashCodes.boxHashOption x.ExecutesProtocol, x.ParameterValues |> Option.map HashCodes.boxHashSeq, x.Comments |> Option.map HashCodes.boxHashSeq
500515 )
501516 |> fun l ->
502517 l
503- |> List.mapi ( fun i (( n , _ , _ ), processes ) ->
518+ |> List.mapi ( fun i (( n , _ , _ , _ ), processes ) ->
504519 let pVs = processes.[ 0 ]. ParameterValues
505520 let inputs = processes |> List.collect ( fun p -> p.Inputs |> Option.defaultValue []) |> Option.fromValueWithDefault []
506521 let outputs = processes |> List.collect ( fun p -> p.Outputs |> Option.defaultValue []) |> Option.fromValueWithDefault []
507522 let n = if l.Length > 1 then Process.composeName n i else n
508- Process.create( Name = n,? ExecutesProtocol = processes.[ 0 ]. ExecutesProtocol,? ParameterValues = pVs,? Inputs = inputs,? Outputs = outputs)
523+ Process.create( Name = n,? ExecutesProtocol = processes.[ 0 ]. ExecutesProtocol,? ParameterValues = pVs,? Inputs = inputs,? Outputs = outputs,? Comments = processes .[ 0 ]. Comments )
509524 )
510525
511526
@@ -530,6 +545,13 @@ module ProcessParsing =
530545 if prot.Version.IsSome then CompositeHeader.ProtocolVersion, CompositeCell.FreeText prot.Version.Value
531546 ]
532547 | None -> []
548+ let comments =
549+ p.Comments
550+ |> Option.defaultValue []
551+ |> List.map ( fun c ->
552+ CompositeHeader.Comment ( Option.defaultValue " " c.Name),
553+ CompositeCell.FreeText ( Option.defaultValue " " c.Value)
554+ )
533555 // zip the inputs and outpus so they are aligned as rows
534556 p.Outputs |> Option.defaultValue []
535557 |> List.zip ( p.Inputs |> Option.defaultValue [])
@@ -565,6 +587,7 @@ module ProcessParsing =
565587 yield JsonTypes.decomposeProcessInput inputForType
566588 yield ! protVals
567589 yield ! vals
590+ yield ! comments
568591 yield JsonTypes.decomposeProcessOutput outputForType
569592 ]
570593 )
0 commit comments