flarebyte / bubblegum-entity / Bubblegum.Entity.Attribute

An attribute represents a small piece of information such as a Semantic triple.

Model setters


type alias Model =
{ id : Maybe String
, key : String
, values : List String
, facets : List String 
}

The core representation of an attribute with:

When representing a RDF triple:

setId : Maybe String -> Model -> Model

Set a possible id to represent the attribute

 setId (Just "id:1234") model

setKey : String -> Model -> Model

Set the key of the attribute

setKey "ui:label" model

setValues : List String -> Model -> Model

Set a list of string values

setValues [ "some label" ] model

setFacets : List String -> Model -> Model

Set an optional list of tags to mark the data

setFacets [ "min", "inclusive" ] model

Attribute

findAttributeByKey : String -> List Model -> Maybe Model

Find an attribute by key

findAttributeByKey "ui:label" models -- Just label

findAttributeFirstValueByKey : String -> List Model -> Maybe String

Find an attribute by key and then get the first value if any

findAttributeFirstValueByKey "ui:label" models -- Just "some label"

replaceAttributeByKey : String -> List String -> List Model -> List Model

Replace or create an attribute by key

 replaceAttributeByKey "ui:label" ["new label"] models -- models

deleteAttributeByKey : String -> List Model -> List Model

Delete an attribute by key

deleteAttributeByKey "ui:label" models -- []

Outcome

findOutcomeByKey : String -> List Model -> Bubblegum.Entity.Outcome.Outcome (List String)

Find an outcome searching by key

findOutcomeByKey "ui:label" models -- Valid ["some label"]

findOutcomeByKeyTuple : ( String, String ) -> List Model -> Bubblegum.Entity.Outcome.Outcome ( List String, List String )

Find an outcome searching by a couple of keys

findOutcomeByKeyTuple ( "ui:min", "ui:max" ) models -- Valid (["1"], ["10"])