2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
module Import
|
|
|
|
module OTRS
|
|
|
|
module HistoryFactory
|
|
|
|
extend Import::Factory
|
|
|
|
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 !determine_class(record)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
false
|
|
|
|
end
|
|
|
|
|
2016-12-20 15:16:09 +00:00
|
|
|
def backend_class(record, *_args)
|
2016-11-25 16:10:37 +00:00
|
|
|
"Import::OTRS::History::#{determine_class(record)}".constantize
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def determine_class(history)
|
|
|
|
check_supported(history) || check_article(history)
|
|
|
|
end
|
|
|
|
|
|
|
|
def supported_types
|
2017-11-23 08:09:44 +00:00
|
|
|
%w[NewTicket StateUpdate Move PriorityUpdate]
|
2016-11-25 16:10:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def check_supported(history)
|
2020-09-30 09:07:01 +00:00
|
|
|
return if supported_types.exclude?(history['HistoryType'])
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
history['HistoryType']
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_article(history)
|
|
|
|
return if !history['ArticleID']
|
|
|
|
return if history['ArticleID'].to_i.zero?
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2016-11-25 16:10:37 +00:00
|
|
|
'Article'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|