check_custom.rb 871 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sequencer::Unit::Import::Zendesk::TicketField::CheckCustom < Sequencer::Unit::Base
  3. uses :resource, :model_class
  4. provides :action
  5. def process
  6. return if custom?
  7. logger.info { "Skipping. Default field '#{attribute}' found for field '#{resource.type}'." }
  8. state.provide(:action, :skipped)
  9. end
  10. private
  11. def custom?
  12. model_class.column_names.exclude?(attribute)
  13. end
  14. def attribute
  15. @attribute ||= mapping.fetch(resource.type, resource.type)
  16. end
  17. def mapping
  18. {
  19. 'subject' => 'title',
  20. 'description' => 'note',
  21. 'status' => 'state_id',
  22. 'priority' => 'priority_id',
  23. 'basic_priority' => 'priority_id',
  24. 'group' => 'group_id',
  25. 'assignee' => 'owner_id',
  26. }.freeze
  27. end
  28. end