glossarist 2.6.5 → 2.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -4
- data/.rubocop_todo.yml +53 -2
- data/CLAUDE.md +27 -2
- data/README.adoc +532 -56
- data/config.yml +68 -1
- data/glossarist.gemspec +2 -0
- data/lib/glossarist/citation.rb +26 -123
- data/lib/glossarist/cli/compare_command.rb +106 -0
- data/lib/glossarist/cli/export_command.rb +11 -14
- data/lib/glossarist/cli/validate_command.rb +111 -20
- data/lib/glossarist/cli.rb +18 -0
- data/lib/glossarist/collections/bibliography_collection.rb +4 -2
- data/lib/glossarist/collections/localization_collection.rb +2 -0
- data/lib/glossarist/comparison_result.rb +35 -0
- data/lib/glossarist/concept.rb +1 -1
- data/lib/glossarist/concept_collector.rb +44 -0
- data/lib/glossarist/concept_comparator.rb +72 -0
- data/lib/glossarist/concept_data.rb +20 -0
- data/lib/glossarist/concept_diff.rb +15 -0
- data/lib/glossarist/concept_document.rb +11 -0
- data/lib/glossarist/concept_manager.rb +19 -5
- data/lib/glossarist/concept_ref.rb +13 -0
- data/lib/glossarist/concept_reference.rb +12 -19
- data/lib/glossarist/concept_validator.rb +6 -1
- data/lib/glossarist/context_configuration.rb +90 -0
- data/lib/glossarist/dataset_validator.rb +8 -4
- data/lib/glossarist/designation/abbreviation.rb +0 -2
- data/lib/glossarist/designation/base.rb +21 -1
- data/lib/glossarist/designation/expression.rb +3 -0
- data/lib/glossarist/designation/letter_symbol.rb +0 -4
- data/lib/glossarist/designation/prefix.rb +17 -0
- data/lib/glossarist/designation/suffix.rb +17 -0
- data/lib/glossarist/designation/symbol.rb +0 -2
- data/lib/glossarist/gcr_metadata.rb +7 -14
- data/lib/glossarist/gcr_package.rb +35 -23
- data/lib/glossarist/gcr_validator.rb +38 -17
- data/lib/glossarist/glossary_definition.rb +5 -0
- data/lib/glossarist/localized_concept.rb +8 -0
- data/lib/glossarist/managed_concept.rb +39 -6
- data/lib/glossarist/managed_concept_data.rb +22 -2
- data/lib/glossarist/non_verb_rep.rb +21 -6
- data/lib/glossarist/pronunciation.rb +32 -0
- data/lib/glossarist/rdf/ext/jsonld_transform_ext.rb +208 -0
- data/lib/glossarist/rdf/ext/mapping_ext.rb +37 -0
- data/lib/glossarist/rdf/ext/mapping_rule_ext.rb +27 -0
- data/lib/glossarist/rdf/ext/member_rule_ext.rb +34 -0
- data/lib/glossarist/rdf/ext/turtle_transform_ext.rb +222 -0
- data/lib/glossarist/rdf/ext.rb +39 -0
- data/lib/glossarist/rdf/gloss_citation.rb +36 -0
- data/lib/glossarist/rdf/gloss_concept.rb +58 -0
- data/lib/glossarist/rdf/gloss_concept_date.rb +24 -0
- data/lib/glossarist/rdf/gloss_concept_reference.rb +29 -0
- data/lib/glossarist/rdf/gloss_concept_source.rb +37 -0
- data/lib/glossarist/rdf/gloss_designation.rb +146 -0
- data/lib/glossarist/rdf/gloss_detailed_definition.rb +24 -0
- data/lib/glossarist/rdf/gloss_grammar_info.rb +57 -0
- data/lib/glossarist/rdf/gloss_locality.rb +25 -0
- data/lib/glossarist/rdf/gloss_localized_concept.rb +67 -0
- data/lib/glossarist/rdf/gloss_non_verbal_rep.rb +31 -0
- data/lib/glossarist/rdf/gloss_pronunciation.rb +32 -0
- data/lib/glossarist/rdf/gloss_reference.rb +55 -0
- data/lib/glossarist/rdf/namespaces/glossarist_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces/iso_thes_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces/owl_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces/prov_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces/rdf_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces/skosxl_namespace.rb +12 -0
- data/lib/glossarist/rdf/namespaces.rb +8 -2
- data/lib/glossarist/rdf/relationships.rb +19 -0
- data/lib/glossarist/rdf/v3/configuration.rb +15 -0
- data/lib/glossarist/rdf/v3.rb +79 -0
- data/lib/glossarist/rdf.rb +22 -2
- data/lib/glossarist/reference_extractor.rb +15 -24
- data/lib/glossarist/reference_resolver.rb +3 -3
- data/lib/glossarist/related_concept.rb +2 -10
- data/lib/glossarist/schema_migration.rb +39 -0
- data/lib/glossarist/sts/term_mapper.rb +2 -2
- data/lib/glossarist/transforms/concept_to_gloss_transform.rb +355 -0
- data/lib/glossarist/transforms.rb +2 -2
- data/lib/glossarist/urn_resolver.rb +13 -1
- data/lib/glossarist/v1/concept.rb +18 -11
- data/lib/glossarist/v2/citation.rb +36 -0
- data/lib/glossarist/v2/concept_data.rb +46 -0
- data/lib/glossarist/v2/concept_document.rb +18 -0
- data/lib/glossarist/v2/concept_ref.rb +8 -0
- data/lib/glossarist/v2/concept_source.rb +16 -0
- data/lib/glossarist/v2/configuration.rb +13 -0
- data/lib/glossarist/v2/detailed_definition.rb +14 -0
- data/lib/glossarist/v2/localized_concept.rb +9 -0
- data/lib/glossarist/v2/managed_concept.rb +25 -0
- data/lib/glossarist/v2/managed_concept_data.rb +49 -0
- data/lib/glossarist/v2/related_concept.rb +15 -0
- data/lib/glossarist/v2.rb +28 -0
- data/lib/glossarist/v3/bibliography_entry.rb +19 -0
- data/lib/glossarist/v3/bibliography_file.rb +27 -0
- data/lib/glossarist/v3/citation.rb +30 -0
- data/lib/glossarist/v3/concept_data.rb +46 -0
- data/lib/glossarist/v3/concept_document.rb +18 -0
- data/lib/glossarist/v3/concept_ref.rb +8 -0
- data/lib/glossarist/v3/concept_source.rb +16 -0
- data/lib/glossarist/v3/configuration.rb +13 -0
- data/lib/glossarist/v3/detailed_definition.rb +14 -0
- data/lib/glossarist/v3/image_entry.rb +21 -0
- data/lib/glossarist/v3/image_file.rb +31 -0
- data/lib/glossarist/v3/localized_concept.rb +9 -0
- data/lib/glossarist/v3/managed_concept.rb +26 -0
- data/lib/glossarist/v3/managed_concept_data.rb +34 -0
- data/lib/glossarist/v3/related_concept.rb +15 -0
- data/lib/glossarist/v3.rb +36 -0
- data/lib/glossarist/validation/asset_index.rb +4 -3
- data/lib/glossarist/validation/bibliography_index.rb +61 -30
- data/lib/glossarist/validation/rules/asciidoc_xref_rule.rb +2 -15
- data/lib/glossarist/validation/rules/authoritative_source_rule.rb +2 -15
- data/lib/glossarist/validation/rules/base.rb +5 -0
- data/lib/glossarist/validation/rules/bibliography_yaml_rule.rb +2 -3
- data/lib/glossarist/validation/rules/citation_completeness_rule.rb +5 -27
- data/lib/glossarist/validation/rules/dataset_context.rb +8 -3
- data/lib/glossarist/validation/rules/date_validity_rule.rb +1 -1
- data/lib/glossarist/validation/rules/designation_status_rule.rb +0 -1
- data/lib/glossarist/validation/rules/designation_type_rule.rb +1 -5
- data/lib/glossarist/validation/rules/domain_ref_rule.rb +37 -0
- data/lib/glossarist/validation/rules/domain_target_rule.rb +56 -0
- data/lib/glossarist/validation/rules/gcr_context.rb +12 -13
- data/lib/glossarist/validation/rules/image_reference_rule.rb +2 -17
- data/lib/glossarist/validation/rules/locality_completeness_rule.rb +58 -0
- data/lib/glossarist/validation/rules/localization_consistency_rule.rb +72 -0
- data/lib/glossarist/validation/rules/localization_presence_rule.rb +1 -1
- data/lib/glossarist/validation/rules/model_validity_rule.rb +71 -0
- data/lib/glossarist/validation/rules/orphaned_bibliography_rule.rb +1 -13
- data/lib/glossarist/validation/rules/orphaned_images_rule.rb +16 -11
- data/lib/glossarist/validation/rules/ref_shape_rule.rb +68 -0
- data/lib/glossarist/validation/rules/related_concept_cycle_rule.rb +1 -3
- data/lib/glossarist/validation/rules/related_concept_symmetry_rule.rb +1 -3
- data/lib/glossarist/validation/rules/related_concept_target_rule.rb +64 -0
- data/lib/glossarist/validation/rules/schema_version_rule.rb +41 -0
- data/lib/glossarist/validation/rules/source_type_rule.rb +1 -15
- data/lib/glossarist/validation/rules/source_urn_format_rule.rb +65 -0
- data/lib/glossarist/validation/rules/uuid_format_rule.rb +33 -0
- data/lib/glossarist/validation/rules.rb +10 -43
- data/lib/glossarist/validation/validation_issue.rb +14 -11
- data/lib/glossarist/validation_result.rb +12 -22
- data/lib/glossarist/version.rb +1 -1
- data/lib/glossarist.rb +10 -0
- data/memory/project-status.md +43 -0
- data/scripts/migrate_dataset.rb +180 -0
- data/scripts/migrate_isotc204_to_v3.rb +134 -0
- data/scripts/migrate_isotc211_to_v3.rb +153 -0
- data/scripts/migrate_osgeo_to_v3.rb +155 -0
- data/scripts/upgrade_dataset_to_v3.rb +47 -0
- metadata +112 -6
- data/TODO.integration/01-gcr-package-cli.md +0 -180
- data/lib/glossarist/rdf/skos_concept.rb +0 -43
- data/lib/glossarist/rdf/skos_vocabulary.rb +0 -25
- data/lib/glossarist/transforms/concept_to_skos_transform.rb +0 -131
|
@@ -42,22 +42,12 @@ module Glossarist
|
|
|
42
42
|
mc.add_localization(LocalizedConcept.of_yaml({ "data" => data }))
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
assign_domains(mc) if groups.is_a?(Array) && groups.any?
|
|
45
46
|
assign_references(mc) if references.is_a?(Array) && references.any?
|
|
46
47
|
|
|
47
48
|
mc
|
|
48
49
|
end
|
|
49
50
|
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
def assign_references(concept)
|
|
53
|
-
l10n = concept.localization("eng") || concept.localizations.values.first
|
|
54
|
-
return unless l10n
|
|
55
|
-
|
|
56
|
-
l10n.data.references = references.map do |r|
|
|
57
|
-
ConceptReference.new(r.transform_keys(&:to_sym))
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
51
|
def lang_blocks_from(model, value)
|
|
62
52
|
blocks = {}
|
|
63
53
|
value.each do |key, v|
|
|
@@ -76,6 +66,23 @@ module Glossarist
|
|
|
76
66
|
doc[lang] = data
|
|
77
67
|
end
|
|
78
68
|
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def assign_domains(concept)
|
|
73
|
+
concept.data.domains = groups.map do |g|
|
|
74
|
+
ConceptReference.new(concept_id: g.to_s, ref_type: "domain")
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def assign_references(concept)
|
|
79
|
+
l10n = concept.localization("eng") || concept.localizations.values.first
|
|
80
|
+
return unless l10n
|
|
81
|
+
|
|
82
|
+
l10n.data.references = references.map do |r|
|
|
83
|
+
ConceptReference.new(r.transform_keys(&:to_sym))
|
|
84
|
+
end
|
|
85
|
+
end
|
|
79
86
|
end
|
|
80
87
|
end
|
|
81
88
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class Citation < Glossarist::Citation
|
|
6
|
+
attribute :text, :string
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :ref, to: :text, with: { from: :ref_from_yaml, to: :ref_to_yaml }
|
|
10
|
+
map %i[clause locality],
|
|
11
|
+
to: :locality,
|
|
12
|
+
with: { from: :locality_from_yaml, to: :locality_to_yaml }
|
|
13
|
+
map :link, to: :link
|
|
14
|
+
map :original, to: :original
|
|
15
|
+
map %i[custom_locality customLocality], to: :custom_locality
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def label
|
|
19
|
+
text
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def ref_from_yaml(model, value)
|
|
23
|
+
model.text = case value
|
|
24
|
+
when Hash
|
|
25
|
+
value["source"] || value[:source]
|
|
26
|
+
when String
|
|
27
|
+
value
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def ref_to_yaml(model, doc)
|
|
32
|
+
doc["ref"] = model.text if model.text
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class ConceptData < Glossarist::ConceptData
|
|
6
|
+
attribute :sources, V2::ConceptSource,
|
|
7
|
+
collection: Collections::ConceptSourceCollection,
|
|
8
|
+
initialize_empty: true
|
|
9
|
+
attribute :definition, V2::DetailedDefinition,
|
|
10
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
11
|
+
initialize_empty: true
|
|
12
|
+
attribute :examples, V2::DetailedDefinition,
|
|
13
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
14
|
+
initialize_empty: true
|
|
15
|
+
attribute :notes, V2::DetailedDefinition,
|
|
16
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
17
|
+
initialize_empty: true
|
|
18
|
+
attribute :related, V2::RelatedConcept, collection: true
|
|
19
|
+
|
|
20
|
+
key_value do
|
|
21
|
+
map :dates, to: :dates
|
|
22
|
+
map :definition, to: :definition, value_map: { to: { empty: :empty } }
|
|
23
|
+
map :examples, to: :examples, value_map: { to: { empty: :empty } }
|
|
24
|
+
map :id, to: :id
|
|
25
|
+
map %i[lineage_source_similarity lineageSourceSimilarity],
|
|
26
|
+
to: :lineage_source_similarity
|
|
27
|
+
map :notes, to: :notes, value_map: { to: { empty: :empty } }
|
|
28
|
+
map :release, to: :release
|
|
29
|
+
map :sources, to: :sources
|
|
30
|
+
map :terms, to: :terms,
|
|
31
|
+
with: { from: :terms_from_yaml, to: :terms_to_yaml }
|
|
32
|
+
map :related, to: :related
|
|
33
|
+
map :references, to: :references
|
|
34
|
+
map :domain, to: :domain
|
|
35
|
+
map %i[language_code languageCode], to: :language_code
|
|
36
|
+
map :script, to: :script
|
|
37
|
+
map :system, to: :system
|
|
38
|
+
map %i[entry_status entryStatus], to: :entry_status
|
|
39
|
+
map %i[review_date reviewDate], to: :review_date
|
|
40
|
+
map %i[review_decision_date reviewDecisionDate], to: :review_decision_date
|
|
41
|
+
map %i[review_decision_event reviewDecisionEvent],
|
|
42
|
+
to: :review_decision_event
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class ConceptDocument < Glossarist::ConceptDocument
|
|
6
|
+
attribute :concept, V2::ManagedConcept
|
|
7
|
+
attribute :localizations, V2::LocalizedConcept, collection: true
|
|
8
|
+
|
|
9
|
+
yamls do
|
|
10
|
+
sequence do
|
|
11
|
+
map_document 0, to: :concept, type: V2::ManagedConcept
|
|
12
|
+
map_document 1.., to: :localizations, type: V2::LocalizedConcept,
|
|
13
|
+
collection: true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class ConceptSource < Glossarist::ConceptSource
|
|
6
|
+
attribute :origin, V2::Citation
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :origin, to: :origin
|
|
10
|
+
map :status, to: :status
|
|
11
|
+
map :type, to: :type
|
|
12
|
+
map :modification, to: :modification
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class DetailedDefinition < Glossarist::DetailedDefinition
|
|
6
|
+
attribute :sources, V2::ConceptSource, collection: true
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :content, to: :content
|
|
10
|
+
map :sources, to: :sources
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class ManagedConcept < Glossarist::ManagedConcept
|
|
6
|
+
attribute :data, V2::ManagedConceptData, default: -> { V2::ManagedConceptData.new }
|
|
7
|
+
attribute :related, V2::RelatedConcept, collection: true
|
|
8
|
+
attribute :sources, V2::ConceptSource, collection: true
|
|
9
|
+
|
|
10
|
+
key_value do
|
|
11
|
+
map :data, to: :data
|
|
12
|
+
map :id, with: { to: :identifier_to_yaml, from: :identifier_from_yaml }
|
|
13
|
+
map :identifier,
|
|
14
|
+
with: { to: :identifier_to_yaml, from: :identifier_from_yaml }
|
|
15
|
+
map :related, to: :related
|
|
16
|
+
map :dates, to: :dates
|
|
17
|
+
map %i[date_accepted dateAccepted],
|
|
18
|
+
with: { from: :date_accepted_from_yaml, to: :date_accepted_to_yaml }
|
|
19
|
+
map :status, to: :status
|
|
20
|
+
map :uuid, to: :uuid, with: { from: :uuid_from_yaml, to: :uuid_to_yaml }
|
|
21
|
+
map :sources, to: :sources
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class ManagedConceptData < Glossarist::ManagedConceptData
|
|
6
|
+
attribute :sources, V2::ConceptSource, collection: true
|
|
7
|
+
attribute :localizations, V2::LocalizedConcept,
|
|
8
|
+
collection: Collections::LocalizationCollection,
|
|
9
|
+
initialize_empty: true
|
|
10
|
+
attribute :related, V2::RelatedConcept, collection: true
|
|
11
|
+
|
|
12
|
+
key_value do
|
|
13
|
+
map %i[id identifier], to: :id,
|
|
14
|
+
with: { to: :id_to_yaml, from: :id_from_yaml }
|
|
15
|
+
map :uri, to: :uri
|
|
16
|
+
map %i[localized_concepts localizedConcepts], to: :localized_concepts
|
|
17
|
+
map %i[domains groups], to: :domains,
|
|
18
|
+
with: { from: :domains_from_yaml, to: :domains_to_yaml }
|
|
19
|
+
map :sources, to: :sources
|
|
20
|
+
map :localizations, to: :localizations,
|
|
21
|
+
with: { from: :localizations_from_yaml, to: :localizations_to_yaml }
|
|
22
|
+
map :related, to: :related,
|
|
23
|
+
with: { from: :related_from_yaml, to: :related_to_yaml }
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def localizations_from_yaml(model, value)
|
|
27
|
+
value.each do |localized_concept_hash|
|
|
28
|
+
localized_concept = V2::LocalizedConcept.of_yaml(localized_concept_hash)
|
|
29
|
+
model.localizations.store(localized_concept.language_code,
|
|
30
|
+
localized_concept)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def localizations_to_yaml(model, doc); end
|
|
35
|
+
|
|
36
|
+
def related_from_yaml(model, value)
|
|
37
|
+
return unless value.is_a?(Array)
|
|
38
|
+
|
|
39
|
+
model.related = value.map { |r| V2::RelatedConcept.of_yaml(r) }
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def related_to_yaml(model, doc)
|
|
43
|
+
return unless model.related&.any?
|
|
44
|
+
|
|
45
|
+
doc["related"] = model.related.map(&:to_hash)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V2
|
|
5
|
+
class RelatedConcept < Glossarist::RelatedConcept
|
|
6
|
+
attribute :ref, V2::ConceptRef
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :content, to: :content
|
|
10
|
+
map :type, to: :type
|
|
11
|
+
map :ref, to: :ref
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "v2/configuration"
|
|
4
|
+
require_relative "v2/citation"
|
|
5
|
+
require_relative "v2/concept_source"
|
|
6
|
+
require_relative "v2/detailed_definition"
|
|
7
|
+
require_relative "v2/concept_ref"
|
|
8
|
+
require_relative "v2/related_concept"
|
|
9
|
+
require_relative "v2/concept_data"
|
|
10
|
+
require_relative "v2/localized_concept"
|
|
11
|
+
require_relative "v2/managed_concept_data"
|
|
12
|
+
require_relative "v2/managed_concept"
|
|
13
|
+
require_relative "v2/concept_document"
|
|
14
|
+
|
|
15
|
+
module Glossarist
|
|
16
|
+
module V2
|
|
17
|
+
Configuration.register_model(Citation, id: :citation)
|
|
18
|
+
Configuration.register_model(ConceptSource, id: :concept_source)
|
|
19
|
+
Configuration.register_model(DetailedDefinition, id: :detailed_definition)
|
|
20
|
+
Configuration.register_model(ConceptData, id: :concept_data)
|
|
21
|
+
Configuration.register_model(LocalizedConcept, id: :localized_concept)
|
|
22
|
+
Configuration.register_model(ConceptRef, id: :concept_ref)
|
|
23
|
+
Configuration.register_model(RelatedConcept, id: :related_concept)
|
|
24
|
+
Configuration.register_model(ManagedConceptData, id: :managed_concept_data)
|
|
25
|
+
Configuration.register_model(ManagedConcept, id: :managed_concept)
|
|
26
|
+
Configuration.register_model(ConceptDocument, id: :concept_document)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class BibliographyEntry < Lutaml::Model::Serializable
|
|
6
|
+
attribute :id, :string
|
|
7
|
+
attribute :reference, :string
|
|
8
|
+
attribute :title, :string
|
|
9
|
+
attribute :link, :string
|
|
10
|
+
|
|
11
|
+
key_value do
|
|
12
|
+
map :id, to: :id
|
|
13
|
+
map :reference, to: :reference
|
|
14
|
+
map :title, to: :title
|
|
15
|
+
map :link, to: :link
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class BibliographyFile < Lutaml::Model::Collection
|
|
6
|
+
instances :entries, BibliographyEntry
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map_instances to: :entries
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.from_file(path)
|
|
13
|
+
return nil unless File.exist?(path)
|
|
14
|
+
|
|
15
|
+
from_yaml(File.read(path))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def resolve?(anchor)
|
|
19
|
+
entries.any? { |e| e.id == anchor.to_s }
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def [](key)
|
|
23
|
+
entries.find { |e| e.id == key.to_s }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class Citation < Glossarist::Citation
|
|
6
|
+
key_value do
|
|
7
|
+
map :ref, to: :ref, with: { from: :ref_from_yaml, to: :ref_to_yaml }
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def ref_from_yaml(model, value)
|
|
11
|
+
case value
|
|
12
|
+
when Hash
|
|
13
|
+
model.ref = Ref.new(value.transform_keys(&:to_sym))
|
|
14
|
+
when String
|
|
15
|
+
model.ref = Ref.new(source: value)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def ref_to_yaml(model, doc)
|
|
20
|
+
return unless model.ref
|
|
21
|
+
|
|
22
|
+
attrs = {}
|
|
23
|
+
attrs["source"] = model.ref.source if model.ref.source
|
|
24
|
+
attrs["id"] = model.ref.id if model.ref.id
|
|
25
|
+
attrs["version"] = model.ref.version if model.ref.version
|
|
26
|
+
doc["ref"] = attrs.empty? ? nil : attrs
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ConceptData < Glossarist::ConceptData
|
|
6
|
+
attribute :sources, V3::ConceptSource,
|
|
7
|
+
collection: Collections::ConceptSourceCollection,
|
|
8
|
+
initialize_empty: true
|
|
9
|
+
attribute :definition, V3::DetailedDefinition,
|
|
10
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
11
|
+
initialize_empty: true
|
|
12
|
+
attribute :examples, V3::DetailedDefinition,
|
|
13
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
14
|
+
initialize_empty: true
|
|
15
|
+
attribute :notes, V3::DetailedDefinition,
|
|
16
|
+
collection: Collections::DetailedDefinitionCollection,
|
|
17
|
+
initialize_empty: true
|
|
18
|
+
attribute :related, V3::RelatedConcept, collection: true
|
|
19
|
+
|
|
20
|
+
key_value do
|
|
21
|
+
map :dates, to: :dates
|
|
22
|
+
map :definition, to: :definition
|
|
23
|
+
map :examples, to: :examples
|
|
24
|
+
map :id, to: :id
|
|
25
|
+
map %i[lineage_source_similarity lineageSourceSimilarity],
|
|
26
|
+
to: :lineage_source_similarity
|
|
27
|
+
map :notes, to: :notes
|
|
28
|
+
map :release, to: :release
|
|
29
|
+
map :sources, to: :sources
|
|
30
|
+
map :terms, to: :terms,
|
|
31
|
+
with: { from: :terms_from_yaml, to: :terms_to_yaml }
|
|
32
|
+
map :related, to: :related
|
|
33
|
+
map :references, to: :references
|
|
34
|
+
map :domain, to: :domain
|
|
35
|
+
map %i[language_code languageCode], to: :language_code
|
|
36
|
+
map :script, to: :script
|
|
37
|
+
map :system, to: :system
|
|
38
|
+
map %i[entry_status entryStatus], to: :entry_status
|
|
39
|
+
map %i[review_date reviewDate], to: :review_date
|
|
40
|
+
map %i[review_decision_date reviewDecisionDate], to: :review_decision_date
|
|
41
|
+
map %i[review_decision_event reviewDecisionEvent],
|
|
42
|
+
to: :review_decision_event
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ConceptDocument < Glossarist::ConceptDocument
|
|
6
|
+
attribute :concept, V3::ManagedConcept
|
|
7
|
+
attribute :localizations, V3::LocalizedConcept, collection: true
|
|
8
|
+
|
|
9
|
+
yamls do
|
|
10
|
+
sequence do
|
|
11
|
+
map_document 0, to: :concept, type: V3::ManagedConcept
|
|
12
|
+
map_document 1.., to: :localizations, type: V3::LocalizedConcept,
|
|
13
|
+
collection: true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ConceptSource < Glossarist::ConceptSource
|
|
6
|
+
attribute :origin, V3::Citation
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :origin, to: :origin
|
|
10
|
+
map :status, to: :status
|
|
11
|
+
map :type, to: :type
|
|
12
|
+
map :modification, to: :modification
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class DetailedDefinition < Glossarist::DetailedDefinition
|
|
6
|
+
attribute :sources, V3::ConceptSource, collection: true
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map :content, to: :content
|
|
10
|
+
map :sources, to: :sources
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ImageEntry < Lutaml::Model::Serializable
|
|
6
|
+
attribute :id, :string
|
|
7
|
+
attribute :path, :string
|
|
8
|
+
attribute :type, :string, default: -> { "image" }
|
|
9
|
+
attribute :title, :string
|
|
10
|
+
attribute :alt, :string
|
|
11
|
+
|
|
12
|
+
key_value do
|
|
13
|
+
map :id, to: :id
|
|
14
|
+
map :path, to: :path
|
|
15
|
+
map :type, to: :type
|
|
16
|
+
map :title, to: :title
|
|
17
|
+
map :alt, to: :alt
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ImageFile < Lutaml::Model::Collection
|
|
6
|
+
instances :entries, ImageEntry
|
|
7
|
+
|
|
8
|
+
key_value do
|
|
9
|
+
map_instances to: :entries
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.from_file(path)
|
|
13
|
+
return nil unless File.exist?(path)
|
|
14
|
+
|
|
15
|
+
from_yaml(File.read(path))
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def path_for_anchor(anchor)
|
|
19
|
+
entries.find { |e| e.id == anchor.to_s }&.path
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def anchor_for_path(path)
|
|
23
|
+
entries.find { |e| e.path == path }&.id
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def path?(path)
|
|
27
|
+
entries.any? { |e| e.path == path }
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ManagedConcept < Glossarist::ManagedConcept
|
|
6
|
+
attribute :data, V3::ManagedConceptData, default: -> { V3::ManagedConceptData.new }
|
|
7
|
+
attribute :related, V3::RelatedConcept, collection: true
|
|
8
|
+
attribute :sources, V3::ConceptSource, collection: true
|
|
9
|
+
|
|
10
|
+
key_value do
|
|
11
|
+
map :data, to: :data
|
|
12
|
+
map :id, with: { to: :identifier_to_yaml, from: :identifier_from_yaml }
|
|
13
|
+
map :identifier,
|
|
14
|
+
with: { to: :identifier_to_yaml, from: :identifier_from_yaml }
|
|
15
|
+
map :related, to: :related
|
|
16
|
+
map :dates, to: :dates
|
|
17
|
+
map %i[date_accepted dateAccepted],
|
|
18
|
+
with: { from: :date_accepted_from_yaml, to: :date_accepted_to_yaml }
|
|
19
|
+
map :status, to: :status
|
|
20
|
+
map :uuid, to: :uuid, with: { from: :uuid_from_yaml, to: :uuid_to_yaml }
|
|
21
|
+
map :schema_version, to: :schema_version
|
|
22
|
+
map :sources, to: :sources
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module V3
|
|
5
|
+
class ManagedConceptData < Glossarist::ManagedConceptData
|
|
6
|
+
attribute :sources, V3::ConceptSource, collection: true
|
|
7
|
+
attribute :localizations, V3::LocalizedConcept,
|
|
8
|
+
collection: Collections::LocalizationCollection,
|
|
9
|
+
initialize_empty: true
|
|
10
|
+
|
|
11
|
+
key_value do
|
|
12
|
+
map %i[id identifier], to: :id,
|
|
13
|
+
with: { to: :id_to_yaml, from: :id_from_yaml }
|
|
14
|
+
map :uri, to: :uri
|
|
15
|
+
map %i[localized_concepts localizedConcepts], to: :localized_concepts
|
|
16
|
+
map %i[domains groups], to: :domains,
|
|
17
|
+
with: { from: :domains_from_yaml, to: :domains_to_yaml }
|
|
18
|
+
map :sources, to: :sources
|
|
19
|
+
map :localizations, to: :localizations,
|
|
20
|
+
with: { from: :localizations_from_yaml, to: :localizations_to_yaml }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def localizations_from_yaml(model, value)
|
|
24
|
+
value.each do |localized_concept_hash|
|
|
25
|
+
localized_concept = V3::LocalizedConcept.of_yaml(localized_concept_hash)
|
|
26
|
+
model.localizations.store(localized_concept.language_code,
|
|
27
|
+
localized_concept)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def localizations_to_yaml(model, doc); end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|