Skip to content

Commit

Permalink
various fixes from testing feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jambun committed Jun 14, 2022
1 parent f71681c commit f0c99d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions backend/model/reftracker_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ def self.closed_offers(page = 1)
]

# status of 700 is 'Closed successful' found this using /codetable?table=status
# qtype of 100 is 'Offerer service' - new requirement
# db = 5 is a magic number from the original plugin.
# without it the api complains about missing a param called 'source'
# sortby = 3 is ClosedDate
search_params = {
:status => '700',
:qtype => '100',
:db => '5',
:sortby => '3',
:sortorder => 'DESC',
Expand Down
34 changes: 24 additions & 10 deletions backend/model/reftracker_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def self.map_agent(qp)
agent = {}

# these come in as: Person, Corporate entity, Family
raise "Offer: #{qp['question_no']} does not have an Agent type set" unless qp['client_udf_cl01']
type = self.agent_type_map[qp['client_udf_cl01']]

agent['jsonmodel_type'] = type
Expand All @@ -103,22 +104,33 @@ def self.map_agent(qp)
if qp['bib_udf_tb04']
agent['notes'] << {
'jsonmodel_type' => 'note_general_context',
'lobel' => 'Vendor Code',
'label' => 'Vendor Code',
'subnotes' => [{'jsonmodel_type' => 'note_text', 'content' => qp['bib_udf_tb04']}]
}
end

if qp['bib_udf_ta03']
agent['notes'] << {
'jsonmodel_type' => 'note_bioghist',
'lobel' => 'Biographical/Historical Notes',
'label' => 'Biographical/Historical Notes',
'subnotes' => [{'jsonmodel_type' => 'note_text', 'content' => qp['bib_udf_ta03']}]
}
end

JSONModel::JSONModel(type).from_hash(agent)
end

def self.map_valuation_status(status)
@valuation_status_map ||= {
'Yes' => 'Valuation Required',
'No' => 'Valuation Not Required',
'Not sure' => 'Valuation Status Not Yet Determined',
'Completed' => 'Valuation Complete'
}

@valuation_status_map[status]
end


def self.map_accession(qp, agent_uri, subject_uris)
acc = {}
Expand All @@ -128,11 +140,18 @@ def self.map_accession(qp, agent_uri, subject_uris)
acc['id_0'] = qp['bib_udf_tb03']

acc['accession_date'] = qp['question_closed_datetime'].split[0]
acc['access_restrictions_note'] = qp['question_udf_ta15']

acc['access_restrictions_note'] = [
qp['question_udf_ta15'],
qp['question_udf_tb06'],
qp['question_udf_ta12'],
qp['question_udf_ta14']
].compact.join("\n")

acc['acquisition_type'] = qp['question_udf_cl03'].downcase
acc['content_description'] = qp['question_udf_ta08'] || qp['question_text']
acc['disposition'] = qp['bib_volume']
acc['inventory'] = qp['question_udf_tb11']
acc['inventory'] = qp['question_udf_tb02']
acc['provenance'] = qp['bib_udf_ta01']
acc['retention_rule'] = qp['question_udf_ta16']
acc['user_defined'] = {}
Expand All @@ -146,14 +165,9 @@ def self.map_accession(qp, agent_uri, subject_uris)
acc['user_defined']['text_2'] = qp['bib_udf_ta02']
acc['user_defined']['text_4'] = qp['question_udf_tb15']
acc['user_defined']['text_5'] = qp['question_udf_ta09']
acc['user_defined']['controlled_value_1'] = qp['question_udf_cl18']
acc['user_defined']['controlled_value_1'] = map_valuation_status(qp['question_udf_cl18'])
acc['user_defined']['controlled_value_3'] = qp['question_udf_cl01']

acc['user_defined'][''] = qp['']
acc['user_defined'][''] = qp['']
acc['user_defined'][''] = qp['']
acc['user_defined'][''] = qp['']

acc['extents'] = [{}]
acc['extents'][0]['container_summary'] = qp['bib_udf_tb01']

Expand Down

0 comments on commit f0c99d1

Please sign in to comment.