Skip to content

Commit 462caff

Browse files
committed
party_ref source place or party
1 parent 6ca87ed commit 462caff

8 files changed

Lines changed: 253 additions & 32 deletions

File tree

lib/diffo/provider.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ defmodule Diffo.Provider do
141141
action: :list_party_refs_by_instance_id,
142142
args: [:instance_id]
143143

144+
define :list_party_refs_by_place_id, action: :list_party_refs_by_place_id, args: [:place_id]
145+
define :list_party_refs_by_source_party_id, action: :list_party_refs_by_source_party_id, args: [:source_party_id]
146+
144147
define :update_party_ref, action: :update
145148
define :delete_party_ref, action: :destroy
146149
end

lib/diffo/provider/components/base_instance.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Diffo.Provider.BaseInstance do
3636
{:notes, :ANNOTATES, :incoming, :Note},
3737
{:event, :FIRED, :outgoing, :Event},
3838
{:places, :LOCATED_BY, :outgoing, :PlaceRef},
39-
{:parties, :INVOLVED_WITH, :outgoing, :PartyRef}
39+
{:parties, :RELATES, :outgoing, :PartyRef}
4040
]
4141

4242
label :Instance

lib/diffo/provider/components/party.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule Diffo.Provider.Party do
2323
translate id: :key
2424

2525
relate [
26-
{:party_refs, :INVOLVED_WITH, :incoming, :PartyRef},
26+
{:party_refs, :RELATES, :incoming, :PartyRef},
2727
{:external_identifiers, :OWNS, :outgoing, :ExternalIdentifier},
2828
{:notes, :AUTHORS, :outgoing, :Note}
2929
]

lib/diffo/provider/components/party_ref.ex

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ defmodule Diffo.Provider.PartyRef do
2121

2222
neo4j do
2323
relate [
24-
{:instance, :INVOLVED_WITH, :incoming, :Instance},
25-
{:party, :INVOLVED_WITH, :outgoing, :Party}
24+
{:instance, :RELATES, :incoming, :Instance},
25+
{:place, :RELATES, :incoming, :Place},
26+
{:source_party, :RELATES, :incoming, :Party},
27+
{:party, :RELATES, :outgoing, :Party}
2628
]
2729
end
2830

@@ -50,13 +52,17 @@ defmodule Diffo.Provider.PartyRef do
5052
defaults [:read, :destroy]
5153

5254
create :create do
53-
description "creates a party ref, relating an instance and a party"
55+
description "creates a party ref, relating an instance, place or source party to a party"
5456
accept [:role]
5557

5658
argument :instance_id, :uuid
59+
argument :place_id, :string
60+
argument :source_party_id, :string
5761
argument :party_id, :string
5862

5963
change manage_relationship(:instance_id, :instance, type: :append_and_remove)
64+
change manage_relationship(:place_id, :place, type: :append_and_remove)
65+
change manage_relationship(:source_party_id, :source_party, type: :append_and_remove)
6066
change manage_relationship(:party_id, :party, type: :append_and_remove)
6167
end
6268

@@ -70,6 +76,18 @@ defmodule Diffo.Provider.PartyRef do
7076
filter expr(instance_id == ^arg(:instance_id))
7177
end
7278

79+
read :list_party_refs_by_place_id do
80+
description "lists party refs by place id"
81+
argument :place_id, :string
82+
filter expr(place_id == ^arg(:place_id))
83+
end
84+
85+
read :list_party_refs_by_source_party_id do
86+
description "lists party refs by source_party id"
87+
argument :source_party_id, :string
88+
filter expr(source_party_id == ^arg(:source_party_id))
89+
end
90+
7391
read :list_party_refs_by_party_id do
7492
description "lists party refs by party id"
7593
argument :party_id, :string
@@ -100,7 +118,7 @@ defmodule Diffo.Provider.PartyRef do
100118
end
101119

102120
attribute :role, :atom do
103-
description "the role of the party to the instance"
121+
description "the role of the party to the instance, place or source party"
104122
allow_nil? true
105123
public? true
106124
end
@@ -113,7 +131,21 @@ defmodule Diffo.Provider.PartyRef do
113131
relationships do
114132
belongs_to :instance, Diffo.Provider.Instance do
115133
description "the instance which relates to a party via this party ref"
116-
allow_nil? false
134+
allow_nil? true
135+
public? true
136+
end
137+
138+
belongs_to :place, Diffo.Provider.Place do
139+
description "the place which relates to a party via this party ref"
140+
attribute_type :string
141+
allow_nil? true
142+
public? true
143+
end
144+
145+
belongs_to :source_party, Diffo.Provider.Party do
146+
description "the source party which relates to a party via this party ref"
147+
attribute_type :string
148+
allow_nil? true
117149
public? true
118150
end
119151

@@ -129,6 +161,20 @@ defmodule Diffo.Provider.PartyRef do
129161
identity :instance_party_uniqueness, [:instance_id, :party_id] do
130162
message "another party ref exists"
131163
end
164+
165+
identity :place_party_uniqueness, [:place_id, :party_id] do
166+
message "another party ref exists"
167+
end
168+
169+
identity :source_party_party_uniqueness, [:source_party_id, :party_id] do
170+
message "another party ref exists"
171+
end
172+
end
173+
174+
validations do
175+
validate present([:instance_id, :place_id, :source_party_id], exactly: 1) do
176+
message "a party ref can relate either an instance, place or source party"
177+
end
132178
end
133179

134180
preparations do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ defmodule Diffo.MixProject do
9494
{:ash_outstanding, "~> 0.2.3"},
9595
{:ash_jason, "~> 3.0"},
9696
{:ash_state_machine, "~> 0.2.12"},
97-
{:ash_neo4j, ash_neo4j_version("~> 0.2.11")},
97+
{:ash_neo4j, ash_neo4j_version("~> 0.2.12")},
9898
{:boltx, "~> 0.0.6"},
9999
{:ash, ash_version("~> 3.0 and >= 3.6.2")},
100100
{:uuid, "~> 1.1"},

mix.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
%{
22
"ash": {:hex, :ash, "3.9.0", "004371ffb181a142cda09544342dad1ffedf360a5636219d71cb5431ccbe3ad6", [:mix], [{:crux, ">= 0.1.2 and < 1.0.0-0", [hex: :crux, repo: "hexpm", optional: false]}, {:decimal, "~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:ecto, "~> 3.7", [hex: :ecto, repo: "hexpm", optional: false]}, {:ets, "~> 0.8", [hex: :ets, repo: "hexpm", optional: false]}, {:igniter, ">= 0.6.29 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:picosat_elixir, "~> 0.2", [hex: :picosat_elixir, repo: "hexpm", optional: true]}, {:plug, ">= 0.0.0", [hex: :plug, repo: "hexpm", optional: true]}, {:reactor, "~> 0.11", [hex: :reactor, repo: "hexpm", optional: false]}, {:simple_sat, ">= 0.1.1 and < 1.0.0-0", [hex: :simple_sat, repo: "hexpm", optional: true]}, {:spark, ">= 2.3.3 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, ">= 0.2.6 and < 1.0.0-0", [hex: :splode, repo: "hexpm", optional: false]}, {:stream_data, "~> 1.0", [hex: :stream_data, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.1", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "e3e80a182c6e8b4d87f1caa4dba774da210f1f75f1420650ba012eb4388dc8c3"},
33
"ash_jason": {:hex, :ash_jason, "3.0.3", "05349fe257c958ce84bcfc35871da7647960fcbcb288025623d1eb19839dc5fd", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:ex_check, "~> 0.16.0", [hex: :ex_check, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}, {:spark, ">= 2.1.21 and < 3.0.0", [hex: :spark, repo: "hexpm", optional: false]}], "hexpm", "1ef2cd24be16a46ee46a9e0de1f319acc6cc71ff31e0bc3e7bfd800955a4c550"},
4-
"ash_neo4j": {:hex, :ash_neo4j, "0.2.11", "41433b79c8dfe1f371faf411757c03b44cb56f14870375e80b348819fb17ddf1", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:boltx, ">= 0.0.6", [hex: :boltx, repo: "hexpm", optional: false]}], "hexpm", "b26a165908af327d45e951794c0fc1eaf4002d23239c41d6c4c01b1203471293"},
4+
"ash_neo4j": {:hex, :ash_neo4j, "0.2.12", "cc662833f3d4eb10ff36b217a1693c6deff3a878a9aea3baaf66090d987bb54a", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:boltx, ">= 0.0.6", [hex: :boltx, repo: "hexpm", optional: false]}], "hexpm", "fda719bfc002ce0840d62eabbf0502ab79dd1e249d852aa3eb0bee457bf96352"},
55
"ash_outstanding": {:hex, :ash_outstanding, "0.2.3", "dc8ec13028ea7bd1d74b46569b9db08f0d275d63700e2418d9e33fe4b21af2eb", [:mix], [{:ash, ">= 3.6.2 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}, {:outstanding, "~> 0.2.4", [hex: :outstanding, repo: "hexpm", optional: false]}], "hexpm", "05e2718b59937d9f7e77b7bc90f70e8f28c3f328de7cabf3ea55ca04a1abed52"},
66
"ash_state_machine": {:hex, :ash_state_machine, "0.2.12", "c0f7ebb8a176584f70c6ed196b7d0118c930d73e0590ade705d2dddc48aa7311", [:mix], [{:ash, ">= 3.4.66 and < 4.0.0-0", [hex: :ash, repo: "hexpm", optional: false]}], "hexpm", "394ce761ce82358e3c715e1cae6c5cf1390be27c03a8b661f2e5a2fda849873d"},
77
"boltx": {:hex, :boltx, "0.0.6", "c6a396b1538b258e4d5ee2a94aaf8fb2c7879240efffba94b9159dbdce963790", [:mix], [{:db_connection, "~> 2.6.0", [hex: :db_connection, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:poison, "~> 5.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm", "576b8f21a2021674130d04cd1fc79a4829a23d2cdf50641b3d7a00ce31b98ead"},
@@ -31,7 +31,7 @@
3131
"outstanding": {:hex, :outstanding, "0.2.5", "2f40416eb9617748cb1f8ae4c8ed94515d731f9c4fcee4f902355d30bc0792cc", [:mix], [], "hexpm", "bb47a210f0d2804ea6b8477fa6f4d15e8c58c18acee79d8e06c9296e6dd004cd"},
3232
"owl": {:hex, :owl, "0.13.0", "26010e066d5992774268f3163506972ddac0a7e77bfe57fa42a250f24d6b876e", [:mix], [{:ucwidth, "~> 0.2", [hex: :ucwidth, repo: "hexpm", optional: true]}], "hexpm", "59bf9d11ce37a4db98f57cb68fbfd61593bf419ec4ed302852b6683d3d2f7475"},
3333
"reactor": {:hex, :reactor, "0.17.0", "eb8bdb530dbae824e2d36a8538f8ec4f3aa7c2d1b61b04959fa787c634f88b49", [:mix], [{:igniter, "~> 0.4", [hex: :igniter, repo: "hexpm", optional: true]}, {:iterex, "~> 0.1", [hex: :iterex, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:libgraph, "~> 0.16", [hex: :libgraph, repo: "hexpm", optional: false]}, {:spark, ">= 2.3.3 and < 3.0.0-0", [hex: :spark, repo: "hexpm", optional: false]}, {:splode, "~> 0.2", [hex: :splode, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.2", [hex: :telemetry, repo: "hexpm", optional: false]}, {:yaml_elixir, "~> 2.11", [hex: :yaml_elixir, repo: "hexpm", optional: false]}, {:ymlr, "~> 5.0", [hex: :ymlr, repo: "hexpm", optional: false]}], "hexpm", "3c3bf71693adbad9117b11ec83cfed7d5851b916ade508ed9718de7ae165bf25"},
34-
"req": {:hex, :req, "0.5.15", "662020efb6ea60b9f0e0fac9be88cd7558b53fe51155a2d9899de594f9906ba9", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "a6513a35fad65467893ced9785457e91693352c70b58bbc045b47e5eb2ef0c53"},
34+
"req": {:hex, :req, "0.5.16", "99ba6a36b014458e52a8b9a0543bfa752cb0344b2a9d756651db1281d4ba4450", [:mix], [{:brotli, "~> 0.3.1", [hex: :brotli, repo: "hexpm", optional: true]}, {:ezstd, "~> 1.0", [hex: :ezstd, repo: "hexpm", optional: true]}, {:finch, "~> 0.17", [hex: :finch, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}, {:mime, "~> 2.0.6 or ~> 2.1", [hex: :mime, repo: "hexpm", optional: false]}, {:nimble_csv, "~> 1.0", [hex: :nimble_csv, repo: "hexpm", optional: true]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "974a7a27982b9b791df84e8f6687d21483795882a7840e8309abdbe08bb06f09"},
3535
"rewrite": {:hex, :rewrite, "1.2.0", "80220eb14010e175b67c939397e1a8cdaa2c32db6e2e0a9d5e23e45c0414ce21", [:mix], [{:glob_ex, "~> 0.1", [hex: :glob_ex, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.0", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "a1cd702bbb9d51613ab21091f04a386d750fc6f4516b81900df082d78b2d8c50"},
3636
"sourceror": {:hex, :sourceror, "1.10.0", "38397dedbbc286966ec48c7af13e228b171332be1ad731974438c77791945ce9", [:mix], [], "hexpm", "29dbdfc92e04569c9d8e6efdc422fc1d815f4bd0055dc7c51b8800fb75c4b3f1"},
3737
"spark": {:hex, :spark, "2.3.14", "a08420d08e6e0e49d740aed3e160f1cb894ba8f6b3f5e6c63253e9df1995265c", [:mix], [{:igniter, ">= 0.3.64 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: true]}, {:sourceror, "~> 1.2", [hex: :sourceror, repo: "hexpm", optional: true]}], "hexpm", "af50c4ea5dd67eba822247f1c98e1d4e598cb7f6c28ccf5d002f0e0718096f4f"},

test/provider/event_test.exs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ defmodule Diffo.Provider.EventTest do
1313

1414
setup do
1515
on_exit(fn ->
16-
# AshNeo4j.Neo4jHelper.delete_all()
17-
:ok
16+
AshNeo4j.Neo4jHelper.delete_all()
1817
end)
1918
end
2019

@@ -149,7 +148,6 @@ defmodule Diffo.Provider.EventTest do
149148
)
150149
end
151150

152-
@tag debug: true
153151
test "fired instance events are chained - success" do
154152
specification = Diffo.Provider.create_specification!(%{name: "nbnAccess"})
155153
instance = Diffo.Provider.create_instance!(%{specified_by: specification.id})

0 commit comments

Comments
 (0)