eco-helpers 2.0.21 → 2.0.26
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 +101 -4
- data/eco-helpers.gemspec +0 -1
- 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.rb +1 -0
- data/lib/eco/api/common/people/default_parsers/csv_parser.rb +93 -1
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +53 -0
- data/lib/eco/api/common/people/entries.rb +83 -14
- data/lib/eco/api/common/people/entry_factory.rb +36 -21
- data/lib/eco/api/common/people/person_attribute_parser.rb +8 -0
- data/lib/eco/api/common/people/person_factory.rb +4 -2
- data/lib/eco/api/common/people/person_parser.rb +8 -2
- 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 +18 -7
- data/lib/eco/api/session/batch.rb +1 -1
- data/lib/eco/api/session/batch/job.rb +42 -9
- data/lib/eco/api/usecases.rb +2 -2
- data/lib/eco/api/usecases/base_case.rb +2 -2
- data/lib/eco/api/usecases/base_io.rb +17 -4
- 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/upsert_case.rb +10 -1
- data/lib/eco/cli/config/default/input.rb +63 -10
- data/lib/eco/cli/config/default/options.rb +40 -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/cli/scripting/args_helpers.rb +2 -2
- data/lib/eco/csv.rb +2 -0
- data/lib/eco/language/models/collection.rb +5 -2
- data/lib/eco/version.rb +1 -1
- metadata +4 -22
- data/lib/eco/api/common/base_loader.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 722e1dc695f9d9fae5fbceca8a2269f4836393ee4dc50fc0f850e43fefc88789
|
4
|
+
data.tar.gz: bc34444cdf33bff51895fa5ed6bb7a89b89074e5bd11852c0a1a4f4bf6bcc574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a18aaa7abf012872f21209907909f1c309ddb530586bc9e27d595ace57377c3c4dba2b0a7bacc902e160cf2f51d4171a5de3e0536b6eda4dff7d018307744ca
|
7
|
+
data.tar.gz: efcaa1832677c0cf13d5dfb0ba6a3abaa8bff3fec4e1d2639b2b832358a1e51b849e594da64827bed096eb4f8f03a5664a6a8245c58128acf3478eaf0e94d38a
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,107 @@
|
|
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.26] - 2021-06-xx
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- `Eco::API::MicroCases#set_supervisor`, tries to keep in sync the `#subordinates` **count** of previous and new supervisor
|
8
|
+
- new **option** `-run-postlaunch` to run post launch cases, even when we run in `dry-run` mode
|
9
|
+
* when in `dry-run` it will **not** reload the people base of the session
|
10
|
+
- new **option** to append **new** entries to the `People` object
|
11
|
+
* **invokable** on **cli** via `-append-starters` (`{people: {append_created: true}}`)
|
12
|
+
* the following use cases include this option:
|
13
|
+
* `Eco::API::UseCases::DefaultCases::UpsertCase`
|
14
|
+
* `Eco::API::UseCases::DefaultCases::HrisCase`
|
15
|
+
* `Eco::API::UseCases::DefaultCases::CreateDetailsWithSupervisorCase`
|
16
|
+
* `Eco::API::UseCases::DefaultCases::CreateDetailsCase`
|
17
|
+
* `Eco::API::UseCases::DefaultCases::CreateCase`
|
18
|
+
* the option involves a new keyed argument `:append_created` in a couple of `MicroCases`
|
19
|
+
* `Eco::API::MicroCases#with_each`: where internally the search is performed against a copy of the `People` object.
|
20
|
+
* `Eco::API::MicroCases#with_each_starter`
|
21
|
+
* when `--help` is invoked option to filter the shown `-options`, `-usecases` and `filters` by a word contained in the option.
|
22
|
+
- **added** `csv` **header checks** for feed files, which entailed some changes:
|
23
|
+
* `Eco::API::Common::Loaders::Parser`
|
24
|
+
- new **subclass** `RequiredAttrs`, creatred when calling `.active_when_all` and `.active_when_any`
|
25
|
+
- **dependency** injection via `.dependencies` as `{required_attrs: RequiredAttrs}`
|
26
|
+
* **added** `Eco::API::Common::People::PersonParser#required_attrs` to offer all the `RequiredAttrs`, where defined
|
27
|
+
- the **new method** `#required_attrs` to expose the injected `RequiredAttrs`
|
28
|
+
* **new** keyed argument `check_headers:` in `Eco::API::Common::People::EntryFactory#entries`
|
29
|
+
- subsequent changes to accommodate the new param in `Eco::API::Session#csv_entries`
|
30
|
+
- `eco/cli/config/default/input` calls using this param to `true`
|
31
|
+
* `Eco::API::Common::People::DefaultParsers::CSVParser`
|
32
|
+
- added option `check_headers` via `dependencies` that enables the headers check
|
33
|
+
- it will now offer detailed warning messages on what can happen with the **missing headers**
|
34
|
+
* it will also list the **unknown header** names
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
- `Eco::API::MicroCases#set_supervisor`, the order of the 2 first parameters
|
38
|
+
- `Eco::API::Organization::People`: internally `@by_id` cache Hash included `nil` values => **not** any more.
|
39
|
+
- removed **unused** methods on **patches** for `Ecoportal::API::V1::Person` and `Ecoportal::API::Internal::Person`
|
40
|
+
* specifically `#reset_account!` and `#consolidate_account!` as well as `#reset_details!` and `#consolidate_details!`
|
41
|
+
- internal changes in `Eco::API::Common::People::Entries#entry`
|
42
|
+
* **added** option to trigger `MultipleSearchResults` StandardError when multiple candiates are found.
|
43
|
+
* **removed** `nil` values from the `caches` (the Hashes to optimize the search)
|
44
|
+
- slight structure refactor of `Eco::API::Common::Loaders`
|
45
|
+
* moved base class to subfolder/namespace
|
46
|
+
* decoupled pure `Loader` logics to `Loaders::Base` and use case inheriance chain loader to `Loaders::CaseBase`
|
47
|
+
- `Eco::API::Session::BatchJob` the `post_launch`:
|
48
|
+
* sets the `id` to the `person` if it was **created** successfully
|
49
|
+
* when in `dry-run` it fakes the `id` with a counter
|
50
|
+
- `Eco::API::Common::People::PersonFactory` gets `subordinates` initialized to `0` (when **creating** a `new` person)
|
51
|
+
|
52
|
+
### Fixed
|
53
|
+
|
54
|
+
|
55
|
+
## [2.0.25] - 2021-06-23
|
56
|
+
|
57
|
+
### Added
|
58
|
+
- `Eco::API::UseCases::DefaultCases::HrisCase` validation error to require `-schema-id` command line when there are people in schemas other than the active one
|
59
|
+
|
60
|
+
### Changed
|
61
|
+
- `Eco::API::Session::Batch::Job`
|
62
|
+
* for backwards compatibility `-include-only-excluded` should bring an options structure compatible with `-include-excluded`
|
63
|
+
|
64
|
+
### Fixed
|
65
|
+
- `Eco::API::Session::Batch` fixed typo that would prevent `prompt_user` to work
|
66
|
+
|
67
|
+
## [2.0.24] - 2021-06-22
|
68
|
+
|
69
|
+
### Added
|
70
|
+
- `Eco::API::Session::Batch::Job` made **native** `-include-excluded`
|
71
|
+
* also added new option `-include-only-excluded` to be able to only target people HRIS excluded
|
72
|
+
|
73
|
+
## [2.0.23] - 2021-06-22
|
74
|
+
|
75
|
+
### Added
|
76
|
+
- `Eco::API::Session::Batch::Job` **new** option (`-save-requests`) to save requests even if in `dry-run` (`-simulate`)
|
77
|
+
### Changed
|
78
|
+
- `Eco::API::Session::Batch::Job` new people won't create updates unless they have either details or account
|
79
|
+
* because that entry is not supposed to be created unless has account or details
|
80
|
+
|
81
|
+
## [2.0.22] - 2021-06-18
|
82
|
+
|
83
|
+
### Added
|
84
|
+
- exposed `logger` in `BaseLoader` and
|
85
|
+
- support for multiple input files
|
86
|
+
* `Eco::API::Common::People::EntryFactory#entries`:
|
87
|
+
- refactored to allow multiple input files parsing
|
88
|
+
- moreover to `idx`, hash entries will get their `source_file`
|
89
|
+
* Input callback at `lib/eco/cli/config/default/input` refactored format detection and enabled folder input
|
90
|
+
* `SCR.get_file` language extended to also mention folder (not just file)
|
91
|
+
- support for `.xls` and `.xlsx` files
|
92
|
+
* `Eco::API::Common::People::DefaultParsers::XLSParser` the Excel files **parser**
|
93
|
+
* `Eco::API::Common::People::PersonParser` added `:xls` as an accepted format
|
94
|
+
* `Eco::API::Session#fields_mapper` exposed mapper through a method to allow **headers detection**
|
95
|
+
- The external names of the fields are the column headers of the input file
|
96
|
+
* `Eco::API::UseCases::BaseIO` when arguments validation rails, now it raises with specific `MissingParameter` error
|
97
|
+
|
98
|
+
### Changed
|
99
|
+
- dry out `BaseLoader` (only session is set as instance variable)
|
100
|
+
- removed `creek` **dependency** (it was not used anywhere in the gem)
|
101
|
+
* we just kept `roo` and `roo-xls`
|
102
|
+
- custom `Error` classes now all inherit from `StandardError` (rather than `Exception`)
|
103
|
+
|
104
|
+
## [2.0.21] - 2021-06-04
|
5
105
|
|
6
106
|
### Added
|
7
107
|
- `Eco::CSV::Table`, support to create the table out of an `Array<Hash>`
|
@@ -11,9 +111,6 @@ All notable changes to this project will be documented in this file.
|
|
11
111
|
### Changed
|
12
112
|
- `Eco::API::Common::People::EntryFactory` slight **refactor** to boost better support for multiple input formats
|
13
113
|
|
14
|
-
### Fixed
|
15
|
-
|
16
|
-
|
17
114
|
## [2.0.20] - 2021-05-31
|
18
115
|
|
19
116
|
### Added
|
data/eco-helpers.gemspec
CHANGED
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,94 @@ 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
|
+
hint = headers & all_internal_attrs
|
74
|
+
hext = headers - hint
|
75
|
+
int_head = hint + hext.map {|e| fields_mapper.to_internal(e)}.compact
|
76
|
+
known_as_int = known_headers.select do |e|
|
77
|
+
i = fields_mapper.to_internal(e)
|
78
|
+
int_head.include?(i)
|
79
|
+
end
|
80
|
+
ext = headers.select do |e|
|
81
|
+
i = fields_mapper.to_internal(e)
|
82
|
+
int_head.include?(i)
|
83
|
+
end
|
84
|
+
ext_present = known_as_int | ext
|
85
|
+
ext_miss = known_headers - ext_present
|
86
|
+
#int_miss = ext_miss.map {|ext| fields_mapper.to_internal(ext)}
|
87
|
+
ext_miss.each_with_object({}) do |ext, missing|
|
88
|
+
next unless int = fields_mapper.to_internal(ext)
|
89
|
+
if all_internal_attrs.include?(int)
|
90
|
+
missing[:direct] ||= []
|
91
|
+
missing[:direct] << ext
|
92
|
+
end
|
93
|
+
related_attrs_requirements = required_attrs.values.select do |req|
|
94
|
+
req.dependant?(int) && !int_head.include?(req.attr)
|
95
|
+
end
|
96
|
+
next if related_attrs_requirements.empty?
|
97
|
+
missing[:indirect] ||= {}
|
98
|
+
data = missing[:indirect][ext] = {}
|
99
|
+
data[:int] = int
|
100
|
+
data[:attrs] = {}
|
101
|
+
related_attrs_requirements.each_with_object(data[:attrs]) do |req, attrs|
|
102
|
+
status = req.active?(*int_head) ? :active : :inactive
|
103
|
+
attrs[status] ||= []
|
104
|
+
attrs[status] << req.attr
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def known_headers
|
110
|
+
@known_headers ||= fields_mapper.list(:external).compact
|
111
|
+
end
|
112
|
+
|
113
|
+
def fields_mapper
|
114
|
+
session.fields_mapper
|
115
|
+
end
|
116
|
+
|
117
|
+
def required_attrs
|
118
|
+
@required_attrs ||= person_parser.required_attrs.each_with_object({}) do |ra, out|
|
119
|
+
out[ra.attr] = ra
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def all_internal_attrs
|
124
|
+
person_parser.all_attrs(include_defined_parsers: true)
|
125
|
+
end
|
126
|
+
|
127
|
+
def person_parser
|
128
|
+
session.entry_factory.person_parser
|
129
|
+
end
|
130
|
+
|
39
131
|
end
|