enju_biblio 0.1.0.pre33 → 0.1.0.pre34

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/manifestations_controller.rb +6 -27
  3. data/app/controllers/series_has_manifestations_controller.rb +2 -2
  4. data/app/controllers/series_statements_controller.rb +1 -17
  5. data/app/models/enju_biblio/ability.rb +2 -2
  6. data/app/models/item.rb +2 -3
  7. data/app/models/manifestation.rb +109 -163
  8. data/app/models/page_sweeper.rb +1 -3
  9. data/app/models/resource_import_file.rb +26 -62
  10. data/app/models/series_statement.rb +35 -76
  11. data/app/views/manifestations/_form.html.erb +9 -24
  12. data/app/views/manifestations/_manifestation.html.erb +5 -5
  13. data/app/views/manifestations/_show_detail_librarian.html.erb +6 -2
  14. data/app/views/manifestations/_show_detail_user.html.erb +6 -2
  15. data/app/views/manifestations/_show_index.html.erb +3 -8
  16. data/app/views/manifestations/_show_periodical_master.html.erb +6 -23
  17. data/app/views/manifestations/_show_series_index.html.erb +1 -9
  18. data/app/views/manifestations/show.html.erb +1 -1
  19. data/app/views/series_statements/_form.html.erb +0 -8
  20. data/app/views/series_statements/_index.html.erb +3 -17
  21. data/app/views/series_statements/_index_manifestation.html.erb +0 -15
  22. data/app/views/series_statements/_index_parent.html.erb +0 -2
  23. data/app/views/series_statements/_index_series_statement_merge_list.html.erb +0 -2
  24. data/app/views/series_statements/_manifestation_list.html.erb +1 -1
  25. data/app/views/series_statements/show.html.erb +0 -9
  26. data/config/locales/translation_en.yml +1 -0
  27. data/config/locales/translation_ja.yml +1 -0
  28. data/db/migrate/20130421093852_add_periodical_to_manifestation.rb +5 -0
  29. data/db/migrate/20130421155019_add_creator_string_to_series_statement.rb +7 -0
  30. data/db/migrate/20130421164124_add_series_master_to_series_statement.rb +5 -0
  31. data/lib/enju_biblio/version.rb +1 -1
  32. data/spec/cassette_library/ImportRequest/import/should_import_bibliographic_record.yml +49 -47
  33. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_isbn_which_is_already_imported/redirects_to_the_created_import_request.yml +624 -0
  34. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +624 -0
  35. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Administrator/with_valid_params/redirects_to_the_created_import_request.yml +624 -0
  36. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/assigns_a_newly_created_import_request_as_import_request.yml +624 -0
  37. data/spec/cassette_library/ImportRequestsController/POST_create/When_logged_in_as_Librarian/with_valid_params/redirects_to_the_created_import_request.yml +624 -0
  38. data/spec/controllers/import_requests_controller_spec.rb +29 -31
  39. data/spec/controllers/manifestations_controller_spec.rb +5 -37
  40. data/spec/dummy/app/models/ability.rb +2 -2
  41. data/spec/dummy/config/application.rb +0 -1
  42. data/spec/dummy/db/development.sqlite3 +0 -0
  43. data/spec/dummy/db/schema.rb +10 -7
  44. data/spec/dummy/db/test.sqlite3 +0 -0
  45. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/resource_import_file_sample1.tsv +1 -1
  46. data/spec/dummy/private/system/resource_import_files/resource_imports/000/000/004/original/resource_import_file_sample2.tsv +1 -1
  47. data/spec/dummy/solr/data/test/index/segments.gen +0 -0
  48. data/spec/dummy/solr/data/test/index/segments_gs2 +0 -0
  49. data/spec/dummy/tmp/cache/4AD/470/country_all +0 -0
  50. data/spec/fixtures/items.yml +2 -3
  51. data/spec/fixtures/manifestations.yml +72 -72
  52. data/spec/fixtures/series_statements.yml +21 -23
  53. data/spec/models/item_spec.rb +26 -28
  54. data/spec/models/manifestation_spec.rb +80 -76
  55. data/spec/models/resource_import_file_spec.rb +33 -9
  56. data/spec/models/series_statement_spec.rb +22 -34
  57. metadata +22 -25
  58. data/app/views/series_statements/_periodical_facet.html.erb +0 -15
  59. data/db/migrate/20110425133109_add_issn_to_series_statement.rb +0 -9
  60. data/db/migrate/20110618091240_add_periodical_to_series_statement.rb +0 -9
  61. data/db/migrate/20110918161853_rename_series_statement_manifestation_id_to_root_manifestation_id.rb +0 -13
  62. data/spec/dummy/solr/data/test/index/segments_6n6 +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0bb9d524879ecae1a94ceafe552c583803ef30d0
4
- data.tar.gz: 7ef2705fa6a004bd94f34e595f54e177d012b198
3
+ metadata.gz: a61cbe1e5100da511b2e44411b7c45727ff50fc4
4
+ data.tar.gz: fdbd62984455ea5e0786a4707bcd8be30e3e258b
5
5
  SHA512:
6
- metadata.gz: d8afb13eeee977807f60a8a769621c29b838ee533c04842166acbc815eb9e0ca1d2d95fdf858ea96d19249db1e5fa157402c1dcbb0ef60e60f532f95439dcffa
7
- data.tar.gz: 4e990c8156c99b94447af4d611bfa3cdf570e196e9754c85366bdc87a04af78d33e73fcbcecdda96a825aa94e647b28fb4c3a8101f80afbe7e3c2ad8798e1bd0
6
+ metadata.gz: 1ccb0b3ffd7d43dc350546820a2303b2a7619f85db19b634596437fb2913c93624e679ea241162abf6bffa72117568ed7aeaf18779ec873d90d946f8f64c7bc2
7
+ data.tar.gz: 3f78f29acd4a0a7a25213fd42737d2ed476c912cea2f45a22b7aeb5d66ab11b93bf1e2c572e20ca36700d22e9c5a10b2e6d62e2cc600b5d16b73cd45c2fc7b61
@@ -97,7 +97,7 @@ class ManifestationsController < ApplicationController
97
97
  @query = query.dup
98
98
  query = query.gsub(' ', ' ')
99
99
 
100
- includes = [:carrier_type, {:series_statement => :root_manifestation}]
100
+ includes = [:carrier_type, :series_statements]
101
101
  includes << :bookmarks if defined?(EnjuBookmark)
102
102
  search = Manifestation.search(:include => includes)
103
103
  role = current_user.try(:role) || Role.default_role
@@ -125,7 +125,7 @@ class ManifestationsController < ApplicationController
125
125
  with(:contributor_ids).equal_to patron[:contributor].id if patron[:contributor]
126
126
  with(:publisher_ids).equal_to patron[:publisher].id if patron[:publisher]
127
127
  with(:original_manifestation_ids).equal_to manifestation.id if manifestation
128
- with(:series_statement_id).equal_to series_statement.id if series_statement
128
+ with(:series_statement_ids).equal_to series_statement.id if series_statement
129
129
  end
130
130
  end
131
131
 
@@ -137,7 +137,7 @@ class ManifestationsController < ApplicationController
137
137
  with(:subject_ids).equal_to subject.id if subject
138
138
  end
139
139
  if series_statement
140
- with(:periodical_master).equal_to false
140
+ with(:series_master).equal_to false
141
141
  if series_statement.periodical?
142
142
  if mode != 'add'
143
143
  order_by :volume_number, sort[:order]
@@ -374,10 +374,10 @@ class ManifestationsController < ApplicationController
374
374
  flash.keep(:search_query)
375
375
  store_location
376
376
 
377
- if @manifestation.periodical_master?
377
+ if @manifestation.series_master?
378
378
  flash.keep(:notice) if flash[:notice]
379
379
  flash[:manifestation_id] = @manifestation.id
380
- redirect_to series_statement_manifestations_url(@manifestation.series_statement)
380
+ redirect_to series_statement_manifestations_url(@manifestation.root_series_statement)
381
381
  return
382
382
  end
383
383
 
@@ -435,11 +435,7 @@ class ManifestationsController < ApplicationController
435
435
  # GET /manifestations/new.json
436
436
  def new
437
437
  @manifestation = Manifestation.new
438
- @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
439
- set_title
440
438
  @manifestation.language = Language.where(:iso_639_1 => @locale).first
441
- @manifestation.series_has_manifestation = SeriesHasManifestation.new
442
- @manifestation.series_has_manifestation.series_statement = @series_statement
443
439
 
444
440
  respond_to do |format|
445
441
  format.html # new.html.erb
@@ -454,8 +450,6 @@ class ManifestationsController < ApplicationController
454
450
  access_denied; return
455
451
  end
456
452
  end
457
- @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
458
- @series_statement = @manifestation.series_statement unless @series_statement
459
453
  if defined?(EnjuSubject)
460
454
  @classification_types = ClassificationType.select(:display_name)
461
455
  end
@@ -472,7 +466,6 @@ class ManifestationsController < ApplicationController
472
466
  # POST /manifestations.json
473
467
  def create
474
468
  @manifestation = Manifestation.new(params[:manifestation])
475
- @original_manifestation = Manifestation.where(:id => params[:manifestation_id]).first
476
469
  unless @manifestation.original_title?
477
470
  @manifestation.original_title = @manifestation.attachment_file_name
478
471
  end
@@ -481,9 +474,6 @@ class ManifestationsController < ApplicationController
481
474
  set_patrons
482
475
  if @manifestation.save
483
476
  Sunspot.commit
484
- if @original_manifestation
485
- @manifestation.derived_manifestations << @original_manifestation
486
- end
487
477
 
488
478
  format.html { redirect_to @manifestation, :notice => t('controller.successfully_created', :model => t('activerecord.models.manifestation')) }
489
479
  format.json { render :json => @manifestation, :status => :created, :location => @manifestation }
@@ -499,8 +489,8 @@ class ManifestationsController < ApplicationController
499
489
  # PUT /manifestations/1.json
500
490
  def update
501
491
  respond_to do |format|
502
- set_patrons
503
492
  if @manifestation.update_attributes(params[:manifestation])
493
+ set_patrons
504
494
  Sunspot.commit
505
495
  format.html { redirect_to @manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.manifestation')) }
506
496
  format.json { head :no_content }
@@ -515,9 +505,7 @@ class ManifestationsController < ApplicationController
515
505
  # DELETE /manifestations/1
516
506
  # DELETE /manifestations/1.json
517
507
  def destroy
518
- series_statement = @manifestation.series_statement
519
508
  @manifestation.destroy
520
- series_statement.try(:index!)
521
509
 
522
510
  respond_to do |format|
523
511
  format.html { redirect_to manifestations_url, :notice => t('controller.successfully_deleted', :model => t('activerecord.models.manifestation')) }
@@ -767,15 +755,6 @@ class ManifestationsController < ApplicationController
767
755
  query
768
756
  end
769
757
 
770
- def set_title
771
- if @series_statement
772
- @manifestation.set_series_statement(@series_statement)
773
- elsif @original_manifestation
774
- @manifestation.original_title = @original_manifestation.original_title
775
- @manifestation.title_transcription = @original_manifestation.title_transcription
776
- end
777
- end
778
-
779
758
  def set_patrons
780
759
  @manifestation.set_creators(@manifestation.creators)
781
760
  @manifestation.set_contributors(@manifestation.contributors)
@@ -66,10 +66,10 @@ class SeriesHasManifestationsController < ApplicationController
66
66
  # PUT /series_has_manifestations/1
67
67
  # PUT /series_has_manifestations/1.json
68
68
  def update
69
- old_series_statement = @series_has_manifestation.manifestation.series_statement
69
+ old_series_statements = @series_has_manifestation.manifestation.series_statements
70
70
  respond_to do |format|
71
71
  if @series_has_manifestation.update_attributes(params[:series_has_manifestation])
72
- old_series_statement.index
72
+ old_series_statements.map{|s| s.index}
73
73
  Sunspot.commit
74
74
  format.html { redirect_to @series_has_manifestation, :notice => t('controller.successfully_updated', :model => t('activerecord.models.series_has_manifestation')) }
75
75
  format.json { head :no_content }
@@ -14,8 +14,6 @@ class SeriesStatementsController < ApplicationController
14
14
  search = Sunspot.new_search(SeriesStatement)
15
15
  query = params[:query].to_s.strip
16
16
  page = params[:page] || 1
17
- set_periodical
18
- periodical = @periodical
19
17
 
20
18
  unless query.blank?
21
19
  @query = query.dup
@@ -25,8 +23,6 @@ class SeriesStatementsController < ApplicationController
25
23
  fulltext query if query.present?
26
24
  paginate :page => page.to_i, :per_page => SeriesStatement.default_per_page
27
25
  order_by :position, :asc
28
- with(:periodical).equal_to periodical unless periodical.nil?
29
- facet :periodical
30
26
  end
31
27
  #work = @work
32
28
  manifestation = @manifestation
@@ -38,7 +34,7 @@ class SeriesStatementsController < ApplicationController
38
34
  # with(:work_id).equal_to work.id if work
39
35
  with(:parent_ids).equal_to parent.id if parent
40
36
  with(:child_ids).equal_to child.id if child
41
- with(:manifestation_ids).equal_to manifestation.id if manifestation
37
+ with(:manifestation_id).equal_to manifestation.id if manifestation
42
38
  with(:series_statement_merge_list_ids).equal_to series_statement_merge_list.id if series_statement_merge_list
43
39
  end
44
40
  else
@@ -50,7 +46,6 @@ class SeriesStatementsController < ApplicationController
50
46
  search.query.paginate(page.to_i, SeriesStatement.default_per_page)
51
47
  search_result = search.execute!
52
48
  @series_statements = search_result.results
53
- @periodical_facet = search_result.facet(:periodical).rows
54
49
 
55
50
  respond_to do |format|
56
51
  format.html # index.html.erb
@@ -151,15 +146,4 @@ class SeriesStatementsController < ApplicationController
151
146
  @parent = SeriesStatement.find(params[:parent_id]) if params[:parent_id]
152
147
  @child = SeriesStatement.find(params[:child_id]) if params[:child_id]
153
148
  end
154
-
155
- def set_periodical
156
- case params[:periodical]
157
- when "true"
158
- @periodical = true
159
- when "false"
160
- @periodical = false
161
- else
162
- @periodical = nil
163
- end
164
- end
165
149
  end
@@ -15,7 +15,7 @@ module EnjuBiblio
15
15
  end
16
16
  can [:read, :create, :update], Manifestation
17
17
  can [:destroy, :delete], Manifestation do |manifestation|
18
- manifestation.items.empty? and !manifestation.periodical_master?
18
+ manifestation.items.empty? and !manifestation.series_master?
19
19
  end
20
20
  can :manage, [
21
21
  Create,
@@ -74,7 +74,7 @@ module EnjuBiblio
74
74
  can :index, Manifestation
75
75
  can [:show, :create, :update], Manifestation
76
76
  can [:destroy, :delete], Manifestation do |manifestation|
77
- manifestation.items.empty? and !manifestation.periodical_master?
77
+ manifestation.items.empty? and !manifestation.series_master?
78
78
  end
79
79
  can [:index, :create], Patron
80
80
  can :show, Patron do |patron|
data/app/models/item.rb CHANGED
@@ -102,8 +102,6 @@ end
102
102
  # id :integer not null, primary key
103
103
  # call_number :string(255)
104
104
  # item_identifier :string(255)
105
- # circulation_status_id :integer default(5), not null
106
- # checkout_type_id :integer default(1), not null
107
105
  # created_at :datetime not null
108
106
  # updated_at :datetime not null
109
107
  # deleted_at :datetime
@@ -119,6 +117,7 @@ end
119
117
  # acquired_at :datetime
120
118
  # bookstore_id :integer
121
119
  # budget_type_id :integer
122
- # manifestation_id :integer
120
+ # circulation_status_id :integer default(5), not null
121
+ # checkout_type_id :integer default(1), not null
123
122
  #
124
123
 
@@ -1,3 +1,4 @@
1
+ # -*- encoding: utf-8 -*-
1
2
  class Manifestation < ActiveRecord::Base
2
3
  enju_circulation_manifestation_model if defined?(EnjuCirculation)
3
4
  enju_subject_manifestation_model if defined?(EnjuSubject)
@@ -19,13 +20,11 @@ class Manifestation < ActiveRecord::Base
19
20
  :valid_until, :date_submitted, :date_accepted, :date_captured, :ndl_bib_id,
20
21
  :pub_date, :edition_string, :volume_number, :issue_number, :serial_number,
21
22
  :ndc, :content_type_id, :attachment, :classification_number,
22
- :series_has_manifestation_attributes,
23
+ :series_statements_attributes,
23
24
  :creators_attributes, :contributors_attributes, :publishers_attributes
24
25
  attr_accessible :fulltext_content,
25
26
  :doi, :number_of_page_string
26
27
 
27
- scope :periodical_master, where(:periodical => false)
28
- scope :periodical_children, where(:periodical => true)
29
28
  has_many :creates, :dependent => :destroy, :foreign_key => 'work_id'
30
29
  has_many :creators, :through => :creates, :source => :patron, :order => 'creates.position'
31
30
  has_many :realizes, :dependent => :destroy, :foreign_key => 'expression_id'
@@ -42,16 +41,15 @@ class Manifestation < ActiveRecord::Base
42
41
  belongs_to :language
43
42
  belongs_to :carrier_type
44
43
  belongs_to :manifestation_content_type, :class_name => 'ContentType', :foreign_key => 'content_type_id'
45
- has_one :series_has_manifestation, :dependent => :destroy
46
- has_one :series_statement, :through => :series_has_manifestation
44
+ has_many :series_statements
47
45
  belongs_to :frequency
48
46
  belongs_to :required_role, :class_name => 'Role', :foreign_key => 'required_role_id', :validate => true
49
47
  has_one :resource_import_result
50
48
  belongs_to :nii_type if defined?(EnjuNii)
51
- accepts_nested_attributes_for :series_has_manifestation
52
49
  accepts_nested_attributes_for :creators, :allow_destroy => true, :reject_if => :all_blank
53
50
  accepts_nested_attributes_for :contributors, :allow_destroy => true, :reject_if => :all_blank
54
51
  accepts_nested_attributes_for :publishers, :allow_destroy => true, :reject_if => :all_blank
52
+ accepts_nested_attributes_for :series_statements, :allow_destroy => true, :reject_if => :all_blank
55
53
 
56
54
  searchable do
57
55
  text :title, :default_boost => 2 do
@@ -59,8 +57,8 @@ class Manifestation < ActiveRecord::Base
59
57
  end
60
58
  text :fulltext, :note, :creator, :contributor, :publisher, :description
61
59
  text :item_identifier do
62
- if periodical_master?
63
- series_statement.manifestations.map{|m| m.items.pluck(:item_identifier)}.flatten
60
+ if series_master?
61
+ root_series_statement.manifestation.items.pluck(:item_identifier)
64
62
  else
65
63
  items.pluck(:item_identifier)
66
64
  end
@@ -82,10 +80,10 @@ class Manifestation < ActiveRecord::Base
82
80
  [isbn, isbn10, wrong_isbn]
83
81
  end
84
82
  string :issn, :multiple => true do
85
- if series_statement
86
- ([series_statement.issn] + series_statement.manifestations.pluck(:issn)).uniq.compact
83
+ if series_statements.exists?
84
+ [issn, (series_statements.map{|s| s.manifestation.issn})].flatten.uniq.compact
87
85
  else
88
- [issn, series_statement.try(:issn)].compact
86
+ issn
89
87
  end
90
88
  end
91
89
  string :lccn
@@ -94,22 +92,18 @@ class Manifestation < ActiveRecord::Base
94
92
  carrier_type.name
95
93
  end
96
94
  string :library, :multiple => true do
97
- if periodical_master?
98
- series_statement.manifestations.map{|m| m.items.map{|i| i.shelf.library.name}}.flatten.uniq
95
+ if series_master?
96
+ root_series_statement.manifestation.items.map{|i| i.shelf.library.name}.flatten.uniq
99
97
  else
100
98
  items.map{|i| i.shelf.library.name}
101
99
  end
102
100
  end
103
101
  string :language do
104
- if periodical_master?
105
- series_statement.last_issue.try(:language).try(:name)
106
- else
107
- language.try(:name)
108
- end
102
+ language.try(:name)
109
103
  end
110
104
  string :item_identifier, :multiple => true do
111
- if periodical_master?
112
- series_statement.manifestations.collect{|m| m.items.pluck(:item_identifier)}.flatten
105
+ if series_master?
106
+ root_series_statement.manifestation.items.pluck(:item_identifier)
113
107
  else
114
108
  items.collect(&:item_identifier)
115
109
  end
@@ -121,8 +115,8 @@ class Manifestation < ActiveRecord::Base
121
115
  time :updated_at
122
116
  time :deleted_at
123
117
  time :pub_date, :multiple => true do
124
- if periodical_master?
125
- series_statement.manifestations.map{|m| m.pub_dates}.flatten
118
+ if series_master?
119
+ root_series_statement.manifestation.pub_dates
126
120
  else
127
121
  pub_dates
128
122
  end
@@ -147,9 +141,7 @@ class Manifestation < ActiveRecord::Base
147
141
  integer :end_page
148
142
  integer :number_of_pages
149
143
  float :price
150
- integer :series_statement_id do
151
- series_has_manifestation.try(:series_statement_id)
152
- end
144
+ integer :series_statement_ids, :multiple => true
153
145
  boolean :repository_content
154
146
  # for OpenURL
155
147
  text :aulast do
@@ -166,24 +158,24 @@ class Manifestation < ActiveRecord::Base
166
158
  creator
167
159
  end
168
160
  text :atitle do
169
- title if series_statement.try(:periodical)
161
+ unless series_master?
162
+ title if periodical?
163
+ end
170
164
  end
171
165
  text :btitle do
172
- title unless series_statement.try(:periodical)
166
+ title unless periodical?
173
167
  end
174
168
  text :jtitle do
175
- if series_statement.try(:periodical) # 雑誌の場合
176
- series_statement.titles
177
- else # 雑誌以外(雑誌の記事も含む)
178
- original_manifestations.map{|m| m.title}.flatten
169
+ if periodical?
170
+ titles
179
171
  end
180
172
  end
181
173
  text :isbn do # 前方一致検索のためtext指定を追加
182
174
  [isbn, isbn10, wrong_isbn]
183
175
  end
184
176
  text :issn do # 前方一致検索のためtext指定を追加
185
- if series_statement
186
- ([series_statement.issn] + series_statement.manifestations.pluck(:issn)).uniq.compact
177
+ if series_statements.exists?
178
+ [issn, (series_statements.map{|s| s.manifestation.issn})].flatten.uniq.compact
187
179
  else
188
180
  issn
189
181
  end
@@ -193,8 +185,8 @@ class Manifestation < ActiveRecord::Base
193
185
  boolean :periodical do
194
186
  periodical?
195
187
  end
196
- boolean :periodical_master do
197
- periodical_master?
188
+ boolean :series_master do
189
+ series_master?
198
190
  end
199
191
  time :acquired_at
200
192
  end
@@ -212,7 +204,7 @@ class Manifestation < ActiveRecord::Base
212
204
  validates_associated :carrier_type, :language
213
205
  validates :start_page, :numericality => true, :allow_blank => true
214
206
  validates :end_page, :numericality => true, :allow_blank => true
215
- validates :isbn, :uniqueness => true, :allow_blank => true, :unless => proc{|manifestation| manifestation.series_statement}
207
+ validates :isbn, :uniqueness => true, :allow_blank => true, :unless => proc{|manifestation| manifestation.series_statements.exists?}
216
208
  validates :nbn, :uniqueness => true, :allow_blank => true
217
209
  validates :manifestation_identifier, :uniqueness => true, :allow_blank => true
218
210
  validates :pub_date, :format => {:with => /\A\[{0,1}\d+([\/-]\d{0,2}){0,2}\]{0,1}\z/}, :allow_blank => true
@@ -340,7 +332,7 @@ class Manifestation < ActiveRecord::Base
340
332
  title << issue_number_string
341
333
  title << serial_number.to_s
342
334
  title << edition_string
343
- title << series_statement.titles if series_statement
335
+ title << series_statements.map{|s| s.titles}
344
336
  #title << original_title.wakati
345
337
  #title << title_transcription.wakati rescue nil
346
338
  #title << title_alternative.wakati rescue nil
@@ -352,17 +344,6 @@ class Manifestation < ActiveRecord::Base
352
344
  "#{LibraryGroup.site_config.url}#{self.class.to_s.tableize}/#{self.id}"
353
345
  end
354
346
 
355
- def set_series_statement(series_statement)
356
- if series_statement
357
- if series_statement.periodical?
358
- set_serial_information(series_statement)
359
- else
360
- self.original_title = series_statement.original_title
361
- self.title_transcription = series_statement.title_transcription
362
- end
363
- end
364
- end
365
-
366
347
  def creator
367
348
  creators.collect(&:name).flatten
368
349
  end
@@ -418,11 +399,11 @@ class Manifestation < ActiveRecord::Base
418
399
  end
419
400
 
420
401
  def sort_title
421
- if periodical_master?
422
- if series_statement.title_transcription?
423
- NKF.nkf('-w --katakana', series_statement.title_transcription)
402
+ if series_master?
403
+ if root_series_statement.title_transcription?
404
+ NKF.nkf('-w --katakana', root_series_statement.title_transcription)
424
405
  else
425
- series_statement.original_title
406
+ root_series_statement.original_title
426
407
  end
427
408
  else
428
409
  if title_transcription?
@@ -441,28 +422,20 @@ class Manifestation < ActiveRecord::Base
441
422
  end
442
423
 
443
424
  def index_series_statement
444
- series_statement.try(:index)
425
+ series_statements.map{|s| s.index}
445
426
  end
446
427
 
447
428
  def acquired_at
448
429
  items.order(:acquired_at).first.try(:acquired_at)
449
430
  end
450
431
 
451
- def root_of_series?
452
- return true if series_statement.try(:root_manifestation) == self
453
- false
454
- end
455
-
456
- def periodical_master?
457
- if series_statement
458
- return true if series_statement.periodical and root_of_series?
459
- end
460
- false
432
+ def root_series_statement
433
+ series_statements.where(:series_master => true).first
461
434
  end
462
435
 
463
- def periodical?
464
- if series_statement.try(:periodical)
465
- return true unless root_of_series?
436
+ def series_master?
437
+ series_statements.each do |series_statement|
438
+ return true if series_statement.series_master
466
439
  end
467
440
  false
468
441
  end
@@ -546,38 +519,6 @@ class Manifestation < ActiveRecord::Base
546
519
  end
547
520
 
548
521
  private
549
- def set_serial_information(series_statement)
550
- return nil unless series_statement.periodical?
551
- manifestation = series_statement.last_issue
552
-
553
- if manifestation
554
- self.original_title = manifestation.original_title
555
- self.title_transcription = manifestation.title_transcription
556
- self.title_alternative = manifestation.title_alternative
557
- self.issn = series_statement.issn
558
- # TODO: 雑誌ごとに巻・号・通号のパターンを設定できるようにする
559
- if manifestation.serial_number.to_i > 0
560
- self.serial_number = manifestation.serial_number.to_i + 1
561
- if manifestation.issue_number.to_i > 0
562
- self.issue_number = manifestation.issue_number.to_i + 1
563
- else
564
- self.issue_number = manifestation.issue_number
565
- end
566
- self.volume_number = manifestation.volume_number
567
- else
568
- if manifestation.issue_number.to_i > 0
569
- self.issue_number = manifestation.issue_number.to_i + 1
570
- self.volume_number = manifestation.volume_number
571
- else
572
- if manifestation.volume_number.to_i > 0
573
- self.volume_number = manifestation.volume_number.to_i + 1
574
- end
575
- end
576
- end
577
- end
578
- self
579
- end
580
-
581
522
  def set_patrons(patrons)
582
523
  new_patrons = []
583
524
  patrons.each do |patron|
@@ -595,70 +536,75 @@ end
595
536
  #
596
537
  # Table name: manifestations
597
538
  #
598
- # id :integer not null, primary key
599
- # original_title :text not null
600
- # title_alternative :text
601
- # title_transcription :text
602
- # classification_number :string(255)
603
- # manifestation_identifier :string(255)
604
- # date_of_publication :datetime
605
- # date_copyrighted :datetime
606
- # created_at :datetime not null
607
- # updated_at :datetime not null
608
- # deleted_at :datetime
609
- # access_address :string(255)
610
- # language_id :integer default(1), not null
611
- # carrier_type_id :integer default(1), not null
612
- # extent_id :integer default(1), not null
613
- # start_page :integer
614
- # end_page :integer
615
- # height :integer
616
- # width :integer
617
- # depth :integer
618
- # isbn :string(255)
619
- # isbn10 :string(255)
620
- # wrong_isbn :string(255)
621
- # nbn :string(255)
622
- # lccn :string(255)
623
- # oclc_number :string(255)
624
- # issn :string(255)
625
- # price :integer
626
- # fulltext :text
627
- # volume_number_string :string(255)
628
- # issue_number_string :string(255)
629
- # serial_number_string :string(255)
630
- # edition :integer
631
- # note :text
632
- # repository_content :boolean default(FALSE), not null
633
- # lock_version :integer default(0), not null
634
- # required_role_id :integer default(1), not null
635
- # state :string(255)
636
- # required_score :integer default(0), not null
637
- # frequency_id :integer default(1), not null
638
- # subscription_master :boolean default(FALSE), not null
639
- # attachment_file_name :string(255)
640
- # attachment_content_type :string(255)
641
- # attachment_file_size :integer
642
- # attachment_updated_at :datetime
643
- # title_alternative_transcription :text
644
- # description :text
645
- # abstract :text
646
- # available_at :datetime
647
- # valid_until :datetime
648
- # date_submitted :datetime
649
- # date_accepted :datetime
650
- # date_caputured :datetime
651
- # pub_date :string(255)
652
- # edition_string :string(255)
653
- # volume_number :integer
654
- # issue_number :integer
655
- # serial_number :integer
656
- # ndc :string(255)
657
- # content_type_id :integer default(1)
658
- # year_of_publication :integer
659
- # attachment_meta :text
660
- # month_of_publication :integer
661
- # fulltext_content :boolean
662
- # doi :string(255)
539
+ # id :integer not null, primary key
540
+ # original_title :text not null
541
+ # title_alternative :text
542
+ # title_transcription :text
543
+ # classification_number :string(255)
544
+ # manifestation_identifier :string(255)
545
+ # date_of_publication :datetime
546
+ # date_copyrighted :datetime
547
+ # created_at :datetime not null
548
+ # updated_at :datetime not null
549
+ # deleted_at :datetime
550
+ # access_address :string(255)
551
+ # language_id :integer default(1), not null
552
+ # carrier_type_id :integer default(1), not null
553
+ # extent_id :integer default(1), not null
554
+ # start_page :integer
555
+ # end_page :integer
556
+ # height :integer
557
+ # width :integer
558
+ # depth :integer
559
+ # isbn :string(255)
560
+ # isbn10 :string(255)
561
+ # wrong_isbn :string(255)
562
+ # nbn :string(255)
563
+ # lccn :string(255)
564
+ # oclc_number :string(255)
565
+ # issn :string(255)
566
+ # price :integer
567
+ # fulltext :text
568
+ # volume_number_string :string(255)
569
+ # issue_number_string :string(255)
570
+ # serial_number_string :string(255)
571
+ # edition :integer
572
+ # note :text
573
+ # repository_content :boolean default(FALSE), not null
574
+ # lock_version :integer default(0), not null
575
+ # required_role_id :integer default(1), not null
576
+ # state :string(255)
577
+ # required_score :integer default(0), not null
578
+ # frequency_id :integer default(1), not null
579
+ # subscription_master :boolean default(FALSE), not null
580
+ # attachment_file_name :string(255)
581
+ # attachment_content_type :string(255)
582
+ # attachment_file_size :integer
583
+ # attachment_updated_at :datetime
584
+ # title_alternative_transcription :text
585
+ # description :text
586
+ # abstract :text
587
+ # available_at :datetime
588
+ # valid_until :datetime
589
+ # date_submitted :datetime
590
+ # date_accepted :datetime
591
+ # date_caputured :datetime
592
+ # pub_date :string(255)
593
+ # edition_string :string(255)
594
+ # volume_number :integer
595
+ # issue_number :integer
596
+ # serial_number :integer
597
+ # ndc :string(255)
598
+ # content_type_id :integer default(1)
599
+ # year_of_publication :integer
600
+ # attachment_meta :text
601
+ # month_of_publication :integer
602
+ # fulltext_content :boolean
603
+ # doi :string(255)
604
+ # periodical :boolean
605
+ # series_original_title :text
606
+ # series_title_transcription :text
607
+ # series_title_creator_string :text
608
+ # series_title_volume_number_string :text
663
609
  #
664
610
 
@@ -22,9 +22,7 @@ class PageSweeper < ActionController::Caching::Sweeper
22
22
  expire_editable_fragment(record.manifestation)
23
23
  expire_editable_fragment(record.item)
24
24
  when :SeriesStatement
25
- record.manifestations.each do |manifestation|
26
- expire_editable_fragment(manifestation)
27
- end
25
+ expire_editable_fragment(record.manifestation)
28
26
  when :SeriesHasManifestation
29
27
  expire_editable_fragment(record.manifestation)
30
28
  when :PictureFile