elibri_onix_generator 0.4.8 → 0.4.53
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 +5 -5
- data/README.md +81 -0
- data/elibri_onix_generator.gemspec +3 -2
- data/lib/elibri_onix_generator/model/product.rb +3 -3
- data/lib/elibri_onix_generator/version.rb +1 -1
- data/lib/elibri_onix_generator.rb +520 -240
- metadata +4 -5
- data/README +0 -1
@@ -1,17 +1,14 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
require "elibri_onix_generator/version"
|
3
|
-
require 'builder'
|
4
2
|
require 'ostruct'
|
5
|
-
require 'elibri_onix_dict'
|
6
3
|
|
7
4
|
module Elibri
|
8
5
|
module ONIX
|
9
6
|
|
10
7
|
module Generator
|
11
8
|
|
12
|
-
DOC_ORDER = ["record_identifiers", "publishing_status", "product_form", "contributors", "titles", "series_memberships", "measurement",
|
9
|
+
DOC_ORDER = ["record_identifiers", "publishing_status", "product_form", "contributors", "titles", "series_memberships", "measurement",
|
13
10
|
"sale_restrictions", "territorial_rights", "audience_range", "publisher_info", "extent", "edition", "languages", "epub_details",
|
14
|
-
"texts", "supporting_resources", "subjects", "elibri_extensions"]
|
11
|
+
"texts", "supporting_resources", "subjects", "pform_features", "elibri_extensions"]
|
15
12
|
|
16
13
|
DEFAULT_DIALECT = '3.0.1'
|
17
14
|
|
@@ -30,19 +27,17 @@ module Elibri
|
|
30
27
|
def render_header(builder, options = {}, &block)
|
31
28
|
builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
|
32
29
|
message_attributes = {:release => "3.0", :xmlns => "http://ns.editeur.org/onix/3.0/reference", "xmlns:elibri" => "http://elibri.com.pl/ns/extensions"}
|
33
|
-
message_attributes.delete('xmlns:elibri') if options[:pure_onix]
|
30
|
+
message_attributes.delete('xmlns:elibri') if options[:pure_onix] || options[:elibri_onix_dialect] == "3.0.2"
|
34
31
|
|
35
32
|
builder.ONIXMessage message_attributes do
|
36
|
-
unless options[:pure_onix]
|
33
|
+
unless options[:pure_onix] || options[:elibri_onix_dialect] == "3.0.2"
|
37
34
|
builder.elibri :Dialect, options[:elibri_onix_dialect] || DEFAULT_DIALECT # potrzebne, aby parser wiedział jak interpretować niektóre tagi
|
38
35
|
end
|
39
36
|
tag(builder, :Header) do
|
40
37
|
tag(builder, :Sender) do
|
41
|
-
tag(builder, :SenderName, "Elibri.com.pl")
|
42
|
-
tag(builder, :ContactName, "Tomasz Meka")
|
43
|
-
tag(builder, :EmailAddress, "kontakt@elibri.com.pl")
|
38
|
+
tag(builder, :SenderName, options[:sender_name] || "Elibri.com.pl")
|
44
39
|
end
|
45
|
-
tag(builder, :SentDateTime, Date.today.strftime("%Y%m%d"))
|
40
|
+
tag(builder, :SentDateTime, Date.today.strftime("%Y%m%d"))
|
46
41
|
end
|
47
42
|
yield(builder) if block_given?
|
48
43
|
end
|
@@ -50,7 +45,7 @@ module Elibri
|
|
50
45
|
|
51
46
|
|
52
47
|
# Zwróć dokumentację dla metod sekcji ONIX z bieżącego pliku. Dzięki temu dokumentacja ONIX jest generowana w locie
|
53
|
-
# i nie rozjedzie się z kodem. Dokumentacje można wygenerować tylko dla metod 'def export_XXX!'.
|
48
|
+
# i nie rozjedzie się z kodem. Dokumentacje można wygenerować tylko dla metod 'def export_XXX!'.
|
54
49
|
#
|
55
50
|
# Przykład dokumentowania:
|
56
51
|
# # @hidden_tags RecordReference NotificationType
|
@@ -85,7 +80,7 @@ module Elibri
|
|
85
80
|
(method_definition_line_idx-1).downto(0).each do |line_idx|
|
86
81
|
# Oczyść linię kodu ze znaku komentarza i zbędnych spacji:
|
87
82
|
line = code_lines[line_idx].strip.sub(/^\s*#\s*/, '#')
|
88
|
-
raise "Nieprawidłowy format dokumentacji dla metody #{method_name}" if line.match(/^end$/)
|
83
|
+
raise "Nieprawidłowy format dokumentacji dla metody #{method_name}" if line.match(/^end$/)
|
89
84
|
if md = line.match(/^\s*$/)
|
90
85
|
break
|
91
86
|
elsif md = line.match(/@render (.*)$/)
|
@@ -96,12 +91,12 @@ module Elibri
|
|
96
91
|
section_docs[section_idx][:section_title] = md[1].gsub(/^#/, '')
|
97
92
|
elsif md = line.match(/@hidden_tags (.*)$/)
|
98
93
|
section_docs[section_idx][:hidden_tags] = md[1].gsub(/^#/, '').scan(/\w+/)
|
99
|
-
elsif line == '#'
|
94
|
+
elsif line == '#'
|
100
95
|
section_docs[section_idx][:description] = ["\n%br/\n", section_docs[section_idx][:description]].join("\n")
|
101
96
|
else
|
102
97
|
section_docs[section_idx][:description] = [line.gsub(/^#/, ''), section_docs[section_idx][:description]].join("\n")
|
103
98
|
end
|
104
|
-
end
|
99
|
+
end
|
105
100
|
end
|
106
101
|
# Zwróć posortowane według kolejności sekcji:
|
107
102
|
section_docs.find_all { |section_hash| DOC_ORDER.index(section_hash[:section_name]) }.sort_by {|section_hash| DOC_ORDER.index(section_hash[:section_name]) }
|
@@ -113,14 +108,14 @@ module Elibri
|
|
113
108
|
options[:export_headers] = true unless options.has_key?(:export_headers)
|
114
109
|
options[:elibri_onix_dialect] = DEFAULT_DIALECT unless options.has_key?(:elibri_onix_dialect)
|
115
110
|
options[:comments] = false unless options.has_key?(:comments)
|
116
|
-
options[:xml_variant] = OpenStruct.new(blank?: false,
|
117
|
-
includes_basic_meta?: true,
|
118
|
-
includes_other_texts?: true,
|
111
|
+
options[:xml_variant] = OpenStruct.new(blank?: false,
|
112
|
+
includes_basic_meta?: true,
|
113
|
+
includes_other_texts?: true,
|
119
114
|
includes_media_files?: true,
|
120
|
-
includes_stocks?:
|
115
|
+
includes_stocks?: true) unless options.has_key?(:xml_variant)
|
121
116
|
|
122
117
|
@xml_variant = options[:xml_variant]
|
123
|
-
raise ":xml_variant unspecified" if @xml_variant.blank?
|
118
|
+
raise ":xml_variant unspecified" if @xml_variant.blank?
|
124
119
|
|
125
120
|
if products.respond_to?(:to_ary)
|
126
121
|
@products = products.to_ary
|
@@ -133,11 +128,14 @@ module Elibri
|
|
133
128
|
@builder = Builder::XmlMarkup.new(:indent => 2, :target => @out)
|
134
129
|
@elibri_onix_dialect = options[:elibri_onix_dialect]
|
135
130
|
# Gdy true, ignorujemy rozszerzenia eLibri
|
136
|
-
@pure_onix = options[:pure_onix]
|
131
|
+
@pure_onix = options[:pure_onix] || options[:elibri_onix_dialect] == '3.0.2'
|
132
|
+
@skip_sourcename_and_timestamp = !!options[:skip_sourcename_and_timestamp]
|
133
|
+
@sender_name = options[:sender_name]
|
134
|
+
@lan = options[:lan] || "pol"
|
137
135
|
|
138
136
|
# W testach często nie chcę żadnych nagłówków - interesuje mnie tylko tag <Product>
|
139
137
|
if options[:export_headers]
|
140
|
-
self.class.render_header(@builder, :
|
138
|
+
self.class.render_header(@builder, elibri_onix_dialect: @elibri_onix_dialect, pure_onix: @pure_onix || !@xml_variant.includes_basic_meta?, sender_name: @sender_name) do
|
141
139
|
render_products!
|
142
140
|
end
|
143
141
|
else
|
@@ -160,13 +158,14 @@ module Elibri
|
|
160
158
|
@builder.comment!("$#{kind}$ #{text}")
|
161
159
|
end
|
162
160
|
elsif @comments
|
163
|
-
@builder.comment!(text)
|
161
|
+
@builder.comment!(text)
|
164
162
|
end
|
165
163
|
end
|
166
164
|
|
167
165
|
def field_exists?(object, method_name)
|
168
|
-
if object.respond_to?(method_name)
|
169
|
-
v = object.send(method_name)
|
166
|
+
if object.respond_to?(method_name)
|
167
|
+
v = object.send(method_name)
|
168
|
+
v = v.strip if v.respond_to?(:strip)
|
170
169
|
v && (v.respond_to?(:size) ? v.size > 0 : true)
|
171
170
|
else
|
172
171
|
false
|
@@ -196,9 +195,12 @@ module Elibri
|
|
196
195
|
export_record_identifiers!(product) #PR.1 + PR.2
|
197
196
|
if @xml_variant.includes_basic_meta?
|
198
197
|
tag(:DescriptiveDetail) do
|
199
|
-
export_product_form!(product) #PR.3
|
200
|
-
export_epub_details!(product) #PR.3
|
198
|
+
export_product_form!(product) #PR.3
|
199
|
+
export_epub_details!(product) #PR.3
|
200
|
+
export_pform_features!(product)
|
201
201
|
export_measurement!(product)
|
202
|
+
export_country_of_manufacture!(product)
|
203
|
+
export_classification!(product)
|
202
204
|
#jak się dodaje tytuł, który nie jest samodzielne w sprzedaży?
|
203
205
|
#jak się dodaje tytuł, który zostanie przeceniony?
|
204
206
|
export_series_memberships!(product) #P.5
|
@@ -209,8 +211,9 @@ module Elibri
|
|
209
211
|
export_languages!(product) #PR.10
|
210
212
|
export_extent!(product) #PR.11
|
211
213
|
export_subjects!(product) #PR.12
|
214
|
+
export_audience!(product) if field_exists?(product, :onix_audience_code_value)
|
212
215
|
export_audience_range!(product) if product.respond_to?(:audience_range_present?) && product.audience_range_present? #PR.13
|
213
|
-
end
|
216
|
+
end
|
214
217
|
end
|
215
218
|
if @xml_variant.includes_other_texts? || @xml_variant.includes_media_files?
|
216
219
|
tag(:CollateralDetail) do
|
@@ -222,34 +225,42 @@ module Elibri
|
|
222
225
|
export_supporting_resources!(product) #PR.16 #TODO - to jest też do przerobienia
|
223
226
|
end
|
224
227
|
#P.17 - nagrody
|
225
|
-
end
|
228
|
+
end
|
226
229
|
end
|
227
230
|
remove_tag_if_empty!(:CollateralDetail)
|
228
231
|
#P.18 - ContentItem
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
232
|
+
|
233
|
+
if @xml_variant.includes_basic_meta?
|
234
|
+
tag(:PublishingDetail) do
|
235
|
+
export_publisher_info!(product) #P.19
|
236
|
+
export_publishing_status!(product) #PR.20
|
237
|
+
export_territorial_rights!(product)
|
238
|
+
export_sale_restrictions!(product) if product.respond_to?(:sale_restricted?) && product.sale_restricted? #PR.21
|
239
|
+
end
|
240
|
+
remove_tag_if_empty!(:PublishingDetail)
|
241
|
+
|
242
|
+
#P.23 - related products
|
243
|
+
if field_exists?(product, :facsimiles_for_onix)
|
244
|
+
export_related_products!(product)
|
245
|
+
end
|
246
|
+
|
247
|
+
export_masters_info!(product)
|
240
248
|
end
|
241
249
|
#P.24 - Market
|
242
250
|
#P.25 - market representation
|
243
251
|
if @xml_variant.includes_stocks?
|
244
252
|
export_supply_details!(product) #PR.26
|
245
253
|
end
|
254
|
+
|
246
255
|
#fake dla exportu ze sklepu - w elibri ten kod nie zadziała
|
247
256
|
# if @xml_variant.respond_to?(:cover_price?) && @xml_variant.cover_price?
|
248
257
|
# export_cover_price!(product) #fake, żeby jakoś te dane wysłać
|
249
258
|
# end
|
250
|
-
|
259
|
+
if @xml_variant.includes_basic_meta?
|
260
|
+
export_elibri_extensions!(product) unless @pure_onix
|
261
|
+
end
|
251
262
|
end
|
252
|
-
end
|
263
|
+
end
|
253
264
|
end
|
254
265
|
|
255
266
|
|
@@ -274,11 +285,11 @@ module Elibri
|
|
274
285
|
# @hidden_tags NotificationType DescriptiveDetail ProductSupply PublishingDetail
|
275
286
|
# @title Identyfikatory rekordu
|
276
287
|
# Każdy rekord w ONIX-ie posiada wewnętrzny identyfikator, który jest dowolnym ciągiem znaków, i jest przekazywany
|
277
|
-
# w tagu <strong><ProductIdentifier></strong>. Gwarantowana jest jego niezmienność.
|
288
|
+
# w tagu <strong><ProductIdentifier></strong>. Gwarantowana jest jego niezmienność.
|
278
289
|
#
|
279
290
|
#
|
280
291
|
# Oprócz tego każdy produkt może posiadać numer ISBN, EAN oraz jeden lub więcej identyfikatorów dostawców (np. numer w bazie Olesiejuka)
|
281
|
-
# Tutaj już nie ma gwarancji niezmienności, choć jest to bardzo rzadka sytuacja (np. wydrukowany został jednak inny numer ISBN na okładce,
|
292
|
+
# Tutaj już nie ma gwarancji niezmienności, choć jest to bardzo rzadka sytuacja (np. wydrukowany został jednak inny numer ISBN na okładce,
|
282
293
|
# i wydawcnictwo zmienia wpis w eLibri)
|
283
294
|
def export_record_identifiers!(product)
|
284
295
|
comment 'Unikalne ID rekordu produktu', :kind => :onix_record_identifiers
|
@@ -289,12 +300,15 @@ module Elibri
|
|
289
300
|
comment "Występuje tylko gdy NotificationType == #{Elibri::ONIX::Dict::Release_3_0::NotificationType::DELETE}", :kind => :onix_record_identifiers
|
290
301
|
tag(:DeletionText, product.deletion_text)
|
291
302
|
end
|
303
|
+
if field_exists?(product, :record_source_name)
|
304
|
+
tag(:RecordSourceName, product.record_source_name)
|
305
|
+
end
|
292
306
|
|
293
307
|
if field_exists?(product, :isbn_value)
|
294
308
|
comment 'ISBN', :kind => :onix_record_identifiers
|
295
309
|
tag(:ProductIdentifier) do
|
296
310
|
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::ISBN13) #lista 5
|
297
|
-
tag(:IDValue, product.isbn_value)
|
311
|
+
tag(:IDValue, product.isbn_value)
|
298
312
|
end
|
299
313
|
end
|
300
314
|
|
@@ -303,7 +317,14 @@ module Elibri
|
|
303
317
|
|
304
318
|
tag(:ProductIdentifier) do
|
305
319
|
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::EAN)
|
306
|
-
tag(:IDValue, product.ean)
|
320
|
+
tag(:IDValue, product.ean)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
if field_exists?(product, :doi)
|
325
|
+
tag(:ProductIdentifier) do
|
326
|
+
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::DOI)
|
327
|
+
tag(:IDValue, product.doi)
|
307
328
|
end
|
308
329
|
end
|
309
330
|
|
@@ -316,7 +337,7 @@ module Elibri
|
|
316
337
|
end
|
317
338
|
|
318
339
|
if @xml_variant.includes_stocks?
|
319
|
-
if product.respond_to?(:product_availabilities)
|
340
|
+
if product.respond_to?(:product_availabilities)
|
320
341
|
product.product_availabilities.each do |pa|
|
321
342
|
if field_exists?(pa, :supplier_identifier)
|
322
343
|
comment "Identyfikator dostawcy: #{pa.supplier.name}", :kind => :onix_record_identifiers
|
@@ -335,44 +356,45 @@ module Elibri
|
|
335
356
|
# @hidden_tags RecordReference NotificationType ProductIdentifier TitleDetail
|
336
357
|
# @title Forma produktu
|
337
358
|
# <strong><ProductForm></strong> określa typ produktu. Np. BA to książka.<br/>
|
338
|
-
# <strong><ProductComposition></strong> przybiera aktualnie zawsze wartość 00 - czyli że przedmiotem handlu jest pojedyncza książka.
|
339
|
-
# W przyszłości ulegnie to zmianie, gdy dodamy do eLibri obsługę pakietów książek. Pakiet książek to komplet kilku książek,
|
340
|
-
# z nowym numerem ISBN, i nową ceną, na ogół niższą, niż suma cen książek zawartych w pakiecie.
|
359
|
+
# <strong><ProductComposition></strong> przybiera aktualnie zawsze wartość 00 - czyli że przedmiotem handlu jest pojedyncza książka.
|
360
|
+
# W przyszłości ulegnie to zmianie, gdy dodamy do eLibri obsługę pakietów książek. Pakiet książek to komplet kilku książek,
|
361
|
+
# z nowym numerem ISBN, i nową ceną, na ogół niższą, niż suma cen książek zawartych w pakiecie.
|
341
362
|
def export_product_form!(product)
|
342
363
|
comment 'W tej chwili tylko 00 - pojedynczy element', :kind => :onix_product_form
|
343
|
-
tag(:ProductComposition,
|
364
|
+
tag(:ProductComposition, Elibri::ONIX::Dict::Release_3_0::ProductComposition::SINGLE_COMPONENT_RETAIL_PRODUCT) #lista 2
|
344
365
|
|
345
|
-
if product.
|
346
|
-
|
347
|
-
|
366
|
+
if @elibri_onix_dialect == "3.0.1" || !product.respond_to?(:product_form_for_3_0_2)
|
367
|
+
if product.product_form_onix_code
|
368
|
+
comment_dictionary "Format produktu", :ProductFormCode, :indent => 10, :kind => [:onix_product_form]
|
369
|
+
tag(:ProductForm, { "PODH" => "BB", "PODS" => "BC", "OPEN_ACCESS" => "EA" }[product.product_form_onix_code] || product.product_form_onix_code)
|
370
|
+
end
|
371
|
+
elsif @elibri_onix_dialect == "3.0.2"
|
372
|
+
if product.product_form_onix_code
|
373
|
+
product_form, product_form_detail = product.product_form_for_3_0_2
|
374
|
+
tag(:ProductForm, product_form)
|
375
|
+
tag(:ProductFormDetail, product_form_detail) if product_form_detail
|
376
|
+
end
|
377
|
+
else
|
378
|
+
raise ArgumentError, "Unknow dialect: #{@elibri_onix_dialect}"
|
348
379
|
end
|
349
380
|
end
|
350
381
|
|
351
|
-
|
352
|
-
# @
|
353
|
-
# @title E-booki
|
382
|
+
# @hidden_tags RecordReference NotificationType ProductIdentifier TitleDetail PublishingDetail ProductComposition
|
383
|
+
# @title E-booki
|
354
384
|
# <strong><EpubTechnicalProtection></strong> Określa typ zabezpieczenia stosowanego przy publikacji e-booka.<br/>
|
355
|
-
#
|
385
|
+
#
|
356
386
|
# <strong><ProductFormDetail></strong> zawiera format w jakim rozprowadzany jest e-book.
|
357
387
|
# Aktualnie może przyjąć wartości takie jak:
|
358
388
|
# #{Elibri::ONIX::Dict::Release_3_0::ProductFormDetail::ALL.map(&:name).to_sentence(:last_word_connector => ' lub ')}<br/>
|
359
|
-
#
|
360
|
-
# @render onix_epub_details_example
|
361
389
|
#
|
362
|
-
#
|
363
|
-
# to czy narzuca ograniczenie co do wielkości fragmentu (w ilości znaków albo procentowo). Ta informacja ma tylko wtedy
|
364
|
-
# znaczenie, gdy dystrybutor samodzielnie dokonuje konwersji, a tym samym tworzy ebooka z fragmentem publikacji.
|
365
|
-
# Wydawnictwa, które samodzielnie konwertują książki nie będą publikować tej informacji.<br/>
|
366
|
-
# @render onix_unlimited_book_sample_example
|
367
|
-
# @render onix_prohibited_book_sample_example
|
368
|
-
# @render onix_limited_book_sample_example
|
390
|
+
# @render onix_epub_details_example
|
369
391
|
# <br/>
|
370
392
|
# Wydawnictwa podają też w systemie eLibri informację, czy prawo do sprzedaży ebook-a jest bezterminowe.
|
371
393
|
# W takim przypadku w opisie produktu wystąpi pusty tag <strong><elibri:SaleNotRestricted></strong> (ostatnie trzy przykłady).<br/><br/>
|
372
|
-
# Jeśli wydawca posiada licencję na określony czas, to w opisie produktu wystąpi tag
|
394
|
+
# Jeśli wydawca posiada licencję na określony czas, to w opisie produktu wystąpi tag
|
373
395
|
# <strong><elibri:SaleRestrictedTo></strong>, w którym będzie podana data wygaśnięcia licencji (w formacie YYYYMMDD).
|
374
396
|
# Przykład użycia w pierwszym przykładzie.
|
375
|
-
#
|
397
|
+
#
|
376
398
|
def export_epub_details!(product)
|
377
399
|
if field_exists?(product, :product_form_detail_onix_codes) #lista 175
|
378
400
|
comment_dictionary "Dostępne formaty produktu", :ProductFormDetail, :indent => 10, :kind => :onix_epub_details
|
@@ -382,28 +404,69 @@ module Elibri
|
|
382
404
|
end
|
383
405
|
|
384
406
|
if product.respond_to?(:digital?) && product.digital?
|
385
|
-
if product
|
407
|
+
if field_exists?(product, :epub_technical_protection_onix_code)
|
386
408
|
comment_dictionary "Zabezpieczenie", :EpubTechnicalProtection, :indent => 10, :kind => :onix_epub_details
|
387
409
|
tag(:EpubTechnicalProtection, product.epub_technical_protection_onix_code)
|
388
410
|
end
|
411
|
+
end
|
389
412
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
413
|
+
if field_exists?(product, :epub_license)
|
414
|
+
tag(:EpubLicense) do
|
415
|
+
tag(:EpubLicenseName, product.epub_license.name)
|
416
|
+
if field_exists?(product.epub_license, :url)
|
417
|
+
tag(:EpubLicenseExpression) do
|
418
|
+
tag(:EpubLicenseExpressionType, Elibri::ONIX::Dict::Release_3_0::EpubLicenseExpressionType::HUMAN_READABLE)
|
419
|
+
tag(:EpubLicenseExpressionLink, product.epub_license.url)
|
420
|
+
end
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
end
|
425
|
+
|
426
|
+
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition TitleDetail PublishingDetail ProductSupply
|
427
|
+
# @title Gry planszowe i puzzle
|
428
|
+
# Gry planszowe i puzlle mogą zawierać dodatkowe informacje o ilości elementów (puzzli) w pudełku, czasie gry oraz dopuszczalnej ilości graczy.
|
429
|
+
# Każda z tych informacji jest umieszczna w blocku <ProductFormFeature>, w którym <ProductFormFeatureType> określa typ wartości,
|
430
|
+
# a sama wartość jest umieszczona w tagu <ProductFormFeatureValue> (wartość liczbowa) lub w tagu <ProductFormFeatureDescription>
|
431
|
+
# (przedział wartości)
|
432
|
+
def export_pform_features!(product)
|
433
|
+
|
434
|
+
if product.respond_to?(:number_of_pieces) && product.number_of_pieces
|
435
|
+
tag(:ProductFormFeature) do
|
436
|
+
comment_dictionary 'Typ warrtości', :ProductFormFeatureType, :indent => 10, :kind => :onix_pform_features
|
437
|
+
|
438
|
+
tag(:ProductFormFeatureType, Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::NUMBER_OF_GAME_PIECES)
|
439
|
+
tag(:ProductFormFeatureValue, product.number_of_pieces)
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
if product.respond_to?(:players_number_from) && product.respond_to?(:players_number_to)
|
444
|
+
players = [product.players_number_from, product.players_number_to].compact.uniq.sort
|
445
|
+
if players.present?
|
446
|
+
tag(:ProductFormFeature) do
|
447
|
+
comment_dictionary 'Typ wartości', :ProductFormFeatureType, :indent => 10, :kind => :onix_pform_features
|
448
|
+
|
449
|
+
tag(:ProductFormFeatureType, Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAYERS)
|
450
|
+
if players.size == 1
|
451
|
+
tag(:ProductFormFeatureValue, players.first)
|
452
|
+
else
|
453
|
+
tag(:ProductFormFeatureDescription, "#{players.first}-#{players.last} graczy")
|
454
|
+
end
|
455
|
+
end
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
if product.respond_to?(:playing_time_from) && product.respond_to?(:playing_time_to)
|
460
|
+
ptime = [product.playing_time_from, product.playing_time_to].compact.uniq.sort
|
461
|
+
if ptime.present?
|
462
|
+
tag(:ProductFormFeature) do
|
463
|
+
comment_dictionary 'Typ wartości', :ProductFormFeatureType, :indent => 10, :kind => :onix_pform_features
|
464
|
+
|
465
|
+
tag(:ProductFormFeatureType, Elibri::ONIX::Dict::Release_3_0::ProductFormFeatureType::GAME_PLAY_TIME)
|
466
|
+
if ptime.size == 1
|
467
|
+
tag(:ProductFormFeatureValue, ptime.first)
|
468
|
+
else
|
469
|
+
tag(:ProductFormFeatureDescription, "#{ptime.first}-#{ptime.last} min.")
|
407
470
|
end
|
408
471
|
end
|
409
472
|
end
|
@@ -416,6 +479,7 @@ module Elibri
|
|
416
479
|
# Następujące atrybuty są udostępniane: wysokość, szerokość, grubość oraz masę produktu. Pierwsze trzy podajemy zawsze w milimetrach, masę w gramach.
|
417
480
|
# W przypadku map eksportujemy również jej skalę w tagu <MapScale>
|
418
481
|
def export_measurement!(product)
|
482
|
+
|
419
483
|
if product.respond_to?(:kind_of_measurable?) && product.kind_of_measurable?
|
420
484
|
[[product.height, Elibri::ONIX::Dict::Release_3_0::MeasureType::HEIGHT, 'mm', 'Wysokość'],
|
421
485
|
[product.width, Elibri::ONIX::Dict::Release_3_0::MeasureType::WIDTH, 'mm', 'Szerokość'],
|
@@ -439,38 +503,64 @@ module Elibri
|
|
439
503
|
end
|
440
504
|
end
|
441
505
|
|
506
|
+
def export_country_of_manufacture!(product)
|
507
|
+
|
508
|
+
if field_exists?(product, :country_of_manufacture)
|
509
|
+
tag(:CountryOfManufacture, product.country_of_manufacture)
|
510
|
+
end
|
511
|
+
|
512
|
+
end
|
513
|
+
|
514
|
+
def export_classification!(product)
|
442
515
|
|
443
|
-
|
516
|
+
if field_exists?(product, :pkwiu)
|
517
|
+
tag(:ProductClassification) do
|
518
|
+
tag(:ProductClassificationType, Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::PKWIU)
|
519
|
+
tag(:ProductClassificationCode, product.pkwiu)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
if field_exists?(product, :cn_code)
|
524
|
+
tag(:ProductClassification) do
|
525
|
+
tag(:ProductClassificationType, Elibri::ONIX::Dict::Release_3_0::ProductClassificationType::CN)
|
526
|
+
tag(:ProductClassificationCode, product.cn_code)
|
527
|
+
end
|
528
|
+
end
|
529
|
+
|
530
|
+
end
|
531
|
+
|
532
|
+
|
533
|
+
# @hidden_tags ProductIdentifier DescriptiveDetail ProductSupply
|
444
534
|
# @title Cykl życia rekordu
|
445
535
|
# W ONIX-ie status rekordu jest reprezentowany za pomocą kombinacji tagów <strong><NotificationType></strong> i <strong><PublishingStatus></strong>
|
446
536
|
#
|
447
537
|
#
|
448
538
|
# Tuż po założeniu przez wydawnictwo każdy rekord ma status prywatny. Jest to wtedy widoczny tylko i wyłącznie dla pracowników wydawnictwa,
|
449
|
-
# i nie jest udostępniany na zewnątrz. Po wypełnieniu kilku podstawowych danych (autor, tytuł) pracownik wydawnictwa może zmienić status
|
450
|
-
# rekordu na <i>zapowiedź</i>. W tym przypadku wartość <strong><NotificationType></strong> to 01 - wczesne powiadomienie.
|
539
|
+
# i nie jest udostępniany na zewnątrz. Po wypełnieniu kilku podstawowych danych (autor, tytuł) pracownik wydawnictwa może zmienić status
|
540
|
+
# rekordu na <i>zapowiedź</i>. W tym przypadku wartość <strong><NotificationType></strong> to 01 - wczesne powiadomienie.
|
451
541
|
#
|
452
542
|
# @render onix_announced_product_example
|
453
543
|
#
|
454
|
-
# Po uzupełnieniu większości danych niezbędnych (okładka, cena, ISBN, okładka, dokładna data premiery) wydawnictwo może zmienić
|
455
|
-
# status rekordu na <i>przedsprzedaż</i>.
|
456
|
-
# W zależności od naszego poziomu zaufania do terminowości wydawnictwa można uruchomić dla takiego tytułu przedsprzedaż na stronie księgarni.
|
457
|
-
# Wydawnictwo może zmienić datę premiery, jeśli produkt znajduje się w przedsprzedaży, warto zaimplementować procedurę poinformowania klientów
|
544
|
+
# Po uzupełnieniu większości danych niezbędnych (okładka, cena, ISBN, okładka, dokładna data premiery) wydawnictwo może zmienić
|
545
|
+
# status rekordu na <i>przedsprzedaż</i>.
|
546
|
+
# W zależności od naszego poziomu zaufania do terminowości wydawnictwa można uruchomić dla takiego tytułu przedsprzedaż na stronie księgarni.
|
547
|
+
# Wydawnictwo może zmienić datę premiery, jeśli produkt znajduje się w przedsprzedaży, warto zaimplementować procedurę poinformowania klientów
|
458
548
|
# o zmianie.
|
459
|
-
# Rekord o takim statusie ma wartość 02 w <strong><NotificationType></strong>
|
549
|
+
# Rekord o takim statusie ma wartość 02 w <strong><NotificationType></strong>
|
460
550
|
#
|
461
551
|
# @render onix_preorder_product_example
|
462
552
|
#
|
463
|
-
# Po ukazaniu się książki jej status zostaje zmieniony na <i>dostępna na rynku</i>.
|
464
|
-
# Rekord o takim statusie ma wartość 03 w <strong><NotificationType></strong> i 04 w <strong><PublishingDetail></strong>
|
553
|
+
# Po ukazaniu się książki jej status zostaje zmieniony na <i>dostępna na rynku</i>.
|
554
|
+
# Rekord o takim statusie ma wartość 03 w <strong><NotificationType></strong> i 04 w <strong><PublishingDetail></strong>
|
465
555
|
#
|
466
556
|
# @render onix_published_product_example
|
467
557
|
#
|
468
|
-
# Każde wydawnictwo oczywiście liczy na to, że nakład książki się wyprzeda. Bardzo trudno jest poprawnie zdefiniować, co oznacza wyczerpany nakład.
|
558
|
+
# Każde wydawnictwo oczywiście liczy na to, że nakład książki się wyprzeda. Bardzo trudno jest poprawnie zdefiniować, co oznacza wyczerpany nakład.
|
469
559
|
# Bardzo długo egzemplarze książki, której nie ma już w magazynie wydawnictwa, mogą znajdować się w księgarniach i być zwracane co jakiś czas do hurtowni,
|
470
560
|
# co powoduje, że dany tytuł będzie się stawał na jakiś czas dostępny. W związku z tym informacje o wyczerpaniu się nakładu podejmuje wydawnictwo, i oznacza
|
471
561
|
# to, że nie będzie akceptować zamówień na określony tytuł. Nie oznacza to jednak, że tytuł jest w ogóle niedostępny, w dalszym ciągu może być w ofercie
|
472
|
-
# hurtowni.
|
473
|
-
# Rekord o statusie <i>nakład wyczerpany</i> ma wartość 03 w <strong><NotificationType></strong> i 07 w <strong><PublishingDetail></strong>
|
562
|
+
# hurtowni.
|
563
|
+
# Rekord o statusie <i>nakład wyczerpany</i> ma wartość 03 w <strong><NotificationType></strong> i 07 w <strong><PublishingDetail></strong>
|
474
564
|
#
|
475
565
|
# @render onix_out_of_print_product_example
|
476
566
|
#
|
@@ -490,8 +580,8 @@ module Elibri
|
|
490
580
|
comment 'Jeśli 01 - data publikacji', :kind => :onix_publishing_status
|
491
581
|
tag(:PublishingDateRole, Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PUBLICATION_DATE) #lista 163
|
492
582
|
comment_dictionary "Format daty", :DateFormat, :indent => 12, :kind => :onix_publishing_status
|
493
|
-
tag(:DateFormat, format_code)
|
494
|
-
tag(:Date, date)
|
583
|
+
tag(:DateFormat, format_code) if @elibri_onix_dialect == '3.0.1' #lista 55
|
584
|
+
tag(:Date, date, dateformat: format_code)
|
495
585
|
end
|
496
586
|
end
|
497
587
|
|
@@ -499,8 +589,19 @@ module Elibri
|
|
499
589
|
tag(:PublishingDate) do
|
500
590
|
comment "Jeśli 27 - to data początku przyjmowania zamówień na dany tytuł"
|
501
591
|
tag(:PublishingDateRole, Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::PREORDER_EMBARGO_DATE) #lista 163
|
502
|
-
tag(:DateFormat, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD)
|
503
|
-
tag(:Date, product.distribution_start.strftime("%Y%m%d"))
|
592
|
+
tag(:DateFormat, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD) if @elibri_onix_dialect == '3.0.1'
|
593
|
+
tag(:Date, product.distribution_start.strftime("%Y%m%d"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD)
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
if product.respond_to?(:epub_sale_not_restricted?) && product.respond_to?(:epub_sale_restricted_to)
|
598
|
+
if !product.epub_sale_not_restricted? && product.epub_sale_restricted_to
|
599
|
+
tag(:PublishingDate) do
|
600
|
+
comment "Jeśli 13 - to data po której książka zostanie wycofana z rynku"
|
601
|
+
tag(:PublishingDateRole, Elibri::ONIX::Dict::Release_3_0::PublishingDateRole::OUT_OF_PRINT_DATE) #lista 163
|
602
|
+
tag(:DateFormat, Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD) if @elibri_onix_dialect == '3.0.1'
|
603
|
+
tag(:Date, product.epub_sale_restricted_to.strftime("%Y%m%d"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDD)
|
604
|
+
end
|
504
605
|
end
|
505
606
|
end
|
506
607
|
end
|
@@ -512,14 +613,16 @@ module Elibri
|
|
512
613
|
# dopuszczający sprzedaż na całym świecie. Informacja o ograniczeniu jest zawarta w obręcie <strong><SalesRights></strong>
|
513
614
|
def export_territorial_rights!(product)
|
514
615
|
if product.respond_to?(:sale_restricted_to_poland?)
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
616
|
+
if !(product.respond_to?(:unpriced_item?) && product.unpriced_item?)
|
617
|
+
tag(:SalesRights) do
|
618
|
+
comment "Typ restrykcji - sprzedaż tylko w wymienionym kraju, regionie, zawsze '01'", :kind => :onix_territorial_rights
|
619
|
+
tag(:SalesRightsType, Elibri::ONIX::Dict::Release_3_0::SalesRightsType::FOR_SALE_WITH_EXLUSIVE_RIGHTS)
|
620
|
+
tag(:Territory) do
|
621
|
+
if product.sale_restricted_to_poland?
|
622
|
+
tag(:CountriesIncluded, "PL")
|
623
|
+
else
|
624
|
+
tag(:RegionsIncluded, "WORLD")
|
625
|
+
end
|
523
626
|
end
|
524
627
|
end
|
525
628
|
end
|
@@ -531,17 +634,19 @@ module Elibri
|
|
531
634
|
# @title Ograniczenia sprzedaży
|
532
635
|
# eLibri umożliwia przechowywanie informacji o ograniczaniach dotyczących sprzedaży produktu.
|
533
636
|
# Obecnie obsługuje tylko 1 typ ograniczenia: wyłączność na produkt dla określonego detalisty.
|
534
|
-
# Opcjonalnie może się też pojawić data wygaśnięcia ograniczenia - w innym przypadku oznacza to, że produkt został przeznaczony tylko
|
535
|
-
# dla jednej, określonej sieci.
|
637
|
+
# Opcjonalnie może się też pojawić data wygaśnięcia ograniczenia - w innym przypadku oznacza to, że produkt został przeznaczony tylko
|
638
|
+
# dla jednej, określonej sieci.
|
536
639
|
# W przypadku, gdy jest podana data wyłączności na sprzedaż produktu, należy ją traktować jako faktyczną datę premiery.
|
537
|
-
def export_sale_restrictions!(product)
|
640
|
+
def export_sale_restrictions!(product)
|
538
641
|
if product.sale_restricted?
|
539
642
|
tag(:SalesRestriction) do
|
540
|
-
#lista 71 - For sale only through designated retailer, though not under retailer's own brand/imprint.
|
643
|
+
#lista 71 - For sale only through designated retailer, though not under retailer's own brand/imprint.
|
541
644
|
comment "Typ restrykcji - używamy tylko #{Elibri::ONIX::Dict::Release_3_0::SalesRestrictionType::RETAILER_EXCLUSIVE} (sprzedaż tylko poprzez wybranego detalistę)", :kind => :onix_sale_restrictions
|
542
|
-
tag(:SalesRestrictionType, Elibri::ONIX::Dict::Release_3_0::SalesRestrictionType::RETAILER_EXCLUSIVE)
|
543
|
-
|
544
|
-
tag(:
|
645
|
+
tag(:SalesRestrictionType, Elibri::ONIX::Dict::Release_3_0::SalesRestrictionType::RETAILER_EXCLUSIVE)
|
646
|
+
if field_exists?(product, :sale_restricted_for)
|
647
|
+
tag(:SalesOutlet) do
|
648
|
+
tag(:SalesOutletName, product.sale_restricted_for)
|
649
|
+
end
|
545
650
|
end
|
546
651
|
comment "Ograniczenie wygasa #{product.sale_restricted_to.strftime("%d.%m.%Y")}", :kind => :onix_sale_restrictions
|
547
652
|
tag(:EndDate, product.sale_restricted_to.strftime("%Y%m%d"))
|
@@ -554,7 +659,7 @@ module Elibri
|
|
554
659
|
# @title Wiek czytelnika
|
555
660
|
# Zarówno wiek 'od', jak i wiek 'do' są opcjonalne.
|
556
661
|
def export_audience_range!(product)
|
557
|
-
if product.audience_age_from
|
662
|
+
if product.audience_age_from
|
558
663
|
tag(:AudienceRange) do
|
559
664
|
comment "Ograniczenie dotyczy wieku czytelnika - zawsze #{Elibri::ONIX::Dict::Release_3_0::AudienceRangeQualifier::READING_AGE}", :kind => :onix_audience_range
|
560
665
|
tag(:AudienceRangeQualifier, Elibri::ONIX::Dict::Release_3_0::AudienceRangeQualifier::READING_AGE)
|
@@ -581,7 +686,7 @@ module Elibri
|
|
581
686
|
# W rekordzie znajduje się oczywiście nazwa wydawnictwa. Wydawca może określić też imprint oraz miasto, w którym została wydana ksiażka.
|
582
687
|
# Z imprintem mamy do czynienia wtedy, gdy książki są wydawane pod różnymi markami, pula ISBN jest jednak wspólna.
|
583
688
|
# Jeśli wydawnictwo uzupełnia nazwę imprintu, to powinna być ona traktowana jako nazwa wydawnictwa przy prezentacji
|
584
|
-
# książki klientowi końcowemu.
|
689
|
+
# książki klientowi końcowemu.
|
585
690
|
def export_publisher_info!(product)
|
586
691
|
if product.respond_to?(:imprint_for_onix) && product.imprint_for_onix
|
587
692
|
tag(:Imprint) do
|
@@ -601,7 +706,13 @@ module Elibri
|
|
601
706
|
tag(:IDValue, product.publisher_id_for_onix)
|
602
707
|
end
|
603
708
|
end
|
604
|
-
tag(:PublisherName, product.publisher_name_for_onix)
|
709
|
+
tag(:PublisherName, product.publisher_name_for_onix)
|
710
|
+
if product.respond_to?(:publisher_product_url) && product.publisher_product_url.present?
|
711
|
+
tag(:Website) do
|
712
|
+
tag(:WebsiteRole, Elibri::ONIX::Dict::Release_3_0::WebsiteRole::PUBLISHER_WEBPAGE_FOR_SPECIFIED_WORK)
|
713
|
+
tag(:WebsiteLink, product.publisher_product_url)
|
714
|
+
end
|
715
|
+
end
|
605
716
|
end
|
606
717
|
end
|
607
718
|
|
@@ -634,7 +745,7 @@ module Elibri
|
|
634
745
|
end
|
635
746
|
end
|
636
747
|
|
637
|
-
if product.respond_to?(:kind_of_audio?) && product.respond_to?(:duration) && product.kind_of_audio? and product.duration
|
748
|
+
if product.respond_to?(:kind_of_audio?) && product.respond_to?(:duration) && product.kind_of_audio? and product.duration && product.duration.to_i > 0
|
638
749
|
tag(:Extent) do
|
639
750
|
comment 'Czas trwania (w minutach) - tylko dla produktów typu audio', :kind => :onix_extent
|
640
751
|
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::DURATION)
|
@@ -644,62 +755,55 @@ module Elibri
|
|
644
755
|
end
|
645
756
|
end
|
646
757
|
|
647
|
-
if field_exists?(product, :number_of_pages)
|
758
|
+
if field_exists?(product, :number_of_pages) && product.number_of_pages.to_i > 0
|
648
759
|
tag(:Extent) do
|
649
760
|
comment 'Liczba stron - tylko dla produktów typu książka', :kind => :onix_extent
|
650
|
-
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::PAGE_COUNT)
|
761
|
+
tag(:ExtentType, Elibri::ONIX::Dict::Release_3_0::ExtentType::PAGE_COUNT)
|
651
762
|
tag(:ExtentValue, product.number_of_pages)
|
652
763
|
tag(:ExtentUnit, Elibri::ONIX::Dict::Release_3_0::ExtentUnit::PAGES)
|
653
764
|
end
|
654
765
|
end
|
655
|
-
if field_exists?(product, :number_of_illustrations)
|
766
|
+
if field_exists?(product, :number_of_illustrations) && product.number_of_illustrations.to_i > 0
|
656
767
|
comment 'Liczba ilustracji - tylko dla produktów typu książka', :kind => :onix_extent
|
657
|
-
tag(:NumberOfIllustrations, product.number_of_illustrations)
|
768
|
+
tag(:NumberOfIllustrations, product.number_of_illustrations)
|
658
769
|
end
|
659
770
|
end
|
660
771
|
|
661
772
|
|
773
|
+
def export_audience!(product)
|
774
|
+
tag(:Audience) do
|
775
|
+
tag(:AudienceCodeType, Elibri::ONIX::Dict::Release_3_0::AudienceCodeType::ONIX)
|
776
|
+
tag(:AudienceCodeValue, product.onix_audience_code_value)
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
662
780
|
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm TitleDetail
|
663
781
|
# @title Kategorie
|
664
|
-
# W dostarczanych przez nas plikach ONIX mogą być zawarte
|
782
|
+
# W dostarczanych przez nas plikach ONIX mogą być zawarte dwa rodzaje kategoryzacji:
|
665
783
|
# <ul>
|
666
|
-
# <li><a href='https://www.elibri.com.pl/doc/api/categories'>kategoryzacja elbri (będzie wkrótce wygaszana)</a></li>
|
667
784
|
# <li>Thema - <a href='https://www.elibri.com.pl/thema'>browser kategorii</a>, <a href='https://www.elibri.com.pl/system/doc/thema-przyklady.pdf'>przykłady</a>,
|
668
785
|
# <a href='https://www.editeur.org/151/Thema/'>oficjalna strona Themy</a>
|
669
786
|
# <li>kategoryzacja wydawnicza</li>
|
787
|
+
# <li>słowa kluczowe (tagi)
|
670
788
|
# </li>
|
671
789
|
# </ul>
|
672
|
-
#
|
790
|
+
# Te kategoryzacje mogą współistnieć, rozróżniane przez wartości w <SubjectSchemeIdentifier> i <SubjectSchemeName>:
|
673
791
|
# <ul>
|
674
792
|
# <li><SubjectSchemeIdentifier> o wartościach 93 - 99 - to są kategorie i kwantyfikatory Thema
|
675
|
-
# <li><SubjectSchemeIdentifier> o wartości 24 oraz <SubjectSchemeName> o wartości elibri.com.pl - to są kategorie elibri
|
676
793
|
# <li><SubjectSchemeIdentifier> o wartości 24 oraz <SubjectSchemeName> z nazwą wydawnictwa - to są kategorie wydawnicze.</li>
|
794
|
+
# <li><SubjectSchemeIdentifier> o wartości 20 - w polu <SubjectHeadingText> są słowa kluczowe rozdzielone średnikiem.</li>
|
677
795
|
# </ul>
|
678
796
|
def export_subjects!(product)
|
679
797
|
|
680
|
-
# Kategorie wg. eLibri
|
681
|
-
if product.respond_to?(:elibri_product_categories)
|
682
|
-
product.elibri_product_categories.each_with_index do |product_category, i|
|
683
|
-
tag(:Subject) do
|
684
|
-
tag(:MainSubject) if i.zero?
|
685
|
-
tag(:SubjectSchemeIdentifier, Elibri::ONIX::Dict::Release_3_0::SubjectSchemeIdentifier::PROPRIETARY)
|
686
|
-
tag(:SubjectSchemeName, 'elibri.com.pl')
|
687
|
-
tag(:SubjectSchemeVersion, '1.0')
|
688
|
-
tag(:SubjectCode, product_category.id)
|
689
|
-
tag(:SubjectHeadingText, product_category.full_node_path_name)
|
690
|
-
end
|
691
|
-
end
|
692
|
-
end
|
693
|
-
|
694
798
|
if product.respond_to?(:thema_codes_for_onix_with_heading_text)
|
695
799
|
product.thema_codes_for_onix_with_heading_text.each do |code, text|
|
696
800
|
|
697
|
-
scheme_id = {
|
698
|
-
"1" => 94, #Thema place qualifier
|
699
|
-
"2" => 95, #Thema language qualifier
|
700
|
-
"3" => 96, #Thema time period qualifier
|
701
|
-
"4" => 97, #Thema educational purpose qualifier
|
702
|
-
"5" => 98, #Thema interest age / special interest qualifier
|
801
|
+
scheme_id = {
|
802
|
+
"1" => 94, #Thema place qualifier
|
803
|
+
"2" => 95, #Thema language qualifier
|
804
|
+
"3" => 96, #Thema time period qualifier
|
805
|
+
"4" => 97, #Thema educational purpose qualifier
|
806
|
+
"5" => 98, #Thema interest age / special interest qualifier
|
703
807
|
"6" => 99, #Thema style qualifier
|
704
808
|
}[code[0]] || 93
|
705
809
|
|
@@ -707,7 +811,7 @@ module Elibri
|
|
707
811
|
tag(:SubjectSchemeIdentifier, scheme_id)
|
708
812
|
tag(:SubjectSchemeVersion, "1.3")
|
709
813
|
tag(:SubjectCode, code)
|
710
|
-
tag(:SubjectHeadingText, text)
|
814
|
+
tag(:SubjectHeadingText, text) if text && text.size > 0
|
711
815
|
end
|
712
816
|
end
|
713
817
|
end
|
@@ -723,6 +827,27 @@ module Elibri
|
|
723
827
|
end
|
724
828
|
end
|
725
829
|
end
|
830
|
+
|
831
|
+
if product.respond_to?(:polish_aggregated_categories)
|
832
|
+
product.polish_aggregated_categories.each do |category|
|
833
|
+
tag(:Subject) do
|
834
|
+
tag(:SubjectSchemeIdentifier, Elibri::ONIX::Dict::Release_3_0::SubjectSchemeIdentifier::PROPRIETARY)
|
835
|
+
tag(:SubjectSchemeName, "Polish Aggregated Category")
|
836
|
+
tag(:SubjectHeadingText, category)
|
837
|
+
end
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
if product.respond_to?(:keywords) && product.keywords.size > 0
|
842
|
+
by_lan = product.keywords.group_by { |k| k.language && k.language.size > 0 ? k.language : @lan }
|
843
|
+
|
844
|
+
tag(:Subject) do
|
845
|
+
tag(:SubjectSchemeIdentifier, Elibri::ONIX::Dict::Release_3_0::SubjectSchemeIdentifier::KEYWORDS)
|
846
|
+
by_lan.keys.sort.each do |language|
|
847
|
+
tag(:SubjectHeadingText, by_lan[language].map(&:keyword).join("; "), language: language)
|
848
|
+
end
|
849
|
+
end
|
850
|
+
end
|
726
851
|
end
|
727
852
|
|
728
853
|
|
@@ -736,7 +861,7 @@ module Elibri
|
|
736
861
|
#
|
737
862
|
#
|
738
863
|
# W przypadku właściwego uzupełnienia danych w eLibri, system potrafi podzielić fragmenty personaliów
|
739
|
-
# autora i wyeksportować je w oddzielnych tagach ONIX. Rozróżniane są następujące fragmenty: tytuł naukowy (<TitlesBeforeNames>),
|
864
|
+
# autora i wyeksportować je w oddzielnych tagach ONIX. Rozróżniane są następujące fragmenty: tytuł naukowy (<TitlesBeforeNames>),
|
740
865
|
# imię (<NamesBeforeKey>), prefix nazwiska (von, van - <PrefixToKey>), nazwisko (<KeyNames>),
|
741
866
|
# postfix nazwiska (najczęściej określenie zakonu, np. OP - <NamesAfterKey>).
|
742
867
|
# Zawsze jest jednak exportowane pełne brzemienie imienia i nazwiska (<PersonName>)
|
@@ -763,25 +888,29 @@ module Elibri
|
|
763
888
|
comment 'Gdy wyszczególniono autorów', :kind => :onix_contributors if product.contributors && product.contributors.size > 0
|
764
889
|
product.contributors.each_with_index do |contributor, idx|
|
765
890
|
options = {}
|
766
|
-
|
767
|
-
|
891
|
+
unless @skip_sourcename_and_timestamp
|
892
|
+
options[:sourcename] = "contributorid:#{contributor.id}" if contributor.respond_to?(:id)
|
893
|
+
options[:datestamp] = contributor.updated_at.to_s(:onix) if contributor.respond_to?(:updated_at)
|
894
|
+
end
|
768
895
|
tag(:Contributor, options) do
|
769
896
|
tag(:SequenceNumber, idx + 1)
|
770
897
|
comment_dictionary 'Rola autora', :ContributorRole, :indent => 10, :kind => :onix_contributors
|
771
898
|
tag(:ContributorRole, contributor.role_onix_code) #lista 17
|
772
899
|
comment 'Tylko w przypadku tłumaczy:', :kind => :onix_contributors
|
773
900
|
tag(:FromLanguage, contributor.language_onix_code) if field_exists?(contributor, :language_onix_code)
|
774
|
-
tag(:PersonName, contributor.generated_full_name)
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
901
|
+
tag(:PersonName, contributor.generated_full_name)
|
902
|
+
if field_exists?(contributor, :name) && field_exists?(contributor, :last_name) #muszą być przynajmniej te dwa pola
|
903
|
+
tag(:TitlesBeforeNames, contributor.title) if field_exists?(contributor, :title)
|
904
|
+
tag(:NamesBeforeKey, contributor.name) if field_exists?(contributor, :name)
|
905
|
+
tag(:PrefixToKey, contributor.last_name_prefix) if field_exists?(contributor, :last_name_prefix)
|
906
|
+
tag(:KeyNames, contributor.last_name) if field_exists?(contributor, :last_name)
|
907
|
+
tag(:NamesAfterKey, contributor.last_name_postfix) if field_exists?(contributor, :last_name_postfix)
|
908
|
+
end
|
780
909
|
if contributor.respond_to?(:biography) && contributor.biography && contributor.biography.text && contributor.biography.text.strip.size > 0
|
781
|
-
tag(:BiographicalNote, contributor.biography.text)
|
910
|
+
tag(:BiographicalNote, contributor.biography.text)
|
782
911
|
end
|
783
912
|
end
|
784
|
-
end
|
913
|
+
end
|
785
914
|
end
|
786
915
|
|
787
916
|
if product.authorship_kind == "collective"
|
@@ -803,9 +932,9 @@ module Elibri
|
|
803
932
|
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm
|
804
933
|
# @title Tytuły
|
805
934
|
# W dokumencie XML mogą pojawić się 3 typy tytułu: pełen tytuł produktu, tytuł w języku oryginału (jeśli jest tłumaczeniem)
|
806
|
-
# oraz roboczy tytuł nadany przez wydawcę.
|
935
|
+
# oraz roboczy tytuł nadany przez wydawcę.
|
807
936
|
# @render onix_titles_example
|
808
|
-
#
|
937
|
+
#
|
809
938
|
# Tytuł może być też kaskadowy. Dobrym przykładem jest na przykład Thorgal, komiks, który ma wiele tomów, każdy tom ma swój numer, jak i tytuł.
|
810
939
|
# W kategoriach ONIX-a Thorgal jest kolekcją. Od serii odróżnia go to, że jest częścią tytułu. Innym dobrym przykładem jest książka "Gra o Tron",
|
811
940
|
# która należy do kolekcji "Pieśń Lodu i Ognia" - ponieważ jest to częścią tytułu.
|
@@ -826,24 +955,35 @@ module Elibri
|
|
826
955
|
end
|
827
956
|
tag(:TitleElementLevel, title_part.level) #odnosi się do tego produktu tylko
|
828
957
|
tag(:PartNumber, title_part.part) if field_exists?(title_part, :part)
|
829
|
-
tag(:TitleText, title_part.title) if field_exists?(title_part, :title)
|
830
|
-
tag(:Subtitle, title_part.subtitle) if field_exists?(title_part, :subtitle)
|
958
|
+
tag(:TitleText, title_part.title.strip, language: @lan) if field_exists?(title_part, :title)
|
959
|
+
tag(:Subtitle, title_part.subtitle.strip, language: @lan) if field_exists?(title_part, :subtitle)
|
831
960
|
end
|
832
961
|
end
|
833
|
-
end
|
962
|
+
end
|
834
963
|
end
|
835
964
|
|
965
|
+
if field_exists?(product, :title_eng)
|
966
|
+
tag(:TitleDetail) do
|
967
|
+
tag(:TitleType, Elibri::ONIX::Dict::Release_3_0::TitleType::DISTINCTIVE_TITLE)
|
968
|
+
tag(:TitleElement) do
|
969
|
+
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT)
|
970
|
+
tag(:TitleText, product.title_eng.strip, language: "eng")
|
971
|
+
end
|
972
|
+
end
|
973
|
+
end
|
974
|
+
|
975
|
+
|
836
976
|
if field_exists?(product, :original_title)
|
837
977
|
tag(:TitleDetail) do
|
838
|
-
comment "Tytuł w języku oryginału - #{Elibri::ONIX::Dict::Release_3_0::TitleType::
|
978
|
+
comment "Tytuł w języku oryginału - #{Elibri::ONIX::Dict::Release_3_0::TitleType::ORIGINAL_TITLE}", :kind => :onix_titles
|
839
979
|
tag(:TitleType, Elibri::ONIX::Dict::Release_3_0::TitleType::ORIGINAL_TITLE)
|
840
980
|
tag(:TitleElement) do
|
841
981
|
comment "Tytuł na poziomie produktu - #{Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT}", :kind => :onix_titles
|
842
|
-
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT)
|
843
|
-
tag(:TitleText, product.original_title)
|
982
|
+
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT)
|
983
|
+
tag(:TitleText, product.original_title.strip)
|
844
984
|
end
|
845
|
-
end
|
846
|
-
end
|
985
|
+
end
|
986
|
+
end
|
847
987
|
|
848
988
|
if field_exists?(product, :trade_title)
|
849
989
|
tag(:TitleDetail) do
|
@@ -851,7 +991,7 @@ module Elibri
|
|
851
991
|
tag(:TitleType, Elibri::ONIX::Dict::Release_3_0::TitleType::DISTRIBUTORS_TITLE) #tytuł produktu
|
852
992
|
tag(:TitleElement) do
|
853
993
|
comment "Tytuł na poziomie produktu - #{Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT}", :kind => :onix_titles
|
854
|
-
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT)
|
994
|
+
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::PRODUCT)
|
855
995
|
tag(:TitleText, product.trade_title)
|
856
996
|
end
|
857
997
|
end
|
@@ -861,8 +1001,20 @@ module Elibri
|
|
861
1001
|
|
862
1002
|
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm TitleDetail
|
863
1003
|
# @title Opis wydania
|
1004
|
+
# System elibri pozwala na dodatkowe opisanie typu wydania w <EditionType>:
|
1005
|
+
# <ul>
|
1006
|
+
# <li>LTE - edycja z powiększoną czcionką</li>
|
1007
|
+
# <li>CRI - wydanie krytyczne (z komentarzem)</li>
|
1008
|
+
# <li>BLL - wydanie dwujęzyczne</li>
|
1009
|
+
# <li>FAC - reprint</li>
|
1010
|
+
# </ul>
|
1011
|
+
# Dodatkowo można określić numer wydania w <EditionStatement>
|
864
1012
|
def export_edition!(product)
|
865
|
-
if field_exists?(product, :
|
1013
|
+
if field_exists?(product, :edition_type_onix_code)
|
1014
|
+
comment 'Typ wydania', :kind => :onix_edition
|
1015
|
+
tag(:EditionType, product.edition_type_onix_code)
|
1016
|
+
end
|
1017
|
+
if field_exists?(product, :edition_statement)
|
866
1018
|
comment 'Opis wydania', :kind => :onix_edition
|
867
1019
|
tag(:EditionStatement, product.edition_statement)
|
868
1020
|
end
|
@@ -870,7 +1022,7 @@ module Elibri
|
|
870
1022
|
|
871
1023
|
|
872
1024
|
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm TitleDetail
|
873
|
-
# @title Języki
|
1025
|
+
# @title Języki
|
874
1026
|
# Języki, w których dostępny jest produkt.
|
875
1027
|
def export_languages!(product)
|
876
1028
|
if product.respond_to?(:languages)
|
@@ -881,14 +1033,14 @@ module Elibri
|
|
881
1033
|
tag(:LanguageCode, language.language_onix_code) #lista 74
|
882
1034
|
end
|
883
1035
|
end
|
884
|
-
end
|
1036
|
+
end
|
885
1037
|
end
|
886
1038
|
|
887
1039
|
|
888
1040
|
# @hidden_tags RecordReference NotificationType ProductIdentifier DescriptiveDetail
|
889
1041
|
# @title Teksty
|
890
1042
|
# Wydawca może wprowadzić do eLibri różne informacje tekstowe - opis produktu, spis treści, recenzję (jeśli ma prawa ją udostępnić), jak i fragment książki.
|
891
|
-
# Biogramy autorów są udostępniane wraz z informacjami o
|
1043
|
+
# Biogramy autorów są udostępniane wraz z informacjami o
|
892
1044
|
# = link_to "autorach", doc_api_path("onix_contributors")
|
893
1045
|
def export_texts!(product)
|
894
1046
|
comment_dictionary 'Typy tekstów', :OtherTextType, :indent => 10, :kind => :onix_texts if product.other_texts && product.other_texts.size > 0
|
@@ -897,28 +1049,51 @@ module Elibri
|
|
897
1049
|
next if other_text.text.nil? || other_text.text.strip.size == 0 || other_text.type_onix_code.nil? || other_text.type_onix_code.strip.size == 0 || !other_text.exportable?
|
898
1050
|
|
899
1051
|
options = {}
|
900
|
-
|
901
|
-
|
1052
|
+
unless @skip_sourcename_and_timestamp
|
1053
|
+
options[:sourcename] = "textid:#{other_text.id}" if other_text.respond_to?(:id)
|
1054
|
+
options[:datestamp] = other_text.updated_at.to_s(:onix) if other_text.respond_to?(:updated_at)
|
1055
|
+
end
|
902
1056
|
tag(:TextContent, options) do
|
903
1057
|
tag(:TextType, other_text.type_onix_code) #lista 153
|
904
1058
|
comment "Zawsze #{Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED} - Unrestricted", :kind => :onix_texts
|
905
1059
|
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
906
1060
|
|
907
|
-
if other_text.respond_to?(:is_a_review?) && other_text.respond_to?(:resource_link) &&
|
1061
|
+
if other_text.respond_to?(:is_a_review?) && other_text.respond_to?(:resource_link) &&
|
908
1062
|
other_text.is_a_review? && other_text.resource_link && other_text.resource_link.size > 0
|
909
1063
|
text_source = {:sourcename => other_text.resource_link}
|
910
1064
|
else
|
911
1065
|
text_source = {}
|
912
1066
|
end
|
913
1067
|
|
914
|
-
tag(:Text, text_source) do |builder|
|
1068
|
+
tag(:Text, text_source.merge(language: @lan)) do |builder|
|
915
1069
|
builder.cdata!(other_text.text)
|
916
1070
|
end
|
917
1071
|
|
918
|
-
|
919
|
-
|
1072
|
+
if field_exists?(other_text, :text_eng)
|
1073
|
+
tag(:Text, language: "eng") do |builder|
|
1074
|
+
builder.cdata!(other_text.text_eng)
|
1075
|
+
end
|
1076
|
+
end
|
1077
|
+
|
1078
|
+
tag(:TextAuthor, other_text.text_author) if field_exists?(other_text, :text_author)
|
1079
|
+
tag(:SourceTitle, other_text.source_title) if field_exists?(other_text, :source_title)
|
1080
|
+
end
|
1081
|
+
end
|
1082
|
+
if field_exists?(product, :open_access_statement)
|
1083
|
+
tag(:TextContent) do
|
1084
|
+
tag(:TextType, Elibri::ONIX::Dict::Release_3_0::OtherTextType::OPEN_ACCESS_STATEMENT)
|
1085
|
+
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
1086
|
+
tag(:Text, product.open_access_statement)
|
1087
|
+
end
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
if field_exists?(product, :box_content)
|
1091
|
+
tag(:TextContent) do
|
1092
|
+
tag(:TextType, Elibri::ONIX::Dict::Release_3_0::OtherTextType::LIST_OF_CONTENTS)
|
1093
|
+
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
1094
|
+
tag(:Text, product.box_content)
|
920
1095
|
end
|
921
|
-
end
|
1096
|
+
end
|
922
1097
|
end
|
923
1098
|
|
924
1099
|
|
@@ -930,8 +1105,10 @@ module Elibri
|
|
930
1105
|
product.attachments.each do |attachment|
|
931
1106
|
if attachment.onix_resource_mode #jeśli klient coś dzikiego wgrał, to ignoruj to
|
932
1107
|
options = {}
|
933
|
-
|
934
|
-
|
1108
|
+
unless @skip_sourcename_and_timestamp
|
1109
|
+
options[:sourcename] = "resourceid:#{attachment.id}" if attachment.respond_to?(:id)
|
1110
|
+
options[:datestamp] = attachment.updated_at.to_s(:onix) if attachment.respond_to?(:updated_at)
|
1111
|
+
end
|
935
1112
|
tag(:SupportingResource, options) do
|
936
1113
|
comment_dictionary 'Typ załącznika', :ResourceContentType, :indent => 12, :kind => :onix_supporting_resources
|
937
1114
|
tag(:ResourceContentType, attachment.attachment_type_code) #lista 158
|
@@ -942,20 +1119,77 @@ module Elibri
|
|
942
1119
|
tag(:ResourceVersion) do
|
943
1120
|
comment 'Zawsze 02 - Downloadable file', :kind => :onix_supporting_resources
|
944
1121
|
tag(:ResourceForm, Elibri::ONIX::Dict::Release_3_0::ResourceForm::DOWNLOADABLE_FILE)
|
945
|
-
|
946
|
-
if
|
947
|
-
tag(:
|
948
|
-
|
949
|
-
|
1122
|
+
tag(:ResourceLink, URI.escape(attachment.url_for_onix))
|
1123
|
+
if attachment.respond_to?(:updated_at)
|
1124
|
+
tag(:ContentDate) do
|
1125
|
+
tag(:ContentDateRole, Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED)
|
1126
|
+
tag(:Date, attachment.updated_at.utc.strftime("%Y%m%dT%H%MZ"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDDTHHMM)
|
1127
|
+
end
|
950
1128
|
end
|
951
|
-
|
1129
|
+
end
|
952
1130
|
end
|
953
1131
|
end
|
954
|
-
end
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
if product.respond_to?(:preview) && product.preview
|
1135
|
+
options = {}
|
1136
|
+
tag(:SupportingResource) do
|
1137
|
+
tag(:ResourceContentType, Elibri::ONIX::Dict::Release_3_0::ResourceContentType::WIDGET) #lista 158
|
1138
|
+
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
1139
|
+
tag(:ResourceMode, Elibri::ONIX::Dict::Release_3_0::ResourceMode::TEXT) #lista 159
|
1140
|
+
tag(:ResourceVersion) do
|
1141
|
+
tag(:ResourceForm, Elibri::ONIX::Dict::Release_3_0::ResourceForm::EMBEDDABLE_APPLICATION)
|
1142
|
+
tag(:ResourceLink, URI.escape(product.preview.url_for_onix))
|
1143
|
+
tag(:ContentDate) do
|
1144
|
+
tag(:ContentDateRole, Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED)
|
1145
|
+
tag(:Date, product.preview.updated_at.utc.strftime("%Y%m%dT%H%MZ"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDDTHHMM)
|
1146
|
+
end
|
1147
|
+
end
|
1148
|
+
end
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
if product.respond_to?(:digital?) && product.digital? && product.respond_to?(:excerpts) && product.excerpts.present?
|
1152
|
+
options = {}
|
1153
|
+
tag(:SupportingResource) do
|
1154
|
+
tag(:ResourceContentType, Elibri::ONIX::Dict::Release_3_0::ResourceContentType::SAMPLE_CONTENT)
|
1155
|
+
tag(:ContentAudience, Elibri::ONIX::Dict::Release_3_0::ContentAudience::UNRESTRICTED)
|
1156
|
+
tag(:ResourceMode, product.excerpt_onix_resource_mode) #lista 159
|
1157
|
+
product.excerpts.each do |excerpt|
|
1158
|
+
tag(:ResourceVersion) do
|
1159
|
+
tag(:ResourceForm, Elibri::ONIX::Dict::Release_3_0::ResourceForm::DOWNLOADABLE_FILE)
|
1160
|
+
|
1161
|
+
comment 'format pliku'
|
1162
|
+
tag(:ResourceVersionFeature) do
|
1163
|
+
tag(:ResourceVersionFeatureType, Elibri::ONIX::Dict::Release_3_0::ResourceVersionFeatureType::FILE_FORMAT) #lista 162
|
1164
|
+
tag(:FeatureValue, excerpt.excerpt_onix_type_name)
|
1165
|
+
end
|
1166
|
+
|
1167
|
+
comment 'md5 pliku'
|
1168
|
+
tag(:ResourceVersionFeature) do
|
1169
|
+
tag(:ResourceVersionFeatureType, Elibri::ONIX::Dict::Release_3_0::ResourceVersionFeatureType::MD5_HASH_VALUE) #lista 162
|
1170
|
+
tag(:FeatureValue, excerpt.file_md5)
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
comment 'wielkość pliku w bajtach'
|
1174
|
+
tag(:ResourceVersionFeature) do
|
1175
|
+
tag(:ResourceVersionFeatureType, Elibri::ONIX::Dict::Release_3_0::ResourceVersionFeatureType::SIZE_IN_BYTES) #lista 162
|
1176
|
+
tag(:FeatureValue, excerpt.stored_file_size)
|
1177
|
+
end
|
1178
|
+
|
1179
|
+
url = "https://www.elibri.com.pl/excerpt/#{excerpt.id}/#{excerpt.file_md5}/#{excerpt.canonical_file_name}"
|
1180
|
+
tag(:ResourceLink, URI.escape(url))
|
1181
|
+
tag(:ContentDate) do
|
1182
|
+
tag(:ContentDateRole, Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED)
|
1183
|
+
tag(:Date, excerpt.stored_updated_at.utc.strftime("%Y%m%dT%H%MZ"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDDTHHMM)
|
1184
|
+
end
|
1185
|
+
end
|
1186
|
+
end
|
1187
|
+
end
|
1188
|
+
end
|
955
1189
|
end
|
956
1190
|
|
957
1191
|
|
958
|
-
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm
|
1192
|
+
# @hidden_tags RecordReference NotificationType ProductIdentifier ProductComposition ProductForm
|
959
1193
|
# @title Serie wydawnicze
|
960
1194
|
# Serie wydawnicze są opisywane w podobny sposób co tytuł, zawarte są jednak w tagu <strong><Collection></strong>
|
961
1195
|
# Struktura jest dosyć zawiła, ale wszystkie wartości są sztywne, więc nie powinno być problemu z odczytaniem informacji.
|
@@ -982,12 +1216,12 @@ module Elibri
|
|
982
1216
|
tag(:TitleElement) do
|
983
1217
|
comment "Używamy tylko #{Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::COLLECTION}", :kind => :onix_series_memberships
|
984
1218
|
tag(:TitleElementLevel, Elibri::ONIX::Dict::Release_3_0::TitleElementLevel::COLLECTION)
|
985
|
-
tag(:PartNumber, series_membership.number_within_series) if series_membership
|
1219
|
+
tag(:PartNumber, series_membership.number_within_series) if field_exists?(series_membership, :number_within_series)
|
986
1220
|
tag(:TitleText, series_membership.series_name)
|
987
1221
|
end
|
988
1222
|
end
|
989
1223
|
end
|
990
|
-
end
|
1224
|
+
end
|
991
1225
|
end
|
992
1226
|
end
|
993
1227
|
|
@@ -998,16 +1232,16 @@ module Elibri
|
|
998
1232
|
tag(:RelatedMaterial) do
|
999
1233
|
|
1000
1234
|
comment_dictionary "Typy relacji", :ProductRelationType, :indent => 10, :kind => :onix_related_products
|
1001
|
-
product.
|
1235
|
+
product.facsimiles_for_onix.each do |facsimile|
|
1002
1236
|
tag(:RelatedProduct) do
|
1003
1237
|
tag(:ProductRelationCode, Elibri::ONIX::Dict::Release_3_0::ProductRelationType::FACSIMILES)
|
1004
1238
|
tag(:ProductIdentifier) do
|
1005
|
-
comment "Zawsze #{Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY} - wewnętrzny kod elibri (record reference)",
|
1239
|
+
comment "Zawsze #{Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY} - wewnętrzny kod elibri (record reference)",
|
1006
1240
|
:kind => :onix_related_products
|
1007
1241
|
tag(:ProductIDType, Elibri::ONIX::Dict::Release_3_0::ProductIDType::PROPRIETARY)
|
1008
1242
|
tag(:IDTypeName, "elibri")
|
1009
1243
|
tag(:IDValue, facsimile.record_reference)
|
1010
|
-
end
|
1244
|
+
end
|
1011
1245
|
end
|
1012
1246
|
end
|
1013
1247
|
end
|
@@ -1030,69 +1264,115 @@ module Elibri
|
|
1030
1264
|
tag(:Supplier) do
|
1031
1265
|
comment_dictionary "Rola dostawcy", :SupplierRole, :indent => 12
|
1032
1266
|
tag(:SupplierRole, pa.supplier_role_onix_code) #lista 93
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1267
|
+
if pa.supplier.vatid.present?
|
1268
|
+
tag(:SupplierIdentifier) do
|
1269
|
+
comment "Zawsze 02 - Proprietary. Identyfikujemy dostawcę po NIP"
|
1270
|
+
tag(:SupplierIDType, Elibri::ONIX::Dict::Release_3_0::SupplierIDType::VAT_IDENTITY_NUMBER) #lista 92, NIP
|
1271
|
+
tag(:IDValue, pa.supplier.vatid)
|
1272
|
+
end
|
1038
1273
|
end
|
1039
1274
|
tag(:SupplierName, pa.supplier.name)
|
1040
1275
|
tag(:TelephoneNumber, pa.supplier.phone) if field_exists?(pa.supplier, :phone)
|
1041
1276
|
tag(:EmailAddress, pa.supplier.email) if field_exists?(pa.supplier, :email)
|
1042
|
-
if field_exists?(pa
|
1043
|
-
|
1044
|
-
tag(:
|
1277
|
+
if field_exists?(pa, :website)
|
1278
|
+
Array(pa.website).each do |website|
|
1279
|
+
tag(:Website) do
|
1280
|
+
tag(:WebsiteRole, website.role)
|
1281
|
+
tag(:WebsiteDescription, website.description)
|
1282
|
+
tag(:WebsiteLink, website.url)
|
1283
|
+
end
|
1045
1284
|
end
|
1046
1285
|
end
|
1047
1286
|
end
|
1287
|
+
if field_exists?(product, :additional_info)
|
1288
|
+
comment 'Dodatkowa klasyfikacja sprzedażowa od wydawcy - np. promocja, albo wyprzedaż'
|
1289
|
+
tag(:SupplierOwnCoding) do
|
1290
|
+
tag(:SupplierCodeType, Elibri::ONIX::Dict::Release_3_0::SupplierOwnCodeType::SUPPLIERS_SALES_CLASSIFICATION)
|
1291
|
+
tag(:SupplierCodeValue, product.additional_info)
|
1292
|
+
end
|
1293
|
+
end
|
1048
1294
|
|
1049
1295
|
comment_dictionary "Typ dostępności", :ProductAvailabilityType, :indent => 10
|
1050
1296
|
tag(:ProductAvailability, pa.product_availability_onix_code) #lista 65
|
1051
|
-
if pa
|
1297
|
+
if field_exists?(pa, :stock_info)
|
1052
1298
|
tag(:Stock) do
|
1053
|
-
|
1054
|
-
|
1055
|
-
else
|
1056
|
-
comment 'Nie znamy konkretnej ilości produktów na stanie'
|
1057
|
-
tag(:StockQuantityCoded) do
|
1058
|
-
comment 'Zawsze 01 - Proprietary'
|
1059
|
-
tag(:StockQuantityCodeType, '01') #lista 70 - proprietary
|
1060
|
-
tag(:StockQuantityCode, pa.stock_info.quantity_code) #low/high
|
1061
|
-
end
|
1062
|
-
end
|
1299
|
+
tag(:OnHand, pa.stock_info.on_hand)
|
1300
|
+
tag(:Proximity, pa.stock_info.proximity)
|
1063
1301
|
end
|
1064
1302
|
end
|
1065
|
-
if product.pack_quantity
|
1303
|
+
if field_exists?(product, :pack_quantity) && product.pack_quantity.to_i > 0
|
1066
1304
|
comment 'Ile produktów dostawca umieszcza w paczce'
|
1067
1305
|
tag(:PackQuantity, product.pack_quantity)
|
1068
1306
|
end
|
1069
1307
|
|
1070
|
-
|
1071
|
-
tag(:
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
tag(:
|
1077
|
-
|
1078
|
-
tag(:
|
1079
|
-
tag(:
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
tag(:
|
1308
|
+
if product.respond_to?(:unpriced_item?) && product.unpriced_item?
|
1309
|
+
tag(:UnpricedItemType, Elibri::ONIX::Dict::Release_3_0::UnpricedItemType::FREE_OF_CHARGE)
|
1310
|
+
end
|
1311
|
+
|
1312
|
+
if pa.respond_to?(:price_infos)
|
1313
|
+
pa.price_infos.each do |price_info|
|
1314
|
+
tag(:Price) do
|
1315
|
+
comment_dictionary "Typ ceny", :PriceTypeCode, :indent => 12
|
1316
|
+
tag(:PriceType, Elibri::ONIX::Dict::Release_3_0::PriceTypeCode::RRP_WITH_TAX) #lista 58
|
1317
|
+
tag(:MinimumOrderQuantity, price_info.minimum_order_quantity) if price_info.minimum_order_quantity
|
1318
|
+
tag(:PriceAmount, price_info.amount)
|
1319
|
+
tag(:Tax) do
|
1320
|
+
comment 'VAT'
|
1321
|
+
tag(:TaxType, Elibri::ONIX::Dict::Release_3_0::TaxType::VAT) #lista 171, VAT
|
1322
|
+
tag(:TaxRatePercent, price_info.vat)
|
1323
|
+
end
|
1324
|
+
tag(:CurrencyCode, price_info.currency_code)
|
1325
|
+
if field_exists?(product, :price_printed_on_product_onix_code)
|
1326
|
+
comment_dictionary "Cena na okładce?", :PricePrintedOnProduct, :indent => 12
|
1327
|
+
tag(:PrintedOnProduct, product.price_printed_on_product_onix_code) #lista 174
|
1328
|
+
if product.price_printed_on_product_onix_code == Elibri::ONIX::Dict::Release_3_0::PricePrintedOnProduct::YES
|
1329
|
+
comment 'Zawsze 00 - Unknown / unspecified'
|
1330
|
+
tag(:PositionOnProduct, Elibri::ONIX::Dict::Release_3_0::PricePositionOnProduct::UNKNOW) #lista 142 - Position unknown or unspecified
|
1331
|
+
end
|
1332
|
+
end
|
1087
1333
|
end
|
1088
1334
|
end
|
1089
1335
|
end
|
1090
1336
|
end
|
1091
1337
|
end
|
1092
1338
|
end
|
1093
|
-
end
|
1339
|
+
end
|
1094
1340
|
end
|
1095
1341
|
|
1342
|
+
def export_masters_info!(product)
|
1343
|
+
if product.respond_to?(:digital_or_pod?) && product.digital_or_pod? && product.respond_to?(:masters) && product.masters.size > 0
|
1344
|
+
tag("ProductionDetail") do
|
1345
|
+
tag("ProductionManifest") do
|
1346
|
+
tag("BodyManifest") do
|
1347
|
+
product.masters.each_with_index do |master, idx|
|
1348
|
+
tag("BodyResource") do
|
1349
|
+
tag("SequenceNumber", idx + 1)
|
1350
|
+
tag("ResourceIdentifier") do
|
1351
|
+
tag("ResourceIDType", Elibri::ONIX::Dict::Release_3_0::ResourceIDType::PROPRIETARY)
|
1352
|
+
tag("IDTypeName", "elibri internal numerical ID")
|
1353
|
+
tag("IDValue", master.id)
|
1354
|
+
end
|
1355
|
+
tag("ResourceFileFeature") do
|
1356
|
+
tag("ResourceFileFeatureType", Elibri::ONIX::Dict::Release_3_0::ResourceFileFeatureType::EXACT_FILE_SIZE)
|
1357
|
+
tag("ResourceFileFeatureValue", master.stored_file_size)
|
1358
|
+
end
|
1359
|
+
|
1360
|
+
tag("ResourceFileFeature") do
|
1361
|
+
tag("ResourceFileFeatureType", Elibri::ONIX::Dict::Release_3_0::ResourceFileFeatureType::MD5)
|
1362
|
+
tag("ResourceFileFeatureValue", master.file_md5)
|
1363
|
+
end
|
1364
|
+
tag("ResourceFileLink", master.stored_file_name)
|
1365
|
+
tag("ResourceFileDate") do
|
1366
|
+
tag("ResourceFileDateRole", Elibri::ONIX::Dict::Release_3_0::ContentDateRole::LAST_UPDATED)
|
1367
|
+
tag("Date", master.stored_updated_at.utc.strftime("%Y%m%dT%H%MZ"), dateformat: Elibri::ONIX::Dict::Release_3_0::DateFormat::YYYYMMDDTHHMM)
|
1368
|
+
end
|
1369
|
+
end
|
1370
|
+
end
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
end
|
1375
|
+
end
|
1096
1376
|
|
1097
1377
|
# @title Rozszerzenia eLibri dla ONIX
|
1098
1378
|
# @hidden_tags RecordReference NotificationType ProductIdentifier DescriptiveDetail
|
@@ -1129,9 +1409,9 @@ module Elibri
|
|
1129
1409
|
tag("elibri:HyphenatedISBN", product.isbn.human_value)
|
1130
1410
|
end
|
1131
1411
|
|
1132
|
-
if product.respond_to?(:
|
1412
|
+
if product.respond_to?(:digital_or_pod?) && product.digital_or_pod?
|
1133
1413
|
if product.excerpts.size > 0
|
1134
|
-
tag("elibri:excerpts") do
|
1414
|
+
tag("elibri:excerpts") do
|
1135
1415
|
product.excerpts.each do |excerpt|
|
1136
1416
|
tag("elibri:excerpt", "https://www.elibri.com.pl/excerpt/#{excerpt.id}", :md5 => excerpt.file_md5, :file_size => excerpt.stored_file_size,
|
1137
1417
|
:file_type => excerpt.file_type, :updated_at => excerpt.stored_updated_at.to_datetime.xmlschema, :id => excerpt.id)
|