2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
module Import
|
|
|
|
module OTRS
|
|
|
|
module DynamicFieldFactory
|
|
|
|
extend Import::Factory
|
|
|
|
extend Import::Helper
|
|
|
|
extend self
|
|
|
|
|
2016-12-20 15:16:09 +00:00
|
|
|
def skip?(record, *_args)
|
2016-11-25 16:10:37 +00:00
|
|
|
return true if skip_field?(record['Name'])
|
2017-01-13 09:59:14 +00:00
|
|
|
return false if importable?(record)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-01-13 09:59:14 +00:00
|
|
|
@skip_fields.push(record['Name'])
|
|
|
|
true
|
2016-11-25 16:10:37 +00:00
|
|
|
end
|
|
|
|
|
2016-12-20 15:16:09 +00:00
|
|
|
def backend_class(record, *_args)
|
2016-11-25 16:10:37 +00:00
|
|
|
"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)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
supported_field_type?(dynamic_field)
|
|
|
|
end
|
|
|
|
|
|
|
|
def supported_object_type?(dynamic_field)
|
|
|
|
return true if dynamic_field['ObjectType'] == 'Ticket'
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
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'])
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
log "ERROR: Unsupported dynamic field field type '#{dynamic_field['FieldType']}' for dynamic field '#{dynamic_field['Name']}'"
|
|
|
|
false
|
|
|
|
end
|
|
|
|
|
|
|
|
def supported_field_types
|
2017-11-23 08:09:44 +00:00
|
|
|
%w[Text TextArea Checkbox DateTime Date Dropdown Multiselect]
|
2016-11-25 16:10:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def skip_fields
|
2017-01-13 09:59:14 +00:00
|
|
|
return @skip_fields if @skip_fields
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2017-11-23 08:09:44 +00:00
|
|
|
@skip_fields = %w[ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld]
|
2016-11-25 16:10:37 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|