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

Corrected mapping from meta.json to CRC Dataset model

parent 51d13c71
No related branches found
No related tags found
3 merge requests!115Tombstone not available for dataset,!77Bump ruby v2.7.7,!31Feature/metadata ui improvements
......@@ -67,19 +67,11 @@ module ComplexField
# solr fields that will be treated as facets
fields = []
# change all dates to years
fields << Solrizer.solr_name('complex_year_accepted', :facetable)
fields << Solrizer.solr_name('complex_year_available', :facetable)
fields << Solrizer.solr_name('complex_year_copyrighted', :facetable)
fields << Solrizer.solr_name('complex_year_collected', :facetable)
fields << Solrizer.solr_name('complex_year_created', :facetable)
fields << Solrizer.solr_name('complex_year_issued', :facetable)
fields << Solrizer.solr_name('complex_year_published', :facetable)
fields << Solrizer.solr_name('complex_year_submitted', :facetable)
fields << Solrizer.solr_name('complex_year_updated', :facetable)
fields << Solrizer.solr_name('complex_year_valid', :facetable)
fields << Solrizer.solr_name('complex_year_processed', :facetable)
fields << Solrizer.solr_name('complex_year_purchased', :facetable)
fields << Solrizer.solr_name('complex_year_other', :facetable)
date_options = DateService.new.select_all_options
date_options.each do |d|
fields << Solrizer.solr_name("complex_date_#{d[0].downcase.tr(' ', '_')}", :dateable)
# fields << Solrizer.solr_name("complex_year_#{d[0].downcase.tr(' ', '_')}", :facetable)
end
fields
end
......@@ -94,19 +86,10 @@ module ComplexField
def self.date_show_fields
# solr fields that will be used to display results on the record page
fields = []
fields << Solrizer.solr_name('complex_date_accepted', :displayable)
fields << Solrizer.solr_name('complex_date_available', :displayable)
fields << Solrizer.solr_name('complex_date_copyrighted', :displayable)
fields << Solrizer.solr_name('complex_date_collected', :displayable)
fields << Solrizer.solr_name('complex_date_created', :displayable)
fields << Solrizer.solr_name('complex_date_issued', :displayable)
fields << Solrizer.solr_name('complex_date_published', :displayable)
fields << Solrizer.solr_name('complex_date_submitted', :displayable)
fields << Solrizer.solr_name('complex_date_updated', :displayable)
fields << Solrizer.solr_name('complex_date_valid', :displayable)
fields << Solrizer.solr_name('complex_date_processed', :displayable)
fields << Solrizer.solr_name('complex_date_purchased', :displayable)
fields << Solrizer.solr_name('complex_date_other', :displayable)
date_options = DateService.new.select_all_options
date_options.each do |d|
fields << Solrizer.solr_name("complex_date_#{d[0].downcase.tr(' ', '_')}", :displayable)
end
fields
end
end
......
......@@ -19,7 +19,6 @@ module Bulkrax::HasLocalProcessing
parsed_metadata['complex_date'] = complex_date
parsed_metadata['complex_subject'] = [complex_subject]
parsed_metadata['complex_funding_reference'] = [complex_funding_reference]
parsed_metadata['complex_relation'] = [complex_relation]
end
def map_multiple_subject
......@@ -27,7 +26,7 @@ module Bulkrax::HasLocalProcessing
end
def map_multiple_modality
parsed_metadata['modality'] = record['modality'].present? ? record['modality'].split(';') : []
parsed_metadata['modality'] = record['modality'].present? ? JSON.parse(record['modality']) : []
end
def collection_type
......@@ -41,6 +40,10 @@ module Bulkrax::HasLocalProcessing
next unless record[role.to_s].present?
full_names = record[role.to_s].split(';')
orcids = record.fetch("#{role}_orcid", '').split(';')
affiliations = record.fetch("#{role}_affilation", '').split(';')
# ignoring creator identifier scheme and contributor identifier scheme
_schemes = record.fetch("#{role}_scheme", '').split(';')
full_names.each_with_index do |full_name, index|
complex_person_object = ComplexPerson.new(RDF::Node.new, ActiveTriples::Resource.new)
......@@ -48,14 +51,8 @@ module Bulkrax::HasLocalProcessing
complex_person_object['last_name'], complex_person_object['first_name'] = full_name.split(',').map(&:strip)
complex_person_object['name'] = full_name
complex_person_object['role'] = role
%w[orcid affilation].each do |key|
value = record["#{role}_#{key}"]
next unless value.present? && value.split(';') == full_names.count
complex_person[key] = value.split(';')[index]
end
complex_person_object['orcid'] = orcids[index] if orcids.count == full_names.count
complex_person_object['affiliation'] = affiliations[index] if affiliations.count == full_names.count
complex_persons << complex_person_object
end
......@@ -67,18 +64,13 @@ module Bulkrax::HasLocalProcessing
def complex_identifier
complex_identifiers = []
unless record['identifier'].present? &&
record['scheme'].present? &&
record['identifier'].split(';') == record['scheme'].split(';')
return complex_identifiers
end
return complex_identifiers unless record['group_identifier'].present?
record['identifier'].split(';').each_with_index do |_id, index|
complex_identifier_object = ComplexPerson.new(RDF::Node.new, ActiveTriples::Resource.new)
record['group_identifier'].split(';').each do |id|
complex_identifier_object = ComplexIdentifier.new(RDF::Node.new, ActiveTriples::Resource.new)
%w[scheme identifier].each do |attribute|
complex_identifier_object[attribute] = record[attribute.to_s].split(';')[index]
end
complex_identifier_object['scheme'] = 'group id'
complex_identifier_object['identifier'] = id
complex_identifiers << complex_identifier_object
end
......@@ -89,18 +81,31 @@ module Bulkrax::HasLocalProcessing
def complex_date
complex_dates = []
unless record['date_description'].present? &&
record['date'].present? &&
record['date_description'].split(';') == record['date'].split(';')
return complex_dates
# record_date
record_dates = record.fetch('record_date', '').split(';')
record_dates.each do |record_date|
complex_date_object = ComplexDate.new(RDF::Node.new, ActiveTriples::Resource.new)
complex_date_object['description'] = 'Recorded'
complex_date_object['date'] = record_date
complex_dates << complex_date_object
end
record['date_description'].split(';').each_with_index do |_date_type, index|
# Datacite date and date type
date_types = record.fetch('date_description', '').split(';')
dates = record.fetch('date', '').split(';')
return complex_dates unless date_types.count == dates.count
date_types.each_with_index do |date_type, index|
typ = DateService.new.find_by_label(date_type)
next unless typ.present?
complex_date_object = ComplexDate.new(RDF::Node.new, ActiveTriples::Resource.new)
%w[date_description date].each do |attribute|
complex_date_object[attribute] = record[attribute.to_s].split(';')[index]
end
complex_date_object['description'] = typ['id']
complex_date_object['date'] = dates[index]
complex_dates << complex_date_object
end
......@@ -111,7 +116,7 @@ module Bulkrax::HasLocalProcessing
def complex_subject
complex_subject_object = ComplexSubject.new(RDF::Node.new, ActiveTriples::Resource.new)
%w[subject_type subject_species subject_type subject_sex subject_sex subject_age].each do |attribute|
%w[subject_identifier subject_species subject_type subject_sex subject_age].each do |attribute|
complex_subject_object[attribute] = record[attribute]
end
......@@ -128,13 +133,4 @@ module Bulkrax::HasLocalProcessing
complex_funding_reference_object
end
def complex_relation
complex_relation_object = ComplexRelation.new(RDF::Node.new, ActiveTriples::Resource.new)
%w[title url relationship].each do |attribute|
complex_relation_object[attribute] = record[attribute]
end
complex_relation_object
end
end
......@@ -44,9 +44,11 @@ class PrepareCsvFromCrcFolder
contributor
contributor_orcid
contributor_affiliation
contributor_scheme
creator
creator_orcid
creator_affiliation
creator_scheme
keyword
resource_type
crc_resource_type
......@@ -56,8 +58,8 @@ class PrepareCsvFromCrcFolder
doi
alternative_title
description
scheme
identifier
group_identifier
record_date
date_description
date
modality
......@@ -75,9 +77,6 @@ class PrepareCsvFromCrcFolder
award_number
award_uri
award_title
relation_title
relation_url
relationship
coverage
software_version
extra_information
......@@ -319,9 +318,11 @@ class PrepareCsvFromCrcFolder
file_attributes['Contributor'],
file_attributes['DataCite-contributorNameIdentifier'],
file_attributes['DataCite-contirbutorAffiliation'],
file_attributes['DataCite-contributorNameIdentifierScheme'],
file_attributes['Creator'],
file_attributes['DataCite-creatorNameIdentifier'],
file_attributes['DataCite-creatorAffiliation'],
file_attributes['DataCite-creatorNameIdentifierScheme'],
'',
'Dataset',
file_attributes['Resource Type'],
......@@ -331,8 +332,8 @@ class PrepareCsvFromCrcFolder
'',
'',
file_attributes['DublinCore-Description'],
file_attributes['DataCite-creatorNameIdentifierScheme'],
file_attributes['Group ID'],
file_attributes['Record date'],
file_attributes['DataCite-dateType'],
file_attributes['DataCite-Date'],
file_attributes['Modality'],
......@@ -350,9 +351,6 @@ class PrepareCsvFromCrcFolder
'',
'',
'',
'',
'',
file_attributes['DublinCore-Relation'],
file_attributes['DublinCore-Coverage'],
file_attributes['Software version'],
file_attributes['Extra information']
......
......@@ -3,7 +3,7 @@ terms:
term: Accepted
active: true
- id: Available
term: Available (Embargo release)
term: Available
active: true
- id: http://bibframe.org/vocab/copyrightDate
term: Copyrighted
......@@ -17,8 +17,8 @@ terms:
- id: Deposited
term: Deposited
active: true
- id: record date
term: Record date
- id: Recorded
term: Recorded
active: true
- id: Registered
term: Registered
......
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