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 Oct 18, 2024
1 parent b038cfc commit d5d5201
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 58 deletions.
23 changes: 13 additions & 10 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 @@ -21,11 +21,14 @@ type Assay(
do
DynObj.setProperty (nameof identifier) identifier this

DynObj.setOptionalProperty (nameof measurementMethod) measurementMethod this
DynObj.setOptionalProperty (nameof measurementTechnique) measurementTechnique this
DynObj.setOptionalProperty (nameof variableMeasured) variableMeasured this
DynObj.setOptionalProperty (nameof about) about this
DynObj.setOptionalProperty (nameof comment) comment this
DynObj.setOptionalProperty (nameof creator) creator this
DynObj.setOptionalProperty (nameof hasPart) hasPart this
DynObj.setOptionalProperty (nameof url) url this
DynObj.setValueOpt this (nameof measurementMethod) measurementMethod
DynObj.setValueOpt this (nameof measurementTechnique) measurementTechnique
DynObj.setValueOpt this (nameof variableMeasured) variableMeasured
DynObj.setValueOpt this (nameof about) about
DynObj.setValueOpt this (nameof comment) comment
DynObj.setValueOpt this (nameof creator) creator
DynObj.setValueOpt this (nameof hasPart) hasPart
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()
29 changes: 16 additions & 13 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 All @@ -24,14 +24,17 @@ type Investigation(
do
DynObj.setProperty (nameof identifier) identifier this

DynObj.setOptionalProperty (nameof citation) citation this
DynObj.setOptionalProperty (nameof comment) comment this
DynObj.setOptionalProperty (nameof creator) creator this
DynObj.setOptionalProperty (nameof dateCreated) dateCreated this
DynObj.setOptionalProperty (nameof dateModified) dateModified this
DynObj.setOptionalProperty (nameof datePublished) datePublished this
DynObj.setOptionalProperty (nameof hasPart) hasPart this
DynObj.setOptionalProperty (nameof headline) headline this
DynObj.setOptionalProperty (nameof mentions) mentions this
DynObj.setOptionalProperty (nameof url) url this
DynObj.setOptionalProperty (nameof description) description this
DynObj.setValueOpt this (nameof citation) citation
DynObj.setValueOpt this (nameof comment) comment
DynObj.setValueOpt this (nameof creator) creator
DynObj.setValueOpt this (nameof dateCreated) dateCreated
DynObj.setValueOpt this (nameof dateModified) dateModified
DynObj.setValueOpt this (nameof datePublished) datePublished
DynObj.setValueOpt this (nameof hasPart) hasPart
DynObj.setValueOpt this (nameof headline) headline
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()
22 changes: 17 additions & 5 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 @@ -24,7 +24,19 @@ type LabProcess(
DynObj.setProperty (nameof object) object this
DynObj.setProperty (nameof result) result this

DynObj.setOptionalProperty (nameof executesLabProtocol) executesLabProtocol this
DynObj.setOptionalProperty (nameof parameterValue) parameterValue this
DynObj.setOptionalProperty (nameof endTime) endTime this
DynObj.setOptionalProperty (nameof disambiguatingDescription) disambiguatingDescription this
DynObj.setValueOpt this (nameof executesLabProtocol) executesLabProtocol
DynObj.setValueOpt this (nameof parameterValue) parameterValue
DynObj.setValueOpt this (nameof endTime) endTime
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.setOptionalProperty (nameof headline) headline this
DynObj.setOptionalProperty (nameof url) url this

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 @@ -44,15 +44,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 d5d5201

Please sign in to comment.