Skip to content
This repository has been archived by the owner on Aug 24, 2024. It is now read-only.

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfliegner committed Sep 12, 2022
1 parent 1c2c74b commit c001bf0
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 63 deletions.
50 changes: 25 additions & 25 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

julia_version = "1.8.0"
manifest_format = "2.0"
project_hash = "344b86b610eaac4a837abbb125dc791fe8fc75cc"
project_hash = "fe4008ee5590ebaaf44da2147bdd1c0ea4790517"

[[deps.AbstractTrees]]
git-tree-sha1 = "5c0b629df8a5566a06f5fef5100b53ea56e465a0"
Expand Down Expand Up @@ -85,9 +85,9 @@ version = "0.1.1"

[[deps.BitemporalPostgres]]
deps = ["AbstractTrees", "Dates", "Intervals", "SearchLight", "SearchLightPostgreSQL", "Test", "TimeZones", "ToStruct"]
git-tree-sha1 = "7d06bb8c5acf4ecf049075d6301e6ca597bfe312"
path = "/home/mf/.julia/dev/BitemporalPostgres"
uuid = "e513cd14-23e6-48df-acf1-d9bc8fa5674b"
version = "1.3.0"
version = "1.3.1"

[[deps.Bzip2_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
Expand All @@ -114,9 +114,9 @@ version = "0.5.1"

[[deps.ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "8a494fe0c4ae21047f28eb48ac968f0b8a6fcaa7"
git-tree-sha1 = "dc4405cee4b2fe9e1108caec2d760b7ea758eca2"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.15.4"
version = "1.15.5"

[[deps.ChangesOfVariables]]
deps = ["ChainRulesCore", "LinearAlgebra", "Test"]
Expand Down Expand Up @@ -217,9 +217,9 @@ version = "1.10.0"

[[deps.DataFrames]]
deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Reexport", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"]
git-tree-sha1 = "daa21eb85147f72e41f6352a57fccea377e310a9"
git-tree-sha1 = "6bce52b2060598d8caaed807ec6d6da2a1de949e"
uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
version = "1.3.4"
version = "1.3.5"

[[deps.DataStructures]]
deps = ["Compat", "InteractiveUtils", "OrderedCollections"]
Expand Down Expand Up @@ -409,21 +409,21 @@ version = "6.2.1+2"

[[deps.Genie]]
deps = ["ArgParse", "Dates", "Distributed", "EzXML", "FilePathsBase", "HTTP", "HttpCommon", "Inflector", "JSON3", "JuliaFormatter", "Logging", "LoggingExtras", "Markdown", "Millboard", "Nettle", "OrderedCollections", "Pkg", "REPL", "Random", "Reexport", "Revise", "SHA", "Serialization", "Sockets", "UUIDs", "Unicode", "YAML"]
git-tree-sha1 = "a4f5ff0a6d8b2993b4cb45cef6d8a5fe41ce76f4"
git-tree-sha1 = "3576bc987786c675ecccf3f7a369155a58e5cfad"
uuid = "c43c736e-a2d1-11e8-161f-af95117fbd1e"
version = "5.3.1"
version = "5.3.2"

[[deps.GenieSession]]
deps = ["Dates", "Genie", "HTTP", "Logging", "Random", "SHA"]
git-tree-sha1 = "7b87e9488c095c9c4b2a120859e23364cb508448"
git-tree-sha1 = "b0e80bc4f077e197910669110b0f840fd26cca92"
uuid = "03cc5b98-4f21-4eb6-99f2-22eced81f962"
version = "1.1.0"
version = "1.1.1"

[[deps.GenieSessionFileSession]]
deps = ["Genie", "GenieSession", "Logging", "Serialization"]
git-tree-sha1 = "1ef0880924bd67c03a416e8c5d574a00735c4b61"
git-tree-sha1 = "6147d9d2c25d9dd489ab0e69d636c0af432eb9f6"
uuid = "5c4fdc26-39e3-47cf-9034-e533e09961c2"
version = "1.0.1"
version = "1.0.2"

[[deps.GeoInterface]]
deps = ["Extents"]
Expand Down Expand Up @@ -539,9 +539,9 @@ version = "0.21.3"

[[deps.JSON3]]
deps = ["Dates", "Mmap", "Parsers", "StructTypes", "UUIDs"]
git-tree-sha1 = "fd6f0cae36f42525567108a42c1c674af2ac620d"
git-tree-sha1 = "f1572de22c866dc92aea032bc89c2b137cbddd6a"
uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
version = "1.9.5"
version = "1.10.0"

[[deps.JuliaFormatter]]
deps = ["CSTParser", "CommonMark", "DataStructures", "Pkg", "Tokenize"]
Expand Down Expand Up @@ -629,9 +629,9 @@ version = "2.3.0"

[[deps.LifeInsuranceDataModel]]
deps = ["BitemporalPostgres", "ColorSchemes", "DataFrames", "Dates", "Intervals", "JSON", "LibPQ", "Revise", "SearchLight", "SearchLightPostgreSQL", "Test", "TimeZones", "ToStruct"]
git-tree-sha1 = "7cad00b59acbc2b32671ce8e4bb7a6fc3d4b7bb5"
path = "/home/mf/.julia/dev/LifeInsuranceDataModel"
uuid = "4892898e-25d7-46ce-b5c3-dea2164303ac"
version = "0.3.1"
version = "0.3.2"

[[deps.LifeInsuranceProduct]]
deps = ["BitemporalPostgres", "Dates", "LifeContingencies", "LifeInsuranceDataModel", "MortalityTables", "Revise", "SearchLight", "SearchLightPostgreSQL", "TimeZones", "ToStruct", "Yields"]
Expand Down Expand Up @@ -836,9 +836,9 @@ version = "0.5.5+0"

[[deps.Optim]]
deps = ["Compat", "FillArrays", "ForwardDiff", "LineSearches", "LinearAlgebra", "NLSolversBase", "NaNMath", "Parameters", "PositiveFactorizations", "Printf", "SparseArrays", "StatsBase"]
git-tree-sha1 = "ad8de074ed5dad13e87d76c467a82e5eff9c693a"
git-tree-sha1 = "b9fe76d1a39807fdcf790b991981a922de0c3050"
uuid = "429524aa-4258-5aef-a3af-852621145aeb"
version = "1.7.2"
version = "1.7.3"

[[deps.OptimBase]]
deps = ["NLSolversBase", "Printf", "Reexport"]
Expand Down Expand Up @@ -979,9 +979,9 @@ version = "1.1.1"

[[deps.SearchLight]]
deps = ["DataFrames", "Dates", "Distributed", "Inflector", "Intervals", "JSON3", "Logging", "Millboard", "OrderedCollections", "Reexport", "SHA", "Unicode", "YAML"]
git-tree-sha1 = "4666379dd8f1c6342835b361ff197f0931519b3f"
git-tree-sha1 = "86ed053297e072920e853e1569121458badc0e65"
uuid = "340e8cb6-72eb-11e8-37ce-c97ebeb32050"
version = "2.7.0"
version = "2.7.1"

[[deps.SearchLightPostgreSQL]]
deps = ["DataFrames", "LibPQ", "Logging", "SearchLight"]
Expand Down Expand Up @@ -1072,15 +1072,15 @@ version = "1.0.1"

[[deps.Stipple]]
deps = ["FilePathsBase", "Genie", "GenieSession", "GenieSessionFileSession", "JSON3", "Logging", "Mixers", "Observables", "OrderedCollections", "Parameters", "Pkg", "Random", "Reexport", "Requires", "StructTypes"]
git-tree-sha1 = "f5ecdc6b1bddbef451e372d396be906e39b1b434"
git-tree-sha1 = "fb86cf24c6e445120f5e64a28476ba9bed0984f0"
uuid = "4acbeb90-81a0-11ea-1966-bdaff8155998"
version = "0.25.0"
version = "0.25.1"

[[deps.StippleUI]]
deps = ["Colors", "DataFrames", "Dates", "Genie", "Stipple"]
git-tree-sha1 = "9236ef7a9de14246aab985fc975e0d08800c0cd9"
git-tree-sha1 = "8cb3feeec1897f04b26e42be54d8c84b87fbd610"
uuid = "a3c5d34a-b254-4859-a8fa-b86abb7e84a3"
version = "0.20.1"
version = "0.20.2"

[[deps.StringDistances]]
deps = ["Distances", "StatsAPI"]
Expand Down
8 changes: 4 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BitemporalReactive"
uuid = "2fc36f50-c0f6-442e-a77c-cf0acc93eef6"
authors = ["michaelfliegner <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
BitemporalPostgres = "e513cd14-23e6-48df-acf1-d9bc8fa5674b"
Expand All @@ -23,14 +23,14 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
ToStruct = "43ec2cc1-0e50-5406-a854-b7ff8fdb8dad"

[compat]
BitemporalPostgres = "1.3"
BitemporalPostgres = "1.3.1"
DataFrames = "1"
Genie = "4,5"
HTTP = "0.9.17, 1"
Intervals = "1.6.0"
JSON = "0.21.3"
LifeInsuranceDataModel = "0.3.1"
LifeInsuranceProduct = "0.2.0"
LifeInsuranceDataModel = "0.3.2"
LifeInsuranceProduct = "0.2"
Revise = "3"
SearchLight = "2"
SearchLightPostgreSQL = "2"
Expand Down
33 changes: 23 additions & 10 deletions src/BitemporalReactive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ include("ContractSectionView.jl")
using .ContractSectionView
include("PartnerSectionView.jl")
using .PartnerSectionView

"""
Activetxn
whether a transaction/workflow is active
"""
Activetxn = 0


"""
load_roles(contractsModel)
Expand Down Expand Up @@ -67,8 +75,16 @@ handlers(contractsModel::ContractSectionView.ContractsModel)
Event handling and synching of the view contractsModel between UI and contractsModel server
"""

function handlers(contractsModel::ContractSectionView.ContractsModel)
on(contractsModel.isready) do _
contractsModel.contracts = LifeInsuranceDataModel.get_contracts()
contractsModel.tab[] = "contracts"
contractsModel.cs["loaded"] = "false"
load_roles(contractsModel)
push!(contractsModel)
println("contractsModel pushed")
end

on(contractsModel.selected_version) do _
println("selected version")
println(contractsModel.selected_version[])
Expand Down Expand Up @@ -97,7 +113,7 @@ function handlers(contractsModel::ContractSectionView.ContractsModel)
println(contractsModel.contracts[contractsModel.selected_contract_idx[]+1])
contractsModel.current_contract[] = contractsModel.contracts[contractsModel.selected_contract_idx[]+1]
contractsModel.histo = map(convert, LifeInsuranceDataModel.history_forest(contractsModel.current_contract[].ref_history.value).shadowed)
contractsModel.cs = JSON.parse(JSON.json(LifeInsuranceDataModel.csection(contractsModel.current_contract[].id.value, now(tz"Europe/Warsaw"), now(tz"Europe/Warsaw"))))
contractsModel.cs = JSON.parse(JSON.json(LifeInsuranceDataModel.csection(contractsModel.current_contract[].id.value, now(tz"Europe/Warsaw"), now(tz"Europe/Warsaw"), contractsModel.activetxn)))
contractsModel.cs["loaded"] = "true"
contractsModel.tab[] = "csection"
ti = contractsModel.cs["product_items"][1]["tariff_items"][1]
Expand Down Expand Up @@ -136,14 +152,6 @@ function handlers(contractsModel::ContractSectionView.ContractsModel)
end
end

on(contractsModel.isready) do _
contractsModel.contracts = LifeInsuranceDataModel.get_contracts()
contractsModel.tab[] = "contracts"
contractsModel.cs["loaded"] = "false"
load_roles(contractsModel)
push!(contractsModel)
println("contractsModel pushed")
end
contractsModel
end
"""
Expand Down Expand Up @@ -203,6 +211,11 @@ creating the route
function run(async::Bool=false)
contractsModel = handlers(Stipple.init(ContractSectionView.ContractsModel))
route("/ContractSection") do
Activetxn = params(:activetxn, "0")
println("from session " * Activetxn)
contractsModel.activetxn = parse(Int64, Activetxn)
println("contractsModel.activetxn " * string(contractsModel.activetxn))
println(params)
html(ContractSectionView.ui(contractsModel), context=@__MODULE__)
end

Expand Down
3 changes: 3 additions & 0 deletions src/ContractSectionView.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ using BitemporalPostgres, LifeInsuranceDataModel, TimeZones
include("HistoryView.jl")
using .HistoryView

activetxn::Integer = 0

"""
ContractsModel
reactive data view model (Stipple/Quasar/Vue)
synched between Julia Server and Browser
"""
@reactive mutable struct ContractsModel <: ReactiveModel
activetxn::Integer = 0
contracts::R{Vector{Contract}} = []
current_contract::R{Contract} = Contract()
selected_contract_idx::R{Integer} = -1
Expand Down
84 changes: 60 additions & 24 deletions testTransactions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mFailed to start the Kernel. \n",
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
]
}
],
"outputs": [],
"source": [
"#loading packages\n",
"push!(LOAD_PATH, \"src\");\n",
Expand All @@ -35,23 +25,69 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"ename": "",
"evalue": "",
"output_type": "error",
"traceback": [
"\u001b[1;31mFailed to start the Kernel. \n",
"\u001b[1;31mView Jupyter <a href='command:jupyter.viewOutput'>log</a> for further details."
]
}
],
"outputs": [],
"source": [
"println(ENV[\"SEARCHLIGHT_USERNAME\"])\n",
"println(ENV[\"SEARCHLIGHT_PASSWORD\"])\n",
"if (haskey(ENV, \"GITPOD_REPO_ROOT\"))\n",
" run(```psql -f sqlsnippets/droptables.sql```)\n",
"else\n",
" ENV[\"SEARCHLIGHT_USERNAME\"] = \"bitemporalpostgres\"\n",
" ENV[\"SEARCHLIGHT_PASSWORD\"] = \"jw8s0F49KL\"\n",
" println(\"execute this in Your REPL\")\n",
" println(\"\"\"run(```sudo -u postgres psql -f sqlsnippets/droptables.sql```)\"\"\")\n",
"end\n",
"\n",
"LifeInsuranceDataModel.connect()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"c = find(Contract, SQLWhereExpression(\"id=?\", 1))[1]\n",
"crOld = find(ContractRevision, SQLWhereExpression(\"ref_component=? and ref_invalidfrom=?\", 1,9223372036854775807))[1]\n",
"\n",
"cr = ContractRevision(ref_component=c.id, description=\"mutation for testing active transactions\")\n",
"w0 = Workflow(\n",
" ref_history=c.ref_history,\n",
" tsw_validfrom=ZonedDateTime(2022, 5, 30, 21, 0, 1, 1, tz\"Africa/Porto-Novo\"),\n",
")\n",
"update_entity!(w0)\n",
"update_component!(crOld, cr, w0)\n",
"# commit_workflow!(w2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"w=find(Workflow,SQLWhereExpression(\"id=?\", 13))[1]\n",
"rollback_workflow!(w)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"function findversion(ref_history::DbId, tsdb::ZonedDateTime, tsw::ZonedDateTime)\n",
" find(\n",
" ValidityInterval,\n",
" SQLWhereExpression(\n",
" \"ref_history=? and tsrworld @> TIMESTAMPTZ ? AND tsrdb @> TIMESTAMPTZ ?\",\n",
" ref_history,\n",
" SQLInput(tsw),\n",
" SQLInput(tsdb),\n",
" ),\n",
" )\n",
"end\n",
"\n",
"findversion(DbId(9), now(tz\"UTC\"), now(tz\"UTC\"))"
]
}
],
"metadata": {
Expand Down

0 comments on commit c001bf0

Please sign in to comment.