Skip to content

Commit

Permalink
rename ROCrateObject to LDObject
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Oct 18, 2024
1 parent cc77790 commit fc2f7d9
Show file tree
Hide file tree
Showing 38 changed files with 381 additions and 356 deletions.
8 changes: 4 additions & 4 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* [[#ef15f35](https://github.com/nfdi4plants/ARCtrl/commit/ef15f35779606a1bfcaecdadfc7532886466ec46)] implement first POC of ISA ROCrate profile
* [[#168ead8](https://github.com/nfdi4plants/ARCtrl/commit/168ead84ca93dc0fae911e760673ef6e33180447)] add test project
* [[#2cea57c](https://github.com/nfdi4plants/ARCtrl/commit/2cea57cc1415310e36f5931ef376ea183b85fb71)] update solution
* [[#ccd1805](https://github.com/nfdi4plants/ARCtrl/commit/ccd18053a83c80f4ca4b7a2ac7008a4a0cf3d348)] Unify Inheritance to ROCrateObject
* [[#ccd1805](https://github.com/nfdi4plants/ARCtrl/commit/ccd18053a83c80f4ca4b7a2ac7008a4a0cf3d348)] Unify Inheritance to LDObject
* [[#95cab6f](https://github.com/nfdi4plants/ARCtrl/commit/95cab6f0f85f71a7adea887a25bd47c714e5af35)] wip ro-crate tests
* [[#9ef48d7](https://github.com/nfdi4plants/ARCtrl/commit/9ef48d75f5439d3a71ca943941b70c5af3ff9261)] only use primary constructor
* [[#9deffb7](https://github.com/nfdi4plants/ARCtrl/commit/9deffb7ea81f76c067de5618f2b3388303402191)] Add basic tests for I/S/A ROCrateObjects
* [[#9deffb7](https://github.com/nfdi4plants/ARCtrl/commit/9deffb7ea81f76c067de5618f2b3388303402191)] Add basic tests for I/S/A LDObjects
* [[#4b4a2fc](https://github.com/nfdi4plants/ARCtrl/commit/4b4a2fcc3bd32b31ec5aa3b4f1127883f7af83fc)] temp workaround in tests for https://github.com/CSBiology/DynamicObj/issues/25
* [[#f67e78b](https://github.com/nfdi4plants/ARCtrl/commit/f67e78b068350a8e1aecf80fa8b9dd4646fb9ddd)] Use unblocking version of DynamicObj, introduce runTestProject target
* [[#4e91e9d](https://github.com/nfdi4plants/ARCtrl/commit/4e91e9dcc5b34747a2e4a16f33aee1a227eb08ef)] finish basic property tests for isa profile types
Expand All @@ -22,11 +22,11 @@
* [[#93030e9](https://github.com/nfdi4plants/ARCtrl/commit/93030e915329c23b4b4f8cddc5b622312de6cedb)] Make use of Fable.Package.SDK
* [[#99b2659](https://github.com/nfdi4plants/ARCtrl/commit/99b2659d1dd5c3815693f4df85691f9bead3e26d)] rename json IO implementations folder to reduce ambiguity in py and javascript packages
* Deletions:
* [[#c71b8a3](https://github.com/nfdi4plants/ARCtrl/commit/c71b8a301fbdf95531a9ba0d33f8e6d0d238adc9)] correct interface implementation on ROCrateObject, remove interface implementation from Dataset
* [[#c71b8a3](https://github.com/nfdi4plants/ARCtrl/commit/c71b8a301fbdf95531a9ba0d33f8e6d0d238adc9)] correct interface implementation on LDObject, remove interface implementation from Dataset
* [[#c429686](https://github.com/nfdi4plants/ARCtrl/commit/c4296864a7443a990257f7eb47fed92458fa0a7b)] remove javascript and pyton packages from main solution
* [[#3586dee](https://github.com/nfdi4plants/ARCtrl/commit/3586dee6a736d3ad2ed9e79778e3ea136c638eac)] remove restorelockedmode flag
* Bugfixes:
* [[#9d526b8](https://github.com/nfdi4plants/ARCtrl/commit/9d526b82df1d7ac04283cbe23c9832f1d5818771)] add LabProcess tests, fix schematype of ROCrateObject base constructor
* [[#9d526b8](https://github.com/nfdi4plants/ARCtrl/commit/9d526b82df1d7ac04283cbe23c9832f1d5818771)] add LabProcess tests, fix schematype of LDObject base constructor
* [[#192812d](https://github.com/nfdi4plants/ARCtrl/commit/192812d43569270845883ca116de9931dea6ba62)] fix error messages of ROCrate testing utils
* [[#43d65db](https://github.com/nfdi4plants/ARCtrl/commit/43d65db3fb121a4832e771541880c1fe79cfe89c)] various test fixes for Fable logic transition
* [[#8552f9e](https://github.com/nfdi4plants/ARCtrl/commit/8552f9ea7b2183c4cb382049c71793918d4128b3)] fix fable ready packaging and/by update package tags
Expand Down
2 changes: 1 addition & 1 deletion src/ARCtrl/ARCtrl.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<Compile Include="JsonIO\Assay.fs" />
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\ROCrateObject.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<None Include="README.md" />
</ItemGroup>-->
Expand Down
2 changes: 1 addition & 1 deletion src/ARCtrl/ARCtrl.Javascript.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<Compile Include="JsonIO\Assay.fs" />
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\ROCrateObject.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<None Include="README.md" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ARCtrl/ARCtrl.Python.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<Compile Include="JsonIO\Assay.fs" />
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\ROCrateObject.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<None Include="README.md" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ARCtrl/ARCtrl.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<Compile Include="JsonIO\Assay.fs" />
<Compile Include="JsonIO\Study.fs" />
<Compile Include="JsonIO\Investigation.fs" />
<Compile Include="JsonIO\ROCrateObject.fs" />
<Compile Include="JsonIO\LDObject.fs" />
<Compile Include="JsonIO\ARC.fs" />
<None Include="README.md" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ open Thoth.Json.Core
open DynamicObj

[<AutoOpen>]
module ROCrateObjectExtensions =
module LDObjectExtensions =

type ROCrateObject with
type LDObject with

static member fromROCrateJsonString (s:string) =
Decode.fromJsonString ROCrateObject.decoder s
Decode.fromJsonString LDObject.decoder s

/// exports in json-ld format
static member toROCrateJsonString(?spaces) =
fun (obj:ROCrateObject) ->
ROCrateObject.encoder obj
fun (obj:LDObject) ->
LDObject.encoder obj
|> Encode.toJsonString (Encode.defaultSpaces spaces)

member this.ToROCrateJsonString(?spaces) =
ROCrateObject.toROCrateJsonString(?spaces=spaces) this
LDObject.toROCrateJsonString(?spaces=spaces) this
2 changes: 1 addition & 1 deletion src/Json/ARCtrl.Json.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Compile Include="Assay.fs" />
<Compile Include="Study.fs" />
<Compile Include="Investigation.fs" />
<Compile Include="ROCrateObject.fs" />
<Compile Include="LDObject.fs" />
<Compile Include="ARC.fs" />
</ItemGroup>
<ItemGroup>
Expand Down
14 changes: 7 additions & 7 deletions src/Json/ROCrateObject.fs → src/Json/LDObject.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ open ARCtrl.ROCrate
open Thoth.Json.Core
open DynamicObj

module rec ROCrateObject =
module rec LDObject =

#if !FABLE_COMPILER
let (|SomeObj|_|) =
Expand Down Expand Up @@ -36,15 +36,15 @@ module rec ROCrateObject =
| :? bool as b -> Encode.bool b
| :? float as f -> Encode.float f
| :? DateTime as d -> Encode.dateTime d
| :? ROCrateObject as o -> encoder o
| :? LDObject as o -> encoder o
#if !FABLE_COMPILER
| SomeObj o -> genericEncoder o
#endif
| null -> Encode.nil
| :? System.Collections.IEnumerable as l -> [ for x in l -> genericEncoder x] |> Encode.list
| _ -> failwith "Unknown type"

let rec encoder(obj: ROCrateObject) =
let rec encoder(obj: LDObject) =
obj.GetProperties true
|> Seq.choose (fun kv ->
let l = kv.Key.ToLower()
Expand All @@ -67,8 +67,8 @@ module rec ROCrateObject =
/// If expectObject is set to true, decoder fails if top-level value is not an ROCrate object
let rec getDecoder (expectObject : bool) : Decoder<obj> =
let rec decode(expectObject) =
let decodeObject : Decoder<ROCrateObject> =
{ new Decoder<ROCrateObject> with
let decodeObject : Decoder<LDObject> =
{ new Decoder<LDObject> with
member _.Decode(helpers, value) =
if helpers.isObject value then
let getters = Decode.Getters(helpers, value)
Expand All @@ -77,7 +77,7 @@ module rec ROCrateObject =
fun (get : Decode.IGetters) ->
let t = get.Required.Field "@type" Decode.string
let id = get.Required.Field "@id" Decode.string
let o = ROCrateObject(id,t)
let o = LDObject(id,t)
for property in properties do
if property <> "@id" && property <> "@type" then
o.SetProperty(property,get.Required.Field property (decode(false)))
Expand Down Expand Up @@ -136,6 +136,6 @@ module rec ROCrateObject =
]
decode(expectObject)

let decoder : Decoder<ROCrateObject> = Decode.map unbox (getDecoder(true))
let decoder : Decoder<LDObject> = Decode.map unbox (getDecoder(true))

let genericDecoder : Decoder<obj> = getDecoder(false)
3 changes: 2 additions & 1 deletion src/ROCrate/ARCtrl.ROCrate.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<Compile Include="DynObjExtensions.fs" />
<Compile Include="ROCrateObject.fs" />
<Compile Include="LDObject.fs" />
<Compile Include="ISAProfile\Dataset.fs" />
<Compile Include="ISAProfile\Investigation.fs" />
<Compile Include="ISAProfile\Study.fs" />
Expand All @@ -20,6 +20,7 @@
<Compile Include="ISAProfile\PropertyValue.fs" />
<Compile Include="ISAProfile\Person.fs" />
<Compile Include="ISAProfile\ScholarlyArticle.fs" />
<Compile Include="ArcROCrateMetadata.fs" />
<None Include="playground.fsx" />
</ItemGroup>
<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions src/ROCrate/ArcROCrateMetadata.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace ARCtrl.ROCrate

open DynamicObj

type ArcROCrateMetadata(?about : LDObject) as this =

inherit LDObject(id = "ro-crate-metadata",schemaType = "CreativeWork")

do DynObj.setOptionalProperty (nameof about) about this

do
let conformsTo = DynamicObj()
conformsTo.SetProperty("@id", "https://w3id.org/ro/crate/1.1")
this.SetProperty("conformsTo", conformsTo)

do
let context = LDContext()
context.SetProperty("sdo", "http://schema.org/")
context.SetProperty("arc", "http://purl.org/nfdi4plants/ontology/")
context.SetProperty("CreativeWork", "sdo:CreativeWork")
context.SetProperty("about", "sdo:about")
context.SetProperty("conformsTo", "sdo:conformsTo")
this.SetProperty("@context", context)

2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/Data.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Data(
?encodingFormat,
?disambiguatingDescription
) as this =
inherit ROCrateObject(id = id, schemaType = "schema.org/MediaObject", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/MediaObject", ?additionalType = additionalType)
do
DynObj.setProperty (nameof name) name this

Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/Dataset.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ open Fable.Core
///
[<AttachMembers>]
type Dataset (id: string, ?additionalType: string) =
inherit ROCrateObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/LabProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type LabProcess(
?endTime,
?disambiguatingDescription
) as this =
inherit ROCrateObject(id = id, schemaType = "bioschemas.org/LabProcess", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "bioschemas.org/LabProcess", ?additionalType = additionalType)
do
DynObj.setProperty (nameof name) name this
DynObj.setProperty (nameof agent) agent this
Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/LabProtocol.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type LabProtocol(
?reagent,
?computationalTool
) as this =
inherit ROCrateObject(id = id, schemaType = "bioschemas.org/LabProtocol", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "bioschemas.org/LabProtocol", ?additionalType = additionalType)
do
DynObj.setOptionalProperty (nameof name) name this
DynObj.setOptionalProperty (nameof intendedUse) intendedUse this
Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/Person.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Person(
?faxNumber,
?disambiguatingDescription
) as this=
inherit ROCrateObject(id = id, schemaType = "schema.org/Person", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/Person", ?additionalType = additionalType)
do

DynObj.setProperty (nameof givenName) givenName this
Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/PropertyValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type PropertyValue(
?valueReference,
?additionalType
) as this =
inherit ROCrateObject(id = id, schemaType = "schema.org/PropertyValue", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/PropertyValue", ?additionalType = additionalType)
do

DynObj.setProperty (nameof name) name this
Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/Sample.fs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Sample(
?additionalProperty,
?derivesFrom
) as this =
inherit ROCrateObject(id = id, schemaType = "bioschemas.org/Sample", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "bioschemas.org/Sample", ?additionalType = additionalType)
do
DynObj.setProperty (nameof name) name this

Expand Down
2 changes: 1 addition & 1 deletion src/ROCrate/ISAProfile/ScholarlyArticle.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type ScholarlyArticle(
?disambiguatingDescription

) as this =
inherit ROCrateObject(id = id, schemaType = "schema.org/ScholarlyArticle", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/ScholarlyArticle", ?additionalType = additionalType)
do

DynObj.setProperty (nameof headline) headline this
Expand Down
14 changes: 7 additions & 7 deletions src/ROCrate/ROCrateObject.fs → src/ROCrate/LDObject.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ open System
type LDContext() = inherit DynamicObj()

/// Base interface implemented by all explicitly known objects in our ROCrate profiles.
type IROCrateObject =
type ILDObject =
abstract member SchemaType : string with get, set
abstract member Id: string
abstract member AdditionalType: string option with get, set

/// Base class for all explicitly known objects in our ROCrate profiles to inherit from.
/// Basically a DynamicObj that implements the IROPCrateObject interface.
/// Basically a DynamicObj that implements the ILDObject interface.
[<AttachMembers>]
type ROCrateObject(id:string, schemaType: string, ?additionalType) =
type LDObject(id:string, schemaType: string, ?additionalType) =
inherit DynamicObj()

let mutable schemaType = schemaType
Expand All @@ -33,7 +33,7 @@ type ROCrateObject(id:string, schemaType: string, ?additionalType) =
with get() = additionalType
and set(value) = additionalType <- value

interface IROCrateObject with
interface ILDObject with

member this.SchemaType
with get() = schemaType
Expand All @@ -48,12 +48,12 @@ type ROCrateObject(id:string, schemaType: string, ?additionalType) =
member this.SetContext (context: LDContext) =
this.SetProperty("@context", context)

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

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

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

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

static member removeContext () = fun (roc: #ROCrateObject) -> roc.RemoveContext()
static member removeContext () = fun (roc: #LDObject) -> roc.RemoveContext()
10 changes: 5 additions & 5 deletions src/ROCrate/playground.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

open DynamicObj

type IROCrateObject =
type ILDObject =
abstract member SchemaType : string
abstract member Id: string
abstract member AdditionalType: string option

type ROCrateObject(id:string, schemaType: string, ?additionalType) =
type LDObject(id:string, schemaType: string, ?additionalType) =
inherit DynamicObj()

let mutable _schemaType = "schema.org/Dataset"
Expand All @@ -24,16 +24,16 @@ type ROCrateObject(id:string, schemaType: string, ?additionalType) =
with get() = _additionalType
and set(value) = _additionalType <- value

interface IROCrateObject with
interface ILDObject with
member this.SchemaType = schemaType
member this.Id = id
member this.AdditionalType = additionalType

type Dataset (id: string, ?additionalType: string) =
inherit ROCrateObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)
inherit LDObject(id = id, schemaType = "schema.org/Dataset", ?additionalType = additionalType)

//interface implementations
interface IROCrateObject with
interface ILDObject with
member this.Id with get () = this.Id
member this.SchemaType with get (): string = this.SchemaType
member this.AdditionalType with get (): string option = this.AdditionalType
Expand Down
2 changes: 1 addition & 1 deletion tests/Json/ARCtrl.Json.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<Compile Include="Process\Protocol.Tests.fs" />
<Compile Include="Process\Process.Tests.fs" />
<Compile Include="Template.Tests.fs" />
<Compile Include="ROCrateObject.Tests.fs" />
<Compile Include="LDObject.Tests.fs" />
<Compile Include="JsonSchema.Tests.fs" />
<Compile Include="Main.fs" />
</ItemGroup>
Expand Down
Loading

0 comments on commit fc2f7d9

Please sign in to comment.