eco-helpers 2.0.24 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +89 -6
- data/lib/eco/api/common.rb +0 -1
- data/lib/eco/api/common/loaders.rb +2 -0
- data/lib/eco/api/common/loaders/base.rb +58 -0
- data/lib/eco/api/common/loaders/case_base.rb +33 -0
- data/lib/eco/api/common/loaders/error_handler.rb +2 -2
- data/lib/eco/api/common/loaders/parser.rb +30 -5
- data/lib/eco/api/common/loaders/policy.rb +1 -1
- data/lib/eco/api/common/loaders/use_case.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +129 -1
- data/lib/eco/api/common/people/entries.rb +83 -14
- data/lib/eco/api/common/people/entry_factory.rb +11 -10
- data/lib/eco/api/common/people/person_attribute_parser.rb +8 -0
- data/lib/eco/api/common/people/person_entry.rb +7 -6
- data/lib/eco/api/common/people/person_entry_attribute_mapper.rb +55 -16
- data/lib/eco/api/common/people/person_factory.rb +4 -2
- data/lib/eco/api/common/people/person_parser.rb +7 -1
- data/lib/eco/api/common/people/supervisor_helpers.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +0 -8
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +0 -8
- data/lib/eco/api/microcases/set_core_with_supervisor.rb +4 -2
- data/lib/eco/api/microcases/set_supervisor.rb +29 -8
- data/lib/eco/api/microcases/with_each.rb +7 -3
- data/lib/eco/api/microcases/with_each_starter.rb +3 -2
- data/lib/eco/api/organization/people.rb +7 -1
- data/lib/eco/api/session.rb +7 -2
- data/lib/eco/api/session/batch.rb +1 -1
- data/lib/eco/api/session/batch/job.rb +9 -1
- data/lib/eco/api/usecases/default_cases/create_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/create_details_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/create_details_with_supervisor_case.rb +10 -1
- data/lib/eco/api/usecases/default_cases/hris_case.rb +25 -1
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +1 -37
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +42 -0
- data/lib/eco/api/usecases/default_cases/upsert_case.rb +10 -1
- data/lib/eco/cli/config/default/input.rb +2 -2
- data/lib/eco/cli/config/default/options.rb +29 -8
- data/lib/eco/cli/config/default/usecases.rb +16 -0
- data/lib/eco/cli/config/default/workflow.rb +7 -4
- data/lib/eco/cli/config/filters.rb +6 -2
- data/lib/eco/cli/config/filters/input_filters.rb +3 -2
- data/lib/eco/cli/config/filters/people_filters.rb +3 -2
- data/lib/eco/cli/config/help.rb +1 -1
- data/lib/eco/cli/config/options_set.rb +6 -4
- data/lib/eco/cli/config/use_cases.rb +6 -3
- data/lib/eco/csv.rb +2 -0
- data/lib/eco/language/models/collection.rb +5 -2
- data/lib/eco/version.rb +1 -1
- metadata +3 -2
- data/lib/eco/api/common/base_loader.rb +0 -72
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89eb45172e9558ceb184ec289f435c5d2d853d8c7740f7922b0f3fe8727341a3
|
4
|
+
data.tar.gz: 7419eaed8d878f2f7d333928683a6f03ddeec94c13fa1fceabb716f8ece9cc4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '00395c4a6f51be7b846a37db9bb9b407ef21dbf8e86f76c41a58cb6ac9a34341f3a9c399d41de14a0f5922b46d9ee7b812750d9db7b1c7b7f4c131f5c17fb0aa'
|
7
|
+
data.tar.gz: df59209eaf8b90dfe43019150b0569398a0fb26ad96894da2641ad453a1d3aa815495ce9f035555a8f7a804689d931dc43e0882022a705bb9f1a650f75cae996
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,101 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [2.0.
|
4
|
+
## [2.0.29] - 2021-07-08
|
5
5
|
|
6
6
|
### Added
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
### Changed
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
- `Eco::API::Common::People::PersonEntryAttributeMapper#details_attrs`
|
12
|
+
* What a mess this was doing to the `csv` export :/
|
13
|
+
|
14
|
+
## [2.0.27] - 2021-07-05
|
15
|
+
|
9
16
|
### Changed
|
17
|
+
- Parent class `Eco::API::UseCases::DefaultCases::ToCsvCase` shouldn't know header maps necessary for `Eco::API::UseCases::DefaultCases::ToCsvDetailedCase`
|
18
|
+
* Moved related header maps to `ToCsvDetailedCase`
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
- `--help` should work fine now
|
22
|
+
- Attribute parsers that depended on indirect parser attributes were **not** included
|
23
|
+
- **changed** a couple of classes
|
24
|
+
- `Eco::API::Common::People::PersonEntryAttributeMapper`, where methods should receive `data` to re-scope if the data is available (most specifically `#internal_attrs`)
|
25
|
+
- `Eco::API::Common::People::PersonEntry`, where when setting the final values on `Person`, it should include any internal attribute that is present in the `final_entry` (the result of all the parsing process)
|
26
|
+
- `Eco::API::Common::People::DefaultParsers::CSVParser`
|
27
|
+
- indirect attributes that depended on other indirect attributes would show as missing even if they were active
|
28
|
+
- i.e. `name` depends on `first-name` & `surname`, **AND** `details-name` depends on `name`
|
29
|
+
|
30
|
+
## [2.0.26] - 2021-06-25
|
31
|
+
|
32
|
+
### Added
|
33
|
+
- `Eco::API::MicroCases#set_supervisor`, tries to keep in sync the `#subordinates` **count** of previous and new supervisor
|
34
|
+
- new **option** `-run-postlaunch` to run post launch cases, even when we run in `dry-run` mode
|
35
|
+
* when in `dry-run` it will **not** reload the people base of the session
|
36
|
+
- new **option** to append **new** entries to the `People` object
|
37
|
+
* **invokable** on **cli** via `-append-starters` (`{people: {append_created: true}}`)
|
38
|
+
* the following use cases include this option:
|
39
|
+
* `Eco::API::UseCases::DefaultCases::UpsertCase`
|
40
|
+
* `Eco::API::UseCases::DefaultCases::HrisCase`
|
41
|
+
* `Eco::API::UseCases::DefaultCases::CreateDetailsWithSupervisorCase`
|
42
|
+
* `Eco::API::UseCases::DefaultCases::CreateDetailsCase`
|
43
|
+
* `Eco::API::UseCases::DefaultCases::CreateCase`
|
44
|
+
* the option involves a new keyed argument `:append_created` in a couple of `MicroCases`
|
45
|
+
* `Eco::API::MicroCases#with_each`: where internally the search is performed against a copy of the `People` object.
|
46
|
+
* `Eco::API::MicroCases#with_each_starter`
|
47
|
+
* when `--help` is invoked option to filter the shown `-options`, `-usecases` and `filters` by a word contained in the option.
|
48
|
+
- **added** `csv` **header checks** for feed files, which entailed some changes:
|
49
|
+
* `Eco::API::Common::Loaders::Parser`
|
50
|
+
- new **subclass** `RequiredAttrs`, creatred when calling `.active_when_all` and `.active_when_any`
|
51
|
+
- **dependency** injection via `.dependencies` as `{required_attrs: RequiredAttrs}`
|
52
|
+
* **added** `Eco::API::Common::People::PersonParser#required_attrs` to offer all the `RequiredAttrs`, where defined
|
53
|
+
- the **new method** `#required_attrs` to expose the injected `RequiredAttrs`
|
54
|
+
* **new** keyed argument `check_headers:` in `Eco::API::Common::People::EntryFactory#entries`
|
55
|
+
- subsequent changes to accommodate the new param in `Eco::API::Session#csv_entries`
|
56
|
+
- `eco/cli/config/default/input` calls using this param to `true`
|
57
|
+
* `Eco::API::Common::People::DefaultParsers::CSVParser`
|
58
|
+
- added option `check_headers` via `dependencies` that enables the headers check
|
59
|
+
- it will now offer detailed warning messages on what can happen with the **missing headers**
|
60
|
+
* it will also list the **unknown header** names
|
61
|
+
|
62
|
+
### Changed
|
63
|
+
- `Eco::API::MicroCases#set_supervisor`, the order of the 2 first parameters
|
64
|
+
- `Eco::API::Organization::People`: internally `@by_id` cache Hash included `nil` values => **not** any more.
|
65
|
+
- removed **unused** methods on **patches** for `Ecoportal::API::V1::Person` and `Ecoportal::API::Internal::Person`
|
66
|
+
* specifically `#reset_account!` and `#consolidate_account!` as well as `#reset_details!` and `#consolidate_details!`
|
67
|
+
- internal changes in `Eco::API::Common::People::Entries#entry`
|
68
|
+
* **added** option to trigger `MultipleSearchResults` StandardError when multiple candiates are found.
|
69
|
+
* **removed** `nil` values from the `caches` (the Hashes to optimize the search)
|
70
|
+
- slight structure refactor of `Eco::API::Common::Loaders`
|
71
|
+
* moved base class to subfolder/namespace
|
72
|
+
* decoupled pure `Loader` logics to `Loaders::Base` and use case inheriance chain loader to `Loaders::CaseBase`
|
73
|
+
- `Eco::API::Session::BatchJob` the `post_launch`:
|
74
|
+
* sets the `id` to the `person` if it was **created** successfully
|
75
|
+
* when in `dry-run` it fakes the `id` with a counter
|
76
|
+
- `Eco::API::Common::People::PersonFactory` gets `subordinates` initialized to `0` (when **creating** a `new` person)
|
77
|
+
|
10
78
|
### Fixed
|
11
79
|
|
12
80
|
|
81
|
+
## [2.0.25] - 2021-06-23
|
82
|
+
|
83
|
+
### Added
|
84
|
+
- `Eco::API::UseCases::DefaultCases::HrisCase` validation error to require `-schema-id` command line when there are people in schemas other than the active one
|
85
|
+
|
86
|
+
### Changed
|
87
|
+
- `Eco::API::Session::Batch::Job`
|
88
|
+
* for backwards compatibility `-include-only-excluded` should bring an options structure compatible with `-include-excluded`
|
89
|
+
|
90
|
+
### Fixed
|
91
|
+
- `Eco::API::Session::Batch` fixed typo that would prevent `prompt_user` to work
|
92
|
+
|
93
|
+
## [2.0.24] - 2021-06-22
|
94
|
+
|
95
|
+
### Added
|
96
|
+
- `Eco::API::Session::Batch::Job` made **native** `-include-excluded`
|
97
|
+
* also added new option `-include-only-excluded` to be able to only target people HRIS excluded
|
98
|
+
|
13
99
|
## [2.0.23] - 2021-06-22
|
14
100
|
|
15
101
|
### Added
|
@@ -41,8 +127,6 @@ All notable changes to this project will be documented in this file.
|
|
41
127
|
* we just kept `roo` and `roo-xls`
|
42
128
|
- custom `Error` classes now all inherit from `StandardError` (rather than `Exception`)
|
43
129
|
|
44
|
-
|
45
|
-
|
46
130
|
## [2.0.21] - 2021-06-04
|
47
131
|
|
48
132
|
### Added
|
@@ -53,7 +137,6 @@ All notable changes to this project will be documented in this file.
|
|
53
137
|
### Changed
|
54
138
|
- `Eco::API::Common::People::EntryFactory` slight **refactor** to boost better support for multiple input formats
|
55
139
|
|
56
|
-
|
57
140
|
## [2.0.20] - 2021-05-31
|
58
141
|
|
59
142
|
### Added
|
data/lib/eco/api/common.rb
CHANGED
@@ -10,7 +10,6 @@ require_relative 'common/class_helpers'
|
|
10
10
|
require_relative 'common/class_auto_loader'
|
11
11
|
require_relative 'common/class_hierarchy'
|
12
12
|
require_relative 'common/class_meta_basics'
|
13
|
-
require_relative 'common/base_loader'
|
14
13
|
require_relative 'common/loaders'
|
15
14
|
require_relative 'common/session'
|
16
15
|
require_relative 'common/people'
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
module Common
|
4
|
+
module Loaders
|
5
|
+
class Base
|
6
|
+
extend Eco::API::Common::ClassHelpers
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# Sort order
|
10
|
+
def <=>(other)
|
11
|
+
created_at <=> other.created_at
|
12
|
+
end
|
13
|
+
|
14
|
+
# If still not set, it sets the `created_at` class timestamp.
|
15
|
+
def set_created_at!
|
16
|
+
@created_at = Time.now unless @created_at
|
17
|
+
end
|
18
|
+
|
19
|
+
# Class creation timestamp, to be able to load them in the order they were declared.
|
20
|
+
def created_at
|
21
|
+
@created_at ||= Time.now
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# This method will be called when the BaseLoader is created
|
26
|
+
# @note
|
27
|
+
# - this method should implement the loading logics for the given `Children` class.
|
28
|
+
def initialize
|
29
|
+
raise "You should implement this method"
|
30
|
+
end
|
31
|
+
|
32
|
+
def name
|
33
|
+
self.class.name
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def session
|
39
|
+
ASSETS.session
|
40
|
+
end
|
41
|
+
|
42
|
+
def config
|
43
|
+
session.config
|
44
|
+
end
|
45
|
+
|
46
|
+
def logger
|
47
|
+
session.logger
|
48
|
+
end
|
49
|
+
|
50
|
+
def micro
|
51
|
+
session.micro
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Eco
|
2
|
+
module API
|
3
|
+
module Common
|
4
|
+
module Loaders
|
5
|
+
class CaseBase < Loaders::Base
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_writer :name, :type
|
9
|
+
|
10
|
+
# The name that this case, policy or error handler will have.
|
11
|
+
def name(value = nil)
|
12
|
+
name_only_once! if value
|
13
|
+
set_created_at!
|
14
|
+
return @name ||= self.to_s unless value
|
15
|
+
@name = value
|
16
|
+
end
|
17
|
+
|
18
|
+
# Prevent the same class to be re-opened/re-named
|
19
|
+
def name_only_once!
|
20
|
+
raise "You have already declared #{self} or you are trying to give it a name twice" if @name
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def name
|
26
|
+
self.class.name
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -2,7 +2,7 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
|
-
class ErrorHandler < Eco::API::Common::
|
5
|
+
class ErrorHandler < Eco::API::Common::Loaders::CaseBase
|
6
6
|
|
7
7
|
class << self
|
8
8
|
attr_writer :error
|
@@ -17,7 +17,7 @@ module Eco
|
|
17
17
|
end
|
18
18
|
|
19
19
|
inheritable_class_vars :error
|
20
|
-
|
20
|
+
|
21
21
|
def initialize(handlers)
|
22
22
|
raise "Expected Eco::API::Policies. Given #{handlers.class}" unless handlers.is_a?(Eco::API::Error::Handlers)
|
23
23
|
handlers.on(self.error, &self.method(:main))
|
@@ -2,7 +2,28 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
|
-
class Parser < Eco::API::Common::
|
5
|
+
class Parser < Eco::API::Common::Loaders::CaseBase
|
6
|
+
|
7
|
+
# Helper class to scope what required attributes it depends on
|
8
|
+
class RequiredAttrs < Struct.new(:attr, :type, :attrs)
|
9
|
+
def active?(*input_attrs)
|
10
|
+
missing(*input_attrs).empty?
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependant?(attr)
|
14
|
+
attrs.include?(attr)
|
15
|
+
end
|
16
|
+
|
17
|
+
def missing(*input_attrs)
|
18
|
+
return [] if input_attrs.include?(attr)
|
19
|
+
match = input_attrs & attrs
|
20
|
+
miss = attrs - match
|
21
|
+
return [] if miss.empty?
|
22
|
+
return attrs if match.empty?
|
23
|
+
return miss if type == :all
|
24
|
+
[]
|
25
|
+
end
|
26
|
+
end
|
6
27
|
|
7
28
|
class << self
|
8
29
|
attr_reader :active_when
|
@@ -19,12 +40,14 @@ module Eco
|
|
19
40
|
@attribute = value
|
20
41
|
end
|
21
42
|
|
22
|
-
# TODO: it migh rather merge?
|
23
43
|
# Some parsers require dependencies to do their job.
|
24
|
-
def dependencies(value
|
44
|
+
def dependencies(**value)
|
25
45
|
@dependencies ||= {}
|
26
|
-
return @dependencies
|
27
|
-
|
46
|
+
return @dependencies.merge({
|
47
|
+
required_attrs: @active_when_attrs
|
48
|
+
}) unless !value.empty?
|
49
|
+
raise "Expected Hash. Given: '#{value.class}'" unless value.is_a?(Hash)
|
50
|
+
@dependencies.merge!(value)
|
28
51
|
end
|
29
52
|
|
30
53
|
# Define or get the `phase` that the `parser` kicks in.
|
@@ -47,6 +70,7 @@ module Eco
|
|
47
70
|
|
48
71
|
# Helper to build the `active_when` condition.
|
49
72
|
def active_when_any(*attrs)
|
73
|
+
@active_when_attrs = RequiredAttrs.new(attribute, :any, attrs)
|
50
74
|
@active_when = Proc.new do |source_data|
|
51
75
|
keys = data_keys(source_data)
|
52
76
|
attrs.any? {|key| keys.include?(key)}
|
@@ -55,6 +79,7 @@ module Eco
|
|
55
79
|
|
56
80
|
# Helper to build the `active_when` condition.
|
57
81
|
def active_when_all(*attrs)
|
82
|
+
@active_when_attrs = RequiredAttrs.new(attribute, :all, attrs)
|
58
83
|
@active_when = Proc.new do |source_data|
|
59
84
|
keys = data_keys(source_data)
|
60
85
|
attrs.all? {|key| keys.include?(key)}
|
@@ -2,7 +2,7 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
|
-
class Policy < Eco::API::Common::
|
5
|
+
class Policy < Eco::API::Common::Loaders::CaseBase
|
6
6
|
|
7
7
|
def initialize(policies)
|
8
8
|
raise "Expected Eco::API::Policies. Given #{policies.class}" unless policies.is_a?(Eco::API::Policies)
|
@@ -2,7 +2,7 @@ module Eco
|
|
2
2
|
module API
|
3
3
|
module Common
|
4
4
|
module Loaders
|
5
|
-
class UseCase < Eco::API::Common::
|
5
|
+
class UseCase < Eco::API::Common::Loaders::CaseBase
|
6
6
|
|
7
7
|
class << self
|
8
8
|
# @return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
|
@@ -2,7 +2,9 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
2
2
|
attribute :csv
|
3
3
|
|
4
4
|
def parser(data, deps)
|
5
|
-
Eco::CSV.parse(data, headers: true, skip_blanks: true).
|
5
|
+
Eco::CSV.parse(data, headers: true, skip_blanks: true).tap do |table|
|
6
|
+
check_headers(table) if deps[:check_headers]
|
7
|
+
end.each_with_object([]) do |row, arr_hash|
|
6
8
|
row_hash = row.headers.uniq.each_with_object({}) do |attr, hash|
|
7
9
|
next if attr.to_s.strip.empty?
|
8
10
|
hash[attr.strip] = parse_string(row[attr])
|
@@ -36,4 +38,130 @@ class Eco::API::Common::People::DefaultParsers::CSVParser < Eco::API::Common::Lo
|
|
36
38
|
["NULL"].any? {|token| str == token}
|
37
39
|
end
|
38
40
|
|
41
|
+
def check_headers(table)
|
42
|
+
headers = table.headers
|
43
|
+
missing = missing_headers(headers)
|
44
|
+
unknown = unknown_headers(headers)
|
45
|
+
unless missing.empty? && unknown.empty?
|
46
|
+
msg = "Detected possible HEADER ISSUES !!!\n"
|
47
|
+
msg << "There might be Missing or Wrong HEADER names in the CSV file:\n"
|
48
|
+
msg << " * UNKNOWN (or not used?): #{unknown}\n" unless unknown.empty?
|
49
|
+
msg << " * MISSING DIRECT: #{missing[:direct]}\n" unless (missing[:direct] || []).empty?
|
50
|
+
unless (data = missing[:indirect] || []).empty?
|
51
|
+
msg << " * MISSING INDIRECT:\n"
|
52
|
+
data.each do |ext, info|
|
53
|
+
msg << " - '#{ext}' => "
|
54
|
+
msg << (info[:attrs] || {}).map do |status, attrs|
|
55
|
+
if status == :inactive
|
56
|
+
"makes inactive: #{attrs}"
|
57
|
+
elsif status == :active
|
58
|
+
"there could be missing info in: #{attrs}"
|
59
|
+
end
|
60
|
+
end.compact.join("; ") + "\n"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
logger.warn(msg)
|
64
|
+
sleep(2)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def unknown_headers(headers)
|
69
|
+
(headers - known_headers) - all_internal_attrs
|
70
|
+
end
|
71
|
+
|
72
|
+
def missing_headers(headers)
|
73
|
+
int_head = internal_present_or_active(headers)
|
74
|
+
ext = headers.select do |e|
|
75
|
+
i = fields_mapper.to_internal(e)
|
76
|
+
int_head.include?(i)
|
77
|
+
end
|
78
|
+
ext_present = known_headers_present(int_head) | ext
|
79
|
+
ext_miss = known_headers - ext_present
|
80
|
+
|
81
|
+
ext_miss.each_with_object({}) do |ext, missing|
|
82
|
+
next unless int = fields_mapper.to_internal(ext)
|
83
|
+
if all_internal_attrs.include?(int)
|
84
|
+
missing[:direct] ||= []
|
85
|
+
missing[:direct] << ext
|
86
|
+
end
|
87
|
+
related_attrs_requirements = required_attrs.values.select do |req|
|
88
|
+
dep = req.dependant?(int)
|
89
|
+
affects = dep && !int_head.include?(int)
|
90
|
+
in_header = int_head.include?(req.attr)
|
91
|
+
affects || (dep && !in_header)
|
92
|
+
end
|
93
|
+
next if related_attrs_requirements.empty?
|
94
|
+
missing[:indirect] ||= {}
|
95
|
+
data = missing[:indirect][ext] = {}
|
96
|
+
data[:int] = int
|
97
|
+
data[:attrs] = {}
|
98
|
+
related_attrs_requirements.each_with_object(data[:attrs]) do |req, attrs|
|
99
|
+
status = req.active?(*int_head) ? :active : :inactive
|
100
|
+
attrs[status] ||= []
|
101
|
+
attrs[status] << req.attr
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def known_headers_present(headers_internal)
|
107
|
+
@known_internal ||= known_headers.select do |ext|
|
108
|
+
int = fields_mapper.to_internal(ext)
|
109
|
+
headers_internal.include?(int)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def internal_present_or_active(headers, inactive_requirements = {})
|
114
|
+
hint = headers & all_internal_attrs
|
115
|
+
hext = headers - hint
|
116
|
+
int_present = hint + hext.map {|e| fields_mapper.to_internal(e)}.compact
|
117
|
+
|
118
|
+
update_inactive = Proc.new do
|
119
|
+
inactive_requirements.dup.each do |attr, req|
|
120
|
+
if req.active?(*int_present)
|
121
|
+
inactive_requirements.delete(attr)
|
122
|
+
int_present << attr
|
123
|
+
update_inactive.call
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
required_attrs.values.each do |req|
|
129
|
+
next if int_present.include?(req)
|
130
|
+
if req.active?(*int_present)
|
131
|
+
inactive_requirements.delete(req.attr)
|
132
|
+
int_present << req.attr
|
133
|
+
update_inactive.call
|
134
|
+
else
|
135
|
+
inactive_requirements[req.attr] = req
|
136
|
+
end
|
137
|
+
end
|
138
|
+
int_present
|
139
|
+
end
|
140
|
+
|
141
|
+
def known_headers
|
142
|
+
@known_headers ||= fields_mapper.list(:external).compact
|
143
|
+
end
|
144
|
+
|
145
|
+
def fields_mapper
|
146
|
+
session.fields_mapper
|
147
|
+
end
|
148
|
+
|
149
|
+
def required_attrs
|
150
|
+
@required_attrs ||= person_parser.required_attrs.each_with_object({}) do |ra, out|
|
151
|
+
out[ra.attr] = ra
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def all_internal_attrs
|
156
|
+
@all_internal_attrs ||= [].tap do |int_attrs|
|
157
|
+
known_int_attrs = person_parser.all_attrs(include_defined_parsers: true)
|
158
|
+
known_int_attrs |= fields_mapper.list(:internal).compact
|
159
|
+
int_attrs.concat(known_int_attrs)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def person_parser
|
164
|
+
session.entry_factory.person_parser
|
165
|
+
end
|
166
|
+
|
39
167
|
end
|