123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- module Import
- module OTRS
- module DynamicFieldFactory
- extend Import::Factory
- extend Import::Helper
- # rubocop:disable Style/ModuleFunction
- extend self
- def skip?(record, *_args)
- return true if skip_field?(record['Name'])
- return false if importable?(record)
- @skip_fields.push(record['Name'])
- true
- end
- def backend_class(record, *_args)
- "Import::OTRS::DynamicField::#{record['FieldType']}".constantize
- end
- def skip_field?(dynamic_field_name)
- skip_fields.include?(dynamic_field_name)
- end
- private
- def importable?(dynamic_field)
- return false if !supported_object_type?(dynamic_field)
- supported_field_type?(dynamic_field)
- end
- def supported_object_type?(dynamic_field)
- return true if dynamic_field['ObjectType'] == 'Ticket'
- log "ERROR: Unsupported dynamic field object type '#{dynamic_field['ObjectType']}' for dynamic field '#{dynamic_field['Name']}'"
- false
- end
- def supported_field_type?(dynamic_field)
- return true if supported_field_types.include?(dynamic_field['FieldType'])
- log "ERROR: Unsupported dynamic field field type '#{dynamic_field['FieldType']}' for dynamic field '#{dynamic_field['Name']}'"
- false
- end
- def supported_field_types
- %w(Text TextArea Checkbox DateTime Date Dropdown Multiselect)
- end
- def skip_fields
- return @skip_fields if @skip_fields
- @skip_fields = %w(ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld)
- end
- end
- end
- end
|