iqvoc 4.10.0 → 4.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +3 -3
  4. data/Gemfile.lock +74 -71
  5. data/LICENSE +1 -1
  6. data/app/aides/rdfapi.rb +1 -0
  7. data/app/assets/javascripts/framework.js +1 -3
  8. data/app/assets/javascripts/iqvoc/federated_concept_mapper.js +1 -1
  9. data/app/assets/javascripts/iqvoc/iqvoc.js +18 -5
  10. data/app/assets/javascripts/iqvoc/label_resolver.js +10 -17
  11. data/app/assets/javascripts/iqvoc/onebox.js.erb +1 -17
  12. data/app/controllers/concepts/alphabetical_controller.rb +3 -1
  13. data/app/controllers/concepts_controller.rb +14 -3
  14. data/app/controllers/dashboard_controller.rb +2 -2
  15. data/app/controllers/rdf_controller.rb +5 -2
  16. data/app/controllers/reverse_matches_controller.rb +29 -23
  17. data/app/exceptions/matched_concept_unpublished.rb +7 -0
  18. data/app/jobs/reverse_match_job.rb +3 -1
  19. data/app/models/collection/base.rb +2 -2
  20. data/app/models/concept/base.rb +12 -16
  21. data/app/models/concept/validations.rb +2 -0
  22. data/app/models/dataset/adaptors/iqvoc/alphabetical_search_adaptor.rb +3 -3
  23. data/app/models/dataset/adaptors/iqvoc/http_adaptor.rb +3 -3
  24. data/app/models/dataset/adaptors/iqvoc/search_adaptor.rb +1 -2
  25. data/app/models/dataset/iqvoc_dataset.rb +14 -4
  26. data/app/models/match/base.rb +4 -0
  27. data/app/models/services/reverse_match_service.rb +7 -7
  28. data/app/presenters/alphabetical_search_result_remote.rb +6 -1
  29. data/app/views/concepts/_form.html.erb +15 -11
  30. data/app/views/layouts/_controls.html.erb +1 -1
  31. data/app/views/layouts/_navigation.html.erb +6 -5
  32. data/app/views/partials/collection/_member.html.erb +1 -1
  33. data/app/views/partials/note/_base.html.erb +1 -1
  34. data/app/views/partials/note/_edit_base.html.erb +1 -1
  35. data/app/views/partials/note/skos/_edit_change_note.html.erb +6 -0
  36. data/app/views/partials/note/skos/change_note/_search_result.html.erb +5 -3
  37. data/app/views/rdf/dataset.iqrdf +2 -2
  38. data/config/locales/de.yml +4 -3
  39. data/config/locales/defaults.de.yml +1 -1
  40. data/config/locales/en.yml +1 -0
  41. data/db/schema.rb +10 -10
  42. data/iqvoc.gemspec +5 -5
  43. data/lib/engine_tasks/db.rake +2 -1
  44. data/lib/iqvoc/version.rb +1 -1
  45. data/lib/tasks/matches.rake +1 -11
  46. data/public/export/10192805148978885837967844546781669290.nt +28 -0
  47. data/public/export/116918272411112416290066634905903813354.nt +28 -0
  48. data/public/export/13837.nt +28 -0
  49. data/public/export/1417.nt +28 -0
  50. data/public/export/153275568579348383693796155341871693100.nt +28 -0
  51. data/public/export/15332.nt +28 -0
  52. data/public/export/19005675879943976619209658028974932617.nt +28 -0
  53. data/public/export/208299769475402765740883052440976216922.nt +28 -0
  54. data/public/export/22367.nt +28 -0
  55. data/public/export/239842039859946079048284298581204422602.nt +28 -0
  56. data/public/export/24489.nt +28 -0
  57. data/public/export/263331012556698690896467806067510942801.nt +28 -0
  58. data/public/export/270933597086710360561526644701101107992.nt +28 -0
  59. data/public/export/30428904238451414062970608699950348184.nt +28 -0
  60. data/public/export/30747.nt +28 -0
  61. data/public/export/31194.nt +28 -0
  62. data/public/export/38674.nt +28 -0
  63. data/public/export/41895.nt +28 -0
  64. data/public/export/44382.nt +28 -0
  65. data/public/export/48640.nt +28 -0
  66. data/public/export/51540.nt +28 -0
  67. data/public/export/55305.nt +28 -0
  68. data/public/export/59453.nt +28 -0
  69. data/public/export/65515.nt +28 -0
  70. data/public/export/8784603487603018400727339241555940088.nt +28 -0
  71. data/public/uploads/import/0c65980ba25416fbc4d503426e1a8f25.nt +259 -0
  72. data/public/uploads/import/13b577babf078cb2daa4886acf527dab.nt +259 -0
  73. data/public/uploads/import/2630c1b010d4f6cd0bfc1a82b567c0f2.nt +259 -0
  74. data/public/uploads/import/2b4c8e8a0e717ec7482fbb0858a73ca9.nt +259 -0
  75. data/public/uploads/import/3b10e21d4d4ae99504757daea91e37ea.nt +259 -0
  76. data/public/uploads/import/3e2c6beca4bc3d1845c608e85a653b6b.nt +259 -0
  77. data/public/uploads/import/484589b64bb31625095e2aa461c7c5f5.nt +259 -0
  78. data/public/uploads/import/549f0c78be0d5a4071366cd5668b4fb8.nt +259 -0
  79. data/public/uploads/import/5d66b58c29807cd92be65cd536c4b237.nt +259 -0
  80. data/public/uploads/import/6c96310921be5d247e00badec43170ff.nt +259 -0
  81. data/public/uploads/import/76e98edd3edd803faa12c82047ebf7fc.nt +259 -0
  82. data/public/uploads/import/7a8c8a3531229829bf7b16380550cb8c.nt +259 -0
  83. data/public/uploads/import/876b3334d3fd4143d573e4e1c213a637.nt +259 -0
  84. data/public/uploads/import/8a39cdbeb92dcabb370bcc9a586a3d2e.nt +259 -0
  85. data/public/uploads/import/94a3ea41583c51b9c36ffe5ea2d0535c.nt +259 -0
  86. data/public/uploads/import/95d86f95ae7ef0a4c45f498587b51700.nt +259 -0
  87. data/public/uploads/import/a8398ee85fdd1f866c2051f1074638b1.nt +259 -0
  88. data/public/uploads/import/addcaf555e2cfcb8baf358fb469f8a0a.nt +259 -0
  89. data/public/uploads/import/ae54ee7fda3362df0f6de4da0459106d.nt +259 -0
  90. data/public/uploads/import/b220fb27294d324cc34a4f32dcb15613.nt +259 -0
  91. data/public/uploads/import/bc8a3cd089026ff128732c047e7b911f.nt +259 -0
  92. data/public/uploads/import/ca4a8b0c64170bc9e93d32be13b30136.nt +259 -0
  93. data/public/uploads/import/f2620905a23bbc9e0e49f186b10ac51a.nt +259 -0
  94. data/public/uploads/import/f3572e0f9e4ec2ef482789e048a11af8.nt +259 -0
  95. data/public/uploads/import/fad73d1341ee30e4888cd1698f502ab5.nt +259 -0
  96. data/public/uploads/tmp/1463649041-61474-2323/hobbies.nt +259 -0
  97. data/public/uploads/tmp/1463664346-5686-2298/hobbies.nt +259 -0
  98. data/public/uploads/tmp/1463665390-6932-0270/hobbies.nt +259 -0
  99. data/public/uploads/tmp/1463668304-9630-3251/hobbies.nt +259 -0
  100. data/public/uploads/tmp/1463669489-10839-0938/hobbies.nt +259 -0
  101. data/public/uploads/tmp/1466609043-45060-5576/hobbies.nt +259 -0
  102. data/public/uploads/tmp/1467099160-32022-0649/hobbies.nt +259 -0
  103. data/public/uploads/tmp/1467099195-32141-0911/hobbies.nt +259 -0
  104. data/public/uploads/tmp/1467104923-38750-3228/hobbies.nt +259 -0
  105. data/public/uploads/tmp/1467195067-15511-1862/hobbies.nt +259 -0
  106. data/public/uploads/tmp/1477904194-9559-9102/hobbies.nt +259 -0
  107. data/public/uploads/tmp/1478096083-30132-9555/hobbies.nt +259 -0
  108. data/public/uploads/tmp/1479132609-14928-7976/hobbies.nt +259 -0
  109. data/public/uploads/tmp/1479133367-19225-4523/hobbies.nt +259 -0
  110. data/public/uploads/tmp/1479139859-34556-4051/hobbies.nt +259 -0
  111. data/public/uploads/tmp/1479201601-72814-6787/hobbies.nt +259 -0
  112. data/public/uploads/tmp/1479208599-84188-0489/hobbies.nt +259 -0
  113. data/public/uploads/tmp/1479210883-89869-0006/hobbies.nt +259 -0
  114. data/public/uploads/tmp/1479219219-14488-9873/hobbies.nt +259 -0
  115. data/public/uploads/tmp/1479220116-16009-2099/hobbies.nt +259 -0
  116. data/public/uploads/tmp/1479221749-20446-1586/hobbies.nt +259 -0
  117. data/public/uploads/tmp/1479221819-21274-6192/hobbies.nt +259 -0
  118. data/public/uploads/tmp/1479292258-60665-3926/hobbies.nt +259 -0
  119. data/public/uploads/tmp/1479903704-8347-9444/hobbies.nt +259 -0
  120. data/public/uploads/tmp/1479905096-13975-7245/hobbies.nt +259 -0
  121. data/test/integration/concept_collection_assignment_test.rb +78 -0
  122. data/test/integration/note_annotations_test.rb +12 -3
  123. data/test/integration/reverse_match_job_test.rb +1 -1
  124. metadata +102 -18
@@ -14,7 +14,7 @@ function OneBox(container) {
14
14
  appendTo(this.container).hide();
15
15
 
16
16
  this.form.on("submit", $.proxy(this, "onSubmit"));
17
- this.input.on("keyup", debounce($.proxy(this, "onInput"), 300));
17
+ this.input.on("keyup", IQVOC.debounce($.proxy(this, "onInput"), 300));
18
18
  }
19
19
  OneBox.prototype.reset = function() {
20
20
  this.container.children().not(this.form).not(this.indicator).remove();
@@ -59,20 +59,4 @@ return function(selector) {
59
59
  return new OneBox(selector); // XXX: returning an instance of a private class seems weird
60
60
  };
61
61
 
62
- function debounce(fn, delay) { // TODO: move elsewhere
63
- var timer;
64
- return function() {
65
- var self = this;
66
- var args = arguments;
67
- if(timer) {
68
- clearTimeout(timer);
69
- timer = null;
70
- }
71
- timer = setTimeout(function() {
72
- fn.apply(self, args);
73
- timer = null;
74
- }, delay);
75
- };
76
- }
77
-
78
62
  }(jQuery));
@@ -24,7 +24,9 @@ class Concepts::AlphabeticalController < ConceptsController
24
24
 
25
25
  redirect_to(url_for prefix: 'a') unless params[:prefix]
26
26
 
27
- datasets = init_datasets
27
+ # only initilaize dataset if dataset param is set
28
+ # prevent obsolet http request when using matches widget
29
+ datasets = params[:dataset] ? init_datasets : []
28
30
 
29
31
  @letters = Label::Base.select("DISTINCT UPPER(SUBSTR(value, 1, 1)) AS letter")
30
32
  .order("letter").map(&:letter)
@@ -15,6 +15,7 @@
15
15
  # limitations under the License.
16
16
 
17
17
  require 'concerns/dataset_initialization'
18
+ require 'reverse_match_job'
18
19
 
19
20
  class ConceptsController < ApplicationController
20
21
  include DatasetInitialization
@@ -25,7 +26,7 @@ class ConceptsController < ApplicationController
25
26
  respond_to do |format|
26
27
  format.json do # Search for widget
27
28
  scope = Iqvoc::Concept.base_class.editor_selectable.with_pref_labels.
28
- merge(Label::Base.by_query_value("#{params[:query]}%"))
29
+ merge(Label::Base.by_query_value("%#{params[:query]}%"))
29
30
  scope = scope.where(top_term: false) if params[:exclude_top_terms]
30
31
  @concepts = scope.all.map { |concept| concept_widget_data(concept) }
31
32
  render json: @concepts
@@ -119,6 +120,16 @@ class ConceptsController < ApplicationController
119
120
 
120
121
  @concept = Iqvoc::Concept.base_class.new
121
122
 
123
+ # initial created-ChangeNote creation
124
+ @concept.send(Iqvoc::change_note_class_name.to_relation_name).new do |change_note|
125
+ change_note.value = I18n.t('txt.views.versioning.initial_version')
126
+ change_note.language = I18n.locale.to_s
127
+ change_note.annotations_attributes = [
128
+ { namespace: 'dct', predicate: 'creator', value: current_user.name },
129
+ { namespace: 'dct', predicate: 'created', value: DateTime.now.to_s }
130
+ ]
131
+ end
132
+
122
133
  Iqvoc::Concept.note_class_names.each do |note_class_name|
123
134
  @concept.send(note_class_name.to_relation_name).build if @concept.send(note_class_name.to_relation_name).empty?
124
135
  end
@@ -132,7 +143,7 @@ class ConceptsController < ApplicationController
132
143
  authorize! :create, Iqvoc::Concept.base_class
133
144
 
134
145
  @concept = Iqvoc::Concept.base_class.new
135
- @concept.reverse_match_service = Services::ReverseMatchService.new(request.host, request.port)
146
+ @concept.reverse_match_service = Services::ReverseMatchService.new(request.host, request.protocol)
136
147
  @concept.assign_attributes(concept_params)
137
148
  @datasets = datasets_as_json
138
149
 
@@ -170,7 +181,7 @@ class ConceptsController < ApplicationController
170
181
  def update
171
182
  @concept = Iqvoc::Concept.base_class.by_origin(params[:id]).unpublished.last!
172
183
  authorize! :update, @concept
173
- @concept.reverse_match_service = Services::ReverseMatchService.new(request.host, request.port)
184
+ @concept.reverse_match_service = Services::ReverseMatchService.new(request.host, request.protocol)
174
185
 
175
186
  @datasets = datasets_as_json
176
187
 
@@ -28,8 +28,8 @@ class DashboardController < ApplicationController
28
28
  if ['class', 'locking_user', 'follow_up', 'updated_at', 'state'].include?(params[:by])
29
29
  @items.sort! do |x, y|
30
30
  xval, yval = x.send(params[:by]), y.send(params[:by])
31
- xval = xval.to_s.downcase unless xval.is_a?(Date)
32
- yval = yval.to_s.downcase unless yval.is_a?(Date)
31
+ xval = xval.to_s.downcase
32
+ yval = yval.to_s.downcase
33
33
  (xval <=> yval) * factor
34
34
  end
35
35
  else
@@ -51,8 +51,11 @@ class RdfController < ApplicationController
51
51
  end
52
52
 
53
53
  def dataset
54
- respond_to do |format|
55
- format.any(:rdf, :ttl, :nt)
54
+ @title = Iqvoc.config['title']
55
+ if stale?(etag: @title)
56
+ respond_to do |format|
57
+ format.any(:rdf, :ttl, :nt)
58
+ end
56
59
  end
57
60
  end
58
61
  end
@@ -4,33 +4,36 @@ class ReverseMatchesController < ApplicationController
4
4
  skip_before_action :verify_authenticity_token
5
5
 
6
6
  def add_match
7
- begin
8
- # NOTE: currently it's only allowed to add matches to published concepts
9
- # which are _NOT_ in processing. See older commits how to work with
10
- # currently edited concepts
11
- matches = @target_match_class.constantize.find_by(concept_id: @published_concept.id, value: @uri)
12
- render_response :mapping_exists and return if matches
13
- unpublished_concept = @published_concept.branch(@botuser)
14
- unpublished_concept.save
15
- @target_match_class.constantize.create(concept_id: unpublished_concept.id, value: @uri)
7
+ # NOTE: currently it's only allowed to add matches to published concepts
8
+ # which are _NOT_ in processing. See older commits how to work with
9
+ # currently edited concepts
10
+ matches = @target_match_class.constantize.find_by(concept_id: @published_concept.id, value: @uri)
11
+ render_response :mapping_exists and return if matches
12
+ unpublished_concept = @published_concept.branch(@botuser)
13
+ unpublished_concept.save!
14
+ @target_match_class.constantize.create(concept_id: unpublished_concept.id, value: @uri)
15
+ ActiveRecord::Base.transaction do
16
+ unpublished_concept.unlock
16
17
  unpublished_concept.publish!
17
- rescue
18
- render_response :server_error and return
18
+ @published_concept.destroy!
19
19
  end
20
20
 
21
21
  render_response :mapping_added
22
22
  end
23
23
 
24
24
  def remove_match
25
- begin
26
- unpublished_concept = @published_concept.branch(@botuser)
27
- unpublished_concept.save
28
- match = @target_match_class.constantize.find_by(concept_id: unpublished_concept.id, value: @uri)
29
- render_response :unknown_relation and return if match.nil?
30
- match.destroy
25
+ unpublished_concept = @published_concept.branch(@botuser)
26
+ unpublished_concept.save!
27
+ match = @target_match_class.constantize.find_by(concept_id: unpublished_concept.id, value: @uri)
28
+ if match.nil?
29
+ Rails.logger.info "Could not remove reverse match - match_class: #{@klass}, target_match_class: #{@target_match_class}, unpublished_concept.id: #{unpublished_concept.id}"
30
+ render_response :unknown_relation and return
31
+ end
32
+ ActiveRecord::Base.transaction do
33
+ match.destroy!
34
+ unpublished_concept.unlock
31
35
  unpublished_concept.publish!
32
- rescue
33
- render_response :server_error and return
36
+ @published_concept.destroy!
34
37
  end
35
38
 
36
39
  render_response :mapping_removed
@@ -49,15 +52,18 @@ class ReverseMatchesController < ApplicationController
49
52
 
50
53
  match_classes = Iqvoc::Concept.reverse_match_class_names
51
54
  render_response :unknown_match and return if match_classes.values.exclude? match_class
52
- klass = match_classes.key(match_class)
53
- @target_match_class = klass.constantize.reverse_match_class_name
55
+ @klass = match_classes.key(match_class)
56
+ @target_match_class = @klass.constantize.reverse_match_class_name
54
57
  render_response :unknown_match and return if @target_match_class.nil?
55
58
 
56
59
  iqvoc_sources = Iqvoc.config['sources.iqvoc'].map{ |s| URI.parse(s) }
57
60
  render_response :no_referer and return if request.referer.nil?
58
- referer = URI.parse(request.referer)
61
+ referer = URI.parse(request.referer).to_s
59
62
 
60
- render_response :unknown_referer and return if iqvoc_sources.exclude? referer
63
+ unless iqvoc_sources.detect {|url| referer.starts_with?(url.to_s) }
64
+ Rails.logger.info "Could not create reverse match - unknown referer: #{referer}"
65
+ render_response :unknown_referer and return
66
+ end
61
67
 
62
68
  @botuser = BotUser.instance
63
69
  @published_concept = Iqvoc::Concept.base_class.by_origin(origin).published.last
@@ -0,0 +1,7 @@
1
+ class MatchedConceptUnpublished < ArgumentError
2
+ attr_reader :original
3
+ def initialize(msg, original = $!)
4
+ super(msg)
5
+ @original = original;
6
+ end
7
+ end
@@ -7,7 +7,9 @@ class ReverseMatchJob < Struct.new(:type, :concept, :match_class, :subject, :ob
7
7
  end
8
8
 
9
9
  def perform
10
- raise 'concept_not_published_yet' if concept.unpublished?
10
+ if concept.unpublished?
11
+ raise MatchedConceptUnpublished, "concept_not_published_yet"
12
+ end
11
13
 
12
14
  conn = connection(subject, { accept: 'application/json' })
13
15
  response = conn.get
@@ -75,11 +75,11 @@ class Collection::Base < Concept::Base
75
75
  end
76
76
 
77
77
  def subcollections
78
- members.map(&:target).select { |m| m.is_a?(::Collection::Base) }
78
+ members.map(&:target).compact.select { |m| m.is_a?(::Collection::Base) }
79
79
  end
80
80
 
81
81
  def concepts
82
- members.map(&:target).reject { |m| m.is_a?(::Collection::Base) }
82
+ members.map(&:target).compact.reject { |m| m.is_a?(::Collection::Base) }
83
83
  end
84
84
 
85
85
  def additional_info
@@ -112,22 +112,18 @@ class Concept::Base < ActiveRecord::Base
112
112
  end
113
113
 
114
114
  # Process assigned collections
115
- if (@assigned_collection_origins ||= {}).any?
116
- # Destroy assigned collections
117
- existing_collection_origins = concept.collections.map(&:origin).uniq
118
- existing_collection_origins.each do |origin|
119
- collection = Iqvoc::Collection.base_class.by_origin(origin).published.first
120
- relation = Iqvoc::Collection.member_class.find_by(collection: collection, target: concept)
121
- relation.destroy! if relation
122
- end
123
-
124
- # Rebuild collection relations
125
- @assigned_collection_origins.each do |origin|
126
- collection = Iqvoc::Collection.base_class.by_origin(origin).published.first
127
- if collection
128
- Iqvoc::Collection.member_class.create! do |m|
129
- m.collection = collection
130
- m.target = concept
115
+ if @assigned_collection_origins
116
+ transaction do
117
+ collections.destroy_all
118
+
119
+ # Rebuild collection relations
120
+ @assigned_collection_origins.each do |origin|
121
+ collection = Iqvoc::Collection.base_class.by_origin(origin).published.first
122
+ if collection
123
+ Iqvoc::Collection.member_class.create! do |m|
124
+ m.collection = collection
125
+ m.target = concept
126
+ end
131
127
  end
132
128
  end
133
129
  end
@@ -56,7 +56,9 @@ module Concept
56
56
  lang = pref_label.language.to_s
57
57
  origin = (pref_label.origin || pref_label.id || pref_label.value).to_s
58
58
  if (languages.keys.include?(lang) && languages[lang] != origin)
59
+ # there are at least two pref labels for one specific language
59
60
  errors.add :pref_labelings, I18n.t('txt.models.concept.pref_labels_with_same_languages_error')
61
+ break
60
62
  end
61
63
  languages[lang] = origin
62
64
  end
@@ -13,8 +13,7 @@ class Dataset::Adaptors::Iqvoc::AlphabeticalSearchAdaptor < Dataset::Adaptors::I
13
13
  fetch_results(more[:href], {})
14
14
  end
15
15
  rescue Faraday::Error::ConnectionFailed,
16
- Faraday::Error::ResourceNotFound,
17
- Faraday::Error::TimeoutError => e
16
+ Faraday::Error::ResourceNotFound => e
18
17
  Rails.logger.warn("HTTP error while querying remote source #{url}: #{e.message}")
19
18
  return nil
20
19
  end
@@ -29,7 +28,8 @@ class Dataset::Adaptors::Iqvoc::AlphabeticalSearchAdaptor < Dataset::Adaptors::I
29
28
 
30
29
  options = {
31
30
  definition: element.at_css('.concept-item-definition').try(:content),
32
- definition_language: element.at_css('.concept-item-definition').try(:[], :lang)
31
+ definition_language: element.at_css('.concept-item-definition').try(:[], :lang),
32
+ additional_info: element.at_css('.additional_info').try(:content)
33
33
  }
34
34
 
35
35
  result = AlphabeticalSearchResultRemote.new(url, path, label, options)
@@ -1,11 +1,12 @@
1
1
  require 'faraday'
2
2
 
3
3
  class Dataset::Adaptors::Iqvoc::HTTPAdaptor
4
+ DEFAULT_TIMEOUT = 5.freeze
4
5
  attr_reader :url
5
6
 
6
7
  def initialize(url)
7
8
  @url = url
8
- @conn = Faraday.new(url: url) do |conn|
9
+ @conn = Faraday.new(url: url, request: { timeout: DEFAULT_TIMEOUT }) do |conn|
9
10
  #conn.use Faraday::Response::Logger if Rails.env.development?
10
11
  conn.adapter Faraday.default_adapter
11
12
  end
@@ -15,8 +16,7 @@ class Dataset::Adaptors::Iqvoc::HTTPAdaptor
15
16
  begin
16
17
  response = @conn.get(path)
17
18
  rescue Faraday::Error::ConnectionFailed,
18
- Faraday::Error::ResourceNotFound,
19
- Faraday::Error::TimeoutError => e
19
+ Faraday::Error::ResourceNotFound => e
20
20
  return failed_request(path)
21
21
  end
22
22
 
@@ -25,8 +25,7 @@ class Dataset::Adaptors::Iqvoc::SearchAdaptor < Dataset::Adaptors::Iqvoc::HTTPAd
25
25
  fetch_results(more[:href], {})
26
26
  end
27
27
  rescue Faraday::Error::ConnectionFailed,
28
- Faraday::Error::ResourceNotFound,
29
- Faraday::Error::TimeoutError => e
28
+ Faraday::Error::ResourceNotFound => e
30
29
  Rails.logger.warn("HTTP error while querying remote source #{path}: #{e.message}")
31
30
  return nil
32
31
  end
@@ -1,11 +1,19 @@
1
1
  require 'linkeddata'
2
+ require 'timeout'
2
3
 
3
4
  class Dataset::IqvocDataset
5
+ DEFAULT_TIMEOUT = 5.freeze
6
+
4
7
  attr_reader :name, :url
5
8
 
6
9
  def initialize(url)
7
10
  @url = URI.parse(url)
8
- @repository = RDF::Repository.load(URI.join(url, 'dataset.rdf').to_s) rescue nil
11
+ dataset_url = URI.join(@url.to_s + '/', 'dataset.rdf')
12
+
13
+ @repository = Timeout::timeout(DEFAULT_TIMEOUT) do
14
+ RDF::Repository.load(dataset_url)
15
+ end
16
+
9
17
  @name = fetch_name
10
18
  end
11
19
 
@@ -27,13 +35,15 @@ class Dataset::IqvocDataset
27
35
 
28
36
  private
29
37
  def fetch_name
30
- return 'unknown' if @repository.nil?
38
+ return @url.to_s if @repository.nil?
31
39
 
32
40
  void = RDF::Vocabulary.new('http://rdfs.org/ns/void#')
33
41
  query = RDF::Query.new({ dataset: { RDF.type => void.Dataset, RDF::DC.title => :title } })
34
- results = query.execute(@repository)
42
+ results = Timeout::timeout(DEFAULT_TIMEOUT) do
43
+ query.execute(@repository)
44
+ end
35
45
 
36
- return 'unknown' if results.empty?
46
+ return @url.to_s if results.nil? || results.empty?
37
47
  results.map { |solution| solution.title.to_s }.first
38
48
  end
39
49
  end
@@ -52,4 +52,8 @@ class Match::Base < ActiveRecord::Base
52
52
  def self.edit_partial_name(obj)
53
53
  'partials/match/edit_base'
54
54
  end
55
+
56
+ def self.reverse_match_class_name
57
+ nil
58
+ end
55
59
  end
@@ -2,17 +2,17 @@ module Services
2
2
  class ReverseMatchService
3
3
  include Rails.application.routes.url_helpers
4
4
 
5
- def initialize(host, port)
6
- raise ArgumentError if host.empty?
7
- raise ArgumentError unless port.is_a?(Integer)
5
+ def initialize(host, protocol)
6
+ raise ArgumentError if host.blank?
7
+ raise ArgumentError if protocol.blank?
8
8
  @host = host
9
- @port = port
9
+ @protocol = protocol
10
10
  end
11
11
 
12
12
  def build_job(type, concept, subject, match_class)
13
- raise ArgumentError if type.empty? || concept.nil? || subject.empty? || match_class.empty?
14
- referer = root_url(host: @host, port: @port)
15
- object = rdf_url(concept.origin, host: @host, port: @port)
13
+ raise ArgumentError if type.empty? || concept.nil? || subject.blank? || match_class.blank?
14
+ referer = root_url(host: @host, protocol: @protocol)
15
+ object = rdf_url(concept.origin, host: @host, protocol: @protocol)
16
16
  match_classes = Iqvoc::Concept.reverse_match_class_names
17
17
  match_class = match_classes[match_class]
18
18
  ReverseMatchJob.new(type, concept, match_class, subject, object, referer)
@@ -5,10 +5,15 @@ class AlphabeticalSearchResultRemote < AlphabeticalSearchResult
5
5
  @label = label
6
6
  @definition = options[:definition]
7
7
  @definition_language = options[:definition_language]
8
+ @additional_info = options[:additional_info]
8
9
  end
9
10
 
10
11
  def label
11
- @label
12
+ if @additional_info.present?
13
+ "#{@label} #{@additional_info}"
14
+ else
15
+ @label
16
+ end
12
17
  end
13
18
 
14
19
  def path
@@ -47,25 +47,29 @@
47
47
 
48
48
  <!-- Notes -->
49
49
  <% Iqvoc::Concept.note_classes.each do |note_class| %>
50
- <%= render note_class.edit_partial_name(concept), :owner_klass => concept, :assoc_klass => note_class, :f => f %>
50
+ <% unless note_class.edit_partial_name(concept).nil? %>
51
+ <%= render note_class.edit_partial_name(concept), :owner_klass => concept, :assoc_klass => note_class, :f => f %>
52
+ <% end %>
51
53
  <% end %>
52
54
  <!-- / Notes -->
53
55
 
54
56
  <!-- Concept relations -->
55
57
  <fieldset>
56
58
  <legend><%= Concept::Relation::Base.model_name.human(:count => 2) %></legend>
57
- <%- if Iqvoc::Concept.broader_relation_class.narrower_editable -%>
58
- <%= render Iqvoc::Concept.broader_relation_class.narrower_class.edit_partial_name(concept),
59
- :concept => concept, :klass => Iqvoc::Concept.broader_relation_class.narrower_class, :f => f %>
60
- <%- end -%>
59
+ <% unless Iqvoc::Concept.broader_relation_class.edit_partial_name(concept).nil? %>
60
+ <%- if Iqvoc::Concept.broader_relation_class.narrower_editable -%>
61
+ <%= render Iqvoc::Concept.broader_relation_class.narrower_class.edit_partial_name(concept),
62
+ :concept => concept, :klass => Iqvoc::Concept.broader_relation_class.narrower_class, :f => f %>
63
+ <%- end -%>
61
64
 
62
- <%= f.form_group :top_term do %>
63
- <%= f.check_box :top_term,
64
- :class => ("exclusive" if Iqvoc::Concept.broader_relation_class.singular?) %>
65
- <% end %>
65
+ <%= f.form_group :top_term do %>
66
+ <%= f.check_box :top_term,
67
+ :class => ("exclusive" if Iqvoc::Concept.broader_relation_class.singular?) %>
68
+ <% end %>
66
69
 
67
- <%= render Iqvoc::Concept.broader_relation_class.edit_partial_name(concept),
68
- :concept => concept, :klass => Iqvoc::Concept.broader_relation_class, :f => f %>
70
+ <%= render Iqvoc::Concept.broader_relation_class.edit_partial_name(concept),
71
+ :concept => concept, :klass => Iqvoc::Concept.broader_relation_class, :f => f %>
72
+ <% end %>
69
73
 
70
74
  <%- Iqvoc::Concept.further_relation_classes.each do |relation_class| -%>
71
75
  <%= render relation_class.edit_partial_name(concept),