-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend CvParam replace CvDoc by CvContainer
- Loading branch information
Showing
15 changed files
with
270 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
namespace ArcGraphModel | ||
|
||
open System.Collections.Generic | ||
open FSharpAux | ||
|
||
/// Represents a collection of structured properties, annotated with a controlled vocabulary term | ||
type CvContainer (cvAccession:string,cvName:string,cvRefUri:string,properties : IDictionary<string,ICvBase seq>) = | ||
|
||
inherit Dictionary<string,ICvBase seq>(properties) | ||
|
||
interface ICvBase with | ||
member this.ID = cvAccession | ||
member this.Name = cvName | ||
member this.RefUri = cvRefUri | ||
|
||
new ((id,name,ref) : CvTerm,properties : IDictionary<string,ICvBase seq>) = | ||
CvContainer(id,name,ref,properties) | ||
|
||
new (term : CvTerm,items : seq<ICvBase>) = | ||
let properties : IDictionary<string,ICvBase seq> = | ||
items | ||
|> Seq.groupBy (fun v -> v.Name) | ||
|> Dictionary.ofSeq | ||
CvContainer(term,properties) | ||
|
||
new (term : CvTerm) = CvContainer (term,Seq.empty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace ArcGraphModel | ||
|
||
/// Represents a generic object, annotated with a controlled vocabulary term | ||
type CvObject<'T>(cvAccession : string, cvName : string, cvRefUri : string, object : 'T) = | ||
interface ICvBase with | ||
member this.ID = cvAccession | ||
member this.Name = cvName | ||
member this.RefUri = cvRefUri | ||
|
||
new ((id,name,ref) : CvTerm,object : 'T) = CvObject (id,name,ref,object) | ||
|
||
member this.Object = object | ||
|
||
override this.ToString() = | ||
$"Name: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).ID}\n\tRefUri: {(this :> ICvBase).RefUri}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace ArcGraphModel | ||
|
||
open System | ||
open System.Collections.Generic | ||
open FSharpAux | ||
|
||
/// Represents a structured value, annotated with a controlled vocabulary term | ||
/// | ||
/// Qualifiers can be used to further describe the CvParam | ||
type CvParam(cvAccession : string, cvName : string, cvRefUri : string, paramValue : ParamValue, qualifiers : IDictionary<string,CvParam>) = | ||
|
||
inherit Dictionary<string,CvParam>(qualifiers) | ||
|
||
interface ICvBase with | ||
member this.ID = cvAccession | ||
member this.Name = cvName | ||
member this.RefUri = cvRefUri | ||
interface IParamBase with | ||
member this.Value = paramValue | ||
|
||
new (id,name,ref,pv,qualifiers : seq<CvParam>) = | ||
let dict = | ||
qualifiers | ||
|> Seq.map (fun cvp -> (cvp :> ICvBase).Name, cvp) | ||
|> Dictionary.ofSeq | ||
CvParam (id,name,ref,pv,dict) | ||
new (id,name,ref,pv) = | ||
CvParam (id,name,ref,pv,Seq.empty) | ||
|
||
new ((id,name,ref) : CvTerm,pv,qualifiers : seq<CvParam>) = | ||
CvParam (id,name,ref,pv,qualifiers) | ||
new (cvTerm,pv : ParamValue) = | ||
CvParam (cvTerm,pv,Seq.empty) | ||
|
||
static member fromValue(category : CvTerm,v : 'T) = | ||
CvParam(category, ParamValue.Value (v :> IConvertible)) | ||
|
||
static member fromCategory(category : CvTerm,term : CvTerm) = | ||
CvParam(category, ParamValue.CvValue term) | ||
|
||
static member fromValueWithUnit(category : CvTerm,v : 'T, unit : CvUnit) = | ||
CvParam(category, ParamValue.WithCvUnitAccession (v :> IConvertible,unit)) | ||
|
||
override this.ToString() = | ||
$"Name: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).ID}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tValue: {(this :> IParamBase).Value}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace ArcGraphModel | ||
|
||
/// Represents a term from a controlled vocabulary (Cv) | ||
/// in the form of: id|accession * name|value * refUri | ||
// ?Maybe [<Struct>] | ||
//[<Struct>] | ||
type CvTerm = string * string * string | ||
|
||
/// Represents a unit term from the unit ontology | ||
/// in the form of: id|accession * name * refUri | ||
// ?Maybe [<Struct>] | ||
type CvUnit = string * string * string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace ArcGraphModel | ||
|
||
|
||
/// Interface ensures the propterties necessary for CvTerm | ||
type ICvBase = | ||
abstract member ID : string | ||
abstract member Name : string | ||
abstract member RefUri : string | ||
// here or as node/edge abstraction | ||
// abstract member DataType : ModelDataType | ||
// abstract member Adress : Adress / Location / Position | ||
|
||
//override this.ToString() = | ||
// $"Name: {this.Name}\nID: {this.ID}\nRefUri: {this.RefUri}" | ||
|
||
module CvBase = | ||
|
||
let getCvAccession (param : #ICvBase) = | ||
param.ID | ||
|
||
let getCvName (param : #ICvBase) = | ||
param.Name | ||
|
||
let getCvRef (param : #ICvBase) = | ||
param.RefUri |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
namespace ArcGraphModel | ||
|
||
open System | ||
|
||
/// Interface ensures the value as ParamValue<'T> | ||
type IParamBase = | ||
abstract member Value : ParamValue | ||
|
||
|
||
module ParamBase = | ||
|
||
let getValue (param : #IParamBase) = | ||
match param.Value with | ||
| Value v -> v | ||
| CvValue (_,v,_) -> v | ||
| WithCvUnitAccession (v,_) -> v | ||
|
||
let tryGetValueAccession (param : #IParamBase) = | ||
match param.Value with | ||
| CvValue (a,_,_) -> Some a | ||
| Value _ -> None // mere Value has no accession number | ||
| WithCvUnitAccession _ -> None // use tryGetCvUnitAccession instead | ||
//| WithCvUnitAccession (_,(a,_,_)) -> Some a | ||
|
||
let tryGetValueRef (param : #IParamBase) = | ||
match param.Value with | ||
| CvValue (_,_,r) -> Some r | ||
| Value _ -> None // mere Value has no ref | ||
| WithCvUnitAccession _ -> None // use tryGetCvUnitRef instead | ||
|
||
let tryGetCvUnit (param : #IParamBase) : CvUnit option = | ||
match param.Value with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (_,u) -> Some u | ||
|
||
let tryGetCvUnitValue (param : #IParamBase) : #IConvertible option = | ||
match param.Value with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (v,_) -> Some v | ||
|
||
let tryGetCvUnitName (param : #IParamBase) = | ||
match param.Value with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (_,(_,n,_)) -> Some n | ||
|
||
let tryGetCvUnitAccession (param : #IParamBase) = | ||
match param.Value with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (_,(a,_,_)) -> Some a | ||
|
||
let tryGetCvUnitRef (param : #IParamBase) = | ||
match param.Value with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (_,(_,_,r)) -> Some r | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
namespace ArcGraphModel | ||
|
||
open System | ||
|
||
/// Represent the different cases of a parameter, which is either a simple value, | ||
/// a CvTerm or a simple value with CvUnit | ||
// ?Maybe [<Struct>] | ||
type ParamValue = | ||
| Value of v: IConvertible | ||
// id|accession * name|value * ref | ||
| CvValue of cv: CvTerm | ||
// value * CvUnit | ||
| WithCvUnitAccession of cvu : IConvertible * CvUnit | ||
|
||
static member getValue (param:ParamValue) = | ||
match param with | ||
| Value v -> string v | ||
| CvValue (_,v,_) -> v | ||
| WithCvUnitAccession (v,_) -> string v | ||
|
||
static member tryGetUnit (param:ParamValue) : CvUnit option = | ||
match param with | ||
| Value _ -> None | ||
| CvValue _ -> None | ||
| WithCvUnitAccession (_,u) -> Some u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace ArcGraphModel | ||
|
||
/// Represents a structured value, annotated by a user defined name | ||
type UserParam(name : string, paramValue : ParamValue) = | ||
interface ICvBase with | ||
member this.ID = name | ||
member this.Name = name | ||
member this.RefUri = "UserTerm" | ||
interface IParamBase with | ||
member this.Value = paramValue | ||
|
||
override this.ToString() = | ||
$"Name: {(this :> ICvBase).Name}\n\tID: {(this :> ICvBase).ID}\n\tRefUri: {(this :> ICvBase).RefUri}\n\tValue: {(this :> IParamBase).Value}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.