From 1821c97506f899cd7f64da1770783bd495601190 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Wed, 20 Dec 2017 16:29:39 +0100 Subject: [PATCH] Intoduced new generic model class structure based on simple provider structure and DRYed up LDAP and Exchange sequences. --- .../import/exchange/folder_contact.rb | 2 +- lib/sequencer/sequence/import/ldap/users.rb | 2 +- lib/sequencer/unit/common/model_class/base.rb | 22 +++++++++++++++++++ lib/sequencer/unit/common/model_class/user.rb | 10 +++++++++ .../folder_contact/static_attributes.rb | 18 --------------- .../import/ldap/users/static_attributes.rb | 18 --------------- 6 files changed, 34 insertions(+), 38 deletions(-) create mode 100644 lib/sequencer/unit/common/model_class/base.rb create mode 100644 lib/sequencer/unit/common/model_class/user.rb delete mode 100644 lib/sequencer/unit/import/exchange/folder_contact/static_attributes.rb delete mode 100644 lib/sequencer/unit/import/ldap/users/static_attributes.rb diff --git a/lib/sequencer/sequence/import/exchange/folder_contact.rb b/lib/sequencer/sequence/import/exchange/folder_contact.rb index 01de2d48f..c435023f0 100644 --- a/lib/sequencer/sequence/import/exchange/folder_contact.rb +++ b/lib/sequencer/sequence/import/exchange/folder_contact.rb @@ -9,7 +9,7 @@ class Sequencer 'Import::Exchange::FolderContact::RemoteId', 'Import::Exchange::FolderContact::Mapping', 'Import::Common::Model::Skip::Blank::Mapped', - 'Import::Exchange::FolderContact::StaticAttributes', + 'Common::ModelClass::User', 'Import::Exchange::FolderContact::ExternalSyncSource', 'Import::Common::Model::Lookup::ExternalSync', 'Import::Common::Model::Associations::Extract', diff --git a/lib/sequencer/sequence/import/ldap/users.rb b/lib/sequencer/sequence/import/ldap/users.rb index 5647c21be..80d6eff9d 100644 --- a/lib/sequencer/sequence/import/ldap/users.rb +++ b/lib/sequencer/sequence/import/ldap/users.rb @@ -6,7 +6,7 @@ class Sequencer def self.sequence [ - 'Import::Ldap::Users::StaticAttributes', + 'Common::ModelClass::User', 'Import::Ldap::Users::ExternalSyncSource', 'Import::Common::ImportJob::DryRun', 'Import::Ldap::Users::DryRun::Payload', diff --git a/lib/sequencer/unit/common/model_class/base.rb b/lib/sequencer/unit/common/model_class/base.rb new file mode 100644 index 000000000..43fc8fc6d --- /dev/null +++ b/lib/sequencer/unit/common/model_class/base.rb @@ -0,0 +1,22 @@ +class Sequencer + class Unit + module Common + module ModelClass + class Base < Sequencer::Unit::Common::Provider::Attribute + + provides :model_class + + private + + def model_class + @model_class ||= class_name.constantize + end + + def class_name + self.class.name.sub('Sequencer::Unit::Common::ModelClass', '') + end + end + end + end + end +end diff --git a/lib/sequencer/unit/common/model_class/user.rb b/lib/sequencer/unit/common/model_class/user.rb new file mode 100644 index 000000000..d7dc6e830 --- /dev/null +++ b/lib/sequencer/unit/common/model_class/user.rb @@ -0,0 +1,10 @@ +class Sequencer + class Unit + module Common + module ModelClass + class User < Sequencer::Unit::Common::ModelClass::Base + end + end + end + end +end diff --git a/lib/sequencer/unit/import/exchange/folder_contact/static_attributes.rb b/lib/sequencer/unit/import/exchange/folder_contact/static_attributes.rb deleted file mode 100644 index 76cebe763..000000000 --- a/lib/sequencer/unit/import/exchange/folder_contact/static_attributes.rb +++ /dev/null @@ -1,18 +0,0 @@ -class Sequencer - class Unit - module Import - module Exchange - module FolderContact - class StaticAttributes < Sequencer::Unit::Base - - provides :model_class - - def process - state.provide(:model_class, ::User) - end - end - end - end - end - end -end diff --git a/lib/sequencer/unit/import/ldap/users/static_attributes.rb b/lib/sequencer/unit/import/ldap/users/static_attributes.rb deleted file mode 100644 index e9723373d..000000000 --- a/lib/sequencer/unit/import/ldap/users/static_attributes.rb +++ /dev/null @@ -1,18 +0,0 @@ -class Sequencer - class Unit - module Import - module Ldap - module Users - class StaticAttributes < Sequencer::Unit::Base - - provides :model_class - - def process - state.provide(:model_class, ::User) - end - end - end - end - end - end -end