Skip to content

Commit

Permalink
Added a few more properties for PDC Describe records
Browse files Browse the repository at this point in the history
Co-authored-by: Claudia Lee <claudiawulee@users.noreply.github.com>
  • Loading branch information
2 people authored and jrgriffiniii committed Apr 18, 2024
1 parent 11836b3 commit 034549b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
10 changes: 9 additions & 1 deletion app/models/document_export.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# frozen_string_literal: true

class DocumentExport
attr_reader :id, :title, :files, :description, :abstract
attr_reader :id, :title, :files, :description, :abstract, :rights, :authors, :doi_value, :doi_url,
:total_file_size, :embargo_date, :globus_url

def initialize(solr_document)
@id = solr_document.id
@title = solr_document.title
@files = solr_document.files
@description = solr_document.description
@abstract = solr_document.abstract
@rights = solr_document.rights_enhanced
@authors = solr_document.authors_ordered
@doi_value = solr_document.doi_value
@doi_url = solr_document.doi_url
@total_file_size = solr_document.total_file_size
@embargo_date = solr_document.embargo_date
@globus_url = solr_document.globus_uri
end
end
38 changes: 28 additions & 10 deletions spec/models/document_export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@

require 'rails_helper'

# rubocop:disable Layout/LineLength
RSpec.describe DocumentExport do
let(:files_pdc_describe) {
[{ name: "file1.zip", full_name: "/folder1/file1.zip", size: 27, url: "https://pdc_describe" }, { name: "data.csv" }, { name: "file2.zip" }]
}
let(:files_pdc_describe) do
[{ name: "file1.zip", full_name: "/folder1/file1.zip", size: 27, url: "https://pdc_describe" }, { name: "data.csv", size: 100 }, { name: "file2.zip", size: 200 }]
end

let(:files_dataspace) {
let(:files_dataspace) do
[{ name: "file1.zip", size: 27, handle: "xyz" }, { name: "data.csv", size: 29, handle: "yzx" }, { name: "file2.zip", size: 28, handle: "zxy" }]
}
end

let(:solr_doc_pdc_describe) {
SolrDocument.new({ id: "1", title_tesim: ["Hello World"], files_ss: files_pdc_describe.to_json, data_source_ssi: "pdc_describe", description_tsim: ["Something"], abstract_tsim: ["Abstract"] })
}
let(:solr_doc_pdc_describe) do
SolrDocument.new({
id: "1", title_tesim: ["Hello World"], files_ss: files_pdc_describe.to_json,
data_source_ssi: "pdc_describe",
description_tsim: ["Something"],
abstract_tsim: ["Abstract"],
uri_ssim: ["https://doi.org/10.34770/bm4s-t361"],
embargo_date_dtsi: "2025-11-28",
globus_uri_ssi: "https://app.globus.org/file-manager?origin_id=something-something",
authors_json_ss: "[{\"value\":\"Alt, Andrew\",\"name_type\":\"Personal\",\"given_name\":\"Andrew\",\"family_name\":\"Alt\",\"identifier\":{\"value\":\"0000-0001-9475-8282\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":0},{\"value\":\"Ji, Hantao\",\"name_type\":\"Personal\",\"given_name\":\"Hantao\",\"family_name\":\"Ji\",\"identifier\":{\"value\":\"0000-0001-9600-9963\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":1},{\"value\":\"Yoo, Jongsoo\",\"name_type\":\"Personal\",\"given_name\":\"Jongsoo\",\"family_name\":\"Yoo\",\"identifier\":{\"value\":\"0000-0003-3881-1995\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":2},{\"value\":\"Bose, Sayak\",\"name_type\":\"Personal\",\"given_name\":\"Sayak\",\"family_name\":\"Bose\",\"identifier\":{\"value\":\"0000-0001-8093-9322\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":3},{\"value\":\"Goodman, Aaron\",\"name_type\":\"Personal\",\"given_name\":\"Aaron\",\"family_name\":\"Goodman\",\"identifier\":{\"value\":\"0000-0003-3639-6572\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":4},{\"value\":\"Yamada, Masaaki\",\"name_type\":\"Personal\",\"given_name\":\"Masaaki\",\"family_name\":\"Yamada\",\"identifier\":{\"value\":\"0000-0003-4996-1649\",\"scheme\":\"ORCID\",\"scheme_uri\":\"https://orcid.org\"},\"affiliations\":[{\"value\":\"Princeton Plasma Physics Laboratory\",\"identifier\":\"https://ror.org/03vn1ts68\",\"scheme\":\"ROR\",\"scheme_uri\":null}],\"sequence\":5}]"
})
end

let(:solr_doc_dataspace) {
let(:solr_doc_dataspace) do
SolrDocument.new({ id: "1", title_tesim: ["Hello World"], files_ss: files_dataspace.to_json, data_source_ssi: "dataspace", description_tsim: ["Something"], abstract_tsim: ["Abstract"] })
}
end

it "returns DocumentExport object's information from pdc_describe" do
document = described_class.new(solr_doc_pdc_describe)
Expand All @@ -29,6 +39,13 @@
expect(document.files.first.name).to eq "file1.zip"
expect(document.files.first.full_path).to eq "/folder1/file1.zip"
expect(document.files.first.download_url).to eq "https://pdc_describe"
expect(document.doi_value).to eq "10.34770/bm4s-t361"
expect(document.doi_url).to eq "https://doi.org/10.34770/bm4s-t361"
expect(document.embargo_date).to eq Date.parse("2025-11-28")
expect(document.total_file_size).to eq 327
expect(document.globus_url).to eq "https://app.globus.org/file-manager?origin_id=something-something"
expect(document.authors.count).to be 6
expect(document.authors[0].value).to eq "Alt, Andrew"
end

it "returns DocumentExport object's information from dataspace" do
Expand All @@ -42,3 +59,4 @@
expect(document.files.first.download_url).to eq "https://dataspace-dev.princeton.edu/bitstream/xyz/0"
end
end
# rubocop:enable Layout/LineLength

0 comments on commit 034549b

Please sign in to comment.