genericode 0.1.2 → 0.2.0
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/.rubocop.yml +1 -28
- data/.rubocop_todo.yml +36 -12
- data/Rakefile +3 -3
- data/exe/genericode +2 -2
- data/lib/genericode/agency.rb +15 -16
- data/lib/genericode/annotation.rb +9 -10
- data/lib/genericode/any_other_content.rb +2 -3
- data/lib/genericode/any_other_language_content.rb +6 -6
- data/lib/genericode/canonical_uri.rb +3 -3
- data/lib/genericode/cli/code_lister.rb +19 -14
- data/lib/genericode/cli/code_lookup.rb +1 -1
- data/lib/genericode/cli/commands.rb +21 -18
- data/lib/genericode/cli/converter.rb +10 -11
- data/lib/genericode/cli/validator.rb +12 -5
- data/lib/genericode/cli.rb +1 -1
- data/lib/genericode/code_list.rb +64 -63
- data/lib/genericode/code_list_ref.rb +12 -13
- data/lib/genericode/code_list_set.rb +20 -21
- data/lib/genericode/code_list_set_ref.rb +14 -14
- data/lib/genericode/column.rb +33 -34
- data/lib/genericode/column_ref.rb +18 -19
- data/lib/genericode/column_set.rb +24 -25
- data/lib/genericode/column_set_ref.rb +9 -10
- data/lib/genericode/data.rb +14 -15
- data/lib/genericode/data_restrictions.rb +7 -8
- data/lib/genericode/datatype_facet.rb +8 -9
- data/lib/genericode/gc_namespace.rb +12 -0
- data/lib/genericode/general_identifier.rb +9 -9
- data/lib/genericode/identification.rb +37 -39
- data/lib/genericode/json/canonical_uri_mixin.rb +1 -1
- data/lib/genericode/json/short_name_mixin.rb +1 -1
- data/lib/genericode/key.rb +28 -29
- data/lib/genericode/key_column_ref.rb +7 -8
- data/lib/genericode/key_ref.rb +13 -14
- data/lib/genericode/long_name.rb +11 -11
- data/lib/genericode/mime_typed_uri.rb +5 -6
- data/lib/genericode/row.rb +8 -9
- data/lib/genericode/short_name.rb +7 -7
- data/lib/genericode/simple_code_list.rb +9 -10
- data/lib/genericode/simple_value.rb +3 -4
- data/lib/genericode/value.rb +14 -15
- data/lib/genericode/version.rb +1 -1
- data/lib/genericode.rb +4 -5
- metadata +14 -12
|
@@ -1,45 +1,44 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
|
+
require_relative 'column'
|
|
7
|
+
require_relative 'column_ref'
|
|
8
|
+
require_relative 'identification'
|
|
9
|
+
require_relative 'key'
|
|
10
|
+
require_relative 'key_ref'
|
|
11
11
|
|
|
12
12
|
module Genericode
|
|
13
13
|
class ColumnSet < Lutaml::Model::Serializable
|
|
14
14
|
attribute :datatype_library, :string
|
|
15
15
|
attribute :annotation, Annotation
|
|
16
16
|
attribute :identification, Identification
|
|
17
|
-
attribute :column, Column, collection: true
|
|
18
|
-
attribute :column_ref, ColumnRef, collection: true
|
|
17
|
+
attribute :column, Column, collection: true, initialize_empty: true
|
|
18
|
+
attribute :column_ref, ColumnRef, collection: true, initialize_empty: true
|
|
19
19
|
attribute :key, Key, collection: true
|
|
20
20
|
attribute :key_ref, KeyRef, collection: true
|
|
21
21
|
|
|
22
22
|
json do
|
|
23
|
-
map
|
|
24
|
-
map
|
|
25
|
-
map
|
|
26
|
-
map
|
|
27
|
-
map
|
|
28
|
-
map
|
|
29
|
-
map
|
|
23
|
+
map 'DatatypeLibrary', to: :datatype_library
|
|
24
|
+
map 'Annotation', to: :annotation
|
|
25
|
+
map 'Identification', to: :identification
|
|
26
|
+
map 'Column', to: :column
|
|
27
|
+
map 'ColumnRef', to: :column_ref
|
|
28
|
+
map 'Key', to: :key
|
|
29
|
+
map 'KeyRef', to: :key_ref
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
xml do
|
|
33
|
-
|
|
34
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
33
|
+
element 'ColumnSet'
|
|
35
34
|
|
|
36
|
-
map_attribute
|
|
37
|
-
map_element
|
|
38
|
-
map_element
|
|
39
|
-
map_element
|
|
40
|
-
map_element
|
|
41
|
-
map_element
|
|
42
|
-
map_element
|
|
35
|
+
map_attribute 'DatatypeLibrary', to: :datatype_library
|
|
36
|
+
map_element 'Annotation', to: :annotation
|
|
37
|
+
map_element 'Identification', to: :identification
|
|
38
|
+
map_element 'Column', to: :column
|
|
39
|
+
map_element 'ColumnRef', to: :column_ref
|
|
40
|
+
map_element 'Key', to: :key
|
|
41
|
+
map_element 'KeyRef', to: :key_ref
|
|
43
42
|
end
|
|
44
43
|
end
|
|
45
44
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
6
|
|
|
7
7
|
module Genericode
|
|
8
8
|
class ColumnSetRef < Lutaml::Model::Serializable
|
|
@@ -11,18 +11,17 @@ module Genericode
|
|
|
11
11
|
attribute :location_uri, :string, collection: true
|
|
12
12
|
|
|
13
13
|
json do
|
|
14
|
-
map
|
|
15
|
-
map
|
|
16
|
-
map
|
|
14
|
+
map 'Annotation', to: :annotation
|
|
15
|
+
map 'CanonicalVersionUri', to: :canonical_version_uri
|
|
16
|
+
map 'LocationUri', to: :location_uri
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
xml do
|
|
20
|
-
|
|
21
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
20
|
+
element 'ColumnSetRef'
|
|
22
21
|
|
|
23
|
-
map_element
|
|
24
|
-
map_element
|
|
25
|
-
map_element
|
|
22
|
+
map_element 'Annotation', to: :annotation
|
|
23
|
+
map_element 'CanonicalVersionUri', to: :canonical_version_uri
|
|
24
|
+
map_element 'LocationUri', to: :location_uri
|
|
26
25
|
end
|
|
27
26
|
end
|
|
28
27
|
end
|
data/lib/genericode/data.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
|
+
require_relative 'datatype_facet'
|
|
7
7
|
|
|
8
8
|
module Genericode
|
|
9
9
|
class Data < Lutaml::Model::Serializable
|
|
@@ -14,22 +14,21 @@ module Genericode
|
|
|
14
14
|
attribute :parameter, DatatypeFacet, collection: true
|
|
15
15
|
|
|
16
16
|
json do
|
|
17
|
-
map
|
|
18
|
-
map
|
|
19
|
-
map
|
|
20
|
-
map
|
|
21
|
-
map
|
|
17
|
+
map 'Type', to: :type
|
|
18
|
+
map 'DatatypeLibrary', to: :datatype_library
|
|
19
|
+
map 'Lang', to: :lang
|
|
20
|
+
map 'Annotation', to: :annotation
|
|
21
|
+
map 'Parameter', to: :parameter
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
xml do
|
|
25
|
-
|
|
26
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
25
|
+
element 'Data'
|
|
27
26
|
|
|
28
|
-
map_attribute
|
|
29
|
-
map_attribute
|
|
30
|
-
map_attribute
|
|
31
|
-
map_element
|
|
32
|
-
map_element
|
|
27
|
+
map_attribute 'Type', to: :type
|
|
28
|
+
map_attribute 'DatatypeLibrary', to: :datatype_library
|
|
29
|
+
map_attribute 'Lang', to: :lang
|
|
30
|
+
map_element 'Annotation', to: :annotation
|
|
31
|
+
map_element 'Parameter', to: :parameter
|
|
33
32
|
end
|
|
34
33
|
end
|
|
35
34
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
5
|
+
require_relative 'datatype_facet'
|
|
6
6
|
|
|
7
7
|
module Genericode
|
|
8
8
|
class DataRestrictions < Lutaml::Model::Serializable
|
|
@@ -10,16 +10,15 @@ module Genericode
|
|
|
10
10
|
attribute :parameter, DatatypeFacet, collection: true
|
|
11
11
|
|
|
12
12
|
json do
|
|
13
|
-
map
|
|
14
|
-
map
|
|
13
|
+
map 'Lang', to: :lang
|
|
14
|
+
map 'Parameter', to: :parameter
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
xml do
|
|
18
|
-
|
|
19
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
18
|
+
element 'DataRestrictions'
|
|
20
19
|
|
|
21
|
-
map_attribute
|
|
22
|
-
map_element
|
|
20
|
+
map_attribute 'Lang', to: :lang
|
|
21
|
+
map_element 'Parameter', to: :parameter
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require_relative
|
|
3
|
+
require 'lutaml/model'
|
|
4
|
+
require_relative 'json/short_name_mixin'
|
|
5
5
|
|
|
6
6
|
module Genericode
|
|
7
7
|
class DatatypeFacet < Lutaml::Model::Serializable
|
|
@@ -12,18 +12,17 @@ module Genericode
|
|
|
12
12
|
attribute :long_name, :string
|
|
13
13
|
|
|
14
14
|
json do
|
|
15
|
-
map
|
|
16
|
-
map
|
|
17
|
-
map
|
|
15
|
+
map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
|
|
16
|
+
map 'LongName', to: :long_name
|
|
17
|
+
map '_', to: :content
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
xml do
|
|
21
|
-
|
|
22
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
21
|
+
element 'DatatypeFacet'
|
|
23
22
|
|
|
24
23
|
map_content to: :content
|
|
25
|
-
map_attribute
|
|
26
|
-
map_attribute
|
|
24
|
+
map_attribute 'ShortName', to: :short_name
|
|
25
|
+
map_attribute 'LongName', to: :long_name
|
|
27
26
|
end
|
|
28
27
|
end
|
|
29
28
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'lutaml/xml/namespace'
|
|
4
|
+
|
|
5
|
+
module Genericode
|
|
6
|
+
class GcNamespace < Lutaml::Xml::Namespace
|
|
7
|
+
uri 'http://docs.oasis-open.org/codelist/ns/genericode/1.0/'
|
|
8
|
+
prefix_default 'gc'
|
|
9
|
+
element_form_default :unqualified
|
|
10
|
+
attribute_form_default :unqualified
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
|
+
require 'lutaml/xml/w3c'
|
|
4
5
|
|
|
5
6
|
module Genericode
|
|
6
7
|
class GeneralIdentifier < Lutaml::Model::Serializable
|
|
7
8
|
attribute :content, :string
|
|
8
9
|
attribute :identifier, :string
|
|
9
|
-
attribute :lang,
|
|
10
|
+
attribute :lang, Lutaml::Xml::W3c::XmlLangType
|
|
10
11
|
|
|
11
12
|
json do
|
|
12
|
-
map
|
|
13
|
-
map
|
|
14
|
-
map
|
|
13
|
+
map 'Identifier', to: :identifier
|
|
14
|
+
map 'lang', to: :lang
|
|
15
|
+
map '_', to: :content
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
xml do
|
|
18
|
-
|
|
19
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
19
|
+
element 'GeneralIdentifier'
|
|
20
20
|
|
|
21
21
|
map_content to: :content
|
|
22
|
-
map_attribute
|
|
23
|
-
map_attribute
|
|
22
|
+
map_attribute 'Identifier', to: :identifier
|
|
23
|
+
map_attribute 'lang', to: :lang
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
5
|
+
require_relative 'agency'
|
|
6
|
+
require_relative 'long_name'
|
|
7
|
+
require_relative 'mime_typed_uri'
|
|
8
|
+
require_relative 'canonical_uri'
|
|
9
|
+
require_relative 'short_name'
|
|
10
|
+
require_relative 'json/short_name_mixin'
|
|
11
|
+
require_relative 'json/canonical_uri_mixin'
|
|
12
|
+
require_relative 'utils'
|
|
13
13
|
|
|
14
14
|
module Genericode
|
|
15
15
|
class Identification < Lutaml::Model::Serializable
|
|
@@ -17,25 +17,25 @@ module Genericode
|
|
|
17
17
|
include Json::ShortNameMixin
|
|
18
18
|
|
|
19
19
|
attribute :short_name, ShortName
|
|
20
|
-
attribute :long_name, LongName, collection: true
|
|
20
|
+
attribute :long_name, LongName, collection: true, initialize_empty: true
|
|
21
21
|
attribute :version, :string
|
|
22
22
|
attribute :canonical_uri, CanonicalUri
|
|
23
23
|
attribute :canonical_version_uri, :string
|
|
24
|
-
attribute :location_uri, :string, collection: true
|
|
25
|
-
attribute :alternate_format_location_uri, MimeTypedUri, collection: true
|
|
24
|
+
attribute :location_uri, :string, collection: true, initialize_empty: true
|
|
25
|
+
attribute :alternate_format_location_uri, MimeTypedUri, collection: true, initialize_empty: true
|
|
26
26
|
attribute :agency, Agency
|
|
27
27
|
|
|
28
28
|
json do
|
|
29
|
-
map
|
|
30
|
-
map
|
|
31
|
-
map
|
|
32
|
-
map
|
|
33
|
-
map
|
|
34
|
-
map
|
|
35
|
-
map
|
|
29
|
+
map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
|
|
30
|
+
map 'LongName', to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
|
|
31
|
+
map 'Version', to: :version
|
|
32
|
+
map 'CanonicalUri', to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
|
|
33
|
+
map 'CanonicalVersionUri', to: :canonical_version_uri
|
|
34
|
+
map 'LocationUri', to: :location_uri, with: { from: :location_uri_from_json, to: :location_uri_to_json }
|
|
35
|
+
map 'AlternateFormatLocationUri', to: :alternate_format_location_uri,
|
|
36
36
|
with: { from: :alternate_format_location_uri_from_json,
|
|
37
|
-
to: :alternate_format_location_uri_to_json
|
|
38
|
-
map
|
|
37
|
+
to: :alternate_format_location_uri_to_json }
|
|
38
|
+
map 'Agency', to: :agency
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def long_name_from_json(model, value)
|
|
@@ -43,22 +43,21 @@ module Genericode
|
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def long_name_to_json(model, doc)
|
|
46
|
-
return if model.long_name.empty?
|
|
46
|
+
return if model.long_name.nil? || model.long_name.empty?
|
|
47
47
|
|
|
48
|
-
doc[
|
|
48
|
+
doc['LongName'] = LongName.as_json(model.long_name)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def location_uri_from_json(model, value)
|
|
52
|
-
# model.location_uri = Shale::Type::String.of_json(Utils.array_wrap(value))
|
|
53
52
|
model.location_uri = Utils.array_wrap(value).map do |val|
|
|
54
53
|
Lutaml::Model::Type::String.cast(val)
|
|
55
54
|
end
|
|
56
55
|
end
|
|
57
56
|
|
|
58
57
|
def location_uri_to_json(model, doc)
|
|
59
|
-
return if model.location_uri.empty?
|
|
58
|
+
return if model.location_uri.nil? || model.location_uri.empty?
|
|
60
59
|
|
|
61
|
-
doc[
|
|
60
|
+
doc['LocationUri'] = Lutaml::Model::Type::String.cast(Utils.one_or_all(model.location_uri))
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
def alternate_format_location_uri_from_json(model, value)
|
|
@@ -66,23 +65,22 @@ module Genericode
|
|
|
66
65
|
end
|
|
67
66
|
|
|
68
67
|
def alternate_format_location_uri_to_json(model, doc)
|
|
69
|
-
return if model.alternate_format_location_uri.empty?
|
|
68
|
+
return if model.alternate_format_location_uri.nil? || model.alternate_format_location_uri.empty?
|
|
70
69
|
|
|
71
|
-
doc[
|
|
70
|
+
doc['AlternateFormatLocationUri'] = MimeTypedUri.as_json(Utils.one_or_all(model.alternate_format_location_uri))
|
|
72
71
|
end
|
|
73
72
|
|
|
74
73
|
xml do
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
map_element
|
|
79
|
-
map_element
|
|
80
|
-
map_element
|
|
81
|
-
map_element
|
|
82
|
-
map_element
|
|
83
|
-
map_element
|
|
84
|
-
map_element
|
|
85
|
-
map_element "Agency", to: :agency, prefix: nil, namespace: nil
|
|
74
|
+
element 'Identification'
|
|
75
|
+
|
|
76
|
+
map_element 'ShortName', to: :short_name
|
|
77
|
+
map_element 'LongName', to: :long_name
|
|
78
|
+
map_element 'Version', to: :version
|
|
79
|
+
map_element 'CanonicalUri', to: :canonical_uri
|
|
80
|
+
map_element 'CanonicalVersionUri', to: :canonical_version_uri
|
|
81
|
+
map_element 'LocationUri', to: :location_uri
|
|
82
|
+
map_element 'AlternateFormatLocationUri', to: :alternate_format_location_uri
|
|
83
|
+
map_element 'Agency', to: :agency
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
end
|
data/lib/genericode/key.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
7
|
-
require_relative
|
|
8
|
-
require_relative
|
|
9
|
-
require_relative
|
|
10
|
-
require_relative
|
|
11
|
-
require_relative
|
|
12
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
|
+
require_relative 'key_column_ref'
|
|
7
|
+
require_relative 'canonical_uri'
|
|
8
|
+
require_relative 'long_name'
|
|
9
|
+
require_relative 'short_name'
|
|
10
|
+
require_relative 'json/short_name_mixin'
|
|
11
|
+
require_relative 'json/canonical_uri_mixin'
|
|
12
|
+
require_relative 'utils'
|
|
13
13
|
|
|
14
14
|
module Genericode
|
|
15
15
|
class Key < Lutaml::Model::Serializable
|
|
@@ -19,19 +19,19 @@ module Genericode
|
|
|
19
19
|
attribute :id, :string
|
|
20
20
|
attribute :annotation, Annotation
|
|
21
21
|
attribute :short_name, ShortName
|
|
22
|
-
attribute :long_name, LongName, collection: true
|
|
22
|
+
attribute :long_name, LongName, collection: true, initialize_empty: true
|
|
23
23
|
attribute :canonical_uri, CanonicalUri
|
|
24
24
|
attribute :canonical_version_uri, :string
|
|
25
25
|
attribute :column_ref, KeyColumnRef, collection: true
|
|
26
26
|
|
|
27
27
|
json do
|
|
28
|
-
map
|
|
29
|
-
map
|
|
30
|
-
map
|
|
31
|
-
map
|
|
32
|
-
map
|
|
33
|
-
map
|
|
34
|
-
map
|
|
28
|
+
map 'Id', to: :id
|
|
29
|
+
map 'Annotation', to: :annotation
|
|
30
|
+
map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
|
|
31
|
+
map 'LongName', to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
|
|
32
|
+
map 'CanonicalUri', to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
|
|
33
|
+
map 'CanonicalVersionUri', to: :canonical_version_uri
|
|
34
|
+
map 'ColumnRef', to: :column_ref, with: { from: :column_ref_from_json, to: :column_ref_to_json }
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def long_name_from_json(model, value)
|
|
@@ -39,9 +39,9 @@ module Genericode
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def long_name_to_json(model, doc)
|
|
42
|
-
return if model.long_name.empty?
|
|
42
|
+
return if model.long_name.nil? || model.long_name.empty?
|
|
43
43
|
|
|
44
|
-
doc[
|
|
44
|
+
doc['LongName'] = LongName.as_json(model.long_name)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
def column_ref_from_json(model, value)
|
|
@@ -49,20 +49,19 @@ module Genericode
|
|
|
49
49
|
end
|
|
50
50
|
|
|
51
51
|
def column_ref_to_json(model, doc)
|
|
52
|
-
doc[
|
|
52
|
+
doc['ColumnRef'] = Utils.one_or_all(model.column_ref.map(&:ref))
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
xml do
|
|
56
|
-
|
|
57
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
56
|
+
element 'Key'
|
|
58
57
|
|
|
59
|
-
map_attribute
|
|
60
|
-
map_element
|
|
61
|
-
map_element
|
|
62
|
-
map_element
|
|
63
|
-
map_element
|
|
64
|
-
map_element
|
|
65
|
-
map_element
|
|
58
|
+
map_attribute 'Id', to: :id
|
|
59
|
+
map_element 'Annotation', to: :annotation
|
|
60
|
+
map_element 'ShortName', to: :short_name
|
|
61
|
+
map_element 'LongName', to: :long_name
|
|
62
|
+
map_element 'CanonicalUri', to: :canonical_uri
|
|
63
|
+
map_element 'CanonicalVersionUri', to: :canonical_version_uri
|
|
64
|
+
map_element 'ColumnRef', to: :column_ref
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
6
|
|
|
7
7
|
module Genericode
|
|
8
8
|
class KeyColumnRef < Lutaml::Model::Serializable
|
|
@@ -10,16 +10,15 @@ module Genericode
|
|
|
10
10
|
attribute :annotation, Annotation
|
|
11
11
|
|
|
12
12
|
json do
|
|
13
|
-
map
|
|
14
|
-
map
|
|
13
|
+
map 'Ref', to: :ref
|
|
14
|
+
map 'Annotation', to: :annotation
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
xml do
|
|
18
|
-
|
|
19
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
18
|
+
element 'KeyColumnRef'
|
|
20
19
|
|
|
21
|
-
map_attribute
|
|
22
|
-
map_element
|
|
20
|
+
map_attribute 'Ref', to: :ref
|
|
21
|
+
map_element 'Annotation', to: :annotation
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
end
|
data/lib/genericode/key_ref.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
4
|
|
|
5
|
-
require_relative
|
|
5
|
+
require_relative 'annotation'
|
|
6
6
|
|
|
7
7
|
module Genericode
|
|
8
8
|
class KeyRef < Lutaml::Model::Serializable
|
|
@@ -13,22 +13,21 @@ module Genericode
|
|
|
13
13
|
attribute :location_uri, :string, collection: true
|
|
14
14
|
|
|
15
15
|
json do
|
|
16
|
-
map
|
|
17
|
-
map
|
|
18
|
-
map
|
|
19
|
-
map
|
|
20
|
-
map
|
|
16
|
+
map 'Id', to: :id
|
|
17
|
+
map 'ExternalRef', to: :external_ref
|
|
18
|
+
map 'Annotation', to: :annotation
|
|
19
|
+
map 'CanonicalVersionUri', to: :canonical_version_uri
|
|
20
|
+
map 'LocationUri', to: :location_uri
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
xml do
|
|
24
|
-
|
|
25
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
24
|
+
element 'KeyRef'
|
|
26
25
|
|
|
27
|
-
map_attribute
|
|
28
|
-
map_attribute
|
|
29
|
-
map_element
|
|
30
|
-
map_element
|
|
31
|
-
map_element
|
|
26
|
+
map_attribute 'Id', to: :id
|
|
27
|
+
map_attribute 'ExternalRef', to: :external_ref
|
|
28
|
+
map_element 'Annotation', to: :annotation
|
|
29
|
+
map_element 'CanonicalVersionUri', to: :canonical_version_uri
|
|
30
|
+
map_element 'LocationUri', to: :location_uri
|
|
32
31
|
end
|
|
33
32
|
end
|
|
34
33
|
end
|
data/lib/genericode/long_name.rb
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require 'lutaml/model'
|
|
4
|
+
require 'lutaml/xml/w3c'
|
|
4
5
|
|
|
5
6
|
module Genericode
|
|
6
7
|
class LongName < Lutaml::Model::Serializable
|
|
7
8
|
attribute :content, :string
|
|
8
9
|
attribute :identifier, :string
|
|
9
|
-
attribute :lang,
|
|
10
|
+
attribute :lang, Lutaml::Xml::W3c::XmlLangType
|
|
10
11
|
|
|
11
12
|
json do
|
|
12
|
-
map
|
|
13
|
-
map
|
|
14
|
-
map
|
|
13
|
+
map 'Identifier', to: :identifier
|
|
14
|
+
map 'http://www.w3.org/XML/1998/namespace', to: :lang, with: { from: :lang_from_json, to: :lang_to_json }
|
|
15
|
+
map '_', to: :content
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
def lang_from_json(model, value)
|
|
18
|
-
model.lang = value[
|
|
19
|
+
model.lang = value['lang']
|
|
19
20
|
end
|
|
20
21
|
|
|
21
22
|
def lang_to_json(model, doc)
|
|
22
23
|
return if model.lang.nil?
|
|
23
24
|
|
|
24
|
-
doc[
|
|
25
|
+
doc['http://www.w3.org/XML/1998/namespace'] = { 'lang' => model.lang }
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
xml do
|
|
28
|
-
|
|
29
|
-
namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
|
|
29
|
+
element 'LongName'
|
|
30
30
|
|
|
31
31
|
map_content to: :content
|
|
32
|
-
map_attribute
|
|
33
|
-
map_attribute
|
|
32
|
+
map_attribute 'Identifier', to: :identifier
|
|
33
|
+
map_attribute 'lang', to: :lang
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
end
|