diff --git a/app/models/publication.rb b/app/models/publication.rb
index 54aeb985a0..872f6bbb8a 100755
--- a/app/models/publication.rb
+++ b/app/models/publication.rb
@@ -248,7 +248,7 @@ def extract_bibtex_metadata(bibtex_record)
month = bibtex_record[:month].try(:to_s)
year = bibtex_record[:year].try(:to_s)
self.published_date = Date.new(bibtex_record.year.try(:to_i) || 1, bibtex_record.month_numeric || 1, bibtex_record[:day].try(:to_i) || 1)
- self.published_date = nil if self.published_date.to_s == "0001-01-01"
+ self.published_date = nil if self.published_date.to_s == '0001-01-01'
self.doi = bibtex_record[:doi].try(:to_s)
self.pubmed_id = bibtex_record[:pubmed_id].try(:to_s)
self.booktitle = bibtex_record[:booktitle].try(:to_s)
@@ -326,7 +326,7 @@ def generate_citation(bibtex_record)
self.citation = ''
month = bibtex_record[:month].try(:to_s)
year = bibtex_record[:year].try(:to_s)
- page_or_pages = (bibtex_record[:pages].try(:to_s).match?(/[^0-9]/) ? "pp." : "p." ) unless bibtex_record[:pages].nil?
+ page_or_pages = (bibtex_record[:pages].try(:to_s).match?(/[^0-9]/) ? 'pp.' : 'p.' ) unless bibtex_record[:pages].nil?
pages = bibtex_record[:pages].try(:to_s)
volume = bibtex_record[:volume].try(:to_s)
series = bibtex_record[:series].try(:to_s)
@@ -344,25 +344,16 @@ def generate_citation(bibtex_record)
url = parse_bibtex_url(bibtex_record).try(:to_s)
publication_type = PublicationType.find(self.publication_type_id)
- if publication_type.is_journal?
+ case publication_type.key
+ when publication_type.journalarticle?
self.citation += self.journal.nil? ? '':self.journal
self.citation += volume.blank? ? '': " #{volume}"
self.citation += number.nil? ? '' : "(#{number})"
self.citation += pages.blank? ? '' : (":#{pages}")
-=begin
- unless year.nil?
- self.citation += year.nil? ? '' : (' '+year)
- end
-=end
- elsif publication_type.is_booklet?
+ when publication_type.booklet?
self.citation += howpublished.blank? ? '': "#{howpublished}"
self.citation += address.nil? ? '' : (", #{address}")
-=begin
- unless year.nil?
- self.citation += year.nil? ? '' : (' '+year)
- end
-=end
- elsif publication_type.is_inbook?
+ when publication_type.bookchapter?
self.citation += self.booktitle.nil? ? '' : ("In #{self.booktitle}")
self.citation += volume.blank? ? '' : (", volume #{volume}")
self.citation += series.blank? ? '' : (" of #{series}")
@@ -372,14 +363,7 @@ def generate_citation(bibtex_record)
unless address.nil? || (self.booktitle.try(:include?, address))
self.citation += address.nil? ? '' : (", #{address}")
end
-=begin
- unless self.booktitle.try(:include?, year)
- unless year.nil?
- self.citation += year.nil? ? '' : (' '+year)
- end
- end
-=end
- elsif publication_type.is_inproceedings? || publication_type.is_incollection? || publication_type.is_book?
+ when publication_type.conferencepaper?, publication_type.collection?, publication_type.book?
# InProceedings / InCollection
self.citation += self.booktitle.nil? ? '' : ("In #{self.booktitle}")
self.citation += volume.blank? ? '' : (", vol. #{volume}")
@@ -390,14 +374,7 @@ def generate_citation(bibtex_record)
unless address.nil? || (self.booktitle.try(:include?, address))
self.citation += address.nil? ? '' : (", #{address}")
end
-=begin
- unless self.booktitle.try(:include?, year)
- unless year.nil?
- self.citation += year.nil? ? '' : (', '+year)
- end
- end
-=end
- elsif publication_type.is_phd_thesis? || publication_type.is_masters_thesis? || publication_type.is_bachelor_thesis?
+ when publication_type.dissertation?
#PhD/Master Thesis
self.citation += school.nil? ? '' : (" #{school}")
self.errors.add(:base,'A thesis need to have a school') if school.nil?
@@ -405,24 +382,17 @@ def generate_citation(bibtex_record)
self.citation += tutor.nil? ? '' : (", #{tutor}(Tutor)")
self.citation += tutorhits.nil? ? '' : (", #{tutorhits}(HITS Tutor)")
self.citation += url.nil? ? '' : (", #{url}")
- elsif publication_type.is_proceedings?
+ when publication_type.conferenceproceeding?
# Proceedings are conference proceedings, it has no authors but editors
# Book
self.journal = self.title
self.citation += volume.blank? ? '' : ("vol. #{volume}")
self.citation += series.blank? ? '' : (" of #{series}")
self.citation += self.publisher.blank? ? '' : (", #{self.publisher}")
-=begin
- unless month.nil? && year.nil?
- self.citation += self.citation.blank? ? '' : ','
- self.citation += month.nil? ? '' : (' '+ month.capitalize)
- self.citation += year.nil? ? '' : (' '+year)
- end
-=end
- elsif publication_type.is_tech_report?
+ when publication_type.report?
self.citation += institution.blank? ? ' ': institution
self.citation += type.blank? ? ' ' : (", #{type}")
- elsif publication_type.is_unpublished?
+ when publication_type.preprint?
self.citation += note.blank? ? ' ': note
end
@@ -583,7 +553,7 @@ def pubmed_entry
if pubmed_id
Rails.cache.fetch("bio-reference-#{pubmed_id}") do
entry = Bio::PubMed.efetch(pubmed_id).first
- raise "PubMed entry was nil" if entry.nil?
+ raise 'PubMed entry was nil' if entry.nil?
entry
end
end
@@ -620,25 +590,25 @@ def check_bibtex_file (bibtex_record)
if self.title.blank?
- errors.add(:base, "Please check your bibtex files, each publication should contain a title or a chapter name.")
+ errors.add(:base, 'Please check your bibtex files, each publication should contain a title or a chapter name.')
return false
end
- if (%w[InCollection InProceedings].include? self.publication_type.title) && (bibtex_record[:booktitle].blank?)
- errors.add(:base, "An #{self.publication_type.title} needs to have a booktitle.")
+ if (publication_type.collection? || publication_type.conferencepaper?) && bibtex_record[:booktitle].blank?
+ errors.add(:base, "A #{self.publication_type.title} needs to have a booktitle.")
return false
end
- unless %w[Booklet Manual Misc Proceedings].include? self.publication_type.title
+ unless publication_type.booklet? || publication_type.text? || publication_type.other? || publication_type.conferenceproceeding?
if bibtex_record[:author].nil? && self.editor.nil?
self.errors.add(:base, "You need at least one author or editor for the #{self.publication_type.title}.")
return false
end
end
- if self.publication_type.is_phd_thesis? || self.publication_type.is_masters_thesis? || self.publication_type.is_bachelor_thesis?
+ if publication_type.dissertation?
if bibtex_record[:school].try(:to_s).nil?
- self.errors.add(:base,"A #{self.publication_type.title} needs to have a school.")
+ self.errors.add(:base,"A #{publication_type.title} needs to have a school.")
return false
end
end
diff --git a/app/models/publication_type.rb b/app/models/publication_type.rb
index c27b939706..402923e9e3 100644
--- a/app/models/publication_type.rb
+++ b/app/models/publication_type.rb
@@ -1,143 +1,184 @@
-class PublicationType < ActiveRecord::Base
-
+class PublicationType < ActiveRecord::Base
has_many :publications
- #this returns an instance of PublicationType according to one of the publication types
- #if there is not a match nil is returned
- #http://bib-it.sourceforge.net/help/fieldsAndEntryTypes.php#Entries
+ # Map BibTeX keys → DataCite keys
+ BIBTEX_TO_DATACITE_KEY = {
+ 'article' => 'journalarticle',
+ 'book' => 'book',
+ 'booklet' => 'booklet',
+ 'inbook' => 'bookchapter',
+ 'incollection' => 'collection',
+ 'inproceedings' => 'conferencepaper',
+ 'proceedings' => 'conferenceproceeding',
+ 'manual' => 'text',
+ 'misc' => 'other',
+ 'unpublished' => 'preprint',
+ 'techreport' => 'report',
+ 'phdthesis' => 'phdthesis',
+ 'mastersthesis' => 'mastersthesis',
+ 'bachelorsthesis' => 'bachelorsthesis'
+ }.freeze
+
- def self.for_type type
- keys = { "Journal"=>"article",
- "Book"=>"book",
- "Booklet"=>"booklet",
- "InBook"=>"inbook",
- "InCollection"=>"incollection",
- "InProceedings"=>"inproceedings",
- "Manual"=>"manual",
- "Masters_Thesis"=>"masters_thesis",
- "Misc"=>"misc",
- "Phd_Thesis"=>"phd_thesis",
- "Bachelor_Thesis"=>"bachelorsthesis",
- "Proceedings"=>"proceedings",
- "Tech_Report"=>"tech_report",
- "Unpublished"=>"unpublished" }
- return PublicationType.find_by(key: keys[type])
+ def journalarticle?
+ key == 'journalarticle'
+ end
+
+ def book?
+ key == 'book'
end
+ def booklet?
+ key == 'booklet'
+ end
+ def bookchapter?
+ key == 'bookchapter'
+ end
- def self.get_publication_type_id(bibtex_record)
- str_begin = "@"
- str_end = "{"
- publication_key = bibtex_record.try(:to_s)[/#{str_begin}(.*?)#{str_end}/m, 1]
- unless PublicationType.find_by(key: publication_key).nil?
- return PublicationType.find_by(key: publication_key).id
- else
- return PublicationType.find_by(key: "misc").id
- end
+ def collection?
+ key == 'collection'
end
+ def conferencepaper?
+ key == 'conferencepaper'
+ end
+
+ def conferenceproceeding?
+ key == 'conferenceproceeding'
+ end
+
+ def text?
+ key == 'text'
+ end
+
+ def bachelorsthesis?
+ key == 'bachelorsthesis'
+ end
+
+ def mastersthesis?
+ key == 'mastersthesis'
+ end
- def self.Journal
- self.for_type('Journal')
+ def diplomathesis?
+ key == 'diplomathesis'
end
- def self.Book
- self.for_type('Book')
+ def phdthesis?
+ key == 'phdthesis'
end
- def self.Booklet
- self.for_type('Booklet')
+ def dissertation?
+ %w[bachelorsthesis mastersthesis diplomathesis phdthesis].include?(key)
end
- def self.InBook
- self.for_type('InBook')
+
+ def other?
+ key == 'other'
end
- def self.InCollection
- self.for_type('InCollection')
+
+ def preprint?
+ key == 'preprint'
end
- def self.InProceedings
- self.for_type('InProceedings')
+
+ def report?
+ key == 'report'
end
- def self.Manual
- self.for_type('Manual')
+
+ def audiovisual?
+ key == 'audiovisual'
end
- def self.Masters_Thesis
- self.for_type('Masters_Thesis')
+
+ def award?
+ key == 'award'
end
- def self.Misc
- self.for_type('Misc')
+
+ def computationalnotebook?
+ key == 'computationalnotebook'
end
- def self.Bachelor_Thesis
- self.for_type('Bachelor_Thesis')
+
+ def datapaper?
+ key == 'datapaper'
end
- def self.Phd_Thesis
- self.for_type('Phd_Thesis')
+
+ def dataset?
+ key == 'dataset'
end
- def self.Proceedings
- self.for_type('Proceedings')
+
+ def event?
+ key == 'event'
end
- def self.Tech_Report
- self.for_type('Tech_Report')
+
+ def image?
+ key == 'image'
end
- def self.Unpublished
- self.for_type('Unpublished')
+
+ def instrument?
+ key == 'instrument'
end
- def is_journal?
- key == "article"
+ def interactiveresource?
+ key == 'interactiveresource'
end
- def is_book?
- key == 'book'
+ def model?
+ key == 'model'
end
- def is_booklet?
- key == 'booklet'
+ def outputmanagementplan?
+ key == 'outputmanagementplan'
end
- def is_inbook?
- key == 'inbook'
+ def peerreview?
+ key == 'peerreview'
end
- def is_incollection?
- key == 'incollection'
+ def physicalobject?
+ key == 'physicalobject'
end
- def is_inproceedings?
- key == 'inproceedings'
+ def project?
+ key == 'project'
end
- def is_manual?
- key == 'manual'
+ def service?
+ key == 'service'
end
- def is_masters_thesis?
- key == 'mastersthesis'
+ def software?
+ key == 'software'
end
- def is_misc?
- key == 'misc'
+ def sound?
+ key == 'sound'
end
- def is_phd_thesis?
- key == 'phdthesis'
+ def standard?
+ key == 'standard'
end
- def is_bachelor_thesis?
- key == 'bachelorsthesis'
+ def studyregistration?
+ key == 'studyregistration'
end
- def is_proceedings?
- key == 'proceedings'
+ def workflow?
+ key == 'workflow'
end
- def is_tech_report?
- key == 'techreport'
+ def projectdeliverable?
+ key == 'projectdeliverable'
end
- def is_unpublished?
- key == 'unpublished'
+
+ # Extract publication type from BibTeX record
+ def self.get_publication_type_id(bibtex_record)
+ # Extract the BibTeX entry type, e.g. article, inbook, misc...
+ publication_key = bibtex_record.to_s[/@(.*?)\{/m, 1].to_s.downcase.strip
+ datacite_key = BIBTEX_TO_DATACITE_KEY[publication_key] || 'other'
+ pub_type = PublicationType.find_by(key: datacite_key)
+ return pub_type.id if pub_type
+ other_type = PublicationType.find_by(key: 'other')
+ other_type&.id
end
-end
\ No newline at end of file
+end
diff --git a/app/views/publications/new.html.erb b/app/views/publications/new.html.erb
index c1297fd0ad..65f70ed9ba 100644
--- a/app/views/publications/new.html.erb
+++ b/app/views/publications/new.html.erb
@@ -29,10 +29,12 @@
- <%= collection_select :publication, :publication_type_id, PublicationType.order(:title), :id, :title,
- {:selected => PublicationType.Journal.id},
- {:class => 'form-control'} -%>
-
+ <%= collection_select :publication, :publication_type_id,
+ PublicationType.order(:title),
+ :id, :title,
+ { include_blank: "Please select a type ..." },
+ { class: "form-control" } %>
+
@@ -78,9 +80,11 @@
- <%= collection_select :publication, :publication_type_id, PublicationType.order(:title), :id, :title,
- {:selected => PublicationType.Journal.id},
- {:class => 'form-control'} -%>
+ <%= collection_select :publication, :publication_type_id,
+ PublicationType.order(:title),
+ :id, :title,
+ { include_blank: "Please select a type ..." },
+ { class: "form-control" } %>
diff --git a/config/default_data/publication_types.yml b/config/default_data/publication_types.yml
new file mode 100644
index 0000000000..4c7ca4d81b
--- /dev/null
+++ b/config/default_data/publication_types.yml
@@ -0,0 +1,153 @@
+# -------------------------------------------------------------------
+# Mapped legacy SEEK Types → New DataCite Types
+# Based on DataCite Metadata Schema Documentation
+# https://datacite-metadata-schema.readthedocs.io/en/4.6/appendices/appendix-1/resourceTypeGeneral/#
+# -------------------------------------------------------------------
+
+JournalArticle:
+ title: Journal Article
+ key: journalarticle # was: article (Journal)
+
+Book:
+ title: Book
+ key: book
+
+Booklet:
+ title: Booklet
+ key: booklet
+
+BookChapter:
+ title: Book Chapter
+ key: bookchapter # was: InBook (inbook)
+
+Collection:
+ title: Collection
+ key: collection # was: InCollection (incollection)
+
+ConferencePaper:
+ title: Conference Paper
+ key: conferencepaper # was: InProceedings (inproceedings)
+
+ConferenceProceeding:
+ title: Conference Proceeding
+ key: conferenceproceeding # was: Proceedings
+
+Text:
+ title: Text
+ key: text # was: Manual (manual)
+
+BachelorThesis:
+ title: Bachelor's Thesis
+ key: bachelorsthesis
+
+MastersThesis:
+ title: Master's Thesis
+ key: mastersthesis
+
+DiplomaThesis:
+ title: Diploma Thesis
+ key: diplomathesis
+
+PhdThesis:
+ title: PhD Thesis
+ key: phdthesis
+
+Other:
+ title: Other
+ key: other # replaces Misc
+
+Preprint:
+ title: Preprint
+ key: preprint # was: Unpublished
+
+Report:
+ title: Report
+ key: report # was: Tech report
+
+# -------------------------------------------------------------------
+# Additional Extended DataCite Types
+# -------------------------------------------------------------------
+
+Audiovisual:
+ title: Audiovisual
+ key: audiovisual
+
+Award:
+ title: Award
+ key: award
+
+ComputationalNotebook:
+ title: Computational Notebook
+ key: computationalnotebook
+
+DataPaper:
+ title: Data Paper
+ key: datapaper
+
+Dataset:
+ title: Dataset
+ key: dataset
+
+Event:
+ title: Event
+ key: event
+
+Image:
+ title: Image
+ key: image
+
+Instrument:
+ title: Instrument
+ key: instrument
+
+InteractiveResource:
+ title: Interactive Resource
+ key: interactiveresource
+
+Model:
+ title: Model
+ key: model
+
+OutputManagementPlan:
+ title: Output Management Plan
+ key: outputmanagementplan
+
+PeerReview:
+ title: Peer Review
+ key: peerreview
+
+PhysicalObject:
+ title: Physical Object
+ key: physicalobject
+
+Project:
+ title: Project
+ key: project
+
+Service:
+ title: Service
+ key: service
+
+Software:
+ title: Software
+ key: software
+
+Sound:
+ title: Sound
+ key: sound
+
+Standard:
+ title: Standard
+ key: standard
+
+StudyRegistration:
+ title: Study Registration
+ key: studyregistration
+
+Workflow:
+ title: Workflow
+ key: workflow
+
+ProjectDeliverable:
+ title: Project Deliverable
+ key: projectdeliverable
\ No newline at end of file
diff --git a/db/seeds/005_publication_types.seeds.rb b/db/seeds/005_publication_types.seeds.rb
index 4983ef6114..41275c3903 100644
--- a/db/seeds/005_publication_types.seeds.rb
+++ b/db/seeds/005_publication_types.seeds.rb
@@ -1,26 +1,66 @@
-PUBLICATION_TYPE = [{ title: "Journal", key: "article" },
- { title: "Book", key: "book" },
- { title: "Booklet", key: "booklet" },
- { title: "InBook", key: "inbook" },
- { title: "InCollection", key: "incollection" },
- { title: "InProceedings", key: "inproceedings" },
- { title: "Manual", key: "manual" },
- { title: "Misc", key: "misc" },
- { title: "Doctoral Thesis", key: "phdthesis" },
- { title: "Master's Thesis", key: "mastersthesis" },
- { title: "Bachelor's Thesis", key: "bachelorsthesis" },
- { title: "Proceedings", key: "proceedings" },
- { title: "Tech report", key: "techreport" },
- { title: "Unpublished", key: "unpublished" },
- { title: "Diplom Thesis", key: "diplomthesis" }
-
-]
-before_n = PublicationType.count
-PUBLICATION_TYPE.each do |type|
- publication_type= PublicationType.find_or_initialize_by(key: type[:key])
- publication_type.update(title: type[:title])
+puts 'Seeding Publication Types...'
+
+yml_path = Rails.root.join('config', 'default_data', 'publication_types.yml')
+pubtypes = YAML.load_file(yml_path)
+
+# Build lookup:
+# "Journal Article" → { "title" => "Journal Article", "key" => "journalarticle" }
+expected = pubtypes.values.index_by { |data| data["title"] }
+
+# -------------------------------------------------------------------
+# Legacy SEEK → DataCite mapping
+# -------------------------------------------------------------------
+LEGACY_MAPPING = {
+ 'Journal' => 'Journal Article',
+ 'InBook' => 'Book Chapter',
+ 'InCollection' => 'Collection',
+ 'InProceedings' => 'Conference Paper',
+ 'Proceedings' => 'Conference Proceeding',
+ 'Manual' => 'Text',
+ 'Misc' => 'Other',
+ 'Tech report' => 'Report',
+ 'Unpublished' => 'Preprint',
+ 'Doctoral Thesis' => 'PhD Thesis',
+ 'Diplom Thesis' => 'Diploma Thesis'
+}.freeze
+
+# -------------------------------------------------------------------
+# STEP 1 — Migrate legacy types to new DataCite types
+# -------------------------------------------------------------------
+PublicationType.all.each do |pt|
+ legacy_name = pt.title
+
+ if LEGACY_MAPPING.key?(legacy_name)
+ new_name = LEGACY_MAPPING[legacy_name]
+ target = expected[new_name]
+
+ if target
+ puts "Migrating #{legacy_name.inspect} → #{new_name.inspect}"
+ pt.update(title: target["title"], key: target["key"])
+ else
+ puts "WARNING: Missing mapping in YAML for #{new_name.inspect}"
+ end
+ end
end
-seeded_n = PublicationType.count - before_n
+# -------------------------------------------------------------------
+# STEP 2 — Ensure all DataCite YAML types exist and match
+# -------------------------------------------------------------------
+existing_by_key = PublicationType.all.index_by(&:key)
+expected.values.each do |etype|
+ title = etype["title"]
+ key = etype["key"]
+ existing = existing_by_key[key]
+
+ if existing.nil?
+ puts "Creating new type: #{title}"
+ PublicationType.create!(title: title, key: key)
+ else
+ if existing.title != title
+ puts "Updating title for #{key}: #{existing.title.inspect} → #{title.inspect}"
+ existing.update(title: title)
+ end
+ end
+end
-puts "Seeded #{seeded_n} publication types" if seeded_n > 0
\ No newline at end of file
+puts 'Publication types synced with publication_types.yml'
diff --git a/lib/tasks/seek_upgrades.rake b/lib/tasks/seek_upgrades.rake
index d1d98840d6..d53009d655 100644
--- a/lib/tasks/seek_upgrades.rake
+++ b/lib/tasks/seek_upgrades.rake
@@ -15,6 +15,7 @@ namespace :seek do
db:seed:003_model_formats
db:seed:004_model_recommended_environments
db:seed:004_model_types
+ db:seed:005_publication_types
update_rdf
update_morpheus_model
db:seed:018_discipline_vocab
diff --git a/test/factories/publications.rb b/test/factories/publications.rb
index 83f956db6e..b133bd0edd 100644
--- a/test/factories/publications.rb
+++ b/test/factories/publications.rb
@@ -2,20 +2,20 @@
# PublicationType
# :journal rely on the existence of the PublicationTypes
factory(:journal, class: PublicationType) do
- title { 'Journal' }
- key { 'article' }
+ title { 'Journal Article' }
+ key { 'journalarticle' }
end
factory(:phdthesis, class: PublicationType) do
- title { 'Phd Thesis' }
- key { 'phdthesis' }
+ title { 'PhD Thesis' }
+ key { 'phdthesis' }
end
factory(:inproceedings, class: PublicationType) do
- title { 'InProceedings' }
- key { 'inproceedings' }
+ title { 'Conference Paper' }
+ key { 'conferencepaper' }
end
# Publication
diff --git a/test/fixtures/files/bibtex/sample_publications.bib b/test/fixtures/files/bibtex/sample_publications.bib
new file mode 100644
index 0000000000..eac646546f
--- /dev/null
+++ b/test/fixtures/files/bibtex/sample_publications.bib
@@ -0,0 +1,59 @@
+
+@article{sample_journal,
+ author = {Doe, John and Smith, Jane},
+ title = {A Sample Journal Article},
+ journal = {Journal of Examples},
+ year = {2024},
+ volume = {12},
+ number = {3},
+ pages = {45--67},
+ doi = {10.1234/example.doi},
+}
+
+@book{sample_book,
+ author = {Adams, Douglas},
+ title = {The Example Book},
+ publisher = {Example Press},
+ year = {2020},
+ address = {Example City},
+}
+
+@inbook{sample_inbook,
+ author = {Brown, Charlie},
+ title = {A Chapter Inside a Book},
+ booktitle = {Collected Examples},
+ publisher = {Example House},
+ year = {2023},
+ pages = {100--120},
+}
+
+@inproceedings{sample_conferencepaper,
+ author = {Miller, Sarah},
+ title = {A Conference Paper Example},
+ booktitle = {Proceedings of the Example Conference},
+ year = {2022},
+ pages = {55--60},
+}
+
+@phdthesis{sample_phdthesis,
+ author = {Taylor, Alex},
+ title = {An Example PhD Thesis},
+ school = {Example University},
+ year = {2021},
+}
+
+@techreport{sample_report,
+ author = {Lee, Carol},
+ title = {A Technical Report Example},
+ institution = {Institute of Examples},
+ year = {2019},
+ number = {TR-2019-01},
+}
+
+@misc{sample_misc,
+ author = {Unknown, Person},
+ title = {Miscellaneous Example},
+ howpublished = {Online Resource},
+ year = {2018},
+ note = {Accessed 2025},
+}
diff --git a/test/fixtures/json/responses/get_max_publication.json.erb b/test/fixtures/json/responses/get_max_publication.json.erb
index 6eb0894965..a53087e94b 100644
--- a/test/fixtures/json/responses/get_max_publication.json.erb
+++ b/test/fixtures/json/responses/get_max_publication.json.erb
@@ -86,7 +86,7 @@
"publisher": "Heidelberg University Library, heiBOOKS",
"url": null,
"link_to_pub": "https://www.ncbi.nlm.nih.gov/pubmed/873864488",
- "publication_type": "Journal",
+ "publication_type": "Journal Article",
"authors": [
"Author_non_registered LastNonReg",
"Author_registered LastReg"
diff --git a/test/fixtures/json/responses/get_min_publication.json.erb b/test/fixtures/json/responses/get_min_publication.json.erb
index 89a5cb6079..c20c0717f6 100644
--- a/test/fixtures/json/responses/get_min_publication.json.erb
+++ b/test/fixtures/json/responses/get_min_publication.json.erb
@@ -53,7 +53,7 @@
"publisher": null,
"url": null,
"link_to_pub": "https://doi.org/10.5075/abcd",
- "publication_type": "Journal",
+ "publication_type": "Journal Article",
"authors": [
]
},
diff --git a/test/fixtures/publication_types.yml b/test/fixtures/publication_types.yml
index 44af087ad8..4c7ca4d81b 100644
--- a/test/fixtures/publication_types.yml
+++ b/test/fixtures/publication_types.yml
@@ -1,7 +1,12 @@
-# Needed as normally the types are Seeded.
-Journal:
- title: Journal
- key: article
+# -------------------------------------------------------------------
+# Mapped legacy SEEK Types → New DataCite Types
+# Based on DataCite Metadata Schema Documentation
+# https://datacite-metadata-schema.readthedocs.io/en/4.6/appendices/appendix-1/resourceTypeGeneral/#
+# -------------------------------------------------------------------
+
+JournalArticle:
+ title: Journal Article
+ key: journalarticle # was: article (Journal)
Book:
title: Book
@@ -11,42 +16,138 @@ Booklet:
title: Booklet
key: booklet
-InBook:
- title: InBook
- key: inbook
+BookChapter:
+ title: Book Chapter
+ key: bookchapter # was: InBook (inbook)
+
+Collection:
+ title: Collection
+ key: collection # was: InCollection (incollection)
-InCollection:
- title: InCollection
- key: incollection
+ConferencePaper:
+ title: Conference Paper
+ key: conferencepaper # was: InProceedings (inproceedings)
-InProceedings:
- title: InProceedings
- key: inproceedings
+ConferenceProceeding:
+ title: Conference Proceeding
+ key: conferenceproceeding # was: Proceedings
-Manual:
- title: Manual
- key: manual
+Text:
+ title: Text
+ key: text # was: Manual (manual)
+
+BachelorThesis:
+ title: Bachelor's Thesis
+ key: bachelorsthesis
MastersThesis:
- title: Masters Thesis
+ title: Master's Thesis
key: mastersthesis
-Misc:
- title: Misc
- key: misc
+DiplomaThesis:
+ title: Diploma Thesis
+ key: diplomathesis
PhdThesis:
- title: Phd Thesis
+ title: PhD Thesis
key: phdthesis
-Proceedings:
- title: Proceedings
- key: proceedings
+Other:
+ title: Other
+ key: other # replaces Misc
+
+Preprint:
+ title: Preprint
+ key: preprint # was: Unpublished
+
+Report:
+ title: Report
+ key: report # was: Tech report
+
+# -------------------------------------------------------------------
+# Additional Extended DataCite Types
+# -------------------------------------------------------------------
+
+Audiovisual:
+ title: Audiovisual
+ key: audiovisual
+
+Award:
+ title: Award
+ key: award
+
+ComputationalNotebook:
+ title: Computational Notebook
+ key: computationalnotebook
+
+DataPaper:
+ title: Data Paper
+ key: datapaper
+
+Dataset:
+ title: Dataset
+ key: dataset
+
+Event:
+ title: Event
+ key: event
+
+Image:
+ title: Image
+ key: image
+
+Instrument:
+ title: Instrument
+ key: instrument
+
+InteractiveResource:
+ title: Interactive Resource
+ key: interactiveresource
+
+Model:
+ title: Model
+ key: model
+
+OutputManagementPlan:
+ title: Output Management Plan
+ key: outputmanagementplan
+
+PeerReview:
+ title: Peer Review
+ key: peerreview
+
+PhysicalObject:
+ title: Physical Object
+ key: physicalobject
+
+Project:
+ title: Project
+ key: project
+
+Service:
+ title: Service
+ key: service
+
+Software:
+ title: Software
+ key: software
+
+Sound:
+ title: Sound
+ key: sound
+
+Standard:
+ title: Standard
+ key: standard
+
+StudyRegistration:
+ title: Study Registration
+ key: studyregistration
-Techreport:
- title: Tech report
- key: techreport
+Workflow:
+ title: Workflow
+ key: workflow
-Unpublished:
- title: Unpublished
- key: unpublished
\ No newline at end of file
+ProjectDeliverable:
+ title: Project Deliverable
+ key: projectdeliverable
\ No newline at end of file
diff --git a/test/functional/publications_controller_test.rb b/test/functional/publications_controller_test.rb
index 9783fbbc7d..7828792a1a 100644
--- a/test/functional/publications_controller_test.rb
+++ b/test/functional/publications_controller_test.rb
@@ -300,16 +300,51 @@ def test_title
assert_difference('Publication.count', 0) do
post :create, params: { subaction: 'ImportMultiple', publication: { bibtex_file: fixture_file_upload('bibtex/error_bibtex.bib'), project_ids: [projects(:one).id] } }
assert_redirected_to publications_path
- assert_includes flash[:error], 'An InProceedings needs to have a booktitle.'
+ assert_includes flash[:error], 'A Conference Paper needs to have a booktitle.'
assert_includes flash[:error], 'Please check your bibtex files, each publication should contain a title or a chapter name.'
- assert_includes flash[:error], 'An InCollection needs to have a booktitle.'
- assert_includes flash[:error], 'A Phd Thesis needs to have a school.'
- assert_includes flash[:error], 'A Masters Thesis needs to have a school.'
- assert_includes flash[:error], 'You need at least one author or editor for the Journal.'
+ assert_includes flash[:error], 'A Collection needs to have a booktitle.'
+ assert_includes flash[:error], 'A PhD Thesis needs to have a school.'
+ assert_includes flash[:error], "A Master's Thesis needs to have a school."
+ assert_includes flash[:error], 'You need at least one author or editor for the Journal Article.'
+ end
+ end
+
+ test 'should import publication types and titles from sample bibtex file' do
+ expected_pubs = [
+ { title: 'A Sample Journal Article', type_title: 'Journal Article' },
+ { title: 'The Example Book', type_title: 'Book' },
+ { title: 'A Chapter Inside a Book', type_title: 'Book Chapter' },
+ { title: 'A Conference Paper Example', type_title: 'Conference Paper' },
+ { title: 'An Example PhD Thesis', type_title: 'PhD Thesis' },
+ { title: 'A Technical Report Example', type_title: 'Report' },
+ { title: 'Miscellaneous Example', type_title: 'Other' }
+ ]
+
+ assert_difference('Publication.count', expected_pubs.count) do
+ post :create, params: {
+ subaction: 'ImportMultiple',
+ publication: {
+ bibtex_file: fixture_file_upload('bibtex/sample_publications.bib'),
+ project_ids: [projects(:one).id]
+ }
+ }
+ end
+
+ expected_pubs.each do |entry|
+ title = entry[:title]
+ expected_title = entry[:type_title]
+
+ publication = Publication.find_by(title: title)
+ assert_not_nil publication, "Publication '#{title}' should have been imported"
+
+ assert_equal expected_title,
+ publication.publication_type.title
end
end
+
+
test 'should associate authors to users when importing multiple publications from bibtex files' do
publications = [