Class: ControlledVocabularyTerm

Inherits:
ApplicationRecord show all
Includes:
Housekeeping, Shared::AlternateValues, Shared::HasPapertrail, Shared::IsData, SoftValidation
Defined in:
app/models/controlled_vocabulary_term.rb

Overview

A controlled vocabulary term is a user defineable attribute, a name and definition is required.

Constant Summary collapse

ALTERNATE_VALUES_FOR =
[:name, :definition].freeze

Constants included from SoftValidation

SoftValidation::ANCESTORS_WITH_SOFT_VALIDATIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SoftValidation

#clear_soft_validations, #fix_for, #fix_soft_validations, #soft_fixed?, #soft_valid?, #soft_validate, #soft_validated?, #soft_validations, #soft_validators

Methods included from Shared::IsData

#errors_excepting, #full_error_messages_excepting, #identical, #is_community?, #is_destroyable?, #is_editable?, #is_in_use?, #is_in_users_projects?, #metamorphosize, #similar

Methods included from Shared::HasPapertrail

#attribute_updated, #attribute_updater

Methods included from Shared::AlternateValues

#all_values_for, #alternate_valued?

Methods included from Housekeeping

#has_polymorphic_relationship?

Methods inherited from ApplicationRecord

transaction_with_retry

Instance Attribute Details

#definitionString

Returns The term definition, required.

Returns:

  • (String)

    The term definition, required.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

#nameString

Returns The term name.

Returns:

  • (String)

    The term name.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

#project_idInteger

the project ID

Returns:

  • (Integer)


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

#typeString

Returns The subclass of the CVT.

Returns:

  • (String)

    The subclass of the CVT.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

#uriString

Returns A URI for an external concept that matches this CVT.

Returns:

  • (String)

    A URI for an external concept that matches this CVT.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

#uri_relationString

Returns A SKOS relationship that defines/describes the relationship between the concept identified by the URI and the concept defined in the definition.

Returns:

  • (String)

    A SKOS relationship that defines/describes the relationship between the concept identified by the URI and the concept defined in the definition.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'app/models/controlled_vocabulary_term.rb', line 27

class ControlledVocabularyTerm < ApplicationRecord
  # ControlledVocabularyTerms are NOT Taggable (with 'Tag')
  include Housekeeping
  include Shared::AlternateValues
  include Shared::HasPapertrail
  include Shared::IsData
  include SoftValidation

  acts_as_list scope: [:project_id, :type]

  ALTERNATE_VALUES_FOR = [:name, :definition].freeze

  validates_presence_of :name, :definition, :type
  validates_length_of :definition, minimum: 20

  validates_uniqueness_of :name, scope: [:type, :project_id]
  validates_uniqueness_of :definition, scope: [:project_id]

  validates_uniqueness_of :uri, scope: [:project_id, :uri_relation], allow_blank: true
  validates_presence_of :uri, unless: -> {uri_relation.blank?}, message: 'must be provided if uri_relation is provided'

  # TODO: DRY with Identifier::Global::Uri
  validate :form_of_uri
  validate :uri_relation_is_a_skos_relation

  has_many :observation_matrix_row_items, as: :observation_object, inverse_of: :observation_object,  class_name: 'ObservationMatrixRowItem::Dynamic::Tag', dependent: :destroy
  has_many :observation_matrix_column_items, inverse_of: :controlled_vocabulary_term, class_name: 'ObservationMatrixColumnItem::Dynamic::Tag', dependent: :destroy

  # TODO: this needs to come through columns rows
  has_many :observation_matrices, through: :observation_matrix_row_items

  scope :of_type, -> (type) { where(type: type.to_s.capitalize) } # TODO, capitalize is not the right method for things like `:foo_bar`

  protected

  def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
    return false if from_id.blank? or to_id.blank? or klass.blank?

    k = klass.safe_constantize
    k.where(project_id: from_id, type: klass).find_each do |cvt|
      begin
        i = cvt.dup
        i.project_id = to_id
        i.save!
      rescue ActiveRecord::RecordInvalid
      end
    end
    true
  end

  # def form_of_uri
  #   if uri.present?
  #     uris = URI.extract(uri)

  #     if uris.count == 0
  #       errors.add(:uri, 'More than a single URI present')
  #     else
  #       unless (uri.lenght == uris[0].length) && (uris.count == 1)
  #     end
  #   end
  # end

  def form_of_uri
    if uri.present?

      uris = URI.extract(uri)

      if uris.count == 0
        errors.add(:uri, 'URI provided by unparsable.')
      elsif uris.count > 1
        errors.add(:uri, 'More than a single URI present.')
      else
        begin
          u = URI(uri)
          scheme = u.scheme.upcase
          unless URI.scheme_list.keys.include?(scheme)
            errors.add(:uri, "#{scheme} is not in the URI schemes list.")
          end
        rescue
          errors.add(:uri, "Badly formed URI #{uri} detected.")
        end
      end
    end
  end

  # @return [Object]
  def uri_relation_is_a_skos_relation
    if uri.present? && uri_relation.present?
      errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
    end
  end

end

Class Method Details

.clone_from_project(from_id: nil, to_id: nil, klass: nil) ⇒ Object (protected)



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'app/models/controlled_vocabulary_term.rb', line 62

def self.clone_from_project(from_id: nil, to_id: nil, klass: nil)
  return false if from_id.blank? or to_id.blank? or klass.blank?

  k = klass.safe_constantize
  k.where(project_id: from_id, type: klass).find_each do |cvt|
    begin
      i = cvt.dup
      i.project_id = to_id
      i.save!
    rescue ActiveRecord::RecordInvalid
    end
  end
  true
end

Instance Method Details

#form_of_uriObject (protected)

if uris.count == 0

    errors.add(:uri, 'More than a single URI present')
  else
    unless (uri.lenght == uris[0].length) && (uris.count == 1)
  end
end

end



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'app/models/controlled_vocabulary_term.rb', line 89

def form_of_uri
  if uri.present?

    uris = URI.extract(uri)

    if uris.count == 0
      errors.add(:uri, 'URI provided by unparsable.')
    elsif uris.count > 1
      errors.add(:uri, 'More than a single URI present.')
    else
      begin
        u = URI(uri)
        scheme = u.scheme.upcase
        unless URI.scheme_list.keys.include?(scheme)
          errors.add(:uri, "#{scheme} is not in the URI schemes list.")
        end
      rescue
        errors.add(:uri, "Badly formed URI #{uri} detected.")
      end
    end
  end
end

#uri_relation_is_a_skos_relationObject (protected)

Returns:

  • (Object)


113
114
115
116
117
# File 'app/models/controlled_vocabulary_term.rb', line 113

def uri_relation_is_a_skos_relation
  if uri.present? && uri_relation.present?
    errors.add(:uri_relation, 'is not a valid uri relation') if !SKOS_RELATIONS.keys.include?(uri_relation)
  end
end