Class: Glossarist::Validation::Rules::PartitiveRelationRule

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/validation/rules/partitive_relation_rule.rb

Overview

Validates semantic invariants of PartitiveRelation entries that the model constructor does NOT enforce. Specifically:

- error when a relation has fewer than 2 partitives
(ISO 704: "two or more"; single binary should use
has_part edge instead)
- error when two relations share the same comprehensive
AND the same non-nil criterion (duplicate decomposition;
ISO 12620 coordinate-concept coherence)
- warning when a relation has no criterion (cannot
distinguish from siblings sharing the comprehensive)
- warning when multiplicity is not the default compulsory
(encourages explicit statement of optional/multiple)
- error when ExternalConcept (status: external) lacks
at least one designation

The model constructor already rejects empty comprehensive, empty partitives list, self-loops, invalid enum values.

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
33
34
35
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 30

def applicable?(context)
  concept = context.concept
  return false unless concept.is_a?(V3::ManagedConcept)

  concept.partitive_relations&.any? || external?(concept)
end

#categoryObject



26
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 26

def category = :schema

#check(context) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 37

def check(context)
  concept = context.concept
  fname = context.file_name
  issues = []

  return issues unless concept.is_a?(V3::ManagedConcept)

  relations = Array(concept.partitive_relations)

  relations.each_with_index do |rel, idx|
    check_cardinality(rel, idx, fname, issues)
    check_criterion_present(rel, idx, fname, issues)
    check_member_multiplicity(rel, idx, fname, issues)
  end

  check_duplicate_decomposition(relations, fname, issues)
  check_external_concept(concept, fname, issues)

  issues
end

#codeObject



25
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 25

def code = "GLS-221"

#scopeObject



28
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 28

def scope = :concept

#severityObject



27
# File 'lib/glossarist/validation/rules/partitive_relation_rule.rb', line 27

def severity = "error"