diff --git a/src/ARCtrl/WebRequest/WebRequest.Node.fs b/src/ARCtrl/WebRequest/WebRequest.Node.fs
index 1a239003..6886c2eb 100644
--- a/src/ARCtrl/WebRequest/WebRequest.Node.fs
+++ b/src/ARCtrl/WebRequest/WebRequest.Node.fs
@@ -1,9 +1,9 @@
-module ARCtrl.WebRequestHelpers.NodeJs
+module ARCtrl.WebRequestHelpers.NodeJs
+#if FABLE_COMPILER_JAVASCRIPT
open Fable.Core
open Fable.SimpleHttp
-#if FABLE_COMPILER_JAVASCRIPT
open Fable.Core.JsInterop
open Fable.SimpleHttp
diff --git a/src/Json/ARC.fs b/src/Json/ARC.fs
index 781bd642..a129ec8c 100644
--- a/src/Json/ARC.fs
+++ b/src/Json/ARC.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
@@ -17,8 +17,8 @@ module ARC =
Encode.tryInclude "@type" Encode.string (Some "CreativeWork")
Encode.tryInclude "@id" Encode.string (Some "ro-crate-metadata.json")
Encode.tryInclude "about" Investigation.ROCrate.encoder (Some isa)
- "conformsTo", ROCrateContext.ROCrate.conformsTo_jsonvalue
- "@context", ROCrateContext.ROCrate.context_jsonvalue
+ "conformsTo", ROCrateContext.ROCrate.conformsTo_jsonvalue |> Some
+ "@context", ROCrateContext.ROCrate.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/ARCtrl.Json.fsproj b/src/Json/ARCtrl.Json.fsproj
index aa191f3b..e7ae82e5 100644
--- a/src/Json/ARCtrl.Json.fsproj
+++ b/src/Json/ARCtrl.Json.fsproj
@@ -82,10 +82,10 @@
-
-
-
-
+
+
+
+
diff --git a/src/Json/Assay.fs b/src/Json/Assay.fs
index 97b6d51a..65b48863 100644
--- a/src/Json/Assay.fs
+++ b/src/Json/Assay.fs
@@ -11,7 +11,7 @@ module Assay =
let encoder (assay:ArcAssay) =
[
- "Identifier", Encode.string assay.Identifier
+ "Identifier", Encode.string assay.Identifier |> Some
Encode.tryInclude "MeasurementType" OntologyAnnotation.encoder assay.MeasurementType
Encode.tryInclude "TechnologyType" OntologyAnnotation.encoder assay.TechnologyType
Encode.tryInclude "TechnologyPlatform" OntologyAnnotation.encoder assay.TechnologyPlatform
@@ -43,7 +43,7 @@ module Assay =
let encoderCompressed (stringTable : StringTableMap) (oaTable : OATableMap) (cellTable : CellTableMap) (assay:ArcAssay) =
[
- "Identifier", Encode.string assay.Identifier
+ "Identifier", Encode.string assay.Identifier |> Some
Encode.tryInclude "MeasurementType" OntologyAnnotation.encoder assay.MeasurementType
Encode.tryInclude "TechnologyType" OntologyAnnotation.encoder assay.TechnologyType
Encode.tryInclude "TechnologyPlatform" OntologyAnnotation.encoder assay.TechnologyPlatform
@@ -84,11 +84,11 @@ module Assay =
let dataFiles = ProcessSequence.getData processes
[
- "@id", Encode.string (a |> genID)
- "@type", (Encode.list [ Encode.string "Assay"])
- "additionalType", Encode.string "Assay"
- "identifier", Encode.string a.Identifier
- "filename", Encode.string fileName
+ "@id", Encode.string (a |> genID) |> Some
+ "@type", (Encode.list [ Encode.string "Assay"]) |> Some
+ "additionalType", Encode.string "Assay" |> Some
+ "identifier", Encode.string a.Identifier |> Some
+ "filename", Encode.string fileName |> Some
Encode.tryInclude "measurementType" OntologyAnnotation.ROCrate.encoderPropertyValue a.MeasurementType
Encode.tryInclude "technologyType" OntologyAnnotation.ROCrate.encoderDefinedTerm a.TechnologyType
Encode.tryInclude "technologyPlatform" OntologyAnnotation.ROCrate.encoderDefinedTerm a.TechnologyPlatform
@@ -96,7 +96,7 @@ module Assay =
Encode.tryIncludeList "dataFiles" Data.ROCrate.encoder dataFiles
Encode.tryIncludeList "processSequence" (Process.ROCrate.encoder studyName (Some a.Identifier)) processes
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoder a.Comments
- "@context", ROCrateContext.Assay.context_jsonvalue
+ "@context", ROCrateContext.Assay.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -139,7 +139,7 @@ module Assay =
|> Encode.tryIncludeList "dataFiles" (Data.ISAJson.encoder idMap)
let units = ProcessSequence.getUnits processes
[
- "filename", Encode.string fileName
+ "filename", Encode.string fileName |> Some
Encode.tryInclude "@id" Encode.string (ROCrate.genID a |> Some)
Encode.tryInclude "measurementType" (OntologyAnnotation.ISAJson.encoder idMap) a.MeasurementType
Encode.tryInclude "technologyType" (OntologyAnnotation.ISAJson.encoder idMap) a.TechnologyType
@@ -199,7 +199,7 @@ module AssayExtensions =
static member fromCompressedJsonString (s: string) =
try Decode.fromJsonString (Compression.decode Assay.decoderCompressed) s with
- | e -> failwithf "Error. Unable to parse json string to ArcStudy: %s" e.Message
+ | e -> failwithf "Error. Unable to parse json string to ArcAssay: %s" e.Message
static member toCompressedJsonString(?spaces) =
fun (obj:ArcAssay) ->
diff --git a/src/Json/Comment.fs b/src/Json/Comment.fs
index 8ac0926b..00384d2c 100644
--- a/src/Json/Comment.fs
+++ b/src/Json/Comment.fs
@@ -32,11 +32,11 @@ module Comment =
let encoder (comment : Comment) =
[
- "@id", Encode.string (comment |> genID)
- "@type", Encode.string "Comment"
+ "@id", Encode.string (comment |> genID) |> Some
+ "@type", Encode.string "Comment" |> Some
Encode.tryInclude "name" Encode.string (comment.Name)
Encode.tryInclude "value" Encode.string (comment.Value)
- "@context", ROCrateContext.Comment.context_jsonvalue
+ "@context", ROCrateContext.Comment.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Data.fs b/src/Json/Data.fs
index 42986661..1f969ceb 100644
--- a/src/Json/Data.fs
+++ b/src/Json/Data.fs
@@ -76,14 +76,14 @@ module Data =
let encoder (oa : Data) =
[
- "@id", Encode.string (oa |> genID)
- "@type", (Encode.list [Encode.string "Data"])
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", (Encode.list [Encode.string "Data"]) |> Some
Encode.tryInclude "name" Encode.string (oa.Name)
Encode.tryInclude "type" DataFile.ROCrate.encoder oa.DataType
Encode.tryInclude "encodingFormat" Encode.string oa.Format
Encode.tryInclude "usageInfo" Encode.string oa.SelectorFormat
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoder oa.Comments
- "@context", ROCrateContext.Data.context_jsonvalue
+ "@context", ROCrateContext.Data.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/DataMap/DataContext.fs b/src/Json/DataMap/DataContext.fs
index ff868359..b7edbca7 100644
--- a/src/Json/DataMap/DataContext.fs
+++ b/src/Json/DataMap/DataContext.fs
@@ -11,7 +11,7 @@ module DataContext =
let encoder (dc:DataContext) =
[
- "data", Data.encoder dc
+ "data", Data.encoder dc |> Some
Encode.tryInclude "explication" OntologyAnnotation.encoder dc.Explication
Encode.tryInclude "unit" OntologyAnnotation.encoder dc.Unit
Encode.tryInclude "objectType" OntologyAnnotation.encoder dc.ObjectType
diff --git a/src/Json/Encode.fs b/src/Json/Encode.fs
index 4b480dcb..72f38233 100644
--- a/src/Json/Encode.fs
+++ b/src/Json/Encode.fs
@@ -14,7 +14,7 @@ open Fable.Core.JsInterop
[]
module Encode =
- let inline toJsonString spaces (value : Json) =
+ let inline toJsonString spaces (value : IEncodable) =
#if FABLE_COMPILER_PYTHON
Thoth.Json.Python.Encode.toString spaces value
#endif
@@ -25,44 +25,43 @@ module Encode =
Thoth.Json.Newtonsoft.Encode.toString spaces value
#endif
- let inline choose (kvs : (string * Json) list) =
+ let inline choose (kvs : (string * IEncodable option) list) =
kvs
- |> List.choose (fun (k,v) ->
- if v = Encode.nil then None
- else Some (k,v)
+ |> List.choose (fun (k,v) ->
+ v
+ |> Option.map (fun v -> k,v)
)
/// Try to encode the given object using the given encoder, or return Encode.nil if the object is null
- let tryInclude (name : string) (encoder : 'Value -> Json) (value : 'Value option) =
+ let tryInclude (name : string) (encoder : 'Value -> IEncodable) (value : 'Value option) =
name,
- match value with
- | Some(o) -> encoder o
- | _ -> Encode.nil
+ value
+ |> Option.map encoder
/// Try to encode the given object using the given encoder, or return Encode.nil if the object is null
- let tryIncludeSeq name (encoder : 'Value -> Json) (value : #seq<'Value>) =
+ let tryIncludeSeq name (encoder : 'Value -> IEncodable) (value : #seq<'Value>) =
name,
- if Seq.isEmpty value then Encode.nil
- else value |> Seq.map encoder |> Encode.seq
+ if Seq.isEmpty value then None
+ else value |> Seq.map encoder |> Encode.seq |> Some
- let tryIncludeArray name (encoder : 'Value -> Json) (value : 'Value array) =
+ let tryIncludeArray name (encoder : 'Value -> IEncodable) (value : 'Value array) =
name,
- if Array.isEmpty value then Encode.nil
- else value |> Array.map encoder |> Encode.array
+ if Array.isEmpty value then None
+ else value |> Array.map encoder |> Encode.array |> Some
- let tryIncludeList name (encoder : 'Value -> Json) (value : 'Value list) =
+ let tryIncludeList name (encoder : 'Value -> IEncodable) (value : 'Value list) =
name,
- if List.isEmpty value then Encode.nil
- else value |> List.map encoder |> Encode.list
+ if List.isEmpty value then None
+ else value |> List.map encoder |> Encode.list |> Some
- let tryIncludeListOpt name (encoder : 'Value -> Json) (value : 'Value list option) =
+ let tryIncludeListOpt name (encoder : 'Value -> IEncodable) (value : 'Value list option) =
name,
match value with
| Some(o) ->
- if List.isEmpty o then Encode.nil
- else o |> List.map encoder |> Encode.list
+ if List.isEmpty o then None
+ else o |> List.map encoder |> Encode.list |> Some
| _ ->
- Encode.nil
+ None
let DefaultSpaces = 0
diff --git a/src/Json/IDTable.fs b/src/Json/IDTable.fs
index b1fa4b11..34fcc3a5 100644
--- a/src/Json/IDTable.fs
+++ b/src/Json/IDTable.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open System.Collections.Generic
open Thoth.Json.Core
@@ -8,7 +8,7 @@ open ARCtrl.Helper
module IDTable =
- type IDTableWrite = Dictionary
+ type IDTableWrite = Dictionary
type IDTableRead = Dictionary
@@ -16,7 +16,7 @@ module IDTable =
["@id",Encode.string id]
|> Encode.object
- let encode (genID: 'Value -> URI) (encoder : 'Value -> Json) (value : 'Value) (table:IDTableWrite) =
+ let encode (genID: 'Value -> URI) (encoder : 'Value -> IEncodable) (value : 'Value) (table:IDTableWrite) =
let id = genID value
if table.ContainsKey id then
encodeID id
diff --git a/src/Json/Investigation.fs b/src/Json/Investigation.fs
index a34e148a..49a54c8c 100644
--- a/src/Json/Investigation.fs
+++ b/src/Json/Investigation.fs
@@ -9,7 +9,7 @@ module Investigation =
let encoder (inv : ArcInvestigation) =
[
- "Identifier", Encode.string inv.Identifier
+ "Identifier", Encode.string inv.Identifier |> Some
Encode.tryInclude "Title" Encode.string inv.Title
Encode.tryInclude "Description" Encode.string inv.Description
Encode.tryInclude "SubmissionDate" Encode.string inv.SubmissionDate
@@ -50,7 +50,7 @@ module Investigation =
let encoderCompressed (stringTable : StringTableMap) (oaTable : OATableMap) (cellTable : CellTableMap) (inv : ArcInvestigation) =
[
- "Identifier", Encode.string inv.Identifier
+ "Identifier", Encode.string inv.Identifier |> Some
Encode.tryInclude "Title" Encode.string inv.Title
Encode.tryInclude "Description" Encode.string inv.Description
Encode.tryInclude "SubmissionDate" Encode.string inv.SubmissionDate
@@ -100,11 +100,11 @@ module Investigation =
let encoder (oa : ArcInvestigation) =
[
- "@id", Encode.string (oa |> genID)
- "@type", Encode.string "Investigation"
- "additionalType", Encode.string "Investigation"
- "identifier", Encode.string oa.Identifier
- "filename", Encode.string ArcInvestigation.FileName
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", Encode.string "Investigation" |> Some
+ "additionalType", Encode.string "Investigation" |> Some
+ "identifier", Encode.string oa.Identifier |> Some
+ "filename", Encode.string ArcInvestigation.FileName |> Some
Encode.tryInclude "title" Encode.string oa.Title
Encode.tryInclude "description" Encode.string oa.Description
Encode.tryInclude "submissionDate" Encode.string oa.SubmissionDate
@@ -114,7 +114,7 @@ module Investigation =
Encode.tryIncludeSeq "people" Person.ROCrate.encoder oa.Contacts
Encode.tryIncludeSeq "studies" (Study.ROCrate.encoder None) oa.Studies
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoder oa.Comments
- "@context", ROCrateContext.Investigation.context_jsonvalue
+ "@context", ROCrateContext.Investigation.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -155,8 +155,8 @@ module Investigation =
Encode.tryInclude "@type" Encode.string (Some "CreativeWork")
Encode.tryInclude "@id" Encode.string (Some "ro-crate-metadata.json")
Encode.tryInclude "about" encoder (Some oa)
- "conformsTo", ROCrateContext.ROCrate.conformsTo_jsonvalue
- "@context", ROCrateContext.ROCrate.context_jsonvalue
+ "conformsTo", ROCrateContext.ROCrate.conformsTo_jsonvalue |> Some
+ "@context", ROCrateContext.ROCrate.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -167,9 +167,9 @@ module Investigation =
let encoder idMap (inv: ArcInvestigation) =
[
- "@id", Encode.string (inv |> ROCrate.genID)
- "filename", Encode.string ArcInvestigation.FileName
- "identifier", Encode.string (inv.Identifier)
+ "@id", Encode.string (inv |> ROCrate.genID) |> Some
+ "filename", Encode.string ArcInvestigation.FileName |> Some
+ "identifier", Encode.string (inv.Identifier) |> Some
Encode.tryInclude "title" Encode.string (inv.Title)
Encode.tryInclude "description" Encode.string (inv.Description)
Encode.tryInclude "submissionDate" Encode.string (inv.SubmissionDate)
diff --git a/src/Json/OntologyAnnotation.fs b/src/Json/OntologyAnnotation.fs
index 2ea0dbf1..bb2a2cd0 100644
--- a/src/Json/OntologyAnnotation.fs
+++ b/src/Json/OntologyAnnotation.fs
@@ -79,13 +79,13 @@ module OntologyAnnotation =
let encoderDefinedTerm (oa : OntologyAnnotation) =
[
- "@id", Encode.string (oa |> genID)
- "@type", Encode.string "OntologyAnnotation"
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", Encode.string "OntologyAnnotation" |> Some
Encode.tryInclude "annotationValue" Encode.string (oa.Name)
Encode.tryInclude "termSource" Encode.string (oa.TermSourceREF)
Encode.tryInclude "termAccession" Encode.string (oa.TermAccessionNumber)
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoderDisambiguatingDescription (oa.Comments)
- "@context", ROCrateContext.OntologyAnnotation.context_jsonvalue
+ "@context", ROCrateContext.OntologyAnnotation.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -102,13 +102,13 @@ module OntologyAnnotation =
let encoderPropertyValue (oa : OntologyAnnotation) =
[
- "@id", Encode.string (oa |> genID)
- "@type", Encode.string "PropertyValue"
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", Encode.string "PropertyValue" |> Some
Encode.tryInclude "category" Encode.string oa.Name
Encode.tryInclude "categoryCode" Encode.string oa.TermAccessionNumber
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoderDisambiguatingDescription (oa.Comments)
- "@context", ROCrateContext.PropertyValue.context_jsonvalue
+ "@context", ROCrateContext.PropertyValue.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/OntologySourceReference.fs b/src/Json/OntologySourceReference.fs
index 4bb17177..90d34a01 100644
--- a/src/Json/OntologySourceReference.fs
+++ b/src/Json/OntologySourceReference.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
open ARCtrl
@@ -42,14 +42,14 @@ module OntologySourceReference =
let encoder (osr : OntologySourceReference) =
[
- "@id", Encode.string (osr |> genID)
- "@type", Encode.string "OntologySourceReference"
+ "@id", Encode.string (osr |> genID) |> Some
+ "@type", Encode.string "OntologySourceReference" |> Some
Encode.tryInclude "description" Encode.string (osr.Description)
Encode.tryInclude "file" Encode.string (osr.File)
Encode.tryInclude "name" Encode.string (osr.Name)
Encode.tryInclude "version" Encode.string (osr.Version)
Encode.tryIncludeSeq "comments" Comment.encoder (osr.Comments)
- "@context", ROCrateContext.OntologySourceReference.context_jsonvalue
+ "@context", ROCrateContext.OntologySourceReference.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Person.fs b/src/Json/Person.fs
index a6fd6d3a..11838e5b 100644
--- a/src/Json/Person.fs
+++ b/src/Json/Person.fs
@@ -81,8 +81,8 @@ module Person =
let encoder (oa : Person) =
[
- "@id", Encode.string (oa |> genID)
- "@type", Encode.string "Person"
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", Encode.string "Person" |> Some
Encode.tryInclude "orcid" Encode.string oa.ORCID
Encode.tryInclude "firstName" Encode.string oa.FirstName
Encode.tryInclude "lastName" Encode.string oa.LastName
@@ -94,7 +94,7 @@ module Person =
Encode.tryInclude "affiliation" Affiliation.encoder oa.Affiliation
Encode.tryIncludeSeq "roles" OntologyAnnotation.ROCrate.encoderDefinedTerm oa.Roles
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoderDisambiguatingDescription oa.Comments
- "@context", ROCrateContext.Person.context_jsonvalue
+ "@context", ROCrateContext.Person.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -133,9 +133,9 @@ module Person =
let names = authorList.Split([|separator|], System.StringSplitOptions.None) |> Array.map (fun s -> s.Trim())
let encodeSingle (name:string) =
[
- "@type", Encode.string "Person"
+ "@type", Encode.string "Person" |> Some
Encode.tryInclude "name" Encode.string (Some name)
- "@context", ROCrateContext.Person.contextMinimal_jsonValue
+ "@context", ROCrateContext.Person.contextMinimal_jsonValue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Process/Component.fs b/src/Json/Process/Component.fs
index 003def93..13c95a57 100644
--- a/src/Json/Process/Component.fs
+++ b/src/Json/Process/Component.fs
@@ -10,7 +10,7 @@ module Component =
module ROCrate =
- let encoder : Component -> Json=
+ let encoder : Component -> IEncodable =
PropertyValue.ROCrate.encoder
let decoder : Decoder =
diff --git a/src/Json/Process/FactorValue.fs b/src/Json/Process/FactorValue.fs
index 59408c32..640b9f4f 100644
--- a/src/Json/Process/FactorValue.fs
+++ b/src/Json/Process/FactorValue.fs
@@ -12,7 +12,7 @@ module FactorValue =
module ROCrate =
- let encoder : FactorValue -> Json=
+ let encoder : FactorValue -> IEncodable =
PropertyValue.ROCrate.encoder
let decoder : Decoder =
diff --git a/src/Json/Process/Material.fs b/src/Json/Process/Material.fs
index d724b746..9173c25e 100644
--- a/src/Json/Process/Material.fs
+++ b/src/Json/Process/Material.fs
@@ -18,13 +18,13 @@ module Material =
let rec encoder (oa : Material) =
[
- "@id", Encode.string (oa |> genID)
- "@type", (Encode.list [Encode.string "Material"])
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", (Encode.list [Encode.string "Material"]) |> Some
Encode.tryInclude "name" Encode.string oa.Name
Encode.tryInclude "type" MaterialType.ROCrate.encoder oa.MaterialType
Encode.tryIncludeListOpt "characteristics" MaterialAttributeValue.ROCrate.encoder oa.Characteristics
Encode.tryIncludeListOpt "derivesFrom" encoder oa.DerivesFrom
- "@context", ROCrateContext.Material.context_jsonvalue
+ "@context", ROCrateContext.Material.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Process/MaterialAttributeValue.fs b/src/Json/Process/MaterialAttributeValue.fs
index 71e79a7d..afd1b047 100644
--- a/src/Json/Process/MaterialAttributeValue.fs
+++ b/src/Json/Process/MaterialAttributeValue.fs
@@ -10,7 +10,7 @@ module MaterialAttributeValue =
module ROCrate =
- let encoder : MaterialAttributeValue -> Json=
+ let encoder : MaterialAttributeValue -> IEncodable =
PropertyValue.ROCrate.encoder
let decoder : Decoder =
diff --git a/src/Json/Process/Process.fs b/src/Json/Process/Process.fs
index d00eaa23..f1a1b46e 100644
--- a/src/Json/Process/Process.fs
+++ b/src/Json/Process/Process.fs
@@ -18,8 +18,8 @@ module Process =
let encoder (studyName:string Option) (assayName:string Option) (oa : Process) =
[
- "@id", Encode.string (oa |> genID)
- "@type", (Encode.list [Encode.string "Process"])
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", (Encode.list [Encode.string "Process"]) |> Some
Encode.tryInclude "name" Encode.string (oa.Name)
Encode.tryInclude "executesProtocol" (Protocol.ROCrate.encoder studyName assayName oa.Name) (oa.ExecutesProtocol)
Encode.tryIncludeListOpt "parameterValues" ProcessParameterValue.ROCrate.encoder (oa.ParameterValues)
@@ -28,7 +28,7 @@ module Process =
Encode.tryIncludeListOpt "inputs" ProcessInput.ROCrate.encoder (oa.Inputs)
Encode.tryIncludeListOpt "outputs" ProcessOutput.ROCrate.encoder (oa.Outputs)
Encode.tryIncludeListOpt "comments" Comment.ROCrate.encoder (oa.Comments)
- "@context", ROCrateContext.Process.context_jsonvalue
+ "@context", ROCrateContext.Process.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Process/ProcessParameterValue.fs b/src/Json/Process/ProcessParameterValue.fs
index 19ad84c1..1768fdec 100644
--- a/src/Json/Process/ProcessParameterValue.fs
+++ b/src/Json/Process/ProcessParameterValue.fs
@@ -9,7 +9,7 @@ module ProcessParameterValue =
module ROCrate =
- let encoder : ProcessParameterValue -> Json=
+ let encoder : ProcessParameterValue -> IEncodable =
PropertyValue.ROCrate.encoder
let decoder : Decoder =
diff --git a/src/Json/Process/Protocol.fs b/src/Json/Process/Protocol.fs
index 5460c6d3..0586e1c2 100644
--- a/src/Json/Process/Protocol.fs
+++ b/src/Json/Process/Protocol.fs
@@ -27,8 +27,8 @@ module Protocol =
let encoder (studyName:string Option) (assayName:string Option) (processName:string Option) (oa : Protocol) =
[
- "@id", Encode.string (genID studyName assayName processName oa)
- "@type", (Encode.list [Encode.string "Protocol"])
+ "@id", Encode.string (genID studyName assayName processName oa) |> Some
+ "@type", (Encode.list [Encode.string "Protocol"]) |> Some
Encode.tryInclude "name" Encode.string (oa.Name)
Encode.tryInclude "protocolType" OntologyAnnotation.ROCrate.encoderDefinedTerm (oa.ProtocolType)
Encode.tryInclude "description" Encode.string (oa.Description)
@@ -36,7 +36,7 @@ module Protocol =
Encode.tryInclude "version" Encode.string (oa.Version)
Encode.tryIncludeListOpt "components" Component.ROCrate.encoder oa.Components
Encode.tryIncludeListOpt "comments" Comment.ROCrate.encoder oa.Comments
- "@context", ROCrateContext.Protocol.context_jsonvalue
+ "@context", ROCrateContext.Protocol.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Process/Sample.fs b/src/Json/Process/Sample.fs
index a4743d0f..eeeed337 100644
--- a/src/Json/Process/Sample.fs
+++ b/src/Json/Process/Sample.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
@@ -22,11 +22,11 @@ module Sample =
oa.Characteristics |> Option.defaultValue [] |> List.map MaterialAttributeValue.ROCrate.encoder
|> List.append (oa.FactorValues |> Option.defaultValue [] |> List.map FactorValue.ROCrate.encoder)
[
- "@id", Encode.string (oa |> genID)
- "@type", (Encode.list [ Encode.string "Sample"])
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", (Encode.list [ Encode.string "Sample"]) |> Some
Encode.tryInclude "name" Encode.string (oa.Name)
Encode.tryIncludeList "additionalProperties" id additionalProperties
- "@context", ROCrateContext.Sample.context_jsonvalue
+ "@context", ROCrateContext.Sample.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Process/Source.fs b/src/Json/Process/Source.fs
index 6a4af31b..fdf39e50 100644
--- a/src/Json/Process/Source.fs
+++ b/src/Json/Process/Source.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
@@ -18,11 +18,11 @@ module Source =
let rec encoder (oa : Source) =
[
- "@id", Encode.string (oa |> genID)
- "@type", (Encode.list [ Encode.string "Source"])
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", (Encode.list [ Encode.string "Source"]) |> Some
Encode.tryInclude "name" Encode.string (oa.Name)
Encode.tryIncludeListOpt "characteristics" MaterialAttributeValue.ROCrate.encoder (oa.Characteristics)
- "@context", ROCrateContext.Source.context_jsonvalue
+ "@context", ROCrateContext.Source.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/PropertyValue.fs b/src/Json/PropertyValue.fs
index ed96feeb..2f1bfbe0 100644
--- a/src/Json/PropertyValue.fs
+++ b/src/Json/PropertyValue.fs
@@ -38,9 +38,9 @@ module PropertyValue =
oa.Name, oa.TermAccessionNumber
| None -> None, None
[
- "@id", Encode.string (pv |> genID)
- "@type", Encode.string "PropertyValue"
- "additionalType", Encode.string (pv.GetAdditionalType())
+ "@id", Encode.string (pv |> genID) |> Some
+ "@type", Encode.string "PropertyValue" |> Some
+ "additionalType", Encode.string (pv.GetAdditionalType()) |> Some
Encode.tryInclude "alternateName" Encode.string (pv.AlternateName())
Encode.tryInclude "measurementMethod" Encode.string (pv.MeasurementMethod())
Encode.tryInclude "description" Encode.string (pv.Description())
@@ -50,7 +50,7 @@ module PropertyValue =
Encode.tryInclude "valueCode" id valueCode
Encode.tryInclude "unit" Encode.string unit
Encode.tryInclude "unitCode" Encode.string unitCode
- "@context", ROCrateContext.PropertyValue.context_jsonvalue
+ "@context", ROCrateContext.PropertyValue.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Publication.fs b/src/Json/Publication.fs
index c841e00c..5a12b226 100644
--- a/src/Json/Publication.fs
+++ b/src/Json/Publication.fs
@@ -46,15 +46,15 @@ module Publication =
let encoder (oa : Publication) =
[
- "@id", Encode.string (oa |> genID)
- "@type", Encode.string "Publication"
+ "@id", Encode.string (oa |> genID) |> Some
+ "@type", Encode.string "Publication" |> Some
Encode.tryInclude "pubMedID" Encode.string oa.PubMedID
Encode.tryInclude "doi" Encode.string (oa.DOI)
Encode.tryInclude "authorList" Person.ROCrate.encodeAuthorListString oa.Authors
Encode.tryInclude "title" Encode.string (oa.Title)
Encode.tryInclude "status" OntologyAnnotation.ROCrate.encoderDefinedTerm oa.Status
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoderDisambiguatingDescription oa.Comments
- "@context", ROCrateContext.Publication.context_jsonvalue
+ "@context", ROCrateContext.Publication.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
diff --git a/src/Json/Study.fs b/src/Json/Study.fs
index 020ac31c..0bb5489a 100644
--- a/src/Json/Study.fs
+++ b/src/Json/Study.fs
@@ -28,7 +28,7 @@ module Study =
let encoder (study:ArcStudy) =
[
- "Identifier", Encode.string study.Identifier
+ "Identifier", Encode.string study.Identifier |> Some
Encode.tryInclude "Title" Encode.string study.Title
Encode.tryInclude "Description" Encode.string study.Description
Encode.tryInclude "SubmissionDate" Encode.string study.SubmissionDate
@@ -68,7 +68,7 @@ module Study =
let encoderCompressed (stringTable : StringTableMap) (oaTable : OATableMap) (cellTable : CellTableMap) (study:ArcStudy) =
[
- "Identifier", Encode.string study.Identifier
+ "Identifier", Encode.string study.Identifier |> Some
Encode.tryInclude "Title" Encode.string study.Title
Encode.tryInclude "Description" Encode.string study.Description
Encode.tryInclude "SubmissionDate" Encode.string study.SubmissionDate
@@ -116,10 +116,10 @@ module Study =
let processes = s.GetProcesses()
let assays = Helper.getAssayInformation assays s
[
- "@id", Encode.string (s |> genID)
- "@type", (Encode.list [Encode.string "Study"])
- "additionalType", Encode.string "Study"
- "identifier", Encode.string (s.Identifier)
+ "@id", Encode.string (s |> genID) |> Some
+ "@type", (Encode.list [Encode.string "Study"]) |> Some
+ "additionalType", Encode.string "Study" |> Some
+ "identifier", Encode.string (s.Identifier) |> Some
Encode.tryInclude "filename" Encode.string fileName
Encode.tryInclude "title" Encode.string (s.Title)
Encode.tryInclude "description" Encode.string (s.Description)
@@ -131,7 +131,7 @@ module Study =
Encode.tryIncludeList "processSequence" (Process.ROCrate.encoder (Some s.Identifier) None) processes
Encode.tryIncludeSeq "assays" (Assay.ROCrate.encoder (Some s.Identifier)) assays
Encode.tryIncludeSeq "comments" Comment.ROCrate.encoder s.Comments
- "@context", ROCrateContext.Study.context_jsonvalue
+ "@context", ROCrateContext.Study.context_jsonvalue |> Some
]
|> Encode.choose
|> Encode.object
@@ -205,9 +205,9 @@ module Study =
ProcessSequence.getProtocols processes
|> Encode.tryIncludeList "protocols" (Protocol.ISAJson.encoder (Some s.Identifier) None None idMap)
[
- "@id", Encode.string (study |> ROCrate.genID)
- "filename", Encode.string fileName
- "identifier", Encode.string study.Identifier
+ "@id", Encode.string (study |> ROCrate.genID) |> Some
+ "filename", Encode.string fileName |> Some
+ "identifier", Encode.string study.Identifier |> Some
Encode.tryInclude "title" Encode.string study.Title
Encode.tryInclude "description" Encode.string study.Description
Encode.tryInclude "submissionDate" Encode.string study.SubmissionDate
diff --git a/src/Json/Table/Compression.fs b/src/Json/Table/Compression.fs
index 2a56fa63..a6376fc9 100644
--- a/src/Json/Table/Compression.fs
+++ b/src/Json/Table/Compression.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
@@ -9,16 +9,21 @@ open System.Collections.Generic
/// This module is used to generalize json compression helpers
module Compression =
- let encode (encoder: Dictionary -> Dictionary -> Dictionary -> 'A -> Json) (obj: 'A) =
- let stringTable = Dictionary()
- let oaTable = Dictionary()
- let cellTable = Dictionary()
- let arcStudy = encoder stringTable oaTable cellTable obj
+ let encode (encoder: Dictionary -> Dictionary -> Dictionary -> 'A -> IEncodable) (obj: 'A) =
+ let stringTable = Dictionary()
+ let oaTable = Dictionary()
+ let cellTable = Dictionary()
+ let object = encoder stringTable oaTable cellTable obj
+ object |> Encode.toJsonString 0 |> ignore
+ let encodedCellTable = CellTable.arrayFromMap cellTable |> CellTable.encoder stringTable oaTable
+ let encodedOATable = OATable.arrayFromMap oaTable |> OATable.encoder stringTable
+ let encodedStringTable = StringTable.arrayFromMap stringTable |> StringTable.encoder
+
Encode.object [
- "cellTable", CellTable.arrayFromMap cellTable |> CellTable.encoder stringTable oaTable
- "oaTable", OATable.arrayFromMap oaTable |> OATable.encoder stringTable
- "stringTable", StringTable.arrayFromMap stringTable |> StringTable.encoder
- "object", arcStudy
+ "cellTable", encodedCellTable
+ "oaTable", encodedOATable
+ "stringTable", encodedStringTable
+ "object", object
]
let decode (decoder) =
diff --git a/src/Json/Table/Templates.fs b/src/Json/Table/Templates.fs
index 56577960..fafea678 100644
--- a/src/Json/Table/Templates.fs
+++ b/src/Json/Table/Templates.fs
@@ -1,4 +1,4 @@
-namespace ARCtrl.Json
+namespace ARCtrl.Json
open Thoth.Json.Core
@@ -28,9 +28,9 @@ module Template =
"description", Encode.string template.Description
"organisation", Organisation.encoder template.Organisation
"version", Encode.string template.Version
- Encode.tryIncludeSeq "authors" Person.encoder template.Authors
- Encode.tryIncludeSeq "endpoint_repositories" OntologyAnnotation.encoder template.EndpointRepositories
- Encode.tryIncludeSeq "tags" OntologyAnnotation.encoder template.Tags
+ "authors", (template.Authors |> Seq.map Person.encoder |> Encode.seq)
+ "endpoint_repositories", (template.EndpointRepositories |> Seq.map OntologyAnnotation.encoder |> Encode.seq)
+ "tags", (template.Tags |> Seq.map OntologyAnnotation.encoder |> Encode.seq)
"last_updated", Encode.dateTime template.LastUpdated
]
@@ -52,15 +52,15 @@ module Template =
let encoderCompressed stringTable oaTable cellTable (template: Template) =
Encode.object [
- "id", Encode.guid template.Id
+ "id", Encode.guid template.Id
"table", ArcTable.encoderCompressed stringTable oaTable cellTable template.Table
"name", Encode.string template.Name
"description", Encode.string template.Description
"organisation", Organisation.encoder template.Organisation
"version", Encode.string template.Version
- Encode.tryIncludeSeq "authors" Person.encoder template.Authors
- Encode.tryIncludeSeq "endpoint_repositories" OntologyAnnotation.encoder template.EndpointRepositories
- Encode.tryIncludeSeq "tags" OntologyAnnotation.encoder template.Tags
+ "authors", (template.Authors |> Seq.map Person.encoder |> Encode.seq)
+ "endpoint_repositories", (template.EndpointRepositories |> Seq.map OntologyAnnotation.encoder |> Encode.seq)
+ "tags", (template.Tags |> Seq.map OntologyAnnotation.encoder |> Encode.seq)
"last_updated", Encode.datetime template.LastUpdated
]
diff --git a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
index f1f6cada..a98bcabb 100644
--- a/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
+++ b/src/Spreadsheet/ARCtrl.Spreadsheet.fsproj
@@ -33,7 +33,7 @@
-
+