Skip to content

Commit

Permalink
Map agencies to the json blob
Browse files Browse the repository at this point in the history
  • Loading branch information
payten committed Aug 27, 2019
1 parent a09543c commit f1f60f2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
34 changes: 34 additions & 0 deletions backend/index_feed/agency_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,38 @@ def map_record(obj, json, solr_doc)
solr_doc
end

def parse_whitelisted_json(obj, json)
whitelisted = super

whitelisted['id'] = obj.id
whitelisted['uri'] = json.uri
whitelisted['qsa_id'] = json.qsa_id
whitelisted['qsa_id_prefixed'] = json.qsa_id_prefixed

whitelisted['display_string'] = json.title
whitelisted['abstract'] = json.agency_note
whitelisted['display_name'] = parse_names([json.display_name]).first
whitelisted['names'] = parse_names(json.names)
whitelisted['notes'] = parse_notes(json.notes)
whitelisted['external_references'] = parse_external_references(json.external_references)
whitelisted['agent_relationships'] = parse_series_system_rlshps(json.series_system_agent_relationships)
whitelisted['function_relationships'] = parse_series_system_rlshps(json.series_system_function_relationships)
whitelisted['mandate_relationships'] = parse_series_system_rlshps(json.series_system_mandate_relationships)

whitelisted
end

def parse_external_references(references)
references.map{|ref| ref['publish']}
end

def parse_names(names)
names.map do |name|
{
'primary_name' => name['primary_name'],
'accronym' => name['subordinate_name_1'],
'alternative_name' => name['subordinate_name_2'],
}
end
end
end
2 changes: 1 addition & 1 deletion backend/index_feed/item_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def parse_whitelisted_json(obj, json)
whitelisted['parent'] = json.parent
whitelisted['resource'] = json.resource

whitelisted['title'] = json.display_string
whitelisted['display_string'] = json.display_string
whitelisted['description'] = json.description
whitelisted['sensitivity_label'] = json.sensitivity_label
whitelisted['agency_assigned_id'] = json.agency_assigned_id
Expand Down
2 changes: 1 addition & 1 deletion backend/index_feed/representation_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def parse_whitelisted_json(obj, json)

whitelisted['controlling_record'] = json.controlling_record

whitelisted['title'] = json.display_string
whitelisted['display_string'] = json.display_string
whitelisted['description'] = json.description
whitelisted['agency_assigned_id'] = json.agency_assigned_id
whitelisted['external_ids'] = parse_external_ids(json.external_ids)
Expand Down
2 changes: 1 addition & 1 deletion backend/index_feed/series_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def parse_whitelisted_json(obj, json)
whitelisted['qsa_id'] = json.qsa_id
whitelisted['qsa_id_prefixed'] = json.qsa_id_prefixed

whitelisted['title'] = json.title
whitelisted['display_string'] = json.title
whitelisted['sensitivity_label'] = json.sensitivity_label
whitelisted['dates'] = parse_dates(json.dates)
whitelisted['subjects'] = parse_subjects(json.subjects)
Expand Down

0 comments on commit f1f60f2

Please sign in to comment.