relaton-iso 1.20.0 → 2.0.0.pre.alpha.1

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.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile +1 -0
  4. data/README.adoc +134 -130
  5. data/bin/console +1 -1
  6. data/grammars/basicdoc.rng +2110 -0
  7. data/grammars/biblio-standoc.rng +287 -0
  8. data/grammars/biblio.rng +2097 -0
  9. data/grammars/relaton-iso-compile.rng +11 -0
  10. data/grammars/relaton-iso.rng +214 -0
  11. data/lib/relaton/iso/bibliography.rb +206 -0
  12. data/lib/relaton/iso/data_fetcher.rb +227 -0
  13. data/lib/relaton/iso/hash_parser_v1.rb +121 -0
  14. data/lib/relaton/iso/hit.rb +62 -0
  15. data/lib/relaton/iso/hit_collection.rb +117 -0
  16. data/lib/relaton/iso/item_data.rb +49 -0
  17. data/lib/relaton/iso/model/bibdata.rb +9 -0
  18. data/lib/relaton/iso/model/bibitem.rb +7 -0
  19. data/lib/relaton/iso/model/contributor.rb +7 -0
  20. data/lib/relaton/iso/model/contributor_info.rb +9 -0
  21. data/lib/relaton/iso/model/docidentifier.rb +128 -0
  22. data/lib/relaton/iso/model/doctype.rb +13 -0
  23. data/lib/relaton/iso/model/ext.rb +47 -0
  24. data/lib/relaton/iso/model/iso_project_group.rb +21 -0
  25. data/lib/relaton/iso/model/item.rb +17 -0
  26. data/lib/relaton/iso/model/item_base.rb +19 -0
  27. data/lib/relaton/iso/model/organization.rb +9 -0
  28. data/lib/relaton/iso/model/project_number.rb +22 -0
  29. data/lib/relaton/iso/model/relation.rb +9 -0
  30. data/lib/relaton/iso/model/stagename.rb +14 -0
  31. data/lib/relaton/iso/model/structured_identifier.rb +31 -0
  32. data/lib/relaton/iso/processor.rb +78 -0
  33. data/lib/relaton/iso/queue.rb +63 -0
  34. data/lib/relaton/iso/scraper.rb +591 -0
  35. data/lib/relaton/iso/util.rb +8 -0
  36. data/lib/relaton/iso/version.rb +7 -0
  37. data/lib/relaton/iso.rb +17 -0
  38. data/relaton_iso.gemspec +9 -7
  39. metadata +76 -46
  40. data/bin/bundle +0 -109
  41. data/bin/byebug +0 -27
  42. data/bin/coderay +0 -27
  43. data/bin/gdb_wrapper +0 -29
  44. data/bin/htmldiff +0 -27
  45. data/bin/httpclient +0 -29
  46. data/bin/ldiff +0 -27
  47. data/bin/nokogiri +0 -27
  48. data/bin/pry +0 -27
  49. data/bin/pubid-nist +0 -27
  50. data/bin/racc +0 -27
  51. data/bin/rackup +0 -29
  52. data/bin/rake +0 -27
  53. data/bin/rubocop +0 -27
  54. data/bin/ruby-parse +0 -27
  55. data/bin/ruby-rewrite +0 -27
  56. data/bin/safe_yaml +0 -29
  57. data/bin/thor +0 -27
  58. data/lib/relaton_iso/data_fetcher.rb +0 -246
  59. data/lib/relaton_iso/document_identifier.rb +0 -46
  60. data/lib/relaton_iso/hash_converter.rb +0 -15
  61. data/lib/relaton_iso/hit.rb +0 -59
  62. data/lib/relaton_iso/hit_collection.rb +0 -100
  63. data/lib/relaton_iso/iso_bibliography.rb +0 -202
  64. data/lib/relaton_iso/processor.rb +0 -67
  65. data/lib/relaton_iso/queue.rb +0 -61
  66. data/lib/relaton_iso/scrapper.rb +0 -553
  67. data/lib/relaton_iso/util.rb +0 -6
  68. data/lib/relaton_iso/version.rb +0 -5
  69. data/lib/relaton_iso.rb +0 -17
@@ -0,0 +1,121 @@
1
+ require "relaton/bib/hash_parser_v1"
2
+ require_relative "../iso"
3
+
4
+ module Relaton
5
+ module Iso
6
+ #
7
+ # This module is used to parse hash data from Relaton YAML version 1 files.
8
+ # It needs for trasition form Relaton v! to Relaton v2.
9
+ #
10
+ module HashParserV1
11
+ include Bib::HashParserV1
12
+ extend self
13
+
14
+ private
15
+
16
+ def ext_hash_to_bib(ret) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
17
+ ret[:ext] ||= {}
18
+ ret[:ext][:schema_version] = ret[:ext].delete(:"schema-version")
19
+ doctype_hash_to_bib ret
20
+ ret[:ext][:subdoctype] = ret.delete(:subdoctype) if ret[:subdoctype]
21
+ ret[:ext][:flavor] ||= flavor(ret)
22
+ ret[:ext][:horizontal] = ret.delete(:horizontal) unless ret[:horizontal].nil?
23
+ editorialgroup_hash_to_bib ret
24
+ approvalgroup_hash_to_bib ret
25
+ ics_hash_to_bib ret
26
+ structuredidentifier_hash_to_bib ret
27
+ stagename_hash_to_bib ret
28
+ ret[:ext][:fast_track] = ret.delete(:fast_track) unless ret[:fast_track].nil?
29
+ ret[:ext][:price_code] = ret.delete(:price_code) if ret[:price_code]
30
+ ret[:ext] = Ext.new(**ret[:ext]) if ret[:ext]
31
+ end
32
+
33
+ def create_docid(**args)
34
+ Docidentifier.new(**args)
35
+ end
36
+
37
+ #
38
+ # Ovverides superclass's method
39
+ #
40
+ # @param item [Hash]
41
+ # @retirn [RelatonIsoBib::IsoBibliographicItem]
42
+ def bib_item(item)
43
+ ItemData.new(**item)
44
+ end
45
+
46
+ #
47
+ # Ovverides superclass's method
48
+ #
49
+ # @param title [Hash]
50
+ # @return [RelatonBib::TypedTitleString]
51
+ def typed_title_strig(title)
52
+ Relaton::Bib::Title.new(**title)
53
+ end
54
+
55
+ # @param ret [Hash]
56
+ def editorialgroup_hash_to_bib(ret)
57
+ eg = ret.dig(:ext, :editorialgroup) || ret[:editorialgroup]
58
+ return unless eg
59
+
60
+ ret[:ext][:editorialgroup] = create_iso_project_group(eg)
61
+ end
62
+
63
+ def approvalgroup_hash_to_bib(ret)
64
+ ag = ret.dig(:ext, :approvalgroup) || ret[:approvalgroup]
65
+ return unless ag
66
+
67
+ ret[:ext][:approvalgroup] = create_iso_project_group(ag)
68
+ end
69
+
70
+ def create_iso_project_group(args)
71
+ args[:technical_committee] = workgroup_hash_to_bib args[:technical_committee]
72
+ args[:subcommittee] = workgroup_hash_to_bib args[:subcommittee]
73
+ args[:workgroup] = workgroup_hash_to_bib args[:workgroup]
74
+ ISOProjectGroup.new(**args)
75
+ end
76
+
77
+ # @param ret [Hash]
78
+ def structuredidentifier_hash_to_bib(ret)
79
+ struct_id = ret.dig(:ext, :structuredidentifier) || ret[:structuredidentifier]
80
+ return unless struct_id
81
+
82
+ struct_id[:project_number] = project_number_hash_to_bib(struct_id)
83
+ ret[:ext][:structuredidentifier] = StructuredIdentifier.new(**struct_id)
84
+ end
85
+
86
+ def project_number_hash_to_bib(struct_id)
87
+ ProjectNumber.new(
88
+ part: struct_id.delete(:part),
89
+ subpart: struct_id.delete(:subpart),
90
+ amendment: struct_id.delete(:amendment),
91
+ corrigendum: struct_id.delete(:corrigendum),
92
+ origyr: struct_id.delete(:origyr),
93
+ content: struct_id.delete(:project_number),
94
+ )
95
+ end
96
+
97
+ def stagename_hash_to_bib(ret)
98
+ stagename = ret.dig(:ext, :stagename) || ret[:stagename]
99
+ return unless stagename
100
+
101
+ ret[:ext][:stagename] = Stagename.new(**stagename_args(stagename))
102
+ end
103
+
104
+ def stagename_args(stagename)
105
+ if stagename.is_a? Hash
106
+ stagename
107
+ else
108
+ { content: stagename }
109
+ end
110
+ end
111
+
112
+ def create_doctype(args)
113
+ Doctype.new(**args)
114
+ end
115
+
116
+ def create_relation(rel)
117
+ Relation.new(**rel)
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Relaton
4
+ module Iso
5
+ # Hit.
6
+ class Hit < Relaton::Core::Hit
7
+ # @return [RelatonIsoBib::IsoBibliographicItem]
8
+ attr_writer :item
9
+
10
+ # @return [Pubid::Iso::Identifier] pubid
11
+ attr_writer :pubid
12
+
13
+ # Update edition for pubid when provided in Bibliographic Item
14
+ # def update_edition(bibliographic_item)
15
+ # if bibliographic_item.edition
16
+ # pubid.root.edition = bibliographic_item.edition.content
17
+ # end
18
+ # end
19
+
20
+ # Parse page.
21
+ # @return [Relaton::Iso::ItemData]
22
+ def item
23
+ @item ||= begin
24
+ url = "#{HitCollection::ENDPOINT}#{hit[:file]}"
25
+ resp = Net::HTTP.get_response URI(url)
26
+ Item.from_yaml resp.body
27
+ end
28
+ end
29
+
30
+ # @return [Integer]
31
+ def sort_weight
32
+ case hit[:status] # && hit["publicationStatus"]["key"]
33
+ when "Published" then 0
34
+ when "Under development" then 1
35
+ when "Withdrawn" then 2
36
+ when "Deleted" then 3
37
+ else 4
38
+ end
39
+ end
40
+
41
+ # @return [Pubid::Iso::Identifier]
42
+ def pubid
43
+ return @pubid if defined? @pubid
44
+
45
+ @pubid = create_pubid hit[:id]
46
+ rescue StandardError
47
+ Util.warn "Unable to create an identifier from #{hit[:id]}"
48
+ @pubid = nil
49
+ end
50
+
51
+ private
52
+
53
+ def create_pubid(id)
54
+ if id.is_a?(Hash)
55
+ ::Pubid::Iso::Identifier.create(**id)
56
+ else
57
+ id
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "hit"
4
+
5
+ module Relaton
6
+ module Iso
7
+ # Page of hit collection.
8
+ class HitCollection < Relaton::Core::HitCollection
9
+ INDEXFILE = "index-v1"
10
+ ENDPOINT = "https://raw.githubusercontent.com/relaton/relaton-data-iso/data-v2/"
11
+
12
+ def opts
13
+ @opts ||= {}
14
+ end
15
+
16
+ def ref_pubid_no_year
17
+ @ref_pubid_no_year ||= ref.base ? ref.dup.tap { |r| r.base = r.base.exclude(:year) } : ref.exclude(:year)
18
+ end
19
+
20
+ def ref_pubid_excluded
21
+ return @ref_pubid_excluded if defined? @ref_pubid_excluded
22
+
23
+ ref_excludings = excludings.dup
24
+ ref_excludings << :all_parts
25
+ @ref_pubid_excluded ||= ref_pubid_no_year.exclude(*ref_excludings)
26
+ end
27
+
28
+ #
29
+ # Find all the entries that match the given reference.
30
+ #
31
+ # @return [Array<Relaton::Iso::Hit>] hits
32
+ #
33
+ def find # rubocop:disable Metrics/AbcSize
34
+ @array = index.search do |row|
35
+ row[:id].is_a?(Hash) ? pubid_match?(row[:id]) : ref.to_s(with_prf: true) == row[:id]
36
+ end.map { |row| Hit.new row, self }
37
+ .sort_by! { |h| h.pubid.to_s }
38
+ .reverse!
39
+ self
40
+ end
41
+
42
+ def pubid_match?(id)
43
+ pubid = create_pubid(id)
44
+ return false unless pubid
45
+
46
+ # pubid.base = pubid.base.exclude(:year, :edition) if pubid.base
47
+ dir_excludings = excludings.dup
48
+ dir_excludings << :edition unless pubid.typed_stage_abbrev == "DIR"
49
+ exclude_id_attrs(pubid, *dir_excludings) == ref_pubid_excluded
50
+ end
51
+
52
+ def create_pubid(id)
53
+ ::Pubid::Iso::Identifier.create(**id)
54
+ rescue StandardError => e
55
+ Util.warn e.message, key: ref.to_s
56
+ end
57
+
58
+ def exclude_id_attrs(pubid, *attrs)
59
+ xid = pubid.exclude(*attrs)
60
+ curr = xid
61
+ while curr.base
62
+ curr.base = curr.base.exclude(*attrs)
63
+ curr = curr.base
64
+ end
65
+ xid
66
+ end
67
+
68
+ def excludings # rubocop:disable Metrics/AbcSize
69
+ return @excludings if defined? @excludings
70
+
71
+ excl_attrs = %i[year]
72
+ excl_attrs << :part if ref.root.part.nil? || ref.root.all_parts
73
+ if ref.stage.nil? || ref.root.all_parts
74
+ excl_attrs << :stage
75
+ excl_attrs << :iteration
76
+ end
77
+ # excl_parts << :edition if ref.root.edition.nil? || all_parts
78
+ @escludings = excl_attrs
79
+ end
80
+
81
+ def index
82
+ @index ||= Relaton::Index.find_or_create :iso, url: "#{ENDPOINT}#{INDEXFILE}.zip", file: "#{INDEXFILE}.yaml"
83
+ end
84
+
85
+ def fetch_doc(options = {})
86
+ @excludeingds = nil if options != opts
87
+ @opts = options
88
+
89
+ if !ref.root.all_parts || size == 1
90
+ any? && first.item # (opts[:lang])
91
+ else
92
+ to_all_parts
93
+ end
94
+ end
95
+
96
+ # @return [RelatonIsoBib::IsoBibliographicItem, nil]
97
+ def to_all_parts # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
98
+ hit = @array.select { |h| h.pubid.part }.min_by { |h| h.pubid.part.to_i }
99
+ return @array.first&.item unless hit
100
+
101
+ bibitem = hit.item
102
+ all_parts_item = bibitem.to_all_parts
103
+ @array.reject { |h| h.pubid.part == hit.pubid.part }.each do |hi|
104
+ all_parts_item.relation << create_relation(hi)
105
+ end
106
+ all_parts_item
107
+ end
108
+
109
+ def create_relation(hit)
110
+ # pubid = Pubid.new hit.pubid
111
+ docid = Docidentifier.new(content: hit.pubid, type: "ISO", primary: true)
112
+ isobib = ItemData.new(formattedref: hit.pubid.to_s, docidentifier: [docid])
113
+ Relation.new(type: "instanceOf", bibitem: isobib)
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,49 @@
1
+ module Relaton
2
+ module Iso
3
+ class ItemData < Bib::ItemData
4
+ def deep_clone
5
+ Item.from_yaml Item.to_yaml(self)
6
+ end
7
+
8
+ def create_id(without_date: false)
9
+ docid = docidentifier.find(&:primary) || docidentifier.first
10
+ return unless docid
11
+
12
+ pubid = without_date ? docid.content.exclude(:year) : docid.content
13
+ self.id = pubid.to_s(with_prf: true).gsub(/\W+/, "")
14
+ end
15
+
16
+ def create_relation(**args)
17
+ Relation.new(**args)
18
+ end
19
+
20
+ def to_xml(bibdata: false, **opts)
21
+ add_notes opts[:note] do
22
+ bibdata ? Bibdata.to_xml(self) : Bibitem.to_xml(self)
23
+ end
24
+ end
25
+
26
+ def to_yaml(**opts)
27
+ add_notes opts[:note] do
28
+ Item.to_yaml(self)
29
+ end
30
+ end
31
+
32
+ def to_json(**opts)
33
+ add_notes opts[:note] do
34
+ Item.to_json(self)
35
+ end
36
+ end
37
+
38
+ # private
39
+
40
+ # def add_notes(notes)
41
+ # self.note ||= []
42
+ # Relaton.array(notes).each { |nt| note << Bib::Note.new(**nt) }
43
+ # result = yield
44
+ # Relaton.array(notes).each { note.pop }
45
+ # result
46
+ # end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ require_relative "ext"
2
+
3
+ module Relaton
4
+ module Iso
5
+ class Bibdata < Item
6
+ include Bib::BibdataShared
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Relaton
2
+ module Iso
3
+ class Bibitem < Item
4
+ include Bib::BibitemShared
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ module Relaton
2
+ module Iso
3
+ class Contributor < Bib::Contributor
4
+ # attributes[:organization].type = :boolean
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ module Relaton
2
+ module Iso
3
+ class ContributorInfo < Lutaml::Model::Serializable
4
+ choice do
5
+ attribute :person, Bib::Person
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,128 @@
1
+ module Relaton
2
+ module Iso
3
+ class Pubid < Lutaml::Model::Type::Value
4
+ module Renderer
5
+ end
6
+
7
+ class << self
8
+ def cast(value)
9
+ value.is_a?(String) ? ::Pubid::Iso::Identifier.parse(value) : value
10
+ rescue StandardError
11
+ Util.warn "Failed to parse Pubid: #{value}"
12
+ value
13
+ end
14
+ end
15
+
16
+ ::Lutaml::Model::Config::AVAILABLE_FORMATS.each do |format|
17
+ define_method(:"to_#{format}") { value.to_s with_prf: true }
18
+ end
19
+
20
+ def to_h = value.to_h
21
+ def urn = value.urn
22
+ end
23
+
24
+ class Docidentifier < Bib::Docidentifier
25
+ include Pubid::Renderer
26
+
27
+ attribute :content, Pubid
28
+
29
+ def content_to_xml(model, parent, doc)
30
+ doc.add_xml_fragment parent, model.to_s
31
+ end
32
+
33
+ def content_to_key_value(model, doc)
34
+ doc["content"] = model.to_s
35
+ end
36
+
37
+ def to_all_parts!
38
+ if content.is_a? String
39
+ Util.warn "Cannot convert String to all parts: #{content}"
40
+ return
41
+ end
42
+
43
+ remove_part!
44
+ remove_date!
45
+ remove_stage!
46
+ content.all_parts = true
47
+ end
48
+
49
+ def remove_stage!
50
+ remove_attr! :stage
51
+ # return if content.is_a? String
52
+
53
+ # content.stage = nil
54
+ # base = content.base
55
+ # while base
56
+ # base.stage = nil
57
+ # base = base.base
58
+ # end
59
+ end
60
+
61
+ def remove_part!
62
+ remove_attr! :part
63
+ # return if content.is_a? String
64
+
65
+ # content.part = nil
66
+ # base = content.base
67
+ # while base
68
+ # base.part = nil
69
+ # base = base.base
70
+ # end
71
+ end
72
+
73
+ def remove_date!
74
+ remove_attr! :year
75
+ # return if content.is_a? String
76
+
77
+ # content.year = nil
78
+ # base = content.base
79
+ # while base
80
+ # base.year = nil
81
+ # base = base.base
82
+ # end
83
+ end
84
+
85
+ def exclude_year
86
+ pubid = content.exlude(:year)
87
+ current_pubid = pubid
88
+ while current_pubid.base
89
+ current_pubid.base = current_pubid.base.exclude(:year)
90
+ current_pubid = current_pubid.base
91
+ end
92
+ pubid
93
+ end
94
+
95
+ def to_s
96
+ return content if content.is_a? String
97
+
98
+ case type
99
+ when "URN" then content.urn
100
+ when "iso-reference" then iso_reference
101
+ else content.to_s with_prf: true
102
+ end
103
+ end
104
+
105
+ def iso_reference
106
+ return content.to_s(format: :ref_num_short, with_prf: true) if content.language
107
+
108
+ pubid_dup = content.dup
109
+ pubid_dup.language = "en"
110
+ pubid_dup.to_s(format: :ref_num_short, with_prf: true)
111
+ end
112
+
113
+ private
114
+
115
+ def remove_attr!(attr)
116
+ return false if content.is_a? String
117
+
118
+ content.send("#{attr}=", nil)
119
+ base = content.base
120
+ while base
121
+ base.send("#{attr}=", nil)
122
+ base = base.base
123
+ end
124
+ true
125
+ end
126
+ end
127
+ end
128
+ end
@@ -0,0 +1,13 @@
1
+ module Relaton
2
+ module Iso
3
+ class Doctype < Bib::Doctype
4
+ TYPES = %w[
5
+ international-standard technical-specification technical-report publicly-available-specification
6
+ international-workshop-agreement guide recommendation amendment technical-corrigendum directive
7
+ committee-document addendum
8
+ ].freeze
9
+
10
+ attribute :content, :string, values: TYPES
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ require_relative "doctype"
2
+ require_relative "iso_project_group"
3
+ require_relative "stagename"
4
+ # require_relative "subdoctype"
5
+ require_relative "structured_identifier"
6
+
7
+ module Relaton
8
+ module Iso
9
+ class Ext < Lutaml::Model::Serializable
10
+ attribute :schema_version, :string
11
+ attribute :doctype, Doctype
12
+ attribute :subdoctype, :string
13
+ attribute :flavor, :string
14
+ attribute :horizontal, :boolean
15
+ attribute :editorialgroup, ISOProjectGroup
16
+ attribute :approvalgroup, ISOProjectGroup
17
+ attribute :ics, Bib::ICS, collection: true
18
+ attribute :structuredidentifier, StructuredIdentifier
19
+ attribute :stagename, Stagename
20
+ attribute :updates_document_type, :string, values: Doctype::TYPES
21
+ attribute :fast_track, :boolean
22
+ attribute :price_code, :string
23
+
24
+ def initialize(**args)
25
+ super
26
+ @schema_version = Relaton.schema_versions["relaton-model-iso"]
27
+ end
28
+
29
+ xml do
30
+ root "ext"
31
+ map_attribute "schema-version", to: :schema_version
32
+ map_element "doctype", to: :doctype
33
+ map_element "subdoctype", to: :subdoctype
34
+ map_element "flavor", to: :flavor
35
+ map_element "horizontal", to: :horizontal
36
+ map_element "editorialgroup", to: :editorialgroup
37
+ map_element "approvalgroup", to: :approvalgroup
38
+ map_element "ics", to: :ics
39
+ map_element "structuredidentifier", to: :structuredidentifier
40
+ map_element "stagename", to: :stagename
41
+ map_element "updates-document-type", to: :updates_document_type
42
+ map_element "fast-track", to: :fast_track
43
+ map_element "price-code", to: :price_code
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,21 @@
1
+ module Relaton
2
+ module Iso
3
+ class ISOProjectGroup < Lutaml::Model::Serializable
4
+ attribute :agency, :string, collection: true
5
+ attribute :technical_committee, Bib::WorkGroup, collection: true
6
+ attribute :subcommittee, Bib::WorkGroup, collection: true
7
+ attribute :workgroup, Bib::WorkGroup, collection: true
8
+ attribute :secretariat, :string
9
+
10
+ xml do
11
+ root "editorialgroup"
12
+
13
+ map_element "agency", to: :agency
14
+ map_element "technical-committee", to: :technical_committee
15
+ map_element "subcommittee", to: :subcommittee
16
+ map_element "workgroup", to: :workgroup
17
+ map_element "secretariat", to: :secretariat
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "docidentifier"
2
+ require_relative "ext"
3
+
4
+ module Relaton
5
+ module Iso
6
+ class Relation < Bib::Relation
7
+ end
8
+
9
+ class Item < Bib::Item
10
+ model ItemData
11
+
12
+ attribute :docidentifier, Docidentifier, collection: true
13
+ attribute :relation, Relation, collection: true
14
+ attribute :ext, Ext
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Relaton
2
+ module Iso
3
+ # The class is for relaton bibitem instances.
4
+ # The in relaton bibitem instances dosn't have schema-version & fetched attributes.
5
+ class ItemBase < Item
6
+ model ItemData
7
+
8
+ # we don't need schema-version & fetched attributes in reation/bibitem
9
+ mappings[:xml].instance_variable_get(:@attributes).delete("id")
10
+ mappings[:xml].instance_variable_get(:@attributes).delete("schema-version")
11
+ mappings[:xml].instance_variable_get(:@elements).delete("fetched")
12
+ mappings[:xml].instance_variable_get(:@elements).delete("ext")
13
+ attributes.delete :id
14
+ attributes.delete :schema_version
15
+ attributes.delete :fetched
16
+ attributes.delete :ext
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module Relaton
2
+ module Iso
3
+ class Organization < Lutaml::Model::Serializable
4
+ # choice(min: 1, max: 1) do
5
+ # attribute
6
+ # end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Relaton
2
+ module Iso
3
+ class ProjectNumber < Lutaml::Model::Serializable
4
+ attribute :part, :integer
5
+ attribute :subpart, :integer
6
+ attribute :amendment, :integer
7
+ attribute :corrigendum, :integer
8
+ attribute :origyr, :string
9
+ attribute :content, :string
10
+
11
+ xml do
12
+ root "project-number"
13
+ map_attribute "part", to: :part
14
+ map_attribute "subpart", to: :subpart
15
+ map_attribute "amendment", to: :amendment
16
+ map_attribute "corrigendum", to: :corrigendum
17
+ map_attribute "origyr", to: :origyr
18
+ map_content to: :content
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ require_relative "item_base"
2
+
3
+ module Relaton
4
+ module Iso
5
+ class Relation
6
+ attribute :bibitem, ItemBase
7
+ end
8
+ end
9
+ end