Skip to content
Snippets Groups Projects
Commit 691e1c6f authored by Anusha Ranganathan's avatar Anusha Ranganathan
Browse files

Merge branch 'update-crc-dataset' into 'develop'

Update CRC dataset model and Add tests

See merge request FDM/rdm-system/rdms!8
parents 1fd4f92b da148f73
No related branches found
No related tags found
2 merge requests!19Develop,!8Update CRC dataset model and Add tests
......@@ -6,7 +6,7 @@ class CrcDataset < ActiveFedora::Base
self.indexer = CrcDatasetIndexer
# Change this to restrict which works can be added as a child.
# self.valid_child_concerns = []
validates :title, presence: { message: 'Your dataset must have a title.' }
validates :title, presence: { message: 'Your CRC dataset must have a title.' }
# ------ properties from core metadata ------
# property date_modified - not displayed (filled in by the system)
......@@ -39,6 +39,7 @@ class CrcDataset < ActiveFedora::Base
# property bibliographic_citation - not displayed (generated by the system)
# property source - do not display (should be filled in by the system for bulk imports)
# ------ properties from Datacite metadata ------
property :doi, predicate: ::RDF::Vocab::DataCite.doi, multiple: false do |index|
index.as :symbol
end
......@@ -66,6 +67,8 @@ class CrcDataset < ActiveFedora::Base
property :complex_relation, predicate: ::RDF::Vocab::DC.relation, class_name:"ComplexRelation"
# ------ properties from CRC metadata ------
property :modality, predicate: ::RDF::Vocab::Rdms.modality, multiple: false do |index|
index.as :stored_searchable, :facetable
end
......@@ -84,6 +87,11 @@ class CrcDataset < ActiveFedora::Base
index.as :stored_searchable
end
# ------ properties from DublinCore metadata ------
property :coverage, predicate: ::RDF::Vocab::DC.coverage do |index|
index.as :stored_searchable
end
# This must be included at the end, because it finalizes the metadata
# schema (by adding accepts_nested_attributes)
include ::Hyrax::BasicMetadata
......
FactoryBot.define do
factory :crc_dataset do
transient do
user { create(:user) }
# Set to true (or a hash) if you want to create an admin set
with_admin_set { false }
end
title { ["CRC dataset"] }
access_control
trait :open do
visibility { 'open' }
title { ["Open CRC dataset"] }
end
trait :authenticated do
visibility { 'authenticated' }
title { ["Authenticated CRC dataset"] }
end
trait :embargo do
visibility { 'embargo' }
title { ["Embargo CRC dataset"] }
end
trait :lease do
visibility { 'lease' }
title { ["Leased CRC dataset"] }
end
trait :restricted do
visibility { 'restricted' }
title { ["Restricted CRC dataset"] }
end
trait :with_abstract do
abstract { ["Abstract-Description-123"] }
end
trait :with_abstract_seq do
sequence(:abstract) { |n| ["Abstract-#{n}"] }
end
trait :with_alternative_title do
alternative_title { ['Alternative-Title-123'] }
end
trait :with_keyword do
keyword { ['Keyword-123'] }
end
trait :with_keyword_seq do
sequence(:keyword) { |n| ["Keyword-#{n}"] }
end
trait :with_subject do
subject { ['Subject-123'] }
end
trait :with_subject_seq do
sequence(:subject) { |n| ["Subject-#{n}"] }
end
trait :with_language do
language { ['Faroese'] }
end
trait :with_publisher do
publisher { ['Publisher-123'] }
end
trait :with_resource_type do
resource_type { ['Resource-Type-123'] }
end
trait :with_article_resource_type do
resource_type { ['Article'] }
end
trait :with_source do
source { ['Source-123'] }
end
trait :with_doi do
doi { "1234-1567" }
end
trait :with_complex_person do
complex_person_attributes {
[{
name: 'Anamika',
role: ['operator'],
orcid: '123456',
affiliation: 'University',
}]
}
end
trait :with_complex_author do
complex_person_attributes {
[{
name: 'Anamika',
role: ['author'],
orcid: '123456',
affiliation: 'University',
}]
}
end
trait :with_detailed_complex_author do
complex_person_attributes {
[{
name: 'Anamika',
first_name: 'First name',
last_name: 'Last name',
email: 'a@example.com',
role: ['author'],
orcid: '23542345234',
affiliation: 'My org'
}]
}
end
trait :with_detailed_complex_people do
complex_person_attributes {
[{
name: 'Anamika',
first_name: 'First name',
last_name: 'Last name',
role: ['author'],
orcid: '123456',
affiliation: 'University',
},
{
name: 'Cee Jay',
first_name: 'First name',
last_name: 'Last name',
role: ['editor'],
orcid: '112233445566',
affiliation: 'My journal org'
}]
}
end
trait :with_complex_date do
complex_date_attributes {
[{
date: '1978-10-28',
description: 'Collected'
}]
}
end
trait :with_complex_identifier do
complex_identifier_attributes {
[{
identifier: '10.0.1111',
scheme: 'DOI'
}]
}
end
trait :with_complex_relation do
complex_relation_attributes {
[{
title: 'A relation label',
url: 'http://example.com/relation',
complex_identifier_attributes: [{
identifier: ['info:hdl/4263537/400'],
scheme: 'identifier persistent'
}],
relationship: 'isNewVersionOf'
}]
}
end
trait :with_rights do
rights_statement {
[
'http://creativecommons.org/publicdomain/zero/1.0/'
]
}
end
trait :with_complex_funding_reference do
complex_funding_reference_attributes {
[{
funder_identifier: 'f1234',
funder_name: 'Bank',
award_number: 'a1234',
award_uri: 'http://example.com/a1234',
award_title: 'No free lunch'
}]
}
end
end
end
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment