Class: Eco::API::MicroCases
- Inherits:
-
Common::Session::BaseSession
- Object
- Common::Session::BaseSession
- Eco::API::MicroCases
- Includes:
- People
- Defined in:
- lib/eco/api/microcases.rb,
lib/eco/api/microcases/people.rb,
lib/eco/api/microcases/people/fetch.rb,
lib/eco/api/microcases/people/macro.rb,
lib/eco/api/microcases/people/manage.rb,
lib/eco/api/microcases/person_update.rb,
lib/eco/api/microcases/strict_search.rb,
lib/eco/api/microcases/people/preserve.rb,
lib/eco/api/microcases/people/integrity.rb,
lib/eco/api/microcases/s3upload_targets.rb,
lib/eco/api/microcases/append_usergroups.rb,
lib/eco/api/microcases/people/manage/load.rb,
lib/eco/api/microcases/people/manage/cache.rb,
lib/eco/api/microcases/people/apply_changes.rb,
lib/eco/api/microcases/people/manage/search.rb,
lib/eco/api/microcases/people/manage/refresh.rb,
lib/eco/api/microcases/people/fetch/with_each.rb,
lib/eco/api/microcases/people/manage/filename.rb,
lib/eco/api/microcases/people/macro/take_email.rb,
lib/eco/api/microcases/people/manage/load_cache.rb,
lib/eco/api/microcases/people/preserve/default_tag.rb,
lib/eco/api/microcases/people/preserve/filter_tags.rb,
lib/eco/api/microcases/people/fetch/with_supervisor.rb,
lib/eco/api/microcases/with_each_contractor_present.rb,
lib/eco/api/microcases/people/apply_changes/set_core.rb,
lib/eco/api/microcases/people/fetch/with_each_leaver.rb,
lib/eco/api/microcases/people/preserve/policy_groups.rb,
lib/eco/api/microcases/people/fetch/with_each_present.rb,
lib/eco/api/microcases/people/fetch/with_each_starter.rb,
lib/eco/api/microcases/people/apply_changes/set_account.rb,
lib/eco/api/microcases/people/integrity/fix_filter_tags.rb,
lib/eco/api/microcases/people/fetch/with_each_subordinate.rb,
lib/eco/api/microcases/people/integrity/fix_default_group.rb,
lib/eco/api/microcases/people/apply_changes/set_supervisor.rb,
lib/eco/api/microcases/people/integrity/refresh_default_tag.rb,
lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb,
lib/eco/api/microcases/people/apply_changes/set_core_with_supervisor.rb,
lib/eco/api/microcases/people/apply_changes/set_account/account_excluded.rb
Defined Under Namespace
Modules: People
Constant Summary
Constants included from People::ApplyChanges::SetCore::CoreExcluded
People::ApplyChanges::SetCore::CoreExcluded::CAN_EXCLUDE_CREATION, People::ApplyChanges::SetCore::CoreExcluded::CAN_EXCLUDE_UPDATE
Instance Attribute Summary
Attributes inherited from Common::Session::BaseSession
#config, #environment, #session
Attributes included from Language::AuxiliarLogger
Instance Method Summary collapse
-
#append_usergroups(entry, person, options) ⇒ Object
It preserves the usergroups of
personand appends those defined inpolicy_group_idsof theentry. - #micro ⇒ Object
-
#person_update!(person, context: 'Session', reason: '') ⇒ Boolean
It updates an idividual person.
-
#s3upload_targets ⇒ Array<String>
Helper to upload target files to
S3. -
#strict_search?(options) ⇒ Boolean
When trying to find an
personwith given a sourceentry, it states if such a search should bestrictorsoft. - #with_each_contractor_present(entries, contractors, options, log_new_record: false) ⇒ Object
Methods included from People::Macro::TakeEmail
Methods included from People::Integrity::FixDefaultGroup
Methods included from People::Integrity::FixFilterTags
Methods included from People::Integrity::RefreshDefaultTag
Methods included from People::Preserve::PolicyGroups
Methods included from People::Preserve::DefaultTag
Methods included from People::Preserve::FilterTags
Methods included from People::ApplyChanges::SetAccount
Methods included from People::ApplyChanges::SetAccount::AccountExcluded
Methods included from People::ApplyChanges::SetCoreWithSupervisor
Methods included from People::ApplyChanges::SetSupervisor
Methods included from People::ApplyChanges::SetCore
Methods included from People::ApplyChanges::SetCore::CoreExcluded
Methods included from People::Fetch::WithEachSubordinate
Methods included from People::Fetch::WithEachLeaver
Methods included from People::Fetch::WithEachStarter
Methods included from People::Fetch::WithEachPresent
Methods included from People::Fetch::WithEach
Methods included from People::Fetch::WithSupervisor
Methods included from People::Manage::Refresh
Methods included from People::Manage::Search
Methods included from People::Manage::Load
Methods included from People::Manage::Cache
Methods inherited from Common::Session::BaseSession
#api, #api?, #fatal, #file_manager, #initialize, #logger, #mailer, #mailer?, #s3uploader, #s3uploader?, #sftp, #sftp?
Methods included from Language::AuxiliarLogger
Constructor Details
This class inherits a constructor from Eco::API::Common::Session::BaseSession
Instance Method Details
#append_usergroups(entry, person, options) ⇒ Object
It preserves the usergroups of person and appends those defined in policy_group_ids of the entry
8 9 10 11 12 13 |
# File 'lib/eco/api/microcases/append_usergroups.rb', line 8 def append_usergroups(entry, person, ) return if .dig(:exclude, :account) return unless person.account person.account.policy_group_ids |= entry.policy_group_ids end |
#micro ⇒ Object
7 8 9 |
# File 'lib/eco/api/microcases.rb', line 7 def micro self end |
#person_update!(person, context: 'Session', reason: '') ⇒ Boolean
if it succeeds the update, it calls person.consolidate!
It updates an idividual person.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/eco/api/microcases/person_update.rb', line 10 def person_update!(person, context: 'Session', reason: '') log(:debug) { "#{context}, going to \"#{reason}\".\nPerson: #{person_ref(person)}" } if (response = api.people.update(person)) if response.success? person.consolidate! true else msg = "#{context} Error #{response.status}: #{response.body}\n" msg += " -- Failed to \"#{reason}\".\n" msg += " * Person: #{person_ref(person)}" log(:error) { msg } false end else msg = "#{context} Error (connection error)\n" msg += " -- Failed to \"#{reason}\".\n" msg += " * Person: #{person_ref(person)}" log(:error) { msg } false end end |
#s3upload_targets ⇒ Array<String>
Helper to upload target files to S3.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/eco/api/microcases/s3upload_targets.rb', line 6 def s3upload_targets # rubocop:disable Metrics/AbcSize [].tap do |paths| session.config.s3storage.target_files.each_with_object(paths) do |file, arr| arr.push(session.s3upload(file: file)) end session.config.s3storage.target_directories.each_with_object(paths) do |folder, arr| arr.concat(session.s3upload(directory: folder)) end session.config.s3storage.target_file_patterns.each_with_object(paths) do |pattern, arr| filenames = [] case pattern when Regexp Dir.entries('.').sort.each do |file| next unless File.file?(file) # Skip directories filenames.push(file) if file =~ pattern end when String Dir.glob(pattern).sort.each do |file| next unless File.file?(file) # Skip directories filenames.push(file) end else # missconfiguration end filenames.each do |file| arr.push(session.s3upload(file: file)) end end end end |
#strict_search?(options) ⇒ Boolean
strictsearches ignore the email when the sourceentryhas anexternal_idspecified.- see related command line options
-search-strictand-search-soft
When trying to find an person with given a source entry, it states if such a search should be strict or soft.
10 11 12 13 14 15 |
# File 'lib/eco/api/microcases/strict_search.rb', line 10 def strict_search?() strict_config = session.config.people.strict_search? strict_option = .dig(:search, :strict) soft_option = .dig(:search, :soft) && !strict_option (strict_config || strict_option) && !soft_option end |
#with_each_contractor_present(entries, contractors, options, log_new_record: false) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/eco/api/microcases/with_each_contractor_present.rb', line 19 def with_each_contractor_present(entries, contractors, , log_new_record: false) found = [] micro.with_each(entries, contractors, ) do |entry, contractor| if contractor.new? if log_new_record log(:error) { "This contractor does not exist: #{entry.to_s(:identify)}" } end next end found << contractor yield(entry, contractor) if block_given? end contractors.newFrom found end |