Class: ReverseMatchesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ReverseMatchesController
- Includes:
- ReverseMatchErrors
- Defined in:
- app/controllers/reverse_matches_controller.rb
Instance Method Summary collapse
Instance Method Details
#add_match ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/reverse_matches_controller.rb', line 6 def add_match # NOTE: currently it's only allowed to add matches to published concepts # which are _NOT_ in processing. See older commits how to work with # currently edited concepts matches = @target_match_class.constantize.find_by(concept_id: @published_concept.id, value: @uri) render_response :mapping_exists and return if matches ActiveRecord::Base.transaction do unpublished_concept = @published_concept.branch unpublished_concept.save! @target_match_class.constantize.create(concept_id: unpublished_concept.id, value: @uri) unpublished_concept.publish! @published_concept.destroy! end render_response :mapping_added end |
#remove_match ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/reverse_matches_controller.rb', line 24 def remove_match unpublished_concept = @published_concept.branch unpublished_concept.save! match = @target_match_class.constantize.find_by(concept_id: unpublished_concept.id, value: @uri) if match.nil? Rails.logger.info "Could not remove reverse match - match_class: #{@klass}, target_match_class: #{@target_match_class}, unpublished_concept.id: #{unpublished_concept.id}" render_response :unknown_relation and return end ActiveRecord::Base.transaction do match.destroy! unpublished_concept.publish! @published_concept.destroy! end render_response :mapping_removed end |