How to use the biblib.services.metajson_service.create_identifier function in biblib

To help you get started, we’ve selected a few biblib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github medialab / reference_manager / biblib / crosswalks / mods_crosswalk.py View on Github external
if mods_name_id is not None:
            if "spire" in mods_name_id:
                # In case of Spire name.ID
                # name.ID format : _-_spire_-_creator_id_-_creator_dai_-_affiliation_id_-_random_id
                spire_name_ids = mods_name_id.split("_-_")
                if spire_name_ids and len(spire_name_ids) >= 4:
                    agent_rec_id = spire_name_ids[2].replace("__", "/")
                    affiliation_rec_id = spire_name_ids[4]
                    if affiliation_rec_id:
                        affiliation_rec_id = affiliation_rec_id.replace("__", "/")
            elif dai_dict is not None and mods_name_id in dai_dict:
                # agent_rec_id
                agent_rec_id = dai_dict[mods_name_id]["value"]
                # agent_identifiers
                id_value = dai_dict[mods_name_id]["authority"] + "/" + dai_dict[mods_name_id]["value"]
                agent_identifiers = [metajson_service.create_identifier("uri", id_value)]

        if mods_name_affiliations:
            affiliation_name = mods_name_affiliations[0].text.strip()

        if affiliation_name or affiliation_rec_id:
            affiliation = metajson_service.create_affiliation(affiliation_rec_id, affiliation_name, None, None, None, False)

        if mods_name_type == "personal":
            # logging.debug("personal")
            person = Person()

            if agent_rec_id:
                person["rec_id"] = agent_rec_id
            if agent_identifiers:
                person["identifiers"] = agent_identifiers
github medialab / reference_manager / biblib / crosswalks / endnotexml_crosswalk.py View on Github external
document.set_key_if_not_none("date_issued_first", date_issued_first)
                if rec_type in unpublished_types:
                    document.set_key_if_not_none("date_created", date_issued)
                else:
                    document.set_key_if_not_none("date_issued", date_issued)
        else:
            document.set_key_if_not_none("date_issued_first", date_issued_first)
            if rec_type in unpublished_types:
                document.set_key_if_not_none("date_created", date_issued)
            else:
                document.set_key_if_not_none("date_issued", date_issued)

    # identifiers[]
    identifiers = []
    if accessionnumber:
        identifiers.append(metajson_service.create_identifier("accessionnumber", accessionnumber))
    if callnumber:
        identifiers.append(metajson_service.create_identifier("callnumber", callnumber))
    if doi:
        identifiers.append(metajson_service.create_identifier("doi", doi))
    if identifiers:
        document["identifiers"] = identifiers

    # language
    if language:
        rfc5646 = language_service.convert_unknown_format_to_rfc5646(language)
        if rfc5646:
            document["languages"] = [rfc5646]

    # note
    if endnote_import_note and note:
        document.set_key_with_value_type_in_list("notes", note, "general")
github medialab / reference_manager / biblib / crosswalks / mods_crosswalk.py View on Github external
# rec_id
    rec_id = None
    mods_id = mods.get("ID")
    if mods_id is not None:
        rec_id = mods_id
    else:
        pass

    # identifiers
    mods_identifiers = mods.findall(xmletree.prefixtag("mods", "identifier"))
    if mods_identifiers:
        identifiers = []
        for mods_identifier in mods_identifiers:
            if mods_identifier is not None:
                identifier = metajson_service.create_identifier(mods_identifier.get("type"), mods_identifier.text.strip())
                if identifier:
                    identifiers.append(identifier)
        if identifiers:
            result["identifiers"] = identifiers
            if rec_id is None:
                rec_id = "{}:{}".format(identifiers[0]["id_type"], identifiers[0]["value"])

    if rec_id:
        result["rec_id"] = rec_id
    return result
github medialab / reference_manager / biblib / crosswalks / researcherml_crosswalk.py View on Github external
rml_identifiers = rml.findall(xmletree.prefixtag("rml", "identifier"))
    if rml_identifiers is not None:
        identifiers = []
        rec_id = None
        for rml_identifier in rml_identifiers:
            if rml_identifier is not None:
                # @type -> id_type
                id_type = rml_identifier.get("type")
                # value
                id_value = xmletree.get_element_text(rml_identifier)
                if id_type is None or id_type == "hdl":
                    # rec_id
                    rec_id = id_value
                else:
                    # identifier
                    identifier = metajson_service.create_identifier(id_type, id_value)
                    if identifier is not None:
                        identifiers.append(identifier)
        if identifiers:
            result["identifiers"] = identifiers
        if rec_id:
            result["rec_id"] = rec_id
    return result
github medialab / reference_manager / biblib / crosswalks / ris_crosswalk.py View on Github external
document["notes"] = [{"language": "und", "value": value}]
                elif key == "PB":
                    document.add_item_to_key(value, "publishers")
                elif key == "CY":
                    document.add_item_to_key(value, "publication_places")
                elif key == "RP":
                    document["publication_status"] = value
                elif key == "ET":
                    document["edition"] = value
                elif key == "UR":
                    resource = Resource()
                    resource["url"] = value
                    document.add_item_to_key(resource, "resources")
                elif key == "AN":
                    # Accession Number
                    identifier = metajson_service.create_identifier("accessionnumber", value)
                    document.add_identifier(identifier)
                elif key == "CN":
                    # Call Number
                    identifier = metajson_service.create_identifier("callnumber", value)
                    document.add_identifier(identifier)
                elif key == "DO":
                    # DOI
                    identifier = metajson_service.create_identifier("doi", value)
                    document.add_identifier(identifier)
                elif key == "SN":
                    # ISBN or ISSN ?
                    id_type = None
                    if rec_type in [constants.DOC_TYPE_JOURNALARTICLE, constants.DOC_TYPE_MAGAZINEARTICLE, constants.DOC_TYPE_NEWSPAPERARTICLE, constants.DOC_TYPE_JOURNAL]:
                        id_type = "issn"
                    else:
                        id_type = "isbn"
github medialab / reference_manager / biblib / crosswalks / summonjson_crosswalk.py View on Github external
title_sub = string.strip_html_tags(extract_value(sum_doc, "Subtitle"))

    # identifiers
    has_isbn = False
    has_eissn = False
    identifiers_item = []
    is_part_of_identifiers = []
    for sum_key in summon_identifier_type_to_metajson_identifier_type:
        if sum_key in sum_doc:
            for id_value in sum_doc[sum_key]:
                id_type = summon_identifier_type_to_metajson_identifier_type[sum_key]
                if id_type == "issn":
                    is_part_of_identifiers.append(metajson_service.create_identifier(id_type, id_value))
                elif id_type == "eissn":
                    has_eissn = True
                    is_part_of_identifiers.append(metajson_service.create_identifier(id_type, id_value))
                elif id_type == "isbn":
                    has_isbn = True
                    is_part_of_identifiers.append(metajson_service.create_identifier(id_type, id_value))
                else:
                    identifiers_item.append(metajson_service.create_identifier(id_type, id_value))

    # is_part_of_type determination
    is_part_of_type = None
    if sum_type in summon_document_type_to_metajson_document_is_part_of_type:
        is_part_of_type = summon_document_type_to_metajson_document_is_part_of_type[sum_type]

    elif is_part_of_title and is_part_of_title != title and rec_type not in ["Book", "Journal", "Magazine", "Newspaper", "Periodical"]:
        if has_isbn:
            is_part_of_type = "Book"
        elif has_eissn:
            is_part_of_type = "Journal"
github medialab / reference_manager / biblib / crosswalks / endnotexml_crosswalk.py View on Github external
if is_part_of_is_part_of_type is not None:
            # is_part_of in case of is_part_of.is_part_of
            # creators with role aut
            is_part_of.add_creators(creator_service.change_contibutors_role(secondary_creators, "aut"))

            # is_part_of.is_part_of
            is_part_of_is_part_of = Document()
            is_part_of_is_part_of.set_key_if_not_none("rec_type", is_part_of_is_part_of_type)
            is_part_of_is_part_of.set_key_if_not_none("title", title_translated)
            # creators with role pbd
            is_part_of_is_part_of.add_creators(creator_service.change_contibutors_role(translated_creators, "pbd"))
            #is_part_of_is_part_of.set_key_if_not_none("date_issued",date_year)
            is_part_of_is_part_of.set_key_if_not_none("publishers", publishers)
            is_part_of_is_part_of.set_key_if_not_none("publication_places", publication_places)
            if isbn_or_issn:
                is_part_of["identifiers"] = [metajson_service.create_identifier(isbn_or_issn_type, isbn_or_issn)]

            is_part_of.add_items_to_key([is_part_of_is_part_of], "is_part_ofs")

        else:
            # is_part_of in case of no is_part_of.is_part_of
            # creators with role edt
            is_part_of.add_creators(secondary_creators)
            #is_part_of.set_key_if_not_none("date_issued",date_year)
            is_part_of.set_key_if_not_none("publishers", publishers)
            is_part_of.set_key_if_not_none("publication_places", publication_places)
            if isbn_or_issn:
                is_part_of["identifiers"] = [metajson_service.create_identifier(isbn_or_issn_type, isbn_or_issn)]

        if "title" in is_part_of and is_part_of["title"]:
            document.add_items_to_key([is_part_of], "is_part_ofs")
github medialab / reference_manager / biblib / cloud / oaipmh_harvester.py View on Github external
def convert_record(record, meta_orig_prefix, source):
    #logging.debug("convert_record")
    header = convert_header(record[0])
    meta_orig_value = record[1].getField("orig").encode('utf-8')
    #logging.debug("meta_orig_value: {}".format(meta_orig_value))
    metajson_list = crosswalks_service.parse_and_convert_string(meta_orig_value, meta_orig_prefix, constants.FORMAT_METAJSON, source, "", False, False)
    #logging.debug("metajson_list: {}".format(metajson_list))
    metajson = None
    if metajson_list:
        metajson = metajson_list.next()
    if metajson:
        # header identifier
        if "identifiers" not in metajson:
            metajson["identifiers"] = []
        metajson["identifiers"].append(metajson_service.create_identifier("oai", header["identifier"]))
        # todo : use the identifier info replace the prefix
        metajson["rec_id"] = header["identifier"].replace("oai:spire.sciences-po.fr:", "")
        # header datestamp
        metajson["rec_modified_date"] = header["datestamp"]
        # header setspecs
        metajson["sets"] = header["setspecs"]
        # header deleted
        if header['deleted']:
            metajson["rec_status"] = "deleted"
        else:
            metajson["rec_status"] = "published"
        #logging.debug("metajson: {}".format(metajson))
    return metajson