Пример #1
0
def get_parent_record(data):
    if data.get("doc_type") == "inproceedings":
        conference_records = InspireRecord.get_linked_records_from_dict_field(
            data, "publication_info.conference_record")
        conference_record = next(conference_records, {})
        return conference_record

    book_records = InspireRecord.get_linked_records_from_dict_field(
        data, "publication_info.parent_record")
    return next(book_records, {})
Пример #2
0
    def get_resolved_references_by_control_number(self, data):
        data = force_list(data)
        resolved_records = InspireRecord.get_linked_records_from_dict_field(
            data, "record"
        )

        return {record["control_number"]: record.dumps() for record in resolved_records}
Пример #3
0
    def get_facet_author_name(self, record):
        """Prepare record for ``facet_author_name`` field."""
        authors_with_record = list(
            InspireRecord.get_linked_records_from_dict_field(
                record, "authors.record"))
        found_authors_control_numbers = set([
            author["control_number"] for author in authors_with_record
            if author.get("control_number")
        ])
        authors_without_record = [
            author for author in record.get("authors", [])
            if "record" not in author or int(
                PidStoreBase.get_pid_from_record_uri(author["record"].get(
                    "$ref"))[1]) not in found_authors_control_numbers
        ]
        result = []

        for author in authors_with_record:
            result.append(get_facet_author_name_for_author(author))

        for author in authors_without_record:
            result.append("NOREC_{}".format(
                get_display_name_for_author_name(author["full_name"])))

        return result
Пример #4
0
 def get_control_numbers_to_resolved_experiments_map(self, record):
     resolved_records = InspireRecord.get_linked_records_from_dict_field(
         record, "record")
     return {
         record["control_number"]: record
         for record in resolved_records
     }