Infrascructure methods

Infrastructure methods

I have taken the Observer Pattern as the goal to implement the project. The main objects are Publisher and Subscriber. The Publisher delivers a message to the Subscribers. The information consists of temperatures that were measured.

Exports

Database methods

connect

RbO.connectFunction.
connect(path::String)::SQLite.DB

Returns a database.

Example

julia> using RbO

julia> db = connect("./rbo.sqlite")
SQLite.DB("./rbo.sqlite")
source
connect()::SQLite.DB

Returns an in-memory database.

Example

julia> using RbO

julia> db = connect()
SQLite.DB(in-memory)
source

create

RbO.createFunction.
create( db::SQLite.DB, table::String, domainItems::Array{Subscriber, 1} )

Store subscribes in a database table.

Example

julia> using RbO

julia> daisy = createSubscriber( "Daisy" );

julia> mickey = createSubscriber( "Mickey" );

julia> data = [ daisy, mickey ];

julia> db = connect()
SQLite.DB(in-memory)

julia> create( db, "subscribers", data )
"subscribers"
source
create( db::SQLite.DB, table::String, domainItems::Array{Publisher, 1} )

Store publishers in a database table.

Exampple

julia> using RbO

julia> nyt = createPublisher( "The New York Times" );

julia> db = connect()
SQLite.DB(in-memory)

julia> create(db, "publishers", [ nyt ])
"publishers"
source
create( db::SQLite.DB, table::String, domainItems::Array{Message, 1} )

Store publishers in a database table.

source

gather (read)

RbO.gatherFunction.
gather( db::SQLite.DB, table::String )::DataFrame

Returns a dataframe with all entries

julia> using RbO

julia> daisy = createSubscriber( "Daisy" )
Subscriber("14400338531749444750", "Daisy", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> mickey = createSubscriber( "Mickey" )
Subscriber("7987502302757180929", "Mickey", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> db = connect()
SQLite.DB(in-memory)

julia> create( db, "subscribers", [ daisy, mickey ] )
"subscribers"

julia> gather(db, "subscribers")
┌ Warning: `T` is deprecated, use `nonmissingtype` instead.
│   caller = compacttype(::Type, ::Int64) at show.jl:39
└ @ DataFrames ~/.julia/packages/DataFrames/XuYBH/src/abstractdataframe/show.jl:39
2×5 DataFrames.DataFrame
│ Row │ time      │ agent   │ action  │ key                  │ item                                                             │
│     │ Float64⍰  │ String⍰ │ String⍰ │ String⍰              │ Union{Missing, Subscriber}                                       │
├─────┼───────────┼─────────┼─────────┼──────────────────────┼──────────────────────────────────────────────────────────────────┤
│ 1   │ 1.56812e9 │ AB9F    │ CREATE  │ 14400338531749444750 │ Subscriber("14400338531749444750", "Daisy", "", MEAN_CALCULATOR) │
│ 2   │ 1.56812e9 │ AB9F    │ CREATE  │ 7987502302757180929  │ Subscriber("7987502302757180929", "Mickey", "", MEAN_CALCULATOR) │
source
gather( db::SQLite.DB, table::String, condition::String )::DataFrame

Return a DataFrame with all entries.

Example

julia> using RbO

julia> daisy = createSubscriber( "Daisy" )
Subscriber("5270518311956369638", "Daisy", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> mickey = createSubscriber( "Mickey" )
Subscriber("8580492032810188742", "Mickey", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> db = connect()
SQLite.DB(in-memory)

julia> create( db, "subscribers", [ daisy, mickey ] )
 "subscribers"

julia> gather( db, "subscribers", "key = '" * daisy.id * "'" )
1×5 DataFrames.DataFrame
│ Row │ time      │ agent   │ action  │ key                 │ item                                                            │
│     │ Float64⍰  │ String⍰ │ String⍰ │ String⍰             │ Union{Missing, Subscriber}                                      │
├─────┼───────────┼─────────┼─────────┼─────────────────────┼─────────────────────────────────────────────────────────────────┤
│ 1   │ 1.56812e9 │ AB9F    │ CREATE  │ 5270518311956369638 │ Subscriber("5270518311956369638", "Daisy", "", MEAN_CALCULATOR) │
source

update

RbO.updateFunction.
update( db::SQLite.DB, table::String, domainItems::Array{Subscribers, 1} )

Example

julia> using RbO

julia> daisy = createSubscriber( "Daisy" )
Subscriber("5270518311956369638", "Daisy", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> mickey = createSubscriber( "Mickey" )
Subscriber("8580492032810188742", "Mickey", "", MEAN_CALCULATOR::SubscriberType = 0)

julia> db = connect()
SQLite.DB(in-memory)

julia> create( db, "subscribers", [ daisy, mickey ] )
 "subscribers"

julia> gather( db, "subscribers", "key = '" * daisy.id * "'" )
1×5 DataFrames.DataFrame
│ Row │ time      │ agent   │ action  │ key                 │ item                                                            │
│     │ Float64⍰  │ String⍰ │ String⍰ │ String⍰             │ Union{Missing, Subscriber}                                      │
├─────┼───────────┼─────────┼─────────┼─────────────────────┼─────────────────────────────────────────────────────────────────┤
│ 1   │ 1.56812e9 │ AB9F    │ CREATE  │ 5270518311956369638 │ Subscriber("5270518311956369638", "Daisy", "", MEAN_CALCULATOR) │

daisy = updateSubscriber( daisy, "Daisy Duck", "daisy@duckcity.com", daisy.subscribertype )
Subscriber("5270518311956369638", "Daisy Duck", "daisy@duckcity.com", MEAN_CALCULATOR::SubscriberType = 0)

julia> update( db, "subscribers", [daisy] )
"subscribers"

julia> gather( db, "subscribers", "key = '" * daisy.id * "'" )
2×5 DataFrames.DataFrame
│ Row │ time      │ agent   │ action  │ key                 │ item                                                                                   │
│     │ Float64⍰  │ String⍰ │ String⍰ │ String⍰             │ Union{Missing, Subscriber}                                                             │
├─────┼───────────┼─────────┼─────────┼─────────────────────┼────────────────────────────────────────────────────────────────────────────────────────┤
│ 1   │ 1.56812e9 │ AB9F    │ CREATE  │ 5270518311956369638 │ Subscriber("5270518311956369638", "Daisy", "", MEAN_CALCULATOR)                        │
│ 2   │ 1.56812e9 │ AB9F    │ UPDATE  │ 5270518311956369638 │ Subscriber("5270518311956369638", "Daisy Duck", "daisy@duckcity.com", MEAN_CALCULATOR) │
source
update( db::SQLite.DB, table::String, domainItems::Array{Publishers, 1} )

Update publishers in a database table.

source
update( db::SQLite.DB, table::String, domainItems::Array{Message, 1} )

Update messages in a database table.

source