diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..0630933 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +PATH_add ~/julia/bin +export SEARCHLIGHT_USERNAME="mf" +export SEARCHLIGHT_PASSWORD="mf" \ No newline at end of file diff --git a/Manifest.toml b/Manifest.toml index 6ae5404..5d70ae3 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -10,10 +10,10 @@ uuid = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" version = "0.4.4" [[deps.Adapt]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "0310e08cb19f5da31d08341c6120c047598f5b9c" +deps = ["LinearAlgebra", "Requires"] +git-tree-sha1 = "76289dc51920fdc6e0013c872ba9551d54961c24" uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "3.5.0" +version = "3.6.2" [[deps.ArgTools]] uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f" @@ -32,9 +32,9 @@ version = "0.4.2" [[deps.Compat]] deps = ["Dates", "LinearAlgebra", "UUIDs"] -git-tree-sha1 = "00a2cccc7f098ff3b66806862d275ca3db9e6e5a" +git-tree-sha1 = "8a62af3e248a8c4bad6b32cbbe663ae02275e32c" uuid = "34da2185-b29b-5c13-b0c7-acf172513d20" -version = "4.5.0" +version = "4.10.0" [[deps.CompilerSupportLibraries_jll]] deps = ["Artifacts", "Libdl"] @@ -46,22 +46,27 @@ git-tree-sha1 = "249fe38abf76d48563e2f4556bebd215aa317e15" uuid = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f" version = "4.1.1" +[[deps.DBInterface]] +git-tree-sha1 = "9b0dc525a052b9269ccc5f7f04d5b3639c65bca5" +uuid = "a10d1c49-ce27-4219-8d33-6db1a4562965" +version = "2.5.0" + [[deps.DataAPI]] -git-tree-sha1 = "e8119c1a33d267e16108be441a287a6981ba1630" +git-tree-sha1 = "8da84edb865b0b5b0100c0666a9bc9a0b71c553c" uuid = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a" -version = "1.14.0" +version = "1.15.0" [[deps.DataFrames]] -deps = ["Compat", "DataAPI", "Future", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SnoopPrecompile", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] -git-tree-sha1 = "d4f69885afa5e6149d0cab3818491565cf41446d" +deps = ["Compat", "DataAPI", "DataStructures", "Future", "InlineStrings", "InvertedIndices", "IteratorInterfaceExtensions", "LinearAlgebra", "Markdown", "Missings", "PooledArrays", "PrecompileTools", "PrettyTables", "Printf", "REPL", "Random", "Reexport", "SentinelArrays", "SortingAlgorithms", "Statistics", "TableTraits", "Tables", "Unicode"] +git-tree-sha1 = "04c738083f29f86e62c8afc341f0967d8717bdb8" uuid = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" -version = "1.4.4" +version = "1.6.1" [[deps.DataStructures]] deps = ["Compat", "InteractiveUtils", "OrderedCollections"] -git-tree-sha1 = "d1fff3a548102f48987a52a2e0d114fa97d730f0" +git-tree-sha1 = "3dbd312d370723b6bb43ba9d02fc36abade4518d" uuid = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" -version = "0.18.13" +version = "0.18.15" [[deps.DataValueInterfaces]] git-tree-sha1 = "bfc1187b79289637fa0ef6d4436ebdfe6905cbd6" @@ -93,19 +98,13 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6" version = "1.6.0" [[deps.ExprTools]] -git-tree-sha1 = "56559bbef6ca5ea0c0818fa5c90320398a6fbf8d" +git-tree-sha1 = "27415f162e6028e81c72b82ef756bf321213b6ec" uuid = "e2ba6199-217a-4e67-a87a-7c52f15ade04" -version = "0.1.8" +version = "0.1.10" [[deps.FileWatching]] uuid = "7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee" -[[deps.Formatting]] -deps = ["Printf"] -git-tree-sha1 = "8339d61043228fdd3eb658d86c926cb282ae72a8" -uuid = "59287772-0a20-5a39-b81b-1366585eb4c0" -version = "0.4.2" - [[deps.Future]] deps = ["Random"] uuid = "9fa8497b-333b-5362-9e8d-4d0656e87820" @@ -118,15 +117,15 @@ version = "0.2.4" [[deps.Inflector]] deps = ["Unicode"] -git-tree-sha1 = "8555b54ddf27806b070ce1d1cf623e1feb13750c" +git-tree-sha1 = "c82a172a07c94887709e613cc67cec0b472fb742" uuid = "6d011eab-0732-4556-8808-e463c76bf3b6" -version = "1.0.1" +version = "1.1.0" [[deps.InlineStrings]] deps = ["Parsers"] -git-tree-sha1 = "0cf92ec945125946352f3d46c96976ab972bde6f" +git-tree-sha1 = "9cc2baf75c6d09f9da536ddf58eb2f29dedaf461" uuid = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48" -version = "1.3.2" +version = "1.4.0" [[deps.InteractiveUtils]] deps = ["Markdown"] @@ -134,19 +133,19 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" [[deps.Intervals]] deps = ["Dates", "Printf", "RecipesBase", "Serialization", "TimeZones"] -git-tree-sha1 = "f3c7f871d642d244e7a27e3fb81e8441e13230d8" +git-tree-sha1 = "ac0aaa807ed5eaf13f67afe188ebc07e828ff640" uuid = "d8418881-c3e1-53bb-8760-2df7ec849ed5" -version = "1.8.0" +version = "1.10.0" [[deps.InvertedIndices]] -git-tree-sha1 = "82aec7a3dd64f4d9584659dc0b62ef7db2ef3e19" +git-tree-sha1 = "0dc7b50b8d436461be01300fd8cd45aa0274b038" uuid = "41ab1584-1d38-5bbf-9106-f11c6c58b48f" -version = "1.2.0" +version = "1.3.0" [[deps.IterTools]] -git-tree-sha1 = "fa6287a4469f5e048d763df38279ee729fbd44e5" +git-tree-sha1 = "4ced6667f9974fc5c5943fa5e2ef1ca43ea9e450" uuid = "c8e1da08-722c-5040-9ed9-7db0dc04731e" -version = "1.4.0" +version = "1.8.0" [[deps.IteratorInterfaceExtensions]] git-tree-sha1 = "a3f24677c21f5bbe9d2a714f95dcd58337fb2856" @@ -154,16 +153,16 @@ uuid = "82899510-4779-5014-852e-03e436cf321d" version = "1.0.0" [[deps.JLLWrappers]] -deps = ["Preferences"] -git-tree-sha1 = "abc9885a7ca2052a736a600f7fa66209f96506e1" +deps = ["Artifacts", "Preferences"] +git-tree-sha1 = "7e5d6779a1e09a36db2a7b6cff50942a0a7d0fca" uuid = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210" -version = "1.4.1" +version = "1.5.0" [[deps.JSON3]] -deps = ["Dates", "Mmap", "Parsers", "SnoopPrecompile", "StructTypes", "UUIDs"] -git-tree-sha1 = "84b10656a41ef564c39d2d477d7236966d2b5683" +deps = ["Dates", "Mmap", "Parsers", "PrecompileTools", "StructTypes", "UUIDs"] +git-tree-sha1 = "95220473901735a0f4df9d1ca5b171b568b2daa3" uuid = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" -version = "1.12.0" +version = "1.13.2" [[deps.Kerberos_krb5_jll]] deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] @@ -200,10 +199,10 @@ deps = ["Base64", "NetworkOptions", "Printf", "SHA"] uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" [[deps.LibPQ]] -deps = ["CEnum", "Dates", "Decimals", "DocStringExtensions", "FileWatching", "Infinity", "Intervals", "IterTools", "LayerDicts", "LibPQ_jll", "Libdl", "Memento", "OffsetArrays", "SQLStrings", "Tables", "TimeZones"] -git-tree-sha1 = "98f4d4dcfd5fca71b8acf0a90772badfdbac5660" +deps = ["CEnum", "DBInterface", "Dates", "Decimals", "DocStringExtensions", "FileWatching", "Infinity", "Intervals", "IterTools", "LayerDicts", "LibPQ_jll", "Libdl", "Memento", "OffsetArrays", "SQLStrings", "Tables", "TimeZones", "UTCDateTimes"] +git-tree-sha1 = "74feb1a63ebbcdcf1730016d2a4dfad0a655404f" uuid = "194296ae-ab2e-5f79-8cd4-7183a0a5a0d1" -version = "1.14.1" +version = "1.17.1" [[deps.LibPQ_jll]] deps = ["Artifacts", "JLLWrappers", "Kerberos_krb5_jll", "Libdl", "OpenSSL_jll", "Pkg"] @@ -220,10 +219,10 @@ version = "1.10.2+0" uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" [[deps.Libiconv_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "c7cb1f5d892775ba13767a87c7ada0b980ea0a71" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "f9557a255370125b405568f9767d6d195822a175" uuid = "94ce4f54-9a6c-5748-9c1c-f9c7231a4531" -version = "1.16.1+2" +version = "1.17.0+0" [[deps.LinearAlgebra]] deps = ["Libdl", "libblastrampoline_jll"] @@ -263,9 +262,9 @@ uuid = "a63ad114-7e13-5084-954f-fe012c677804" [[deps.Mocking]] deps = ["Compat", "ExprTools"] -git-tree-sha1 = "c272302b22479a24d1cf48c114ad702933414f80" +git-tree-sha1 = "4cc0c5a83933648b615c36c2b956d94fda70641e" uuid = "78c3b35d-d492-501b-9361-3d52fe80e533" -version = "0.7.5" +version = "0.7.7" [[deps.MozillaCACerts_jll]] uuid = "14a3606d-f60d-562e-9121-12d972cd8159" @@ -277,9 +276,9 @@ version = "1.2.0" [[deps.OffsetArrays]] deps = ["Adapt"] -git-tree-sha1 = "f71d8950b724e9ff6110fc948dff5a329f901d64" +git-tree-sha1 = "2ac17d29c523ce1cd38e27785a7d23024853a4bb" uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.12.8" +version = "1.12.10" [[deps.OpenBLAS_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] @@ -287,21 +286,21 @@ uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" version = "0.3.20+0" [[deps.OpenSSL_jll]] -deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"] -git-tree-sha1 = "f6e9dba33f9f2c44e08a020b0caf6903be540004" +deps = ["Artifacts", "JLLWrappers", "Libdl"] +git-tree-sha1 = "a12e56c72edee3ce6b96667745e6cbbe5498f200" uuid = "458c3c95-2e84-50aa-8efc-19380b2a3a95" -version = "1.1.19+0" +version = "1.1.23+0" [[deps.OrderedCollections]] -git-tree-sha1 = "85f8e6578bf1f9ee0d11e7bb1b1456435479d47c" +git-tree-sha1 = "2e73fe17cac3c62ad1aebe70d44c963c3cfdc3e3" uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d" -version = "1.4.1" +version = "1.6.2" [[deps.Parsers]] -deps = ["Dates", "SnoopPrecompile"] -git-tree-sha1 = "8175fc2b118a3755113c8e68084dc1a9e63c61ee" +deps = ["Dates", "PrecompileTools", "UUIDs"] +git-tree-sha1 = "716e24b21538abc91f6205fd1d8363f39b442851" uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" -version = "2.5.3" +version = "2.7.2" [[deps.Pkg]] deps = ["Artifacts", "Dates", "Downloads", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Serialization", "TOML", "Tar", "UUIDs", "p7zip_jll"] @@ -310,21 +309,27 @@ version = "1.8.0" [[deps.PooledArrays]] deps = ["DataAPI", "Future"] -git-tree-sha1 = "a6062fe4063cdafe78f4a0a81cfffb89721b30e7" +git-tree-sha1 = "36d8b4b899628fb92c2749eb488d884a926614d3" uuid = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" -version = "1.4.2" +version = "1.4.3" + +[[deps.PrecompileTools]] +deps = ["Preferences"] +git-tree-sha1 = "03b4c25b43cb84cee5c90aa9b5ea0a78fd848d2f" +uuid = "aea7be01-6a6a-4083-8856-8a6e6704d82a" +version = "1.2.0" [[deps.Preferences]] deps = ["TOML"] -git-tree-sha1 = "47e5f437cc0e7ef2ce8406ce1e7e24d44915f88d" +git-tree-sha1 = "00805cd429dcb4870060ff49ef443486c262e38e" uuid = "21216c6a-2e73-6563-6e65-726566657250" -version = "1.3.0" +version = "1.4.1" [[deps.PrettyTables]] -deps = ["Crayons", "Formatting", "LaTeXStrings", "Markdown", "Reexport", "StringManipulation", "Tables"] -git-tree-sha1 = "96f6db03ab535bdb901300f88335257b0018689d" +deps = ["Crayons", "LaTeXStrings", "Markdown", "Printf", "Reexport", "StringManipulation", "Tables"] +git-tree-sha1 = "ee094908d720185ddbdc58dbe0c1cbe35453ec7a" uuid = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" -version = "2.2.2" +version = "2.2.7" [[deps.Printf]] deps = ["Unicode"] @@ -339,10 +344,10 @@ deps = ["SHA", "Serialization"] uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [[deps.RecipesBase]] -deps = ["SnoopPrecompile"] -git-tree-sha1 = "261dddd3b862bd2c940cf6ca4d1c8fe593e457c8" +deps = ["PrecompileTools"] +git-tree-sha1 = "5c3d09cc4f31f5fc6af001c250bf1278733100ff" uuid = "3cdcf5f2-1ef4-517c-9805-6587b60abb01" -version = "1.3.3" +version = "1.3.4" [[deps.Reexport]] git-tree-sha1 = "45e428421666073eab6f2da5c9d310d99bb12f9b" @@ -366,9 +371,9 @@ version = "0.1.0" [[deps.Scratch]] deps = ["Dates"] -git-tree-sha1 = "f94f779c94e58bf9ea243e77a37e16d9de9126bd" +git-tree-sha1 = "30449ee12237627992a99d5e30ae63e4d78cd24a" uuid = "6c6a2e73-6563-6170-7368-637461726353" -version = "1.1.1" +version = "1.2.0" [[deps.SearchLight]] deps = ["DataFrames", "Dates", "Distributed", "Inflector", "Intervals", "JSON3", "Logging", "Millboard", "OrderedCollections", "Reexport", "SHA", "Unicode", "YAML"] @@ -382,23 +387,23 @@ git-tree-sha1 = "dd8cab8a1f07e7aae8c7a563f3ba442a5a0e2faf" uuid = "4327cdd6-4902-11ea-0272-430cea0431bd" version = "2.3.3" +[[deps.SentinelArrays]] +deps = ["Dates", "Random"] +git-tree-sha1 = "04bdff0b09c65ff3e06a05e3eb7b120223da3d39" +uuid = "91c51154-3ec4-41a3-a24f-3f23e20d615c" +version = "1.4.0" + [[deps.Serialization]] uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" -[[deps.SnoopPrecompile]] -deps = ["Preferences"] -git-tree-sha1 = "e760a70afdcd461cf01a575947738d359234665c" -uuid = "66db9d55-30c0-4569-8b51-7e840670fc0c" -version = "1.0.3" - [[deps.Sockets]] uuid = "6462fe0b-24de-5631-8697-dd941f90decc" [[deps.SortingAlgorithms]] deps = ["DataStructures"] -git-tree-sha1 = "a4ada03f999bd01b3a25dcaa30b2d929fe537e00" +git-tree-sha1 = "c60ec5c62180f27efea3ba2908480f8055e17cee" uuid = "a2af1166-a08f-5f64-846c-94a0d3cef48c" -version = "1.1.0" +version = "1.1.1" [[deps.SparseArrays]] deps = ["LinearAlgebra", "Random"] @@ -410,14 +415,15 @@ uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [[deps.StringEncodings]] deps = ["Libiconv_jll"] -git-tree-sha1 = "33c0da881af3248dafefb939a21694b97cfece76" +git-tree-sha1 = "b765e46ba27ecf6b44faf70df40c57aa3a547dcb" uuid = "69024149-9ee7-55f6-a4c4-859efe599b68" -version = "0.3.6" +version = "0.3.7" [[deps.StringManipulation]] -git-tree-sha1 = "46da2434b41f41ac3594ee9816ce5541c6096123" +deps = ["PrecompileTools"] +git-tree-sha1 = "a04cabe79c5f01f4d723cc6704070ada0b9d46d5" uuid = "892a3eda-7b42-436c-8928-eab12a02cf0e" -version = "0.3.0" +version = "0.3.4" [[deps.StructTypes]] deps = ["Dates", "UUIDs"] @@ -430,6 +436,12 @@ deps = ["Dates"] uuid = "fa267f1f-6049-4f14-aa54-33bafae1ed76" version = "1.0.0" +[[deps.TZJData]] +deps = ["Artifacts"] +git-tree-sha1 = "d39314cdbaf5b90a047db33858626f8d1cc973e1" +uuid = "dc5dba14-91b3-4cab-a142-028a31da12f7" +version = "1.0.0+2023c" + [[deps.TableTraits]] deps = ["IteratorInterfaceExtensions"] git-tree-sha1 = "c06b2f539df1c6efa794486abfb6ed2022561a39" @@ -437,10 +449,10 @@ uuid = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" version = "1.0.1" [[deps.Tables]] -deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits", "Test"] -git-tree-sha1 = "c79322d36826aa2f4fd8ecfa96ddb47b174ac78d" +deps = ["DataAPI", "DataValueInterfaces", "IteratorInterfaceExtensions", "LinearAlgebra", "OrderedCollections", "TableTraits"] +git-tree-sha1 = "a1f34829d5ac0ef499f6d84428bd6b4c71f02ead" uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" -version = "1.10.0" +version = "1.11.0" [[deps.Tar]] deps = ["ArgTools", "SHA"] @@ -452,16 +464,22 @@ deps = ["InteractiveUtils", "Logging", "Random", "Serialization"] uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [[deps.TimeZones]] -deps = ["Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "RecipesBase", "Scratch", "Unicode"] -git-tree-sha1 = "a92ec4466fc6e3dd704e2668b5e7f24add36d242" +deps = ["Artifacts", "Dates", "Downloads", "InlineStrings", "LazyArtifacts", "Mocking", "Printf", "RecipesBase", "Scratch", "TZJData", "Unicode", "p7zip_jll"] +git-tree-sha1 = "89e64d61ef3cd9e80f7fc12b7d13db2d75a23c03" uuid = "f269a46b-ccf7-5d73-abea-4c690281aa53" -version = "1.9.1" +version = "1.13.0" [[deps.ToStruct]] git-tree-sha1 = "f96bb06d38c94de6b6d0199fe5e73067c6f46edf" uuid = "43ec2cc1-0e50-5406-a854-b7ff8fdb8dad" version = "0.2.3" +[[deps.UTCDateTimes]] +deps = ["Dates", "TimeZones"] +git-tree-sha1 = "4af3552bf0cf4a071bf3d14bd20023ea70f31b62" +uuid = "0f7cfa37-7abf-4834-b969-a8aa512401c2" +version = "1.6.1" + [[deps.UUIDs]] deps = ["Random", "SHA"] uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" @@ -471,9 +489,9 @@ uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" [[deps.YAML]] deps = ["Base64", "Dates", "Printf", "StringEncodings"] -git-tree-sha1 = "dbc7f1c0012a69486af79c8bcdb31be820670ba2" +git-tree-sha1 = "e6330e4b731a6af7959673621e91645eb1356884" uuid = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6" -version = "0.4.8" +version = "0.4.9" [[deps.Zlib_jll]] deps = ["Libdl"] diff --git a/Project.toml b/Project.toml index ffa7764..a61a547 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BitemporalPostgres" uuid = "e513cd14-23e6-48df-acf1-d9bc8fa5674b" authors = ["michaelfliegner "] -version = "1.7.0" +version = "1.8.0" [deps] AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c" diff --git a/workflowtest_repeatable.jl b/workflowtest_repeatable.jl new file mode 100644 index 0000000..8a389a9 --- /dev/null +++ b/workflowtest_repeatable.jl @@ -0,0 +1,195 @@ +# content +# Introduction +# connecting to POSTGRES +# creating the db schema +# testing bitemporal crud +# 1. Introduction +# If You start this repo in gitpod, You can open this notebook in vscode and execute the code with julia and postgres up and running https://www.gitpod.io/docs/ +# +# 1.1. connecting to POSTGRES +include("init.jl") +using Logging, SearchLight +using SearchLightPostgreSQL +SearchLight.connect(SearchLight.Configuration.load()) +setfield!(SearchLight.config, :log_queries, false) +setfield!(SearchLight.config, :log_level, Logging.Error) + +# 2 Starting with workflows +# 2.1 Workflow 1 (the blue rectangle :=) ) +# 2.1.1 Starting workflow 1 +# inserting component 1 and subcomponent 1.1 + +using Dates, Test, TimeZones +import BitemporalPostgres +using BitemporalPostgres + +w1blue = Workflow(type_of_entity="TestDummyComponent", + tsw_validfrom=ZonedDateTime(2014, 5, 30, 21, 0, 1, 1, tz"UTC")) + +t1 = TestDummyComponent() +t1r1blue = TestDummyComponentRevision(description="blue") +ts = TestDummySubComponent(ref_super=t1.id) +ts1r1green = TestDummySubComponentRevision(description="green") +create_entity!(w1blue) +create_component!(t1, t1r1blue, w1blue) +println(t1r1blue) +create_subcomponent!(t1, ts, ts1r1green, w1blue) +@test !isnothing(w1blue.ref_history) +@test w1blue.is_committed == 0 + +@test w1blue.ref_version == t1r1blue.ref_validfrom +@test w1blue.ref_version == ts1r1green.ref_validfrom + +#2.1.2 Commiting workflow 1 +commit_workflow!(w1blue) +@test w1blue.is_committed == 1 + +#2.2 Workflow 2 ( the yellow rectangle that shortens the blue one) +#2.2.1 Starting workflow 2 +#mutating component 1 + +w2yellow = Workflow(type_of_entity="TestDummyComponent", + ref_history=w1blue.ref_history, + tsw_validfrom=ZonedDateTime(2015, 5, 30, 21, 0, 1, 1, tz"UTC"), +) +t1r2yellow = copy(t1r1blue) +t1r2yellow.description = "yellow" +update_entity!(w2yellow) +update_component!(t1r1blue, t1r2yellow, w2yellow) +println(t1r2yellow) +@test w2yellow.ref_version == t1r2yellow.ref_validfrom +@test w2yellow.ref_version == t1r1blue.ref_invalidfrom + +# 2.2.2 Committing workflow 2 +commit_workflow!(w2yellow) +@test w2yellow.is_committed == 1 + +# 2.3 workflow 3 (the red rectancle that shadows the yellow one) +# 2.3.1 Starting workflow 3 +w3redshadow = Workflow(type_of_entity="TestDummyComponent", + ref_history=w1blue.ref_history, + tsw_validfrom=ZonedDateTime(2014, 11, 30, 21, 0, 1, 1, tz"UTC"), +) +update_entity!(w3redshadow) +t1r1blue = findcomponentrevision(TestDummyComponentRevision, t1.id, w3redshadow.ref_version)[1] +t1r3red = copy(t1r1blue) +t1r3red.description = "red" +update_component!(t1r1blue, t1r3red, w3redshadow) +@test w3redshadow.ref_version == t1r3red.ref_validfrom +# .3.4 Committing workflow 3 +commit_workflow!(w3redshadow) +@test w3redshadow.is_committed == 1 +# 3 Testing +# For each workflow +# +# as of its intervals valid from points +# as of its intervals db valid from and 1 second before its world validfrom +v1 = findversion(w1blue.ref_history, w1blue.tsdb_validfrom, w1blue.tsw_validfrom) + +@test findcomponentrevision(TestDummyComponentRevision, t1.id, v1)[1].description == "blue" + +v2 = findversion(w2yellow.ref_history, w2yellow.tsdb_validfrom, w2yellow.tsw_validfrom) + +@test findcomponentrevision(TestDummyComponentRevision, t1.id, v2)[1].description == "yellow" + +v2a = findversion(w2yellow.ref_history, w2yellow.tsdb_validfrom, w2yellow.tsw_validfrom - Dates.Second(1)) + +@test findcomponentrevision(TestDummyComponentRevision, t1.id, v2a)[1].description == "blue" + +v3 = findversion(w3redshadow.ref_history, w3redshadow.tsdb_validfrom, w3redshadow.tsw_validfrom) + +@test findcomponentrevision(TestDummyComponentRevision, t1.id, v3)[1].description == "red" + +v3a = findversion(w3redshadow.ref_history, w3redshadow.tsdb_validfrom, w3redshadow.tsw_validfrom - Dates.Second(1)) + +@test findcomponentrevision(TestDummyComponentRevision, t1.id, v3a)[1].description == "blue" +v1 = findversion(w1blue.ref_history, w1blue.tsdb_validfrom, w1blue.tsw_validfrom) +r1 = findcomponentrevision(TestDummySubComponentRevision, ts.id, v1) +@testset "reading tests" begin + v1 = findversion(w1blue.ref_history, w1blue.tsdb_validfrom, w1blue.tsw_validfrom) + + @test findcomponentrevision(TestDummyComponentRevision, t1.id, v1)[1].description == "blue" + @test findcomponentrevision(TestDummySubComponentRevision, ts.id, v1)[1].description == "green" + + v2 = findversion(w2yellow.ref_history, w2yellow.tsdb_validfrom, w2yellow.tsw_validfrom) + + @test findcomponentrevision(TestDummyComponentRevision, t1.id, v2)[1].description == "yellow" + @test findcomponentrevision(TestDummySubComponentRevision, ts.id, v2)[1].description == "green" + + v2a = findversion(w2yellow.ref_history, w2yellow.tsdb_validfrom, w2yellow.tsw_validfrom - Dates.Second(1)) + + @test findcomponentrevision(TestDummyComponentRevision, t1.id, v2a)[1].description == "blue" + @test findcomponentrevision(TestDummySubComponentRevision, ts.id, v2a)[1].description == "green" + + + v3 = findversion(w3redshadow.ref_history, w3redshadow.tsdb_validfrom, w3redshadow.tsw_validfrom) + + @test findcomponentrevision(TestDummyComponentRevision, t1.id, v3)[1].description == "red" + @test findcomponentrevision(TestDummySubComponentRevision, ts.id, v3)[1].description == "green" + + v3a = findversion(w3redshadow.ref_history, w3redshadow.tsdb_validfrom, w3redshadow.tsw_validfrom - Dates.Second(1)) + + @test findcomponentrevision(TestDummyComponentRevision, t1.id, v3a)[1].description == "blue" + @test findcomponentrevision(TestDummySubComponentRevision, ts.id, v3a)[1].description == "green" + +end +# Testing pending transactions and rollback + +w4PendingRollback = Workflow(type_of_entity="TestDummyComponent", + ref_history=w1blue.ref_history, + tsdb_validfrom=now(tz"UTC"), + tsw_validfrom=ZonedDateTime(2017, 11, 30, 21, 0, 1, 1, tz"UTC"), +) +update_entity!(w4PendingRollback) + +t1r3red = findcomponentrevision(TestDummyComponentRevision, t1.id, w4PendingRollback.ref_version)[1] +t1r4green = copy(t1r3red) +t1r4green.description = "green" + +t2 = TestDummyComponent() +t2r1pink = TestDummyComponentRevision(description="pink") + +@test t1r3red.ref_invalidfrom == MaxVersion +update_component!(t1r3red, t1r4green, w4PendingRollback) +create_component!(t2, t2r1pink, w4PendingRollback) +@testset "pending transaction tests" begin + @test findcomponentrevision(TestDummyComponentRevision, t1.id, w4PendingRollback.ref_version)[1].description == "green" + @test findcomponentrevision(TestDummyComponentRevision, t2.id, w4PendingRollback.ref_version)[1].description == "pink" + @test w4PendingRollback.ref_version == t1r3red.ref_invalidfrom + @test w4PendingRollback.ref_version == t1r4green.ref_validfrom + @test MaxVersion == t1r4green.ref_invalidfrom + @test w4PendingRollback.ref_version == t2r1pink.ref_validfrom +end +@testset "rollbacked transaction tests" begin + rollback_workflow!(w4PendingRollback) + @test !isempty(findcomponentrevision(TestDummyComponentRevision, t1.id, w4PendingRollback.ref_version)) + w4PendingRollback.ref_version == t1r3red.ref_invalidfrom + w4PendingRollback.ref_version == t1r4green.ref_validfrom +end +w3redshadow = Workflow(type_of_entity="TestDummyComponent", + ref_history=w1blue.ref_history, + tsw_validfrom=ZonedDateTime(2014, 11, 30, 21, 0, 1, 1, tz"UTC"), +) +# 2.3.2 Testing retrospective transactions +# 2.3.2.1 preparing the retrospective transaction by +# preliminarily invalidating all insertions and mutations from shadowed versions and +# reviving all revisions invalidated by shadowed versions +update_entity!(w3redshadow) +@testset "retrospective update entity red revive and invalidate shadowed " begin + # have currently shadowed revisions been invalidated? + @test !isempty(find(TestDummyComponentRevision, SQLWhereExpression("ref_invalidfrom=?", w3redshadow.ref_version))) + # have revisions invalidated by shadowed versions been revived? + @test !isempty(find(TestDummyComponentRevision, SQLWhereExpression("ref_validfrom=?", w3redshadow.ref_version))) +end +# 2.3.2.2 Does rolling back the transaction delete the preliminary revisions? +rollback_workflow!(w3redshadow) +@testset "retrospective update entity red revive and invalidate shadowed " begin + # have currently shadowed revisions been invalidated? + @test isempty(find(TestDummyComponentRevision, SQLWhereExpression("ref_invalidfrom=?", w3redshadow.ref_version))) + # have revisions invalidated by shadowed versions been revived? + @test isempty(find(TestDummyComponentRevision, SQLWhereExpression("ref_validfrom=?", w3redshadow.ref_version))) +end + +@testset "get_typeof functions" begin + @test get_typeof_revision(get_typeof_component(TestDummyComponentRevision())()) == TestDummyComponentRevision +end \ No newline at end of file