iqvoc 4.5.2 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile +1 -0
  4. data/Gemfile.lock +78 -80
  5. data/app/assets/javascripts/iqvoc/concept_mapper.js +15 -7
  6. data/app/assets/javascripts/iqvoc/entityselect.js.erb +11 -1
  7. data/app/assets/javascripts/iqvoc/federated_concept_mapper.js +13 -6
  8. data/app/assets/stylesheets/iqvoc/components/_components.css.scss +12 -1
  9. data/app/concerns/reverse_match_errors.rb +23 -0
  10. data/app/concerns/versioning.rb +1 -1
  11. data/app/controllers/concepts_controller.rb +26 -3
  12. data/app/controllers/rdf_controller.rb +3 -0
  13. data/app/controllers/reverse_matches_controller.rb +73 -0
  14. data/app/jobs/reverse_match_job.rb +57 -0
  15. data/app/models/abstract_user.rb +51 -0
  16. data/app/models/bot_user.rb +25 -0
  17. data/app/models/concept/base.rb +16 -0
  18. data/app/models/job_relation.rb +26 -0
  19. data/app/models/match/skos/broad_match.rb +4 -0
  20. data/app/models/match/skos/close_match.rb +4 -0
  21. data/app/models/match/skos/exact_match.rb +4 -0
  22. data/app/models/match/skos/narrow_match.rb +4 -0
  23. data/app/models/match/skos/related_match.rb +4 -0
  24. data/app/models/note/base.rb +4 -2
  25. data/app/models/services/reverse_match_service.rb +25 -0
  26. data/app/models/user.rb +3 -46
  27. data/app/views/concepts/_form.html.erb +6 -1
  28. data/app/views/concepts/show_published.html.erb +3 -0
  29. data/app/views/concepts/show_unpublished.html.erb +4 -0
  30. data/app/views/partials/concept/_reverse_match_notice.html.erb +25 -0
  31. data/app/views/partials/concept/relation/_edit_base.html.erb +3 -1
  32. data/app/views/partials/concept/relation/_edit_ranked.html.erb +3 -1
  33. data/app/views/partials/note/_search_result.html.erb +1 -1
  34. data/config/locales/de.yml +8 -0
  35. data/config/locales/en.yml +8 -0
  36. data/config/routes.rb +4 -1
  37. data/db/migrate/20140730132113_add_type_to_users.rb +5 -0
  38. data/db/migrate/20140807072457_create_job_relations.rb +11 -0
  39. data/db/migrate/20140807123413_add_response_error_to_job_relation.rb +5 -0
  40. data/iqvoc.gemspec +1 -0
  41. data/lib/iqvoc/ability.rb +8 -0
  42. data/lib/iqvoc/configuration/concept.rb +7 -0
  43. data/lib/iqvoc/version.rb +1 -1
  44. data/lib/tasks/matches.rake +51 -0
  45. data/test/controllers/concept_movement_test.rb +1 -1
  46. data/test/controllers/reverse_match_test.rb +146 -0
  47. data/test/integration/create_concept_test.rb +48 -0
  48. data/test/integration/reverse_match_job_test.rb +111 -0
  49. metadata +33 -1
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2011-2013 innoQ Deutschland GmbH
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../integration_test_helper')
18
+
19
+ class CreateConceptTest < ActionDispatch::IntegrationTest
20
+ test 'concept creation' do
21
+ login('administrator')
22
+ visit dashboard_path(lang: 'en')
23
+
24
+ assert page.has_content? 'New Concept'
25
+ click_link_or_button 'New Concept'
26
+
27
+ assert page.has_content? 'A concept have to be published before you can assign mapping properties.'
28
+ # fill in english pref label
29
+ fill_in 'concept_labelings_by_text_labeling_skos_pref_labels_en', with: 'Foo'
30
+
31
+ save_check_and_publish
32
+ end
33
+
34
+ private
35
+
36
+ def save_check_and_publish
37
+ click_link_or_button 'Save'
38
+
39
+ assert page.has_content? 'Concept has been successfully created.'
40
+ assert page.has_content? 'Current revision 1'
41
+
42
+ click_link_or_button 'Check consistency'
43
+ assert page.has_content? 'Instance is consistent.'
44
+
45
+ click_link_or_button 'Publish'
46
+ assert page.has_content? 'Instance has been successfully published.'
47
+ end
48
+ end
@@ -0,0 +1,111 @@
1
+ # encoding: UTF-8
2
+
3
+ # Copyright 2011-2014 innoQ Deutschland GmbH
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require File.join(File.expand_path(File.dirname(__FILE__)), '../test_helper')
18
+ require 'webmock/minitest'
19
+
20
+ class ReverseMatchJobTest < ActiveSupport::TestCase
21
+ include ReverseMatchErrors
22
+
23
+ setup do
24
+ @achievement_hobbies = Concept::SKOS::Base.new.tap do |c|
25
+ Iqvoc::RDFAPI.devour c, 'skos:prefLabel', '"Achievement hobbies"@en'
26
+ c.publish
27
+ c.save
28
+ end
29
+
30
+ @airsoft = Concept::SKOS::Base.new(origin: 'airsoft').tap do |c|
31
+ Iqvoc::RDFAPI.devour c, 'skos:prefLabel', '"Airsoft"@en'
32
+ c.publish
33
+ c.save
34
+ end
35
+
36
+ @reverse_match_service = Services::ReverseMatchService.new('http://try.iqvoc.com', 80)
37
+
38
+ body = {links: [
39
+ { rel: 'self', href: 'http://0.0.0.0:3000/en/concepts/airsoft', method: 'get' },
40
+ { rel: 'add_match',href: 'http://0.0.0.0:3000/airsoft/add_match', method: 'patch' },
41
+ { rel: 'remove_match', href: 'http://0.0.0.0:3000/airsoft/remove_match', method: 'patch' }
42
+ ]}.to_json
43
+
44
+ stub_request(:get, 'http://try.iqvoc.com/')
45
+ .with(:headers => {'Accept' => 'application/json', 'User-Agent' => 'Faraday v0.9.0'})
46
+ .to_return(status: 200, body: body, headers: {})
47
+
48
+ DatabaseCleaner.start
49
+ end
50
+
51
+ teardown do
52
+ DatabaseCleaner.clean
53
+ end
54
+
55
+ test 'successfull job' do
56
+ status, body = status_and_body(:mapping_added)
57
+ stub_request(:patch, 'http://0.0.0.0:3000/airsoft/add_match?match_class=match_skos_broadmatch&uri=http://try.iqvoc.com/airsoft')
58
+ .with(:headers => {'Accept' => '*/*', 'Content-Type'=>'application/json', 'Referer'=>'http://try.iqvoc.com/', 'User-Agent'=>'Faraday v0.9.0'})
59
+ .to_return(status: status, body: body.to_json, headers: {})
60
+
61
+ job = @reverse_match_service.build_job(:add_match, 'airsoft', 'http://try.iqvoc.com', 'Match::SKOS::BroadMatch')
62
+ @reverse_match_service.add(job)
63
+
64
+ Delayed::Worker.new.work_off
65
+ assert_equal 0, @airsoft.jobs.size
66
+ end
67
+
68
+ test 'job timeout' do
69
+ status, body = status_and_body(:mapping_added)
70
+ stub_request(:patch, 'http://0.0.0.0:3000/airsoft/add_match?match_class=match_skos_broadmatch&uri=http://try.iqvoc.com/airsoft').to_timeout
71
+
72
+ job = @reverse_match_service.build_job(:add_match, 'airsoft', 'http://try.iqvoc.com', 'Match::SKOS::BroadMatch')
73
+ @reverse_match_service.add(job)
74
+
75
+ Delayed::Worker.new.work_off
76
+ assert_equal 1, @airsoft.jobs.size
77
+
78
+ job_relation = @airsoft.job_relations.first
79
+ assert_equal 'timeout_error', job_relation.response_error
80
+ end
81
+
82
+ test 'unknown resource' do
83
+ status, body = status_and_body(:mapping_added)
84
+ stub_request(:patch, 'http://0.0.0.0:3000/airsoft/add_match?match_class=match_skos_broadmatch&uri=http://try.iqvoc.com/airsoft').to_return(status: 404)
85
+
86
+ job = @reverse_match_service.build_job(:add_match, 'airsoft', 'http://try.iqvoc.com', 'Match::SKOS::BroadMatch')
87
+ @reverse_match_service.add(job)
88
+
89
+ Delayed::Worker.new.work_off
90
+ assert_equal 1, @airsoft.jobs.size
91
+
92
+ job_relation = @airsoft.job_relations.first
93
+ assert_equal 'resource_not_found', job_relation.response_error
94
+ end
95
+
96
+ test 'unknown match class' do
97
+ status, body = status_and_body(:unknown_match)
98
+ stub_request(:patch, 'http://0.0.0.0:3000/airsoft/add_match?match_class=match_skos_broadmatch&uri=http://try.iqvoc.com/airsoft')
99
+ .with(:headers => {'Accept' => '*/*', 'Content-Type'=>'application/json', 'Referer'=>'http://try.iqvoc.com/', 'User-Agent'=>'Faraday v0.9.0'})
100
+ .to_return(status: status, body: body.to_json, headers: {})
101
+
102
+ job = @reverse_match_service.build_job(:add_match, 'airsoft', 'http://try.iqvoc.com', 'Match::SKOS::BroadMatch')
103
+ @reverse_match_service.add(job)
104
+
105
+ Delayed::Worker.new.work_off
106
+ assert_equal 1, @airsoft.jobs.size
107
+
108
+ job_relation = @airsoft.job_relations.first
109
+ assert_equal 'unknown_match', job_relation.response_error
110
+ end
111
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iqvoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.2
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Glaser
@@ -153,6 +153,20 @@ dependencies:
153
153
  - - ">="
154
154
  - !ruby/object:Gem::Version
155
155
  version: '0'
156
+ - !ruby/object:Gem::Dependency
157
+ name: faraday_middleware
158
+ requirement: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ type: :runtime
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
156
170
  - !ruby/object:Gem::Dependency
157
171
  name: sass-rails
158
172
  requirement: !ruby/object:Gem::Requirement
@@ -384,6 +398,7 @@ files:
384
398
  - app/assets/stylesheets/iqvoc/manifest.css.scss
385
399
  - app/assets/stylesheets/manifest.css.scss
386
400
  - app/concerns/first_level_object_validations.rb
401
+ - app/concerns/reverse_match_errors.rb
387
402
  - app/concerns/versioning.rb
388
403
  - app/controllers/application_controller.rb
389
404
  - app/controllers/collections/versions_controller.rb
@@ -405,6 +420,7 @@ files:
405
420
  - app/controllers/pages_controller.rb
406
421
  - app/controllers/rdf_controller.rb
407
422
  - app/controllers/remote_labels_controller.rb
423
+ - app/controllers/reverse_matches_controller.rb
408
424
  - app/controllers/search_results_controller.rb
409
425
  - app/controllers/triplestore_sync_controller.rb
410
426
  - app/controllers/user_sessions_controller.rb
@@ -422,6 +438,9 @@ files:
422
438
  - app/helpers/widget_helper.rb
423
439
  - app/jobs/export_job.rb
424
440
  - app/jobs/import_job.rb
441
+ - app/jobs/reverse_match_job.rb
442
+ - app/models/abstract_user.rb
443
+ - app/models/bot_user.rb
425
444
  - app/models/collection/base.rb
426
445
  - app/models/collection/member/base.rb
427
446
  - app/models/collection/member/skos/base.rb
@@ -448,6 +467,7 @@ files:
448
467
  - app/models/dataset/iqvoc_dataset.rb
449
468
  - app/models/export.rb
450
469
  - app/models/import.rb
470
+ - app/models/job_relation.rb
451
471
  - app/models/label/base.rb
452
472
  - app/models/label/skos/base.rb
453
473
  - app/models/labeling/base.rb
@@ -475,6 +495,7 @@ files:
475
495
  - app/models/note/skos/history_note.rb
476
496
  - app/models/note/skos/scope_note.rb
477
497
  - app/models/search_extension.rb
498
+ - app/models/services/reverse_match_service.rb
478
499
  - app/models/user.rb
479
500
  - app/models/user_session.rb
480
501
  - app/presenters/alphabetical_search_result.rb
@@ -541,6 +562,7 @@ files:
541
562
  - app/views/partials/concept/_edit_link_base.html.erb
542
563
  - app/views/partials/concept/_inline_base.html.erb
543
564
  - app/views/partials/concept/_new_link_base.html.erb
565
+ - app/views/partials/concept/_reverse_match_notice.html.erb
544
566
  - app/views/partials/concept/relation/_base.html.erb
545
567
  - app/views/partials/concept/relation/_edit_base.html.erb
546
568
  - app/views/partials/concept/relation/_edit_ranked.html.erb
@@ -660,6 +682,9 @@ files:
660
682
  - db/migrate/20140505144919_add_import_file_to_imports.rb
661
683
  - db/migrate/20140506073428_add_missing_imports_attributes.rb
662
684
  - db/migrate/20140506133619_add_namespace_to_exports.rb
685
+ - db/migrate/20140730132113_add_type_to_users.rb
686
+ - db/migrate/20140807072457_create_job_relations.rb
687
+ - db/migrate/20140807123413_add_response_error_to_job_relation.rb
663
688
  - db/schema.rb
664
689
  - db/seeds.rb
665
690
  - iqvoc.gemspec
@@ -692,6 +717,7 @@ files:
692
717
  - lib/string.rb
693
718
  - lib/tasks/exporter.rake
694
719
  - lib/tasks/importer.rake
720
+ - lib/tasks/matches.rake
695
721
  - lib/tasks/release.rake
696
722
  - lib/tasks/reset.rake
697
723
  - lib/tasks/sync.rake
@@ -1033,6 +1059,7 @@ files:
1033
1059
  - test/controllers/concept_movement_test.rb
1034
1060
  - test/controllers/hierarchy_test.rb
1035
1061
  - test/controllers/rdf_rendering_test.rb
1062
+ - test/controllers/reverse_match_test.rb
1036
1063
  - test/integration/alphabetical_test.rb
1037
1064
  - test/integration/authentication_test.rb
1038
1065
  - test/integration/browse_concepts_and_labels_test.rb
@@ -1041,6 +1068,7 @@ files:
1041
1068
  - test/integration/collection_circularity_test.rb
1042
1069
  - test/integration/concept_browsing_test.rb
1043
1070
  - test/integration/concept_scheme_browsing_test.rb
1071
+ - test/integration/create_concept_test.rb
1044
1072
  - test/integration/edit_collections_test.rb
1045
1073
  - test/integration/edit_concepts_test.rb
1046
1074
  - test/integration/export_test.rb
@@ -1048,6 +1076,7 @@ files:
1048
1076
  - test/integration/instance_configuration_browsing_test.rb
1049
1077
  - test/integration/navigation_test.rb
1050
1078
  - test/integration/note_annotations_test.rb
1079
+ - test/integration/reverse_match_job_test.rb
1051
1080
  - test/integration/search_test.rb
1052
1081
  - test/integration/tree_test.rb
1053
1082
  - test/integration/untranslated_test.rb
@@ -1138,6 +1167,7 @@ test_files:
1138
1167
  - test/controllers/concept_movement_test.rb
1139
1168
  - test/controllers/hierarchy_test.rb
1140
1169
  - test/controllers/rdf_rendering_test.rb
1170
+ - test/controllers/reverse_match_test.rb
1141
1171
  - test/integration/alphabetical_test.rb
1142
1172
  - test/integration/authentication_test.rb
1143
1173
  - test/integration/browse_concepts_and_labels_test.rb
@@ -1146,6 +1176,7 @@ test_files:
1146
1176
  - test/integration/collection_circularity_test.rb
1147
1177
  - test/integration/concept_browsing_test.rb
1148
1178
  - test/integration/concept_scheme_browsing_test.rb
1179
+ - test/integration/create_concept_test.rb
1149
1180
  - test/integration/edit_collections_test.rb
1150
1181
  - test/integration/edit_concepts_test.rb
1151
1182
  - test/integration/export_test.rb
@@ -1153,6 +1184,7 @@ test_files:
1153
1184
  - test/integration/instance_configuration_browsing_test.rb
1154
1185
  - test/integration/navigation_test.rb
1155
1186
  - test/integration/note_annotations_test.rb
1187
+ - test/integration/reverse_match_job_test.rb
1156
1188
  - test/integration/search_test.rb
1157
1189
  - test/integration/tree_test.rb
1158
1190
  - test/integration/untranslated_test.rb