enju_biblio 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/app/controllers/manifestations_controller.rb +36 -20
  2. data/app/controllers/picture_files_controller.rb +25 -16
  3. data/app/controllers/series_has_manifestations_controller.rb +4 -0
  4. data/app/controllers/series_statements_controller.rb +9 -7
  5. data/app/helpers/series_statements_helper.rb +6 -0
  6. data/app/models/item.rb +3 -0
  7. data/app/models/manifestation.rb +29 -15
  8. data/app/models/patron.rb +2 -0
  9. data/app/models/resource_import_file.rb +47 -12
  10. data/app/models/series_has_manifestation.rb +2 -3
  11. data/app/views/carrier_types/index.html.erb +1 -1
  12. data/app/views/content_types/index.html.erb +1 -1
  13. data/app/views/create_types/index.html.erb +1 -1
  14. data/app/views/creates/_index.html.erb +1 -1
  15. data/app/views/creates/_index_patron.html.erb +1 -1
  16. data/app/views/creates/_index_work.html.erb +2 -9
  17. data/app/views/donates/index.html.erb +1 -1
  18. data/app/views/exemplifies/index.html.erb +1 -1
  19. data/app/views/extents/index.html.erb +1 -1
  20. data/app/views/form_of_works/index.html.erb +1 -1
  21. data/app/views/frequencies/index.html.erb +1 -1
  22. data/app/views/import_requests/index.html.erb +1 -1
  23. data/app/views/import_requests/new.html.erb +1 -1
  24. data/app/views/items/edit.html.erb +1 -1
  25. data/app/views/items/show.html.erb +2 -1
  26. data/app/views/licenses/index.html.erb +1 -1
  27. data/app/views/manifestation_relationship_types/index.html.erb +1 -1
  28. data/app/views/manifestation_relationships/index.html.erb +1 -1
  29. data/app/views/manifestations/_form.html.erb +1 -1
  30. data/app/views/manifestations/_manifestation.html.erb +21 -17
  31. data/app/views/manifestations/_paginate_id_link.html.erb +20 -2
  32. data/app/views/manifestations/_session_ids.html.erb +10 -0
  33. data/app/views/manifestations/_show_detail_librarian.html.erb +7 -5
  34. data/app/views/manifestations/_show_detail_user.html.erb +7 -5
  35. data/app/views/manifestations/_show_index.html.erb +7 -1
  36. data/app/views/manifestations/_show_series_index.html.erb +15 -0
  37. data/app/views/manifestations/_show_series_statement.html.erb +30 -0
  38. data/app/views/manifestations/_submenu_series_statement.html.erb +8 -0
  39. data/app/views/manifestations/edit.html.erb +1 -1
  40. data/app/views/manifestations/index.html.erb +11 -0
  41. data/app/views/manifestations/show.html.erb +2 -2
  42. data/app/views/medium_of_performances/index.html.erb +1 -1
  43. data/app/views/owns/index.html.erb +1 -1
  44. data/app/views/patron_import_files/index.html.erb +1 -1
  45. data/app/views/patron_import_results/index.html.erb +1 -1
  46. data/app/views/patron_relationship_types/index.html.erb +1 -1
  47. data/app/views/patron_relationships/index.html.erb +1 -1
  48. data/app/views/patron_types/index.html.erb +1 -1
  49. data/app/views/patrons/_index_expression.html.erb +2 -1
  50. data/app/views/patrons/_index_manifestation.html.erb +2 -1
  51. data/app/views/patrons/_index_patron.html.erb +1 -1
  52. data/app/views/patrons/_index_patron_merge_list.html.erb +1 -1
  53. data/app/views/patrons/_index_work.html.erb +2 -1
  54. data/app/views/patrons/edit.html.erb +1 -1
  55. data/app/views/patrons/show.html.erb +1 -1
  56. data/app/views/picture_files/_index.html.erb +1 -1
  57. data/app/views/picture_files/_index_event.html.erb +1 -1
  58. data/app/views/picture_files/_index_manifestation.html.erb +1 -1
  59. data/app/views/picture_files/_index_patron.html.erb +1 -1
  60. data/app/views/picture_files/_index_shelf.html.erb +1 -1
  61. data/app/views/picture_files/_link.mobile.erb +3 -0
  62. data/app/views/picture_files/show.mobile.erb +49 -0
  63. data/app/views/produce_types/index.html.erb +1 -1
  64. data/app/views/produces/_index.html.erb +1 -1
  65. data/app/views/produces/_index_manifestation.html.erb +5 -11
  66. data/app/views/produces/_index_patron.html.erb +1 -1
  67. data/app/views/realize_types/index.html.erb +1 -1
  68. data/app/views/realizes/_index.html.erb +1 -1
  69. data/app/views/realizes/_index_expression.html.erb +5 -11
  70. data/app/views/realizes/_index_patron.html.erb +1 -1
  71. data/app/views/resource_import_files/index.html.erb +1 -1
  72. data/app/views/resource_import_results/index.html.erb +1 -1
  73. data/app/views/series_has_manifestations/index.html.erb +1 -1
  74. data/app/views/series_statements/_index.html.erb +1 -1
  75. data/app/views/series_statements/_index_manifestation.html.erb +1 -1
  76. data/app/views/series_statements/_index_series_statement_merge_list.html.erb +1 -1
  77. data/app/views/series_statements/show.html.erb +0 -3
  78. data/config/locales/translation_en.yml +34 -0
  79. data/config/locales/translation_ja.yml +34 -0
  80. data/config/routes.rb +7 -2
  81. data/lib/enju_biblio.rb +0 -5
  82. data/lib/enju_biblio/engine.rb +2 -6
  83. data/lib/enju_biblio/version.rb +1 -1
  84. data/spec/cassette_library/enju_ndl/ndl_search.yml +1140 -0
  85. data/spec/controllers/items_controller_spec.rb +1 -1
  86. data/spec/controllers/series_statements_controller_spec.rb +26 -21
  87. data/spec/dummy/config/application.rb +1 -0
  88. data/spec/dummy/config/routes.rb +1 -1
  89. data/spec/dummy/db/schema.rb +1 -1
  90. data/spec/dummy/db/test.sqlite3 +0 -0
  91. data/spec/dummy/lib/enju_leaf.rb +0 -1
  92. data/spec/dummy/private/system/patron_import_files/patron_imports/000/000/004/original/patron_delete_file.tsv +8 -0
  93. data/spec/dummy/private/system/patron_import_files/patron_imports/000/000/004/original/patron_import_file_sample1.tsv +5 -0
  94. data/spec/dummy/private/system/patron_import_files/patron_imports/000/000/004/original/patron_import_file_sample3.tsv +5 -0
  95. data/spec/dummy/private/system/patron_import_files/patron_imports/000/000/004/original/patron_update_file.tsv +3 -0
  96. data/spec/dummy/private/system/picture_files/pictures/000/000/005/medium/spinner.gif +0 -0
  97. data/spec/dummy/private/system/picture_files/pictures/000/000/005/original/spinner.gif +0 -0
  98. data/spec/dummy/private/system/picture_files/pictures/000/000/005/thumb/spinner.gif +0 -0
  99. data/spec/dummy/private/system/resource_imports/4/original/isbn_sample.txt +3 -0
  100. data/spec/dummy/private/system/resource_imports/4/original/item_delete_file.tsv +11 -0
  101. data/spec/dummy/private/system/resource_imports/4/original/item_update_file.tsv +4 -0
  102. data/spec/dummy/private/system/resource_imports/4/original/resource_import_file_sample1.tsv +19 -0
  103. data/spec/dummy/private/system/resource_imports/4/original/resource_import_file_sample2.tsv +19 -0
  104. data/spec/dummy/private/system/resource_imports/4/original/update_series_statement.tsv +2 -0
  105. data/spec/dummy/solr/data/test/index/_2z.fdt +0 -0
  106. data/spec/dummy/solr/data/test/index/_2z.fdx +0 -0
  107. data/spec/dummy/solr/data/test/index/{_2v.fnm → _2z.fnm} +0 -0
  108. data/spec/dummy/solr/data/test/index/_2z.frq +0 -0
  109. data/spec/dummy/solr/data/test/index/_2z.nrm +1 -0
  110. data/spec/dummy/solr/data/test/index/_2z.prx +0 -0
  111. data/spec/dummy/solr/data/test/index/_2z.tii +0 -0
  112. data/spec/dummy/solr/data/test/index/_2z.tis +0 -0
  113. data/spec/dummy/solr/data/test/index/{_2v.fdt → _39.fdt} +0 -0
  114. data/spec/dummy/solr/data/test/index/{_2v.fdx → _39.fdx} +0 -0
  115. data/spec/dummy/solr/data/test/index/_39.fnm +10 -0
  116. data/spec/dummy/solr/data/test/index/_39.frq +0 -0
  117. data/spec/dummy/solr/data/test/index/_39.nrm +1 -0
  118. data/spec/dummy/solr/data/test/index/_39.prx +0 -0
  119. data/spec/dummy/solr/data/test/index/{_2v.tii → _39.tii} +0 -0
  120. data/spec/dummy/solr/data/test/index/_39.tis +0 -0
  121. data/spec/dummy/solr/data/test/index/_39_1.del +0 -0
  122. data/spec/dummy/solr/data/test/index/_k_3.del +0 -0
  123. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  124. data/spec/dummy/solr/data/test/index/{segments_2v → segments_39} +0 -0
  125. data/spec/dummy/tmp/cache/4F7/F90/default_role +0 -0
  126. data/spec/dummy/tmp/cache/6E4/420/search_engine_all +0 -0
  127. data/spec/fixtures/exemplifies.yml +6 -0
  128. data/spec/models/resource_import_file_spec.rb +8 -0
  129. metadata +88 -129
  130. data/lib/enju_biblio/expire_editable_fragment.rb +0 -30
  131. data/lib/enju_biblio/expire_fragment_cache.rb +0 -17
  132. data/lib/enju_biblio/import_file.rb +0 -13
  133. data/lib/enju_biblio/master_model.rb +0 -19
  134. data/lib/enju_biblio/url_validator.rb +0 -10
  135. data/spec/dummy/app/models/library_group.rb +0 -86
  136. data/spec/dummy/lib/enju_leaf/localized_name.rb +0 -15
  137. data/spec/dummy/solr/data/test/index/_2v.frq +0 -0
  138. data/spec/dummy/solr/data/test/index/_2v.nrm +0 -1
  139. data/spec/dummy/solr/data/test/index/_2v.prx +0 -0
  140. data/spec/dummy/solr/data/test/index/_2v.tis +0 -0
  141. data/spec/dummy/solr/data/test/index/_2v_1.del +0 -0
  142. data/spec/dummy/solr/data/test/index/_k_2.del +0 -0
  143. data/spec/dummy/tmp/cache/4AD/470/country_all +0 -0
@@ -12,7 +12,7 @@ class ManifestationsController < ApplicationController
12
12
  before_filter :get_item, :get_libraries, :only => :index
13
13
  before_filter :prepare_options, :only => [:new, :edit]
14
14
  before_filter :get_version, :only => [:show]
15
- after_filter :solr_commit, :only => [:create, :update, :destroy]
15
+ after_filter :solr_commit, :only => :destroy
16
16
  after_filter :convert_charset, :only => :index
17
17
  cache_sweeper :manifestation_sweeper, :only => [:create, :update, :destroy]
18
18
  include EnjuOai::OaiController if defined?(EnjuOai)
@@ -138,8 +138,12 @@ class ManifestationsController < ApplicationController
138
138
  end
139
139
  if series_statement
140
140
  with(:periodical_master).equal_to false
141
- if mode != 'add'
142
- with(:periodical).equal_to true
141
+ if series_statement.periodical?
142
+ if mode != 'add'
143
+ with(:periodical).equal_to true
144
+ end
145
+ else
146
+ with(:periodical).equal_to false
143
147
  end
144
148
  else
145
149
  if mode != 'add'
@@ -187,20 +191,29 @@ class ManifestationsController < ApplicationController
187
191
  session[:query] = @query
188
192
  end
189
193
 
190
- unless session[:manifestation_ids]
191
- manifestation_ids = search.build do
192
- paginate :page => 1, :per_page => configatron.max_number_of_results
193
- end.execute.raw_results.collect(&:primary_key).map{|id| id.to_i}
194
- session[:manifestation_ids] = manifestation_ids
195
- end
194
+ if params[:format] == 'html' or params[:format].nil?
195
+ @search_query = Digest::SHA1.hexdigest(Marshal.dump(search.query.to_params).force_encoding('UTF-8'))
196
+ if flash[:search_query] == @search_query
197
+ flash.keep(:search_query)
198
+ else
199
+ #raise flash[:search_query].to_s
200
+ flash[:search_query] = @search_query
201
+ @manifestation_ids = search.build do
202
+ paginate :page => 1, :per_page => configatron.max_number_of_results
203
+ end.execute.raw_results.collect(&:primary_key).map{|id| id.to_i}
204
+ end
196
205
 
197
- if defined?(EnjuBookmark)
198
- if session[:manifestation_ids]
206
+ if defined?(EnjuBookmark)
199
207
  if params[:view] == 'tag_cloud'
200
- bookmark_ids = Bookmark.where(:manifestation_id => session[:manifestation_ids]).limit(1000).select(:id).collect(&:id)
208
+ unless @manifestation_ids
209
+ @manifestation_ids = search.build do
210
+ paginate :page => 1, :per_page => configatron.max_number_of_results
211
+ end.execute.raw_results.collect(&:primary_key).map{|id| id.to_i}
212
+ end
213
+ #bookmark_ids = Bookmark.where(:manifestation_id => flash[:manifestation_ids]).limit(1000).select(:id).collect(&:id)
214
+ bookmark_ids = Bookmark.where(:manifestation_id => @manifestation_ids).limit(1000).select(:id).collect(&:id)
201
215
  @tags = Tag.bookmarked(bookmark_ids)
202
216
  render :partial => 'manifestations/tag_cloud'
203
- #session[:manifestation_ids] = nil
204
217
  return
205
218
  end
206
219
  end
@@ -240,7 +253,7 @@ class ManifestationsController < ApplicationController
240
253
 
241
254
  if defined?(EnjuBookmark)
242
255
  # TODO: 検索結果が少ない場合にも表示させる
243
- if manifestation_ids.blank?
256
+ if @manifestation_ids.blank?
244
257
  if query.respond_to?(:suggest_tags)
245
258
  @suggested_tag = query.suggest_tags.first
246
259
  end
@@ -330,10 +343,12 @@ class ManifestationsController < ApplicationController
330
343
 
331
344
  return if render_mode(params[:mode])
332
345
 
346
+ flash.keep(:search_query)
333
347
  store_location
334
348
 
335
349
  if @manifestation.periodical_master?
336
350
  flash.keep(:notice) if flash[:notice]
351
+ flash[:manifestation_id] = @manifestation.id
337
352
  redirect_to series_statement_url(@manifestation.series_statement, :manifestation_id => @manifestation.id)
338
353
  return
339
354
  end
@@ -355,10 +370,6 @@ class ManifestationsController < ApplicationController
355
370
  end
356
371
  end
357
372
 
358
- if session[:manifestation_ids]
359
- @manifestation_ids = session[:manifestation_ids]
360
- end
361
-
362
373
  respond_to do |format|
363
374
  format.html # show.html.erb
364
375
  format.mobile
@@ -416,6 +427,7 @@ class ManifestationsController < ApplicationController
416
427
  end
417
428
  end
418
429
  @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
430
+ @series_statement = @manifestation.series_statement unless @series_statement
419
431
  if defined?(EnjuBookmark)
420
432
  if params[:mode] == 'tag_edit'
421
433
  @bookmark = current_user.bookmarks.where(:manifestation_id => @manifestation.id).first if @manifestation rescue nil
@@ -436,6 +448,7 @@ class ManifestationsController < ApplicationController
436
448
 
437
449
  respond_to do |format|
438
450
  if @manifestation.save
451
+ Sunspot.commit
439
452
  Manifestation.transaction do
440
453
  if @original_manifestation
441
454
  @manifestation.derived_manifestations << @original_manifestation
@@ -457,6 +470,7 @@ class ManifestationsController < ApplicationController
457
470
  def update
458
471
  respond_to do |format|
459
472
  if @manifestation.update_attributes(params[:manifestation])
473
+ Sunspot.commit
460
474
  format.html { redirect_to @manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.manifestation')) }
461
475
  format.json { head :no_content }
462
476
  else
@@ -470,7 +484,9 @@ class ManifestationsController < ApplicationController
470
484
  # DELETE /manifestations/1
471
485
  # DELETE /manifestations/1.json
472
486
  def destroy
487
+ series_statement = @manifestation.series_statement
473
488
  @manifestation.destroy
489
+ series_statement.try(:index!)
474
490
 
475
491
  respond_to do |format|
476
492
  format.html { redirect_to manifestations_url, :notice => t('controller.successfully_deleted', :model => t('activerecord.models.manifestation')) }
@@ -526,7 +542,7 @@ class ManifestationsController < ApplicationController
526
542
  end
527
543
 
528
544
  unless options[:issn].blank?
529
- query = "#{query} issn_s:#{options[:issn].gsub('-', '')}"
545
+ query = "#{query} issn_sm:#{options[:issn].gsub('-', '')}"
530
546
  end
531
547
 
532
548
  unless options[:lccn].blank?
@@ -631,7 +647,7 @@ class ManifestationsController < ApplicationController
631
647
  @roles = Role.all
632
648
  @languages = Language.all_cache
633
649
  @frequencies = Frequency.all
634
- @nii_types = NiiType.all if defined?(NiiType)
650
+ @nii_types = NiiType.all if defined?(EnjuNii)
635
651
  end
636
652
 
637
653
  def get_index_patron
@@ -41,24 +41,14 @@ class PictureFilesController < ApplicationController
41
41
  respond_to do |format|
42
42
  format.html # show.html.erb
43
43
  format.json { render :json => @picture_file }
44
- format.download {
45
- case params[:mode]
46
- when 'download'
47
- disposition = 'attachment'
48
- else
49
- disposition = 'inline'
50
- end
51
-
52
- if @picture_file.picture.path
53
- if configatron.uploaded_file.storage == :s3
54
- send_data data, :filename => File.basename(@picture_file.picture_file_name), :type => @picture_file.picture_content_type, :disposition => disposition
55
- else
56
- if File.exist?(file) and File.file?(file)
57
- send_file file, :filename => File.basename(@picture_file.picture_file_name), :type => @picture_file.picture_content_type, :disposition => disposition
58
- end
59
- end
44
+ format.mobile {
45
+ if params[:format] == 'download'
46
+ render_image(file)
60
47
  end
61
48
  }
49
+ format.download {
50
+ render_image(file)
51
+ }
62
52
  end
63
53
  end
64
54
 
@@ -166,4 +156,23 @@ class PictureFilesController < ApplicationController
166
156
  return
167
157
  end
168
158
  end
159
+
160
+ def render_image(file)
161
+ case params[:mode]
162
+ when 'download'
163
+ disposition = 'attachment'
164
+ else
165
+ disposition = 'inline'
166
+ end
167
+
168
+ if @picture_file.picture.path
169
+ if configatron.uploaded_file.storage == :s3
170
+ send_data data, :filename => File.basename(@picture_file.picture_file_name), :type => @picture_file.picture_content_type, :disposition => disposition
171
+ else
172
+ if File.exist?(file) and File.file?(file)
173
+ send_file file, :filename => File.basename(@picture_file.picture_file_name), :type => @picture_file.picture_content_type, :disposition => disposition
174
+ end
175
+ end
176
+ end
177
+ end
169
178
  end
@@ -52,6 +52,7 @@ class SeriesHasManifestationsController < ApplicationController
52
52
  def create
53
53
  respond_to do |format|
54
54
  if @series_has_manifestation.save
55
+ Sunspot.commit
55
56
  format.html { redirect_to @series_has_manifestation, :notice => t('controller.successfully_created', :model => t('activerecord.models.series_has_manifestation')) }
56
57
  format.json { render :json => @series_has_manifestation, :status => :created, :location => @series_has_manifestation }
57
58
  else
@@ -64,8 +65,11 @@ class SeriesHasManifestationsController < ApplicationController
64
65
  # PUT /series_has_manifestations/1
65
66
  # PUT /series_has_manifestations/1.json
66
67
  def update
68
+ old_series_statement = @series_has_manifestation.manifestation.series_statement
67
69
  respond_to do |format|
68
70
  if @series_has_manifestation.update_attributes(params[:series_has_manifestation])
71
+ old_series_statement.index
72
+ Sunspot.commit
69
73
  format.html { redirect_to @series_has_manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.series_has_manifestation')) }
70
74
  format.json { head :no_content }
71
75
  else
@@ -46,16 +46,18 @@ class SeriesStatementsController < ApplicationController
46
46
  # GET /series_statements/1
47
47
  # GET /series_statements/1.json
48
48
  def show
49
- @manifestations = @series_statement.manifestations.order('date_of_publication DESC').page(params[:manifestation_page]).per_page(Manifestation.per_page)
50
- if session[:manifestation_ids]
51
- @manifestation_ids = session[:manifestation_ids]
52
- end
53
- store_location
49
+ #@manifestations = @series_statement.manifestations.order('date_of_publication DESC').page(params[:manifestation_page]).per_page(Manifestation.per_page)
50
+ #store_location
54
51
 
55
52
  respond_to do |format|
56
- format.html # show.html.erb
53
+ format.html { # show.html.erb
54
+ redirect_to series_statement_manifestations_url(@series_statement)
55
+ }
57
56
  format.json { render :json => @series_statement }
58
- format.js
57
+ #format.js
58
+ format.mobile {
59
+ redirect_to series_statement_manifestations_url(@series_statement)
60
+ }
59
61
  end
60
62
  end
61
63
 
@@ -1,3 +1,9 @@
1
1
  module SeriesStatementsHelper
2
2
  include ManifestationsHelper
3
+
4
+ def series_pagination_link
5
+ if flash[:manifestation_id]
6
+ render 'manifestations/paginate_id_link', :manifestation => Manifestation.find(flash[:manifestation_id])
7
+ end
8
+ end
3
9
  end
@@ -31,6 +31,8 @@ class Item < ActiveRecord::Base
31
31
  has_paper_trail
32
32
  normalize_attributes :item_identifier
33
33
 
34
+ enju_export
35
+
34
36
  searchable do
35
37
  text :item_identifier, :note, :title, :creator, :contributor, :publisher
36
38
  string :item_identifier
@@ -83,6 +85,7 @@ class Item < ActiveRecord::Base
83
85
  searchable do
84
86
  integer :circulation_status_id
85
87
  end
88
+ attr_accessible :item_has_use_restriction_attributes
86
89
  accepts_nested_attributes_for :item_has_use_restriction
87
90
 
88
91
  def set_circulation_status
@@ -15,11 +15,11 @@ class Manifestation < ActiveRecord::Base
15
15
  scope :periodical_master, where(:periodical => false)
16
16
  scope :periodical_children, where(:periodical => true)
17
17
  has_many :creates, :dependent => :destroy, :foreign_key => 'work_id'
18
- has_many :creators, :through => :creates, :source => :patron
18
+ has_many :creators, :through => :creates, :source => :patron, :order => 'creates.position'
19
19
  has_many :realizes, :dependent => :destroy, :foreign_key => 'expression_id'
20
- has_many :contributors, :through => :realizes, :source => :patron
20
+ has_many :contributors, :through => :realizes, :source => :patron, :order => 'realizes.position'
21
21
  has_many :produces, :dependent => :destroy, :foreign_key => 'manifestation_id'
22
- has_many :publishers, :through => :produces, :source => :patron
22
+ has_many :publishers, :through => :produces, :source => :patron, :order => 'produces.position'
23
23
  has_many :exemplifies, :dependent => :destroy
24
24
  has_many :items, :through => :exemplifies
25
25
  has_many :children, :foreign_key => 'parent_id', :class_name => 'ManifestationRelationship', :dependent => :destroy
@@ -35,6 +35,7 @@ class Manifestation < ActiveRecord::Base
35
35
  belongs_to :frequency
36
36
  belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id', :validate => true
37
37
  has_one :resource_import_result
38
+ belongs_to :nii_type if defined?(EnjuNii)
38
39
  accepts_nested_attributes_for :series_has_manifestation
39
40
 
40
41
  searchable do
@@ -43,7 +44,11 @@ class Manifestation < ActiveRecord::Base
43
44
  end
44
45
  text :fulltext, :note, :creator, :contributor, :publisher, :description
45
46
  text :item_identifier do
46
- items.collect(&:item_identifier)
47
+ if periodical_master?
48
+ series_statement.manifestations.collect{|m| m.items.collect(&:item_identifier)}.flatten
49
+ else
50
+ items.collect(&:item_identifier)
51
+ end
47
52
  end
48
53
  string :title, :multiple => true
49
54
  # text フィールドだと区切りのない文字列の index が上手く作成
@@ -74,13 +79,21 @@ class Manifestation < ActiveRecord::Base
74
79
  carrier_type.name
75
80
  end
76
81
  string :library, :multiple => true do
77
- items.map{|i| i.shelf.library.name}
82
+ if periodical_master?
83
+ series_statement.manifestations.map{|m| m.items.map{|i| i.shelf.library.name}}.flatten.uniq
84
+ else
85
+ items.map{|i| i.shelf.library.name}
86
+ end
78
87
  end
79
88
  string :language do
80
89
  language.try(:name)
81
90
  end
82
91
  string :item_identifier, :multiple => true do
83
- items.collect(&:item_identifier)
92
+ if periodical_master?
93
+ series_statement.manifestations.collect{|m| m.items.collect(&:item_identifier)}.flatten
94
+ else
95
+ items.collect(&:item_identifier)
96
+ end
84
97
  end
85
98
  string :shelf, :multiple => true do
86
99
  items.collect{|i| "#{i.shelf.library.name}_#{i.shelf.name}"}
@@ -143,14 +156,13 @@ class Manifestation < ActiveRecord::Base
143
156
  text :isbn do # 前方一致検索のためtext指定を追加
144
157
  [isbn, isbn10, wrong_isbn]
145
158
  end
146
- text :issn # 前方一致検索のためtext指定を追加
147
- #text :ndl_jpno do
148
- # TODO 詳細不明
149
- #end
150
- #string :ndl_dpid do
151
- # TODO 詳細不明
152
- #end
153
- # OTC end
159
+ text :issn do # 前方一致検索のためtext指定を追加
160
+ if periodical_master?
161
+ series_statement.issn
162
+ else
163
+ issn
164
+ end
165
+ end
154
166
  string :sort_title
155
167
  boolean :periodical do
156
168
  periodical?
@@ -167,6 +179,8 @@ class Manifestation < ActiveRecord::Base
167
179
  enju_oai
168
180
  #enju_calil_check
169
181
  #enju_cinii
182
+ enju_export
183
+
170
184
  has_paper_trail
171
185
  if configatron.uploaded_file.storage == :s3
172
186
  has_attached_file :attachment, :storage => :s3, :s3_credentials => "#{Rails.root.to_s}/config/s3.yml"
@@ -256,7 +270,7 @@ class Manifestation < ActiveRecord::Base
256
270
 
257
271
  while date.nil? do
258
272
  pub_date_string += '-01'
259
- break if date =~ /-01-01-01$/
273
+ break if pub_date_string =~ /-01-01-01$/
260
274
  begin
261
275
  date = Time.zone.parse(pub_date_string)
262
276
  rescue ArgumentError
@@ -77,6 +77,8 @@ class Patron < ActiveRecord::Base
77
77
  integer :patron_type_id
78
78
  end
79
79
 
80
+ enju_export
81
+
80
82
  def self.per_page
81
83
  10
82
84
  end
@@ -11,7 +11,9 @@ class ResourceImportFile < ActiveRecord::Base
11
11
  :path => "resource_import_files/:id/:filename",
12
12
  :s3_permissions => :private
13
13
  else
14
- has_attached_file :resource_import, :path => ":rails_root/private:url"
14
+ has_attached_file :resource_import,
15
+ :path => ":rails_root/private/system/:attachment/:id/:style/:filename",
16
+ :url => "/system/:attachment/:id/:style/:filename"
15
17
  end
16
18
  validates_attachment_content_type :resource_import, :content_type => ['text/csv', 'text/plain', 'text/tab-separated-values', 'application/octet-stream']
17
19
  validates_attachment_presence :resource_import
@@ -259,6 +261,15 @@ class ResourceImportFile < ActiveRecord::Base
259
261
  item.note = row['note'] if row['note']
260
262
  item.save!
261
263
  ExpireFragmentCache.expire_fragment_cache(item.manifestation)
264
+ else
265
+ manifestation_identifier = row['manifestation_identifier'].to_s.strip
266
+ manifestation = Manifestation.where(:manifestation_identifier => manifestation_identifier).first if manifestation_identifier.present?
267
+ unless manifestation
268
+ manifestation = Manifestation.where(:id => row['manifestation_id']).first
269
+ end
270
+ if manifestation
271
+ fetch(row, :edit_mode => 'update')
272
+ end
262
273
  end
263
274
  row_num += 1
264
275
  end
@@ -318,6 +329,7 @@ class ResourceImportFile < ActiveRecord::Base
318
329
  import_result.save!
319
330
  row_num += 1
320
331
  end
332
+ sm_complete!
321
333
  end
322
334
 
323
335
  private
@@ -388,6 +400,11 @@ class ResourceImportFile < ActiveRecord::Base
388
400
  manifestation = nil
389
401
  when 'update'
390
402
  manifestation = Item.where(:item_identifier => row['item_identifier'].to_s.strip).first.try(:manifestation)
403
+ unless manifestation
404
+ manifestation_identifier = row['manifestation_identifier'].to_s.strip
405
+ manifestation = Manifestation.where(:manifestation_identifier => manifestation_identifier).first if manifestation_identifier
406
+ manifestation = Manifestation.where(:id => row['manifestation_id']).first unless manifestation
407
+ end
391
408
  end
392
409
 
393
410
  title = {}
@@ -418,7 +435,6 @@ class ResourceImportFile < ActiveRecord::Base
418
435
  language = Language.where(:name => row['language'].to_s.strip.camelize).first
419
436
  language = Language.where(:iso_639_2 => row['language'].to_s.strip.downcase).first unless language
420
437
  language = Language.where(:iso_639_1 => row['language'].to_s.strip.downcase).first unless language
421
- language = Language.where(:name => 'unknown').first unless language
422
438
 
423
439
  if end_page >= 1
424
440
  start_page = 1
@@ -454,7 +470,7 @@ class ResourceImportFile < ActiveRecord::Base
454
470
  when 'update'
455
471
  expression = manifestation
456
472
  work = expression
457
- work.series_statement = series_statement
473
+ work.series_statement = series_statement if series_statement
458
474
  work.creators = creator_patrons.uniq unless creator_patrons.empty?
459
475
  expression.contributors = contributor_patrons.uniq unless contributor_patrons.empty?
460
476
  if defined?(EnjuSubject)
@@ -465,7 +481,7 @@ class ResourceImportFile < ActiveRecord::Base
465
481
  volume_number = row['volume_number'].to_s.tr('0-9', '0-9').to_i
466
482
  end
467
483
 
468
- manifestation = self.class.import_manifestation(expression, publisher_patrons, {
484
+ attributes = {
469
485
  :original_title => title[:original_title],
470
486
  :title_transcription => title[:title_transcription],
471
487
  :title_alternative => title[:title_alternative],
@@ -492,19 +508,34 @@ class ResourceImportFile < ActiveRecord::Base
492
508
  :end_page => end_page,
493
509
  :access_address => row['access_addres'],
494
510
  :manifestation_identifier => row['manifestation_identifier']
495
- },
511
+ }.delete_if{|key, value| value.nil?}
512
+ manifestation = self.class.import_manifestation(expression, publisher_patrons, attributes,
496
513
  {
497
514
  :edit_mode => options[:edit_mode]
498
515
  })
499
- manifestation.volume_number = volume_number
500
- manifestation.required_role = Role.where(:name => row['required_role_name'].to_s.strip.camelize).first || Role.find('Guest')
501
- manifestation.language = language
502
- manifestation.series_statement = series_statement
516
+ manifestation.volume_number = volume_number if volume_number
517
+
518
+ required_role = Role.where(:name => row['required_role_name'].to_s.strip.camelize).first
519
+ if required_role and row['required_role_name'].present?
520
+ manifestation.required_role = required_role
521
+ else
522
+ manifestation.required_role = Role.where(:name => 'Guest').first unless manifestation.required_role
523
+ end
524
+
525
+ if language and row['language'].present?
526
+ manifestation.language = language
527
+ else
528
+ manifestation.language = Language.where(:name => 'unknown').first unless manifestation.language
529
+ end
530
+
531
+ manifestation.series_statement = series_statement if series_statement
503
532
  manifestation.save!
504
533
 
505
- manifestation.set_patron_role_type(creators_list)
506
- manifestation.set_patron_role_type(contributors_list, :scope => :contributor)
507
- manifestation.set_patron_role_type(publishers_list, :scope => :publisher)
534
+ if options[:edit_mode] == 'create'
535
+ manifestation.set_patron_role_type(creators_list)
536
+ manifestation.set_patron_role_type(contributors_list, :scope => :contributor)
537
+ manifestation.set_patron_role_type(publishers_list, :scope => :publisher)
538
+ end
508
539
  end
509
540
  manifestation
510
541
  end
@@ -551,10 +582,14 @@ class ResourceImportFile < ActiveRecord::Base
551
582
  def find_series_statement(row)
552
583
  issn = StdNum::ISSN.normalize(row['issn'].to_s)
553
584
  series_statement_identifier = row['series_statement_identifier'].to_s.strip
585
+ series_statement_id = row['series_statement_id'].to_s.strip
554
586
  series_statement = SeriesStatement.where(:issn => issn).first if issn.present?
555
587
  unless series_statement
556
588
  series_statement = SeriesStatement.where(:series_statement_identifier => series_statement_identifier).first if series_statement_identifier.present?
557
589
  end
590
+ unless series_statement
591
+ series_statement = SeriesStatement.where(:id => series_statement_id).first if series_statement_id
592
+ end
558
593
  series_statement = SeriesStatement.where(:original_title => row['series_statement_original_title'].to_s.strip).first unless series_statement
559
594
  series_statement
560
595
  end