iqvoc_skosxl 2.3.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +17 -7
  3. data/Gemfile.lock +200 -156
  4. data/README.md +8 -0
  5. data/app/assets/stylesheets/iqvoc_skosxl/{entity_select.css → entity_select.css.scss} +1 -1
  6. data/app/assets/stylesheets/iqvoc_skosxl/manifest.css.scss +1 -0
  7. data/app/assets/stylesheets/manifest.css.scss +3 -0
  8. data/app/controllers/labels/versions_controller.rb +33 -37
  9. data/app/controllers/labels_controller.rb +32 -31
  10. data/app/controllers/rdf_controller.rb +6 -7
  11. data/app/helpers/iqvoc_skosxl_helper.rb +2 -9
  12. data/app/helpers/labels_helper.rb +7 -9
  13. data/app/models/concept/skosxl/extension.rb +2 -4
  14. data/app/models/label/relation/base.rb +10 -12
  15. data/app/models/label/relation/skosxl/base.rb +5 -3
  16. data/app/models/label/skosxl/base.rb +44 -70
  17. data/app/models/label/skosxl/properties/literal_form.rb +23 -0
  18. data/app/models/label/skosxl/validations.rb +28 -0
  19. data/app/models/labeling/skosxl/alt_label.rb +0 -2
  20. data/app/models/labeling/skosxl/base.rb +22 -16
  21. data/app/models/labeling/skosxl/hidden_label.rb +1 -3
  22. data/app/models/labeling/skosxl/pref_label.rb +0 -2
  23. data/app/views/labels/_form.html.erb +12 -10
  24. data/app/views/labels/_sidebar.html.erb +1 -0
  25. data/app/views/labels/show_published.html.erb +2 -2
  26. data/app/views/labels/show_unpublished.html.erb +6 -6
  27. data/app/views/partials/label/relation/_edit_base.html.erb +1 -1
  28. data/app/views/partials/label/skosxl/_new_link_base.html.erb +5 -5
  29. data/app/views/partials/labeling/skosxl/_edit_base.html.erb +13 -13
  30. data/app/views/rdf/show_label.iqrdf +2 -2
  31. data/config/application.rb +4 -34
  32. data/config/boot.rb +3 -12
  33. data/config/engine.rb +2 -4
  34. data/config/environment.rb +3 -3
  35. data/config/initializers/backtrace_silencers.rb +7 -0
  36. data/config/initializers/cookies_serializer.rb +3 -0
  37. data/config/initializers/filter_parameter_logging.rb +4 -0
  38. data/config/initializers/inflections.rb +16 -0
  39. data/config/initializers/iqvoc.rb +49 -3
  40. data/config/initializers/mime_types.rb +4 -0
  41. data/config/initializers/session_store.rb +1 -1
  42. data/config/initializers/wrap_parameters.rb +14 -0
  43. data/config/routes.rb +16 -8
  44. data/config/secrets.yml +11 -0
  45. data/db/migrate/20110408121540_extend_label.rb +9 -12
  46. data/db/migrate/20110408123644_add_label_relations.rb +11 -13
  47. data/iqvoc_skosxl.gemspec +15 -14
  48. data/lib/iqvoc/skosxl/version.rb +1 -1
  49. data/lib/iqvoc/xllabel.rb +1 -5
  50. data/lib/iqvoc_skosxl.rb +13 -12
  51. data/test/{functional → controllers}/routing_test.rb +4 -6
  52. data/test/fixtures/hobbies.nt +11 -0
  53. data/test/integration/concept_label_language_test.rb +44 -45
  54. data/test/integration/dashboard_test.rb +10 -12
  55. data/test/integration/edit_labels_test.rb +12 -14
  56. data/test/integration/label_creation_test.rb +43 -0
  57. data/test/integration/labels_order_test.rb +17 -17
  58. data/test/integration_test_helper.rb +29 -0
  59. data/test/models/label_test.rb +54 -0
  60. data/test/models/skos_importer_test.rb +55 -0
  61. data/test/test_helper.rb +6 -12
  62. metadata +45 -24
  63. data/app/assets/stylesheets/iqvoc_skosxl/manifest.css +0 -3
  64. data/app/assets/stylesheets/manifest.css +0 -5
  65. data/config/initializers/secret_token.rb +0 -10
  66. data/config/initializers/secret_token.rb.template +0 -9
  67. data/test/factories.rb +0 -22
  68. data/test/unit/label_test.rb +0 -41
@@ -1,16 +1,15 @@
1
1
  class Labels::VersionsController < ApplicationController
2
-
3
2
  def merge
4
3
  current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last
5
- new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
6
- raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished label with origin '#{params[:origin]}'") unless new_version
4
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
5
+
7
6
  authorize! :merge, new_version
8
7
 
9
8
  ActiveRecord::Base.transaction do
10
9
  if current_label.blank? || current_label.destroy
11
10
  new_version.publish
12
11
  new_version.unlock
13
- if new_version.valid_with_full_validation?
12
+ if new_version.publishable?
14
13
  new_version.save
15
14
  begin
16
15
  # TODO if RdfStore.update(new_version.rdf_uri, label_url(:id => new_version, :format => :ttl))
@@ -20,40 +19,41 @@ class Labels::VersionsController < ApplicationController
20
19
  handle_virtuoso_exception(e.message)
21
20
  end
22
21
  if new_version.has_concept_or_label_relations?
23
- flash[:success] = t("txt.controllers.versioning.published")
24
- redirect_to label_path(:id => new_version)
22
+ flash[:success] = t('txt.controllers.versioning.published')
23
+ redirect_to label_path(id: new_version)
25
24
  else
26
- flash[:error] = t("txt.controllers.versioning.published_with_warning")
27
- redirect_to label_path(:id => new_version)
25
+ flash[:error] = t('txt.controllers.versioning.published_with_warning')
26
+ redirect_to label_path(id: new_version)
28
27
  end
29
28
  else
30
- flash[:error] = t("txt.controllers.versioning.merged_publishing_error")
31
- redirect_to label_path(:published => 0, :id => new_version)
29
+ flash[:error] = t('txt.controllers.versioning.merged_publishing_error')
30
+ redirect_to label_path(published: 0, id: new_version)
32
31
  end
33
32
  else
34
- flash[:error] = t("txt.controllers.versioning.merged_delete_error")
35
- redirect_to label_path(:published => 0, :id => new_version)
33
+ flash[:error] = t('txt.controllers.versioning.merged_delete_error')
34
+ redirect_to label_path(published: 0, id: new_version)
36
35
  end
37
36
  end
38
37
  end
39
38
 
40
39
  def branch
41
- current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last
42
- raise ActiveRecord::RecordNotFound.new("Couldn't find published Label with origin '#{params[:origin]}'") unless current_label
43
- raise "There is already an unpublished version for Label '#{params[:origin]}'" if Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
40
+ current_label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).published.last!
41
+ if Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
42
+ raise "There is already an unpublished version for Label '#{params[:origin]}'"
43
+ end
44
+
44
45
  authorize! :branch, current_label
45
46
  new_version = nil
46
47
  ActiveRecord::Base.transaction do
47
48
  new_version = current_label.branch(current_user)
48
49
  new_version.save!
49
50
  end
50
- flash[:success] = t("txt.controllers.versioning.branched")
51
- redirect_to edit_label_path(:published => 0, :id => new_version, :check_associations_in_editing_mode => true)
51
+ flash[:success] = t('txt.controllers.versioning.branched')
52
+ redirect_to edit_label_path(published: 0, id: new_version, check_associations_in_editing_mode: true)
52
53
  end
53
54
 
54
55
  def lock
55
- new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
56
- raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished Label with origin '#{params[:origin]}'") unless new_version
56
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
57
57
  raise "Label with origin '#{params[:origin]}' has already been locked." if new_version.locked?
58
58
 
59
59
  authorize! :lock, new_version
@@ -61,13 +61,12 @@ class Labels::VersionsController < ApplicationController
61
61
  new_version.lock_by_user(current_user.id)
62
62
  new_version.save!
63
63
 
64
- flash[:success] = t("txt.controllers.versioning.locked")
65
- redirect_to edit_label_path(:published => 0, :id => new_version)
64
+ flash[:success] = t('txt.controllers.versioning.locked')
65
+ redirect_to edit_label_path(published: 0, id: new_version)
66
66
  end
67
67
 
68
68
  def unlock
69
- new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
70
- raise ActiveRecord::RecordNotFound.new("Couldn't find unpublished Label with origin '#{params[:origin]}'") unless new_version
69
+ new_version = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
71
70
  raise "Label with origin '#{params[:origin]}' wasn't locked." unless new_version.locked?
72
71
 
73
72
  authorize! :unlock, new_version
@@ -75,35 +74,32 @@ class Labels::VersionsController < ApplicationController
75
74
  new_version.unlock
76
75
  new_version.save!
77
76
 
78
- flash[:success] = t("txt.controllers.versioning.unlocked")
79
- redirect_to label_path(:published => 0, :id => new_version)
77
+ flash[:success] = t('txt.controllers.versioning.unlocked')
78
+ redirect_to label_path(published: 0, id: new_version)
80
79
  end
81
80
 
82
81
  def consistency_check
83
- label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
84
- raise ActiveRecord::RecordNotFound unless label
82
+ label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
85
83
 
86
84
  authorize! :check_consistency, label
87
85
 
88
- if label.valid_with_full_validation?
89
- flash[:success] = t("txt.controllers.versioning.consistency_check_success")
90
- redirect_to label_path(:published => 0, :id => label)
86
+ if label.publishable?
87
+ flash[:success] = t('txt.controllers.versioning.consistency_check_success')
88
+ redirect_to label_path(published: 0, id: label)
91
89
  else
92
- flash[:error] = t("txt.controllers.versioning.consistency_check_error")
93
- redirect_to edit_label_path(:published => 0, :id => label, :full_consistency_check => 1)
90
+ flash[:error] = t('txt.controllers.versioning.consistency_check_error')
91
+ redirect_to edit_label_path(published: 0, id: label, full_consistency_check: 1)
94
92
  end
95
93
  end
96
94
 
97
95
  def to_review
98
- label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last
99
- raise ActiveRecord::RecordNotFound unless label
96
+ label = Iqvoc::XLLabel.base_class.by_origin(params[:origin]).unpublished.last!
100
97
 
101
98
  authorize! :send_to_review, label
102
99
 
103
100
  label.to_review
104
101
  label.save!
105
- flash[:success] = t("txt.controllers.versioning.to_review_success")
106
- redirect_to label_path(:published => 0, :id => label)
102
+ flash[:success] = t('txt.controllers.versioning.to_review_success')
103
+ redirect_to label_path(published: 0, id: label)
107
104
  end
108
-
109
105
  end
@@ -8,21 +8,21 @@ class LabelsController < ApplicationController
8
8
  if params[:language] # NB: this is not the same as :lang, which is supplied via route
9
9
  scope = scope.by_language(params[:language])
10
10
  end
11
- @labels = scope.published.order("LOWER(value)").all
11
+ @labels = scope.published.order('LOWER(value)').all
12
12
 
13
13
  respond_to do |format|
14
14
  format.html do
15
- redirect_to :action => "index", :format => "txt"
15
+ redirect_to action: 'index', format: 'txt'
16
16
  end
17
17
  format.text do
18
- render :content_type => "text/plain",
19
- :text => @labels.map { |label| "#{label.origin}: #{label.value}" }.join("\n")
18
+ render content_type: 'text/plain',
19
+ text: @labels.map { |label| "#{label.origin}: #{label.value}" }.join("\n")
20
20
  end
21
21
  format.json do
22
22
  response = []
23
23
  @labels.each { |label| response << label_widget_data(label) }
24
24
 
25
- render :json => response
25
+ render json: response
26
26
  end
27
27
  end
28
28
  end
@@ -34,10 +34,9 @@ class LabelsController < ApplicationController
34
34
  @new_label_version = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
35
35
  elsif params[:published] == '0'
36
36
  published = false
37
- @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
37
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
38
38
  end
39
39
 
40
- raise ActiveRecord::RecordNotFound unless @label
41
40
  authorize! :read, @label
42
41
 
43
42
  respond_to do |format|
@@ -50,32 +49,31 @@ class LabelsController < ApplicationController
50
49
 
51
50
  def new
52
51
  authorize! :create, Iqvoc::XLLabel.base_class
53
- raise "You have to specify a language parameter!" if params[:language].blank?
54
- data = {:language => params[:language]}
55
- data.merge(:value => params[:value]) if params[:value]
52
+ raise 'You have to specify a language parameter!' if params[:language].blank?
53
+ data = {language: params[:language]}
54
+ data.merge(value: params[:value]) if params[:value]
56
55
  @label = Iqvoc::XLLabel.base_class.new(data)
57
56
  end
58
57
 
59
58
  def create
60
59
  authorize! :create, Iqvoc::XLLabel.base_class
61
- @label = Iqvoc::XLLabel.base_class.new(params[:label])
60
+ @label = Iqvoc::XLLabel.base_class.new(label_params)
62
61
  if @label.valid?
63
62
  if @label.save
64
- flash[:success] = I18n.t("txt.controllers.versioned_label.success")
65
- redirect_to label_path(:published => 0, :id => @label.origin)
63
+ flash[:success] = I18n.t('txt.controllers.versioned_label.success')
64
+ redirect_to label_path(published: 0, id: @label.origin)
66
65
  else
67
- flash.now[:error] = I18n.t("txt.controllers.versioned_label.error")
66
+ flash.now[:error] = I18n.t('txt.controllers.versioned_label.error')
68
67
  render :new
69
68
  end
70
69
  else
71
- flash.now[:error] = I18n.t("txt.controllers.versioned_label.error")
70
+ flash.now[:error] = I18n.t('txt.controllers.versioned_label.error')
72
71
  render :new
73
72
  end
74
73
  end
75
74
 
76
75
  def edit
77
- @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
78
- raise ActiveRecord::RecordNotFound unless @label
76
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
79
77
  authorize! :update, @label
80
78
 
81
79
  if params[:check_associations_in_editing_mode]
@@ -86,7 +84,7 @@ class LabelsController < ApplicationController
86
84
  # @alt_labelings = AltLabeling.by_label(@label).all(:include => {:owner => :pref_labels}).sort
87
85
 
88
86
  if params[:full_consistency_check]
89
- @label.valid_with_full_validation?
87
+ @label.publishable?
90
88
  end
91
89
 
92
90
  Iqvoc::XLLabel.note_class_names.each do |note_class_name|
@@ -95,35 +93,38 @@ class LabelsController < ApplicationController
95
93
  end
96
94
 
97
95
  def update
98
- @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
99
- raise ActiveRecord::RecordNotFound unless @label
96
+ @label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
100
97
  authorize! :update, @label
101
98
 
102
99
  respond_to do |format|
103
100
  format.html do
104
- raise ActiveRecord::RecordNotFound unless @label
105
- if @label.update_attributes(params[:label])
106
- flash[:success] = I18n.t("txt.controllers.versioned_label.update_success")
107
- redirect_to label_path(:published => 0, :id => @label)
101
+ if @label.update_attributes(label_params)
102
+ flash[:success] = I18n.t('txt.controllers.versioned_label.update_success')
103
+ redirect_to label_path(published: 0, id: @label)
108
104
  else
109
- flash.now[:error] = I18n.t("txt.controllers.versioned_label.update_error")
110
- render :action => :edit
105
+ flash.now[:error] = I18n.t('txt.controllers.versioned_label.update_error')
106
+ render action: :edit
111
107
  end
112
108
  end
113
109
  end
114
110
  end
115
111
 
116
112
  def destroy
117
- @new_label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last
118
- raise ActiveRecord::RecordNotFound unless @new_label
113
+ @new_label = Iqvoc::XLLabel.base_class.by_origin(params[:id]).unpublished.last!
119
114
  authorize! :destroy, @new_label
120
115
 
121
116
  if @new_label.destroy
122
- flash[:success] = I18n.t("txt.controllers.label_versions.delete")
117
+ flash[:success] = I18n.t('txt.controllers.label_versions.delete')
123
118
  redirect_to dashboard_path
124
119
  else
125
- flash[:error] = I18n.t("txt.controllers.label_versions.delete_error")
126
- redirect_to label_path(:published => 0, :id => @new_label)
120
+ flash[:error] = I18n.t('txt.controllers.label_versions.delete_error')
121
+ redirect_to label_path(published: 0, id: @new_label)
127
122
  end
128
123
  end
124
+
125
+ private
126
+
127
+ def label_params
128
+ params.require(:label).permit!
129
+ end
129
130
  end
@@ -1,16 +1,16 @@
1
- require_dependency Iqvoc::Engine.find_root_with_flag("app").join("app/controllers/rdf_controller").to_s
2
- class RdfController
1
+ require_dependency Iqvoc.root.join('app/controllers/rdf_controller').to_s
3
2
 
3
+ class RdfController
4
4
  def show_with_labels
5
- scope = params[:published] == "0" ? Iqvoc::XLLabel.base_class.scoped.unpublished : Iqvoc::XLLabel.base_class.scoped.published
5
+ scope = params[:published] == '0' ? Iqvoc::XLLabel.base_class.unpublished : Iqvoc::XLLabel.base_class.published
6
6
  if @label = scope.by_origin(params[:id]).with_associations.last
7
7
  respond_to do |format|
8
8
  format.html {
9
- redirect_to label_url(:id => @label.origin, :published => params[:published])
9
+ redirect_to label_url(id: @label.origin, published: params[:published])
10
10
  }
11
11
  format.any {
12
12
  authorize! :read, @label
13
- render "show_label"
13
+ render 'show_label'
14
14
  }
15
15
  end
16
16
  else
@@ -19,5 +19,4 @@ class RdfController
19
19
  end
20
20
 
21
21
  alias_method_chain(:show, :labels)
22
-
23
- end
22
+ end
@@ -1,15 +1,9 @@
1
1
  module IqvocSkosxlHelper
2
-
3
- def iqvoc_skosxl_default_rdf_namespaces
4
- {
5
- }
6
- end
7
-
8
2
  def render_label(label)
9
3
  if label.new_record?
10
- "-"
4
+ '-'
11
5
  elsif label.is_a?(Label::SKOSXL::Base)
12
- link_to(label.to_s, label_path(:id => label))
6
+ link_to(label.to_s, label_path(id: label))
13
7
  else
14
8
  label.to_s
15
9
  end
@@ -21,5 +15,4 @@ module IqvocSkosxlHelper
21
15
  str << " (#{concept.additional_info})" if concept.additional_info
22
16
  str
23
17
  end
24
-
25
18
  end
@@ -1,5 +1,4 @@
1
1
  module LabelsHelper
2
-
3
2
  def render_label_rdf(document, label)
4
3
  document << label.build_rdf_subject do |c|
5
4
 
@@ -7,7 +6,7 @@ module LabelsHelper
7
6
 
8
7
  c.Owl::deprecated(true) if label.expired_at and label.expired_at <= Date.new
9
8
 
10
- c.Skosxl::literalForm(label.value, :lang => label.language)
9
+ c.Skosxl::literalForm(label.value, lang: label.language)
11
10
 
12
11
  label.relations.each do |relation|
13
12
  relation.build_rdf(document, c)
@@ -27,16 +26,16 @@ module LabelsHelper
27
26
 
28
27
  def render_label_association(hash, label, association_class, further_options = {})
29
28
  return unless association_class.partial_name(label)
30
- ((hash[association_class.view_section(label)] ||= {})[association_class.view_section_sort_key(label)] ||= "") <<
31
- render(association_class.partial_name(label), further_options.merge(:label => label, :klass => association_class))
29
+ ((hash[association_class.view_section(label)] ||= {})[association_class.view_section_sort_key(label)] ||= '') <<
30
+ render(association_class.partial_name(label), further_options.merge(label: label, klass: association_class))
32
31
  end
33
32
 
34
33
  def label_view_data(label)
35
34
  res = {'main' => {}}
36
35
 
37
- res['main'][10] = render 'labels/value_and_language', :label => label
36
+ res['main'][10] = render 'labels/value_and_language', label: label
38
37
 
39
- res['main'][1000] = render 'labels/details', :label => label
38
+ res['main'][1000] = render 'labels/details', label: label
40
39
 
41
40
  Iqvoc::Concept.labeling_classes.keys.each do |labeling_class|
42
41
  render_label_association(res, label, labeling_class)
@@ -61,12 +60,11 @@ module LabelsHelper
61
60
  desc = label.class.model_name.human
62
61
 
63
62
  if label.expired_at
64
- desc += " #{t('txt.views.concepts.expired_at', :date => l(label.expired_at, :format => :long))} "
63
+ desc += " #{t('txt.views.concepts.expired_at', date: l(label.expired_at, format: :long))} "
65
64
  end
66
65
 
67
66
  title = label.origin
68
67
 
69
- page_header :title => title.to_s, :desc => desc.html_safe
68
+ page_header title: title.to_s, desc: desc.html_safe
70
69
  end
71
-
72
70
  end
@@ -1,7 +1,6 @@
1
1
  module Concept
2
2
  module SKOSXL
3
3
  module Extension
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
@@ -24,7 +23,7 @@ module Concept
24
23
 
25
24
  # Iterate over all labels to be added and create them
26
25
  Iqvoc::XLLabel.base_class.by_origin(new_origins).each do |l|
27
- concept.send(labeling_relation_name).create!(:target => l)
26
+ concept.send(labeling_relation_name).create!(target: l)
28
27
  end
29
28
  end
30
29
  end
@@ -48,13 +47,12 @@ module Concept
48
47
  Iqvoc::XLLabel.base_class.by_origin(new_origins).each do |label|
49
48
  if label.language != language.to_s
50
49
  errors.add(:base,
51
- I18n.t("txt.controllers.versioned_concept.label_error") % label)
50
+ I18n.t('txt.controllers.versioned_concept.label_error') % label)
52
51
  end
53
52
  end
54
53
  }
55
54
  }
56
55
  end
57
-
58
56
  end
59
57
  end
60
58
  end
@@ -1,39 +1,38 @@
1
1
  class Label::Relation::Base < ActiveRecord::Base
2
-
3
2
  class_attribute :rdf_namespace, :rdf_predicate
4
3
  self.rdf_namespace = nil
5
4
  self.rdf_predicate = nil
6
5
 
7
6
  self.table_name ='label_relations'
8
7
 
9
- belongs_to :domain, :class_name => "Label::Base"
10
- belongs_to :range, :class_name => "Label::Base"
8
+ belongs_to :domain, class_name: 'Label::Base'
9
+ belongs_to :range, class_name: 'Label::Base'
11
10
 
12
11
  def self.by_domain(domain)
13
- where(:domain_id => domain)
12
+ where(domain_id: domain)
14
13
  end
15
14
 
16
15
  def self.by_range(range)
17
- where(:range_id => range)
16
+ where(range_id: range)
18
17
  end
19
18
 
20
19
  def self.by_range_origin(origin)
21
- includes(:range).merge(Label::Base.by_origin(origin))
20
+ includes(:range).references(:labels).merge(Label::Base.by_origin(origin))
22
21
  end
23
22
 
24
23
  def self.range_editor_selectable
25
24
  # includes(:range) & Iqvoc::XLLabel.base_class.editor_selectable
26
25
  # Doesn't work correctly (kills label_relations.type condition :-( )
27
26
  includes(:range).
28
- where("labels.published_at IS NOT NULL OR (labels.published_at IS NULL AND labels.published_version_id IS NULL) ")
27
+ where('labels.published_at IS NOT NULL OR (labels.published_at IS NULL AND labels.published_version_id IS NULL) ')
29
28
  end
30
29
 
31
30
  def self.range_in_edit_mode
32
- joins(:range).merge(Iqvoc::XLLabel.base_class.in_edit_mode)
31
+ joins(:range).references(:labels).merge(Iqvoc::XLLabel.base_class.in_edit_mode)
33
32
  end
34
33
 
35
34
  def self.view_section(obj)
36
- "relations"
35
+ 'relations'
37
36
  end
38
37
 
39
38
  def self.view_section_sort_key(obj)
@@ -41,15 +40,14 @@ class Label::Relation::Base < ActiveRecord::Base
41
40
  end
42
41
 
43
42
  def self.partial_name(obj)
44
- "partials/label/relation/base"
43
+ 'partials/label/relation/base'
45
44
  end
46
45
 
47
46
  def self.edit_partial_name(obj)
48
- "partials/label/relation/edit_base"
47
+ 'partials/label/relation/edit_base'
49
48
  end
50
49
 
51
50
  def self.only_one_allowed?
52
51
  false
53
52
  end
54
-
55
53
  end
@@ -1,12 +1,14 @@
1
1
  class Label::Relation::SKOSXL::Base < Label::Relation::Base
2
-
3
2
  self.rdf_namespace = 'skosxl'
4
3
 
4
+ def self.build_from_rdf(subject, predicate, object)
5
+ create(domain: subject, range: object)
6
+ end
7
+
5
8
  def build_rdf(document, subject)
6
9
  pred = self.class == Label::Relation::SKOSXL::Base ? :labelRelation : self.rdf_predicate
7
10
  raise "Match::SKOS::Base#build_rdf: Class #{self.class.name} needs to define self.rdf_namespace and self.rdf_predicate." unless pred
8
11
 
9
12
  subject.send(self.rdf_namespace.camelcase).send(pred, IqRdf.build_uri(range.origin))
10
13
  end
11
-
12
- end
14
+ end