global-registry-bindings 0.6.2 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/global_registry_bindings/entity/entity_type_methods.rb +16 -18
- data/lib/global_registry_bindings/entity/mdm_methods.rb +11 -12
- data/lib/global_registry_bindings/entity/push_entity_methods.rb +23 -23
- data/lib/global_registry_bindings/entity/push_relationship_methods.rb +18 -18
- data/lib/global_registry_bindings/entity/relationship_type_methods.rb +26 -26
- data/lib/global_registry_bindings/exceptions.rb +7 -2
- data/lib/global_registry_bindings/global_registry_bindings.rb +19 -19
- data/lib/global_registry_bindings/model/delete_entity.rb +4 -4
- data/lib/global_registry_bindings/model/entity.rb +25 -25
- data/lib/global_registry_bindings/model/pull_mdm.rb +5 -5
- data/lib/global_registry_bindings/model/push_entity.rb +4 -4
- data/lib/global_registry_bindings/model/push_relationship.rb +10 -8
- data/lib/global_registry_bindings/model/relationship.rb +18 -18
- data/lib/global_registry_bindings/options/entity_class_options.rb +15 -15
- data/lib/global_registry_bindings/options/entity_instance_options.rb +11 -11
- data/lib/global_registry_bindings/options/entity_options_parser.rb +3 -3
- data/lib/global_registry_bindings/options/relationship_class_options.rb +22 -22
- data/lib/global_registry_bindings/options/relationship_instance_options.rb +12 -12
- data/lib/global_registry_bindings/options/relationship_options_parser.rb +7 -7
- data/lib/global_registry_bindings/options.rb +6 -6
- data/lib/global_registry_bindings/railtie.rb +7 -7
- data/lib/global_registry_bindings/testing.rb +3 -3
- data/lib/global_registry_bindings/version.rb +3 -3
- data/lib/global_registry_bindings/worker.rb +5 -5
- data/lib/global_registry_bindings/workers/delete_entity_worker.rb +3 -3
- data/lib/global_registry_bindings/workers/pull_mdm_id_worker.rb +5 -5
- data/lib/global_registry_bindings/workers/push_entity_worker.rb +6 -6
- data/lib/global_registry_bindings/workers/push_relationship_worker.rb +6 -6
- data/lib/global_registry_bindings.rb +3 -3
- metadata +15 -155
- data/spec/acceptance/global_registry_bindings_spec.rb +0 -191
- data/spec/factories/factories.rb +0 -72
- data/spec/fixtures/get_entities_person.json +0 -8
- data/spec/fixtures/get_entities_person_mdm.json +0 -13
- data/spec/fixtures/get_entities_person_relationship.json +0 -32
- data/spec/fixtures/get_entity_types.json +0 -9
- data/spec/fixtures/get_entity_types_address.json +0 -59
- data/spec/fixtures/get_entity_types_address_partial.json +0 -43
- data/spec/fixtures/get_entity_types_area.json +0 -44
- data/spec/fixtures/get_entity_types_community.json +0 -18
- data/spec/fixtures/get_entity_types_fancy_org.json +0 -43
- data/spec/fixtures/get_entity_types_fancy_org_assignment.json +0 -35
- data/spec/fixtures/get_entity_types_fancy_org_partial.json +0 -35
- data/spec/fixtures/get_entity_types_ministry.json +0 -18
- data/spec/fixtures/get_entity_types_person.json +0 -42
- data/spec/fixtures/get_entity_types_person_partial.json +0 -34
- data/spec/fixtures/get_relationship_types.json +0 -9
- data/spec/fixtures/get_relationship_types_person_fancy_org.json +0 -41
- data/spec/fixtures/get_relationship_types_person_fancy_org_partial.json +0 -33
- data/spec/fixtures/post_entities_community.json +0 -8
- data/spec/fixtures/post_entities_fancy_org.json +0 -8
- data/spec/fixtures/post_entities_fancy_org_parent.json +0 -8
- data/spec/fixtures/post_entities_person.json +0 -8
- data/spec/fixtures/post_entity_types_address.json +0 -9
- data/spec/fixtures/post_entity_types_fancy_org.json +0 -9
- data/spec/fixtures/post_entity_types_person.json +0 -9
- data/spec/fixtures/post_relationship_types_assigned_by.json +0 -16
- data/spec/fixtures/post_relationship_types_community_ministry.json +0 -16
- data/spec/fixtures/post_relationship_types_fancy_org_area.json +0 -16
- data/spec/fixtures/post_relationship_types_person_fancy_org.json +0 -16
- data/spec/fixtures/put_entities_address.json +0 -20
- data/spec/fixtures/put_entities_community_relationship.json +0 -16
- data/spec/fixtures/put_entities_fancy_org_area_relationship.json +0 -8
- data/spec/fixtures/put_entities_fancy_org_assignment_assigned_by.json +0 -20
- data/spec/fixtures/put_entities_fancy_org_relationship.json +0 -17
- data/spec/fixtures/put_entities_person_country_relationship.json +0 -23
- data/spec/fixtures/put_entities_person_relationship.json +0 -29
- data/spec/fixtures/put_entities_relationship.json +0 -8
- data/spec/fixtures/put_entities_relationship_400.json +0 -3
- data/spec/fixtures/put_relationship_types_fields.json +0 -33
- data/spec/fixtures/put_relationship_types_fields_fancy_org_area.json +0 -25
- data/spec/helpers/sidekiq_helpers.rb +0 -14
- data/spec/internal/app/models/address.rb +0 -17
- data/spec/internal/app/models/application_record.rb +0 -5
- data/spec/internal/app/models/area.rb +0 -7
- data/spec/internal/app/models/assignment.rb +0 -21
- data/spec/internal/app/models/community.rb +0 -20
- data/spec/internal/app/models/country.rb +0 -8
- data/spec/internal/app/models/default.rb +0 -6
- data/spec/internal/app/models/namespaced/person/user_edited.rb +0 -8
- data/spec/internal/app/models/namespaced/person.rb +0 -68
- data/spec/internal/app/models/organization.rb +0 -37
- data/spec/internal/config/database.yml +0 -4
- data/spec/internal/config/initializers/global_registry.rb +0 -8
- data/spec/internal/config/routes.rb +0 -5
- data/spec/internal/db/schema.rb +0 -75
- data/spec/internal/db/test.sqlite +0 -0
- data/spec/internal/log/test.log +0 -1457
- data/spec/models/address_spec.rb +0 -30
- data/spec/models/assignment_spec.rb +0 -54
- data/spec/models/organization_spec.rb +0 -125
- data/spec/models/person_spec.rb +0 -191
- data/spec/models/testing_spec.rb +0 -55
- data/spec/models/user_edited_person_spec.rb +0 -14
- data/spec/options/if_unless_spec.rb +0 -147
- data/spec/spec_helper.rb +0 -52
- data/spec/workers/delete_gr_entity_worker_spec.rb +0 -33
- data/spec/workers/pull_mdm_id_worker_spec.rb +0 -133
- data/spec/workers/push_entity_worker_spec.rb +0 -506
- data/spec/workers/push_relationship_worker_spec.rb +0 -503
@@ -1,33 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"relationship_type": {
|
3
|
-
"id": "5d721db8-4248-11e7-90b4-129bd0521531",
|
4
|
-
"relationship_entity_type_id": "5d70b630-4248-11e7-90b4-129bd0521531",
|
5
|
-
"relationship1": {
|
6
|
-
"entity_type": "person",
|
7
|
-
"relationship_name": "person"
|
8
|
-
},
|
9
|
-
"relationship2": {
|
10
|
-
"entity_type": "fancy_org",
|
11
|
-
"relationship_name": "fancy_org"
|
12
|
-
},
|
13
|
-
"fields": [
|
14
|
-
{
|
15
|
-
"id": "235ce6fc-4249-11e7-944f-129bd0521531",
|
16
|
-
"name": "role",
|
17
|
-
"data_visibility": "public",
|
18
|
-
"field_type": "string",
|
19
|
-
"is_editable": true,
|
20
|
-
"unique_value": false
|
21
|
-
},
|
22
|
-
{
|
23
|
-
"id": "675bd9ee-4249-11e7-9e93-129bd0521531",
|
24
|
-
"name": "hired_on",
|
25
|
-
"data_visibility": "public",
|
26
|
-
"field_type": "datetime",
|
27
|
-
"is_editable": true,
|
28
|
-
"unique_value": false
|
29
|
-
}
|
30
|
-
],
|
31
|
-
"is_editable": true
|
32
|
-
}
|
33
|
-
}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"relationship_type": {
|
3
|
-
"id": "f03b947e-6644-11e7-93dd-129bd0521531",
|
4
|
-
"relationship_entity_type_id": "f03a929a-6644-11e7-93dd-129bd0521531",
|
5
|
-
"relationship1": {
|
6
|
-
"entity_type": "fancy_org",
|
7
|
-
"relationship_name": "fancy_org"
|
8
|
-
},
|
9
|
-
"relationship2": {
|
10
|
-
"entity_type": "area",
|
11
|
-
"relationship_name": "area"
|
12
|
-
},
|
13
|
-
"fields": [
|
14
|
-
{
|
15
|
-
"id": "ac0bde52-6645-11e7-80e8-129bd0521531",
|
16
|
-
"name": "priority",
|
17
|
-
"data_visibility": "public",
|
18
|
-
"field_type": "string",
|
19
|
-
"is_editable": true,
|
20
|
-
"unique_value": false
|
21
|
-
}
|
22
|
-
],
|
23
|
-
"is_editable": true
|
24
|
-
}
|
25
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module SidekiqHelpers
|
4
|
-
def clear_sidekiq_jobs_and_locks
|
5
|
-
# Drop sidekiq-unique-jobs locks
|
6
|
-
MOCK_REDIS.keys.each do |key|
|
7
|
-
MOCK_REDIS.del(key)
|
8
|
-
end
|
9
|
-
|
10
|
-
# Clear sidekiq queues and workers
|
11
|
-
Sidekiq::Queues.clear_all
|
12
|
-
Sidekiq::Worker.clear_all
|
13
|
-
end
|
14
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Address < ApplicationRecord
|
4
|
-
EXCLUDE_GR_FIELDS = %i[id created_at updated_at global_registry_id person_id address1].freeze
|
5
|
-
belongs_to :person, class_name: 'Namespaced::Person', inverse_of: :addresses
|
6
|
-
global_registry_bindings parent: :person,
|
7
|
-
exclude: proc { |_type, _model| EXCLUDE_GR_FIELDS },
|
8
|
-
fields: :global_registry_extra_fields,
|
9
|
-
include_all_columns: true
|
10
|
-
|
11
|
-
alias_attribute :line1, :address1
|
12
|
-
alias_attribute :postal_code, :zip
|
13
|
-
|
14
|
-
def global_registry_extra_fields(_type)
|
15
|
-
{ line1: :string, line2: :string, postal_code: :string }
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Assignment < ApplicationRecord
|
4
|
-
belongs_to :person, class_name: 'Namespaced::Person'
|
5
|
-
belongs_to :organization
|
6
|
-
belongs_to :assigned_by, class_name: 'Namespaced::Person', foreign_key: 'assigned_by_id'
|
7
|
-
|
8
|
-
global_registry_bindings binding: :relationship,
|
9
|
-
type: :fancy_org_assignment,
|
10
|
-
primary: :person,
|
11
|
-
related: :organization,
|
12
|
-
include_all_columns: true,
|
13
|
-
exclude: %i[assigned_by_id assigned_by_gr_rel_id]
|
14
|
-
|
15
|
-
global_registry_bindings binding: :relationship,
|
16
|
-
type: :assigned_by,
|
17
|
-
id_column: :assigned_by_gr_rel_id,
|
18
|
-
primary_binding: :fancy_org_assignment,
|
19
|
-
primary_name: :assigned_by,
|
20
|
-
related: :assigned_by
|
21
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Community < ApplicationRecord
|
4
|
-
global_registry_bindings ensure_type: false,
|
5
|
-
include_all_columns: true,
|
6
|
-
exclude: %i[infobase_id infobase_gr_id]
|
7
|
-
|
8
|
-
global_registry_bindings binding: :relationship,
|
9
|
-
type: :infobase_ministry,
|
10
|
-
id_column: :infobase_gr_id,
|
11
|
-
related_binding: :remote,
|
12
|
-
related_name: :ministry,
|
13
|
-
related_type: :ministry,
|
14
|
-
related_foreign_key: :infobase_id,
|
15
|
-
related_global_registry_id: :pull_infobase_global_registry_id
|
16
|
-
|
17
|
-
def pull_infobase_global_registry_id(_type)
|
18
|
-
'41f767fd-86f4-42e2-8d24-cbc3f697b794'
|
19
|
-
end
|
20
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Country < ApplicationRecord
|
4
|
-
has_many :employees, class_name: 'Namespaced::Person', inverse_of: :country_of_service
|
5
|
-
has_many :residents, class_name: 'Namespaced::Person', inverse_of: :country_of_residence
|
6
|
-
|
7
|
-
global_registry_bindings ensure_type: false, include_all_columns: true
|
8
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Namespaced
|
4
|
-
class Person < ApplicationRecord
|
5
|
-
has_many :addresses, dependent: :destroy, inverse_of: :person
|
6
|
-
has_many :assignments
|
7
|
-
has_many :organizations, through: :assignments
|
8
|
-
belongs_to :country_of_service,
|
9
|
-
class_name: 'Country',
|
10
|
-
foreign_key: :country_of_service_id,
|
11
|
-
inverse_of: :employees
|
12
|
-
belongs_to :country_of_residence,
|
13
|
-
class_name: 'Country',
|
14
|
-
foreign_key: :country_of_residence_id,
|
15
|
-
inverse_of: :residents
|
16
|
-
|
17
|
-
global_registry_bindings binding: :entity,
|
18
|
-
mdm_id_column: :global_registry_mdm_id,
|
19
|
-
mdm_timeout: 24.hours,
|
20
|
-
fingerprint_column: :global_registry_fingerprint,
|
21
|
-
include_all_columns: true,
|
22
|
-
exclude: %i[guid country_of_service_gr_id country_of_service_id
|
23
|
-
country_of_residence_gr_id country_of_residence_id]
|
24
|
-
|
25
|
-
global_registry_bindings binding: :relationship,
|
26
|
-
type: :country_of_service,
|
27
|
-
id_column: :country_of_service_gr_id,
|
28
|
-
client_integration_id: ->(model) { "cos_#{model.id}" },
|
29
|
-
related: :country_of_service,
|
30
|
-
exclude: :exclude_cos_fields,
|
31
|
-
fields: :extra_cos_fields,
|
32
|
-
ensure_type: false,
|
33
|
-
rename_entity_type: false
|
34
|
-
|
35
|
-
global_registry_bindings binding: :relationship,
|
36
|
-
type: :country_of_residence,
|
37
|
-
id_column: :country_of_residence_gr_id,
|
38
|
-
client_integration_id: ->(model) { "cor_#{model.id}" },
|
39
|
-
related: :country_of_residence,
|
40
|
-
ensure_type: false,
|
41
|
-
rename_entity_type: false
|
42
|
-
|
43
|
-
def entity_attributes_to_push
|
44
|
-
entity_attributes = super
|
45
|
-
entity_attributes[:authentication] = { key_guid: guid }
|
46
|
-
entity_attributes
|
47
|
-
end
|
48
|
-
|
49
|
-
def exclude_cos_fields(_type)
|
50
|
-
%i[]
|
51
|
-
end
|
52
|
-
|
53
|
-
def extra_cos_fields(_type)
|
54
|
-
{}
|
55
|
-
end
|
56
|
-
|
57
|
-
def relationship_attributes_to_push(type)
|
58
|
-
entity_attributes = super(type)
|
59
|
-
case type
|
60
|
-
when :country_of_service
|
61
|
-
entity_attributes[:country_of_service] = true
|
62
|
-
when :country_of_residence
|
63
|
-
entity_attributes[:country_of_residence] = true
|
64
|
-
end
|
65
|
-
entity_attributes
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Organization < ApplicationRecord
|
4
|
-
has_many :children, class_name: 'Organization', foreign_key: :parent_id
|
5
|
-
belongs_to :parent, class_name: 'Organization'
|
6
|
-
|
7
|
-
has_many :assignments
|
8
|
-
has_many :people, class_name: 'Namespaced::Person', through: :assignments
|
9
|
-
|
10
|
-
belongs_to :area
|
11
|
-
|
12
|
-
global_registry_bindings id_column: :gr_id,
|
13
|
-
type: ->(_model) { :fancy_org },
|
14
|
-
push_on: %i[create destroy],
|
15
|
-
parent: :parent,
|
16
|
-
include_all_columns: true,
|
17
|
-
exclude: :exclude_gr_fields,
|
18
|
-
fields: proc { |_type, _model| {} }
|
19
|
-
|
20
|
-
global_registry_bindings binding: :relationship,
|
21
|
-
type: :area,
|
22
|
-
id_column: :global_registry_area_id,
|
23
|
-
related: :area,
|
24
|
-
exclude: proc { |_type, _model| %i[] },
|
25
|
-
fields: proc { |_type, _model| { priority: :string } },
|
26
|
-
rename_entity_type: false
|
27
|
-
|
28
|
-
def exclude_gr_fields(_type)
|
29
|
-
%i[id created_at updated_at gr_id parent_id area_id global_registry_area_id]
|
30
|
-
end
|
31
|
-
|
32
|
-
def relationship_attributes_to_push(type)
|
33
|
-
entity_attributes = super(type)
|
34
|
-
entity_attributes[:priority] = 'High' if type == :area
|
35
|
-
entity_attributes
|
36
|
-
end
|
37
|
-
end
|
data/spec/internal/db/schema.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
ActiveRecord::Schema.define(version: 0) do
|
4
|
-
create_table :people, force: true do |t|
|
5
|
-
t.string :global_registry_id
|
6
|
-
t.string :global_registry_mdm_id
|
7
|
-
t.string :global_registry_fingerprint
|
8
|
-
t.string :first_name
|
9
|
-
t.string :last_name
|
10
|
-
t.string :guid
|
11
|
-
t.references :country_of_service, index: true
|
12
|
-
t.references :country_of_residence, index: true
|
13
|
-
t.string :country_of_service_gr_id
|
14
|
-
t.string :country_of_residence_gr_id
|
15
|
-
t.timestamps
|
16
|
-
end
|
17
|
-
|
18
|
-
create_table :addresses, force: true do |t|
|
19
|
-
t.string :global_registry_id
|
20
|
-
t.string :address1
|
21
|
-
t.string :zip
|
22
|
-
t.boolean :primary
|
23
|
-
t.references :person, index: true
|
24
|
-
t.timestamps
|
25
|
-
end
|
26
|
-
|
27
|
-
create_table :organizations, force: true do |t|
|
28
|
-
t.string :gr_id
|
29
|
-
t.string :name
|
30
|
-
t.text :description
|
31
|
-
t.date :start_date
|
32
|
-
t.references :parent, index: true
|
33
|
-
t.references :area, index: true
|
34
|
-
t.string :global_registry_area_id
|
35
|
-
t.timestamps
|
36
|
-
end
|
37
|
-
|
38
|
-
create_table :assignments, force: true do |t|
|
39
|
-
t.string :global_registry_id
|
40
|
-
t.string :assigned_by_gr_rel_id
|
41
|
-
t.string :role
|
42
|
-
t.datetime :hired_at
|
43
|
-
t.references :person, index: true
|
44
|
-
t.references :organization, index: true
|
45
|
-
t.references :assigned_by, index: true
|
46
|
-
t.timestamps
|
47
|
-
end
|
48
|
-
|
49
|
-
create_table :areas, force: true do |t|
|
50
|
-
t.string :global_registry_id
|
51
|
-
t.string :area_name
|
52
|
-
t.string :area_code
|
53
|
-
t.boolean :is_active
|
54
|
-
t.timestamps
|
55
|
-
end
|
56
|
-
|
57
|
-
create_table :countries, force: true do |t|
|
58
|
-
t.string :name
|
59
|
-
t.string :global_registry_id
|
60
|
-
t.timestamps
|
61
|
-
end
|
62
|
-
|
63
|
-
create_table :communities, force: true do |t|
|
64
|
-
t.string :name
|
65
|
-
t.string :global_registry_id
|
66
|
-
t.integer :infobase_id
|
67
|
-
t.string :infobase_gr_id
|
68
|
-
t.timestamps
|
69
|
-
end
|
70
|
-
|
71
|
-
create_table :foos, force: true do |t|
|
72
|
-
t.string :global_registry_id
|
73
|
-
t.timestamps
|
74
|
-
end
|
75
|
-
end
|
Binary file
|