trabajo-afectivo/lib/import/otrs/dynamic_field_factory.rb

53 lines
1.5 KiB
Ruby
Raw Normal View History

module Import
module OTRS
module DynamicFieldFactory
extend Import::Factory
extend Import::Helper
# rubocop:disable Style/ModuleFunction
extend self
def skip?(record)
return true if !importable?(record)
return true if skip_field?(record['Name'])
false
end
def backend_class(record)
"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
%w(ProcessManagementProcessID ProcessManagementActivityID ZammadMigratorChanged ZammadMigratorChangedOld)
end
end
end
end