Skip to content

Commit

Permalink
add helper functions to CvAttribute Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Apr 27, 2023
1 parent ac5ab8c commit bb20906
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/ArcGraphModel/CvTokens/CvAttributeCollection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,23 @@ type CvAttributeCollection(attributes : IDictionary<string,IParam>) =
ac.TryGetAttribute name
| _ -> None

/// Returns true, if it implements a CvAttributeCollection and the attribute exists, else returns None
/// Returns the attribute of the value, if it implements CvAttributeCollection and the attribute exists, else returns None
static member tryGetAttributeByTerm (term : string) (v : IAttributeCollection) =
match box v with
| :? CvAttributeCollection as ac ->
ac.TryGetAttribute term
| _ -> None

/// Returns true, if it implements a CvAttributeCollection and the attribute exists
static member containsAttribute (name : string) (v : IAttributeCollection) =
match box v with
| :? CvAttributeCollection as ac ->
ac.ContainsAttribute name
| _ -> false

/// Returns true, if it implements a CvAttributeCollection and the attribute exists
static member containsAttributeTerm (term : CvTerm) (v : IAttributeCollection) =
match box v with
| :? CvAttributeCollection as ac ->
ac.ContainsAttribute term
| _ -> false
4 changes: 4 additions & 0 deletions src/ArcGraphModel/CvTokens/CvParam.fs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ type CvParam(cvAccession : string, cvName : string, cvRefUri : string, paramValu
CvParam (id,name,ref,pv,dict)
new (id,name,ref,pv) =
CvParam (id,name,ref,pv,Seq.empty)
new (id,name,ref,v : IConvertible) =
CvParam (id,name,ref,ParamValue.Value v)

new ((id,name,ref) : CvTerm,pv,attributes : seq<IParam>) =
CvParam (id,name,ref,pv,attributes)
new (cvTerm,pv : ParamValue) =
CvParam (cvTerm,pv,Seq.empty)
new (cvTerm,v : IConvertible) =
CvParam (cvTerm,ParamValue.Value v)

member this.Equals (term : CvTerm) =
CvBase.equalsTerm term this
Expand Down
5 changes: 5 additions & 0 deletions src/ArcGraphModel/CvTokens/CvTerm.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ module CvTerm =
match cvTerm with
| id, name, refUri -> id

/// gets the source reference of the CvTerm
let getRef (cvTerm : CvTerm) =
match cvTerm with
| id, name, refUri -> refUri

/// creates a CvTerm from name
let fromName (name : string) : CvTerm=
"", name, ""
Expand Down

0 comments on commit bb20906

Please sign in to comment.