Skip to content

Commit

Permalink
#433: Add api functions for mandatory dynamic props on some classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 6, 2024
1 parent ac7e6d2 commit 7d1e733
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 37 deletions.
9 changes: 6 additions & 3 deletions src/ROCrate/ISAProfile/Assay.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ open Fable.Core
///
[<AttachMembers>]
type Assay(
id,
identifier,
id: string,
identifier: string,
?about,
?comment,
?creator,
Expand All @@ -28,4 +28,7 @@ type Assay(
DynObj.setValueOpt this (nameof comment) comment
DynObj.setValueOpt this (nameof creator) creator
DynObj.setValueOpt this (nameof hasPart) hasPart
DynObj.setValueOpt this (nameof url) url
DynObj.setValueOpt this (nameof url) url

member this.GetIdentifier() = DynObj.tryGetTypedValue<string> (nameof identifier) this |> Option.get
static member getIdentifier = fun (ass: Assay) -> ass.GetIdentifier()
7 changes: 5 additions & 2 deletions src/ROCrate/ISAProfile/Investigation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ open Fable.Core
///
[<AttachMembers>]
type Investigation(
id,
identifier,
id: string,
identifier: string,
?citation,
?comment,
?creator,
Expand Down Expand Up @@ -35,3 +35,6 @@ type Investigation(
DynObj.setValueOpt this (nameof mentions) mentions
DynObj.setValueOpt this (nameof url) url
DynObj.setValueOpt this (nameof description) description

member this.GetIdentifier() = DynObj.tryGetTypedValue<string> (nameof identifier) this |> Option.get
static member getIdentifier = fun (inv: Investigation) -> inv.GetIdentifier()
16 changes: 14 additions & 2 deletions src/ROCrate/ISAProfile/LabProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open Fable.Core
///
[<AttachMembers>]
type LabProcess(
id,
id: string,
name,
agent,
object,
Expand All @@ -27,4 +27,16 @@ type LabProcess(
DynObj.setValueOpt this (nameof executesLabProtocol) executesLabProtocol
DynObj.setValueOpt this (nameof parameterValue) parameterValue
DynObj.setValueOpt this (nameof endTime) endTime
DynObj.setValueOpt this (nameof disambiguatingDescription) disambiguatingDescription
DynObj.setValueOpt this (nameof disambiguatingDescription) disambiguatingDescription

member this.GetName() = DynObj.tryGetValue this (nameof name) |> Option.get
static member getName = fun (lp: LabProcess) -> lp.GetName()

member this.GetAgent() = DynObj.tryGetTypedValue<string> (nameof agent) this |> Option.get
static member getAgent = fun (lp: LabProcess) -> lp.GetAgent()

member this.GetObject() = DynObj.tryGetTypedValue<string> (nameof object) this |> Option.get
static member getObject = fun (lp: LabProcess) -> lp.GetObject()

member this.GetResult() = DynObj.tryGetTypedValue<string> (nameof result) this |> Option.get
static member getResult = fun (lp: LabProcess) -> lp.GetResult()
6 changes: 4 additions & 2 deletions src/ROCrate/ISAProfile/Study.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ open Fable.Core
///
[<AttachMembers>]
type Study(
id,
identifier,
id: string,
identifier: string,
?about,
?citation,
?comment,
Expand Down Expand Up @@ -36,3 +36,5 @@ type Study(
DynObj.setValueOpt this (nameof headline) headline
DynObj.setValueOpt this (nameof url) url

member this.GetIdentifier() = DynObj.tryGetTypedValue<string> (nameof identifier) this |> Option.get
static member getIdentifier = fun (inv: Investigation) -> inv.GetIdentifier()
7 changes: 3 additions & 4 deletions src/ROCrate/ROCrateObject.fs
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,14 @@ type ROCrateObject(id:string, schemaType: string, ?additionalType) =
member this.SetContext (context: #DynamicObj) =
this.SetValue("@context", context)

static member setContext (context: #DynamicObj) =
fun (roc: #ROCrateObject) -> roc.SetContext(context)
static member setContext (context: #DynamicObj) = fun (roc: #ROCrateObject) -> roc.SetContext(context)

member this.TryGetContext() =
DynObj.tryGetTypedValue<DynamicObj>("@context") this

static member tryGetContext (roc: #ROCrateObject) = roc.TryGetContext()
static member tryGetContext () = fun (roc: #ROCrateObject) -> roc.TryGetContext()

member this.RemoveContext() =
this.Remove("@context")

static member removeContext (roc: #ROCrateObject) = roc.RemoveContext()
static member removeContext () = fun (roc: #ROCrateObject) -> roc.RemoveContext()
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Assay.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Data.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Dataset.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Investigation.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/LabProcess.tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/LabProtocol.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Person.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/PropertyValue.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Sample.tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/ScholarlyArticle.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ISAProfile/Study.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down
4 changes: 2 additions & 2 deletions tests/ROCrate/ROCrateObject.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ let tests_static_methods = testSequenced (
ROCrateObject.setContext context mandatory_properties
Expect.ROCrateObjectHasDynamicProperty "@context" context mandatory_properties
testCase "can get context" <| fun _ ->
let ctx = ROCrateObject.tryGetContext mandatory_properties
let ctx = ROCrateObject.tryGetContext() mandatory_properties
Expect.equal ctx (Some context) "context was not set correctly"
testCase "can remove context" <| fun _ ->
ROCrateObject.removeContext mandatory_properties
ROCrateObject.removeContext() mandatory_properties
Expect.isNone (DynObj.tryGetTypedValue<DynamicObj> "@context" mandatory_properties) "context was not removed correctly"
]
)
Expand Down

0 comments on commit 7d1e733

Please sign in to comment.