elibri_onix 0.1.23 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -5
- data/elibri_onix.gemspec +2 -1
- data/lib/elibri_onix.rb +3 -2
- data/lib/elibri_onix/external_id.rb +15 -2
- data/lib/elibri_onix/external_timestamp.rb +5 -1
- data/lib/elibri_onix/nokogiri_patch.rb +17 -0
- data/lib/elibri_onix/onix_3_0/audience_range.rb +14 -8
- data/lib/elibri_onix/onix_3_0/collection.rb +10 -9
- data/lib/elibri_onix/onix_3_0/contributor.rb +21 -18
- data/lib/elibri_onix/onix_3_0/extent.rb +18 -11
- data/lib/elibri_onix/onix_3_0/header.rb +7 -6
- data/lib/elibri_onix/onix_3_0/imprint.rb +6 -5
- data/lib/elibri_onix/onix_3_0/language.rb +16 -9
- data/lib/elibri_onix/onix_3_0/measure.rb +17 -9
- data/lib/elibri_onix/onix_3_0/onix_message.rb +14 -30
- data/lib/elibri_onix/onix_3_0/price.rb +19 -17
- data/lib/elibri_onix/onix_3_0/product.rb +118 -77
- data/lib/elibri_onix/onix_3_0/product_identifier.rb +9 -7
- data/lib/elibri_onix/onix_3_0/publisher.rb +19 -9
- data/lib/elibri_onix/onix_3_0/publishing_date.rb +10 -9
- data/lib/elibri_onix/onix_3_0/related_product.rb +10 -15
- data/lib/elibri_onix/onix_3_0/sales_restriction.rb +11 -8
- data/lib/elibri_onix/onix_3_0/sender.rb +9 -8
- data/lib/elibri_onix/onix_3_0/stock_quantity_coded.rb +8 -11
- data/lib/elibri_onix/onix_3_0/subject.rb +19 -13
- data/lib/elibri_onix/onix_3_0/supplier.rb +15 -12
- data/lib/elibri_onix/onix_3_0/supplier_identifier.rb +9 -8
- data/lib/elibri_onix/onix_3_0/supply_detail.rb +16 -15
- data/lib/elibri_onix/onix_3_0/supporting_resource.rb +15 -15
- data/lib/elibri_onix/onix_3_0/text_content.rb +18 -15
- data/lib/elibri_onix/onix_3_0/title_detail.rb +17 -11
- data/lib/elibri_onix/onix_3_0/title_element.rb +10 -9
- data/lib/elibri_onix/version.rb +1 -1
- data/test/elibri_contributors_test.rb +1 -1
- data/test/elibri_onix_release_3_0_onix_message_test.rb +2 -2
- data/test/elibri_supporting_resources_test.rb +1 -1
- data/test/elibri_texts_test.rb +4 -4
- data/test/helper.rb +2 -1
- metadata +252 -295
@@ -3,16 +3,8 @@ module Elibri
|
|
3
3
|
module ONIX
|
4
4
|
module Release_3_0
|
5
5
|
|
6
|
-
class ONIXMessage
|
7
|
-
|
8
|
-
#include Inspector
|
9
|
-
|
10
|
-
xml_name 'ONIXMessage'
|
11
|
-
xml_accessor :release, :from => "@release"
|
12
|
-
xml_accessor :elibri_dialect, :from => "elibri:Dialect"
|
13
|
-
|
14
|
-
xml_accessor :products, :as => [Product]
|
15
|
-
xml_accessor :header, :as => Header
|
6
|
+
class ONIXMessage
|
7
|
+
attr_accessor :release, :elibri_dialect, :products, :header, :to_xml
|
16
8
|
|
17
9
|
ATTRIBUTES = [
|
18
10
|
:release, :elibri_dialect, :header
|
@@ -21,28 +13,20 @@ module Elibri
|
|
21
13
|
RELATIONS = [
|
22
14
|
:products
|
23
15
|
]
|
24
|
-
|
16
|
+
|
25
17
|
def self.from_xml(data, *initialization_args)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
inst.roxml_references = roxml_attrs.map {|attr| attr.to_ref(inst) }
|
18
|
+
Kernel.warn "[DEPRECATION] `from_xml` is deprecated. Please use `new` instead."
|
19
|
+
self.new(data, *initialization_args)
|
20
|
+
end
|
30
21
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
? inst.send(ref.opts.setter, value) \
|
40
|
-
: inst.instance_variable_set(ref.opts.instance_variable_name, value)
|
41
|
-
end
|
42
|
-
inst.send(:after_parse) if inst.respond_to?(:after_parse, true)
|
43
|
-
end
|
44
|
-
rescue ArgumentError => e
|
45
|
-
raise e, e.message + " for class #{self}"
|
22
|
+
def initialize(data, *initialization_args)
|
23
|
+
@to_xml = data.to_s
|
24
|
+
xml = Nokogiri::XML(data) unless xml.is_a?(Nokogiri::XML::Document)
|
25
|
+
onix_message = xml.children.first
|
26
|
+
@release = onix_message['release']
|
27
|
+
@elibri_dialect = onix_message.at_xpath('elibri:Dialect').try(:text)
|
28
|
+
@header = Header.new(onix_message.at_xpath('xmlns:Header')) if onix_message.at_xpath('xmlns:Header')
|
29
|
+
@products = onix_message.xpath('xmlns:Product').map { |product_node| Product.new(product_node) }
|
46
30
|
end
|
47
31
|
|
48
32
|
|
@@ -7,10 +7,6 @@ module Elibri
|
|
7
7
|
module Release_3_0
|
8
8
|
|
9
9
|
class Price
|
10
|
-
include ROXML
|
11
|
-
include Inspector
|
12
|
-
|
13
|
-
xml_name 'Price'
|
14
10
|
|
15
11
|
ATTRIBUTES = [
|
16
12
|
:type, :minimum_order_quantity, :amount, :currency_code, :printed_on_product,
|
@@ -18,25 +14,31 @@ module Elibri
|
|
18
14
|
]
|
19
15
|
|
20
16
|
RELATIONS = []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
17
|
+
|
18
|
+
attr_accessor :type, :minimum_order_quantity, :amount, :currency_code, :printed_on_product,
|
19
|
+
:position_on_product, :tax_type, :tax_rate_percent, :to_xml
|
20
|
+
|
21
|
+
def initialize(data)
|
22
|
+
@to_xml = data.to_s
|
23
|
+
@type = data.at_xpath('xmlns:PriceType').try(:text).try(:to_i)
|
24
|
+
@minimum_order_quantity = data.at_xpath('xmlns:MinimumOrderQuantity').try(:text).try(:to_i)
|
25
|
+
@amount = BigDecimal.new(data.at_xpath('xmlns:PriceAmount').try(:text))
|
26
|
+
@currency_code = data.at_xpath('xmlns:CurrencyCode').try(:text)
|
27
|
+
@printed_on_product = data.at_xpath('xmlns:PrintedOnProduct').try(:text).try(:to_i)
|
28
|
+
@position_on_product = data.at_xpath('xmlns:PositionOnProduct').try(:text).try(:to_i)
|
29
|
+
if data.at_xpath('xmlns:Tax')
|
30
|
+
@tax_type = data.at_xpath('xmlns:Tax').at_xpath('xmlns:TaxType').try(:text).try(:to_i)
|
31
|
+
@tax_rate_percent = BigDecimal.new(data.at_xpath('xmlns:Tax').at_xpath('xmlns:TaxRatePercent').try(:text)) if data.at_xpath('xmlns:Tax').at_xpath('xmlns:TaxRatePercent')
|
32
|
+
end
|
33
|
+
end
|
32
34
|
|
33
35
|
def printed_on_product?
|
34
|
-
printed_on_product == 2
|
36
|
+
@printed_on_product == 2
|
35
37
|
end
|
36
38
|
|
37
39
|
|
38
40
|
def vat
|
39
|
-
tax_type == 1 ? tax_rate_percent : nil
|
41
|
+
@tax_type == 1 ? @tax_rate_percent : nil
|
40
42
|
end
|
41
43
|
|
42
44
|
end
|
@@ -30,31 +30,99 @@ module Elibri
|
|
30
30
|
:ghostwriters, :scenarists, :originators, :illustrators, :photographers, :author_of_prefaces, :drawers,
|
31
31
|
:cover_designers, :inked_or_colored_bys, :editors, :revisors, :translators, :editor_in_chiefs, :read_bys
|
32
32
|
]
|
33
|
-
|
34
|
-
|
35
|
-
include ROXML
|
36
|
-
|
37
|
-
|
38
33
|
|
39
34
|
attr_accessor :elibri_dialect, :height, :width, :thickness, :weight, :ean, :isbn13, :number_of_pages, :duration,
|
40
35
|
:file_size, :publisher_name, :publisher_id, :imprint_name, :current_state, :reading_age_from, :reading_age_to,
|
41
36
|
:table_of_contents, :description, :reviews, :excerpts, :series, :title, :subtitle, :collection_title,
|
42
37
|
:collection_part, :full_title, :original_title, :trade_title, :short_description,
|
43
38
|
:elibri_product_category1_id, :elibri_product_category2_id, :preview_exists
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
39
|
+
|
40
|
+
|
41
|
+
#from xml_accessor
|
42
|
+
attr_accessor :record_reference, :notification_type, :deletion_text
|
43
|
+
|
44
|
+
# Load attributes specific for dialect 3.0.1
|
45
|
+
attr_accessor :cover_type_from_3_0_1, :cover_price_from_3_0_1, :vat_from_3_0_1, :pkwiu_from_3_0_1, :preview_exists_from_3_0_1,
|
46
|
+
:product_composition, :product_form, :measures, :title_details, :collections, :contributors, :no_contributor,
|
47
|
+
:languages, :extents, :subjects, :audience_ranges, :edition_statement, :number_of_illustrations, :text_contents,
|
48
|
+
:supporting_resources, :imprint, :publisher, :publishing_status, :publishing_date, :sales_restrictions,
|
49
|
+
:identifiers, :related_products, :supply_details, :to_xml
|
50
|
+
|
51
|
+
|
52
|
+
def initialize(data)
|
53
|
+
@to_xml = data.to_s
|
54
|
+
#initialize variables that need to be array
|
55
|
+
##descriptive_details
|
56
|
+
@text_contents = []
|
57
|
+
@supporting_resources = []
|
58
|
+
##collateral_details
|
59
|
+
@measures = []
|
60
|
+
@title_details = []
|
61
|
+
@collections = []
|
62
|
+
@contributors = []
|
63
|
+
@languages = []
|
64
|
+
@extents = []
|
65
|
+
@subjects = []
|
66
|
+
@audience_ranges = []
|
67
|
+
##publishing_details
|
68
|
+
@sales_restrictions = []
|
69
|
+
|
70
|
+
#moving to parsing attributes
|
71
|
+
|
72
|
+
@elibri_dialect = data.at_xpath('//elibri:Dialect').try(:text)
|
73
|
+
@record_reference = data.at_xpath('xmlns:RecordReference').try(:text)
|
74
|
+
@notification_type = data.at_xpath('xmlns:NotificationType').try(:text)
|
75
|
+
@deletion_text = data.at_xpath('xmlns:DeletionText').try(:text)
|
76
|
+
@cover_type_from_3_0_1 = data.at_xpath('elibri:CoverType').try(:text)
|
77
|
+
@cover_price_from_3_0_1 = BigDecimal.new(data.at_xpath('elibri:CoverPrice').try(:text)) if data.at_xpath('elibri:CoverPrice')
|
78
|
+
@vat_from_3_0_1 = data.at_xpath('elibri:Vat').try(:text).try(:to_i)
|
79
|
+
@pkwiu_from_3_0_1 = data.at_xpath('elibri:PKWiU').try(:text)
|
80
|
+
@preview_exists_from_3_0_1 = data.at_xpath('elibri:preview_exists').try(:text)
|
81
|
+
@identifiers = data.xpath('xmlns:ProductIdentifier').map { |ident_data| ProductIdentifier.new(ident_data) }
|
82
|
+
begin
|
83
|
+
@related_products = data.at_xpath('xmlns:RelatedMaterial').xpath('xmlns:RelatedProduct').map { |related_data| RelatedProduct.new(related_data) }
|
84
|
+
rescue
|
85
|
+
@related_products = []
|
86
|
+
end
|
87
|
+
begin
|
88
|
+
@supply_details = data.at_xpath('xmlns:ProductSupply').xpath('xmlns:SupplyDetail').map { |supply_data| SupplyDetail.new(supply_data) }
|
89
|
+
rescue
|
90
|
+
@supply_details = []
|
91
|
+
end
|
92
|
+
descriptive_details_setup(data.at_xpath('xmlns:DescriptiveDetail')) if data.at_xpath('xmlns:DescriptiveDetail')
|
93
|
+
collateral_details_setup(data.at_xpath('xmlns:CollateralDetail')) if data.at_xpath('xmlns:CollateralDetail')
|
94
|
+
publishing_details_setup(data.at_xpath('xmlns:PublishingDetail')) if data.at_xpath('xmlns:PublishingDetail')
|
95
|
+
after_parse
|
96
|
+
end
|
97
|
+
|
98
|
+
def descriptive_details_setup(data)
|
99
|
+
@product_composition = data.at_xpath('xmlns:ProductComposition').try(:text)
|
100
|
+
@product_form = data.at_xpath('xmlns:ProductForm').try(:text)
|
101
|
+
@measures = data.xpath('xmlns:Measure').map { |measure_data| Measure.new(measure_data) }
|
102
|
+
@title_details = data.xpath('xmlns:TitleDetail').map { |title_data| TitleDetail.new(title_data) }
|
103
|
+
@collections = data.xpath('xmlns:Collection').map { |collection_data| Collection.new(collection_data) }
|
104
|
+
@contributors = data.xpath('xmlns:Contributor').map { |contributor_data| Contributor.new(contributor_data) }
|
105
|
+
@no_contributor = data.at_xpath('xmlns:NoContributor').try(:text)
|
106
|
+
@languages = data.xpath('xmlns:Language').map { |language_data| Language.new(language_data) }
|
107
|
+
@extents = data.xpath('xmlns:Extent').map { |extent_data| Extent.new(extent_data) }
|
108
|
+
@subjects = data.xpath('xmlns:Subject').map { |subject_data| Subject.new(subject_data) }
|
109
|
+
@audience_ranges = data.xpath('xmlns:AudienceRange').map { |audience_data| AudienceRange.new(audience_data) }
|
110
|
+
@edition_statement = data.at_xpath('xmlns:EditionStatement').try(:text)
|
111
|
+
@number_of_illustrations = data.at_xpath('xmlns:NumberOfIllustrations').try(:text).try(:to_i)
|
112
|
+
end
|
113
|
+
|
114
|
+
def collateral_details_setup(data)
|
115
|
+
@text_contents = data.xpath('xmlns:TextContent').map { |text_detail| TextContent.new(text_detail) }
|
116
|
+
@supporting_resources = data.xpath('xmlns:SupportingResource').map { |supporting_data| SupportingResource.new(supporting_data) }
|
117
|
+
end
|
118
|
+
|
119
|
+
def publishing_details_setup(data)
|
120
|
+
@imprint = Imprint.new(data.at_xpath('xmlns:Imprint')) if data.at_xpath('xmlns:Imprint')
|
121
|
+
@publisher = Publisher.new(data.at_xpath('xmlns:Publisher')) if data.at_xpath('xmlns:Publisher')
|
122
|
+
@publishing_status = data.at_xpath('xmlns:PublishingStatus').try(:text)
|
123
|
+
@publishing_date = PublishingDate.new(data.at_xpath('xmlns:PublishingDate')) if data.at_xpath('xmlns:PublishingDate')
|
124
|
+
@sales_restrictions = data.xpath('xmlns:SalesRestriction').map { |restriction_data| SalesRestriction.new(restriction_data) }
|
125
|
+
end
|
58
126
|
|
59
127
|
# Attributes in namespace elibri:* are specific for dialect >= 3.0.1.
|
60
128
|
# If dialect is less than 3.0.1, returns nil.
|
@@ -70,53 +138,26 @@ module Elibri
|
|
70
138
|
EVAL_END
|
71
139
|
end
|
72
140
|
|
73
|
-
xml_accessor :identifiers, :as => [ProductIdentifier]
|
74
|
-
xml_accessor :related_products, :as => [RelatedProduct], :in => 'RelatedMaterial'
|
75
|
-
xml_accessor :supply_details, :as => [SupplyDetail], :in => 'ProductSupply'
|
76
|
-
|
77
|
-
xml_accessor :product_composition, :in => 'DescriptiveDetail', :from => 'ProductComposition'
|
78
|
-
xml_accessor :product_form, :in => 'DescriptiveDetail', :from => 'ProductForm'
|
79
|
-
xml_accessor :measures, :in => 'DescriptiveDetail', :as => [Measure]
|
80
|
-
xml_accessor :title_details, :in => 'DescriptiveDetail', :as => [TitleDetail]
|
81
|
-
xml_accessor :collections, :in => 'DescriptiveDetail', :as => [Collection]
|
82
|
-
xml_accessor :contributors, :in => 'DescriptiveDetail', :as => [Contributor]
|
83
|
-
xml_accessor :no_contributor, :in => 'DescriptiveDetail', :from => 'NoContributor'
|
84
|
-
xml_accessor :languages, :in => 'DescriptiveDetail', :as => [Language]
|
85
|
-
xml_accessor :extents, :in => 'DescriptiveDetail', :as => [Extent]
|
86
|
-
xml_accessor :subjects, :in => 'DescriptiveDetail', :as => [Subject]
|
87
|
-
xml_accessor :audience_ranges, :in => 'DescriptiveDetail', :as => [AudienceRange]
|
88
|
-
xml_accessor :edition_statement, :in => 'DescriptiveDetail', :from => 'EditionStatement'
|
89
|
-
xml_accessor :number_of_illustrations, :in => 'DescriptiveDetail', :from => 'NumberOfIllustrations', :as => Fixnum
|
90
|
-
|
91
|
-
xml_accessor :text_contents, :in => 'CollateralDetail', :as => [TextContent]
|
92
|
-
xml_accessor :supporting_resources, :in => 'CollateralDetail', :as => [SupportingResource]
|
93
|
-
|
94
|
-
xml_accessor :imprint, :in => 'PublishingDetail', :as => Imprint
|
95
|
-
xml_accessor :publisher, :in => 'PublishingDetail', :as => Publisher
|
96
|
-
xml_accessor :publishing_status, :in => 'PublishingDetail', :from => 'PublishingStatus'
|
97
|
-
xml_accessor :publishing_date, :in => 'PublishingDetail', :as => PublishingDate
|
98
|
-
xml_accessor :sales_restrictions, :in => 'PublishingDetail', :as => [SalesRestriction]
|
99
|
-
|
100
141
|
def sales_restrictions?
|
101
|
-
sales_restrictions.size > 0
|
142
|
+
@sales_restrictions.size > 0
|
102
143
|
end
|
103
144
|
|
104
145
|
def no_contributor?
|
105
|
-
no_contributor == ""
|
146
|
+
@no_contributor == ""
|
106
147
|
end
|
107
148
|
|
108
149
|
def unnamed_persons?
|
109
|
-
contributors.size == 1 && contributors[0].unnamed_persons.present?
|
150
|
+
@contributors.size == 1 && contributors[0].unnamed_persons.present?
|
110
151
|
end
|
111
152
|
|
112
153
|
def authors
|
113
|
-
unnamed_persons? ? ["praca zbiorowa"] : contributors.find_all { |c| c.role_name == "author" }.map(&:person_name)
|
154
|
+
unnamed_persons? ? ["praca zbiorowa"] : @contributors.find_all { |c| c.role_name == "author" }.map(&:person_name)
|
114
155
|
end
|
115
156
|
|
116
157
|
[:ghostwriter, :scenarist, :originator, :illustrator, :photographer, :author_of_preface, :drawer, :cover_designer,
|
117
158
|
:inked_or_colored_by, :editor, :revisor, :translator, :editor_in_chief, :read_by].each do |role|
|
118
159
|
define_method "#{role}s" do
|
119
|
-
contributors.find_all { |c| c.role_name == role.to_s }.map(&:person_name)
|
160
|
+
@contributors.find_all { |c| c.role_name == role.to_s }.map(&:person_name)
|
120
161
|
end
|
121
162
|
end
|
122
163
|
|
@@ -131,11 +172,11 @@ module Elibri
|
|
131
172
|
end
|
132
173
|
|
133
174
|
def front_cover
|
134
|
-
supporting_resources.find { |resource| resource.content_type_name == "front_cover" }
|
175
|
+
@supporting_resources.find { |resource| resource.content_type_name == "front_cover" }
|
135
176
|
end
|
136
177
|
|
137
178
|
def series_names
|
138
|
-
series.map { |series| series[0] }
|
179
|
+
@series.map { |series| series[0] }
|
139
180
|
end
|
140
181
|
|
141
182
|
def premiere
|
@@ -143,7 +184,7 @@ module Elibri
|
|
143
184
|
end
|
144
185
|
|
145
186
|
def proprietary_identifiers
|
146
|
-
identifiers.find_all { |i| i.identifier_type == "proprietary" }.inject({}) { |res, ident| res[ident.type_name] = ident.value; res }
|
187
|
+
@identifiers.find_all { |i| i.identifier_type == "proprietary" }.inject({}) { |res, ident| res[ident.type_name] = ident.value; res }
|
147
188
|
end
|
148
189
|
|
149
190
|
#I don't want to see roxml_references in output - it's faar to big output
|
@@ -186,7 +227,7 @@ module Elibri
|
|
186
227
|
private
|
187
228
|
|
188
229
|
def find_title(code)
|
189
|
-
title_details.find {|title_detail| title_detail.type == code}
|
230
|
+
@title_details.find {|title_detail| title_detail.type == code}
|
190
231
|
end
|
191
232
|
|
192
233
|
def after_parse
|
@@ -194,23 +235,23 @@ private
|
|
194
235
|
instance_variable_set("@#{mn}", measures.find { |m| m.type_name == mn }.try(:measurement))
|
195
236
|
end
|
196
237
|
|
197
|
-
@ean = identifiers.find { |identifier| identifier.identifier_type == "ean" }.try(:value)
|
198
|
-
|
199
|
-
@number_of_pages = extents.find {|extent| extent.type_name == "page_count" }.try(:value)
|
200
|
-
@duration = extents.find {|extent| extent.type_name == "duration" }.try(:value)
|
201
|
-
@file_size = extents.find {|extent| extent.type_name == "file_size" }.try(:value)
|
202
|
-
@publisher_name = publisher.name if publisher
|
203
|
-
@publisher_id = publisher.
|
204
|
-
@imprint_name = imprint.name if imprint
|
205
|
-
|
206
|
-
@reading_age_from = audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "03")}.try(:value)
|
207
|
-
@reading_age_to = audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "04")}.try(:value)
|
208
|
-
@table_of_contents = text_contents.find { |t| t.type_name == "table_of_contents" }
|
209
|
-
@description = text_contents.find { |t| t.type_name == "main_description" }
|
210
|
-
@short_description = text_contents.find { |t| t.type_name == "short_description" }
|
211
|
-
@reviews = text_contents.find_all { |t| t.type_name == "review" }
|
212
|
-
@excerpts = text_contents.find_all { |t| t.type_name == "excerpt" }
|
213
|
-
@series = collections.map { |c| [c.title_detail.elements[0].title, c.title_detail.elements[0].part_number] }
|
238
|
+
@ean = @identifiers.find { |identifier| identifier.identifier_type == "ean" }.try(:value)
|
239
|
+
|
240
|
+
@number_of_pages = @extents.find {|extent| extent.type_name == "page_count" }.try(:value)
|
241
|
+
@duration = @extents.find {|extent| extent.type_name == "duration" }.try(:value)
|
242
|
+
@file_size = @extents.find {|extent| extent.type_name == "file_size" }.try(:value)
|
243
|
+
@publisher_name = @publisher.name if publisher
|
244
|
+
@publisher_id = @publisher.eid if publisher
|
245
|
+
@imprint_name = @imprint.name if imprint
|
246
|
+
@isbn13 = @identifiers.find { |identifier| identifier.identifier_type == "isbn13" }.try(:value)
|
247
|
+
@reading_age_from = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "03")}.try(:value)
|
248
|
+
@reading_age_to = @audience_ranges.find {|ar| (ar.qualifier == "18") && (ar.precision == "04")}.try(:value)
|
249
|
+
@table_of_contents = @text_contents.find { |t| t.type_name == "table_of_contents" }
|
250
|
+
@description = @text_contents.find { |t| t.type_name == "main_description" }
|
251
|
+
@short_description = @text_contents.find { |t| t.type_name == "short_description" }
|
252
|
+
@reviews = @text_contents.find_all { |t| t.type_name == "review" }
|
253
|
+
@excerpts = @text_contents.find_all { |t| t.type_name == "excerpt" }
|
254
|
+
@series = @collections.map { |c| [c.title_detail.elements[0].title, c.title_detail.elements[0].part_number] }
|
214
255
|
distinctive_title = find_title(Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)
|
215
256
|
if distinctive_title
|
216
257
|
@title = distinctive_title.product_level.try(:title)
|
@@ -230,17 +271,17 @@ private
|
|
230
271
|
end
|
231
272
|
|
232
273
|
def compute_state!
|
233
|
-
if notification_type == "01"
|
274
|
+
if @notification_type == "01"
|
234
275
|
@current_state = :announced
|
235
|
-
elsif notification_type == "02"
|
276
|
+
elsif @notification_type == "02"
|
236
277
|
@current_state = :preorder
|
237
278
|
else
|
238
|
-
if publishing_status == "04"
|
279
|
+
if @publishing_status == "04"
|
239
280
|
@current_state = :published
|
240
|
-
elsif publishing_status == "07"
|
281
|
+
elsif @publishing_status == "07"
|
241
282
|
@current_state = :out_of_print
|
242
283
|
else
|
243
|
-
raise "cannot determine the state of the product #{record_reference}"
|
284
|
+
raise "cannot determine the state of the product #{@record_reference}"
|
244
285
|
end
|
245
286
|
end
|
246
287
|
end
|
@@ -4,13 +4,8 @@ module Elibri
|
|
4
4
|
module Release_3_0
|
5
5
|
|
6
6
|
class ProductIdentifier
|
7
|
-
include ROXML
|
8
|
-
include Inspector
|
9
7
|
|
10
|
-
|
11
|
-
xml_accessor :type, :from => 'ProductIDType'
|
12
|
-
xml_accessor :type_name, :from => 'IDTypeName'
|
13
|
-
xml_accessor :value, :from => 'IDValue'
|
8
|
+
attr_accessor :type, :type_name, :value, :to_xml
|
14
9
|
|
15
10
|
ATTRIBUTES = [
|
16
11
|
:type, :type_name, :value, :identifier_type
|
@@ -19,9 +14,16 @@ module Elibri
|
|
19
14
|
RELATIONS = [
|
20
15
|
:inspect_include_fields
|
21
16
|
]
|
17
|
+
|
18
|
+
def initialize(data)
|
19
|
+
@to_xml = data.to_s
|
20
|
+
@type = data.at_xpath('xmlns:ProductIDType').try(:text)
|
21
|
+
@type_name = data.at_xpath('xmlns:IDTypeName').try(:text)
|
22
|
+
@value = data.at_xpath('xmlns:IDValue').try(:text)
|
23
|
+
end
|
22
24
|
|
23
25
|
def identifier_type
|
24
|
-
Elibri::ONIX::Dict::Release_3_0::ProductIDType.find_by_onix_code(type).const_name.downcase
|
26
|
+
Elibri::ONIX::Dict::Release_3_0::ProductIDType.find_by_onix_code(@type).const_name.downcase
|
25
27
|
end
|
26
28
|
|
27
29
|
def inspect_include_fields
|
@@ -6,21 +6,31 @@ module Elibri
|
|
6
6
|
module Release_3_0
|
7
7
|
|
8
8
|
class Publisher
|
9
|
-
include ROXML
|
10
|
-
include Inspector
|
11
|
-
|
12
|
-
xml_name 'Publisher'
|
13
9
|
|
14
10
|
ATTRIBUTES = [
|
15
|
-
:role, :name, :
|
11
|
+
:role, :name, :eid
|
16
12
|
]
|
17
13
|
|
18
14
|
RELATIONS = []
|
19
15
|
|
20
|
-
#występuje w tej chwili tylko 01 - główny wydawca
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
#role występuje w tej chwili tylko 01 - główny wydawca
|
17
|
+
|
18
|
+
attr_accessor :role, :name, :eid, :to_xml
|
19
|
+
|
20
|
+
def initialize(data)
|
21
|
+
@to_xml = data.to_s
|
22
|
+
@role = data.at_xpath('xmlns:PublishingRole').try(:text)
|
23
|
+
@name = data.at_xpath('xmlns:PublisherName').try(:text)
|
24
|
+
if data.at_xpath('xmlns:PublisherIdentifier')
|
25
|
+
@eid = data.at_xpath('xmlns:PublisherIdentifier').at_xpath('xmlns:IDValue').try(:text).try(:to_i)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def id
|
30
|
+
Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
|
31
|
+
@eid
|
32
|
+
end
|
33
|
+
|
24
34
|
end
|
25
35
|
|
26
36
|
end
|