invenio_migrator/tasks/deposit.py
def create_record_and_pid(data):
    """Create the deposit record metadata and persistent identifier.

    :param data: Raw JSON dump of the deposit.
    :type data: dict
    :returns: A deposit object and its pid
    :rtype: (`invenio_records.api.Record`,
             `invenio_pidstore.models.PersistentIdentifier`)
    """
    from invenio_records.api import Record
    from invenio_pidstore.models import PersistentIdentifier, PIDStatus, \
        RecordIdentifier

    deposit = Record.create(data=data)

    created = arrow.get(data['_p']['created']).datetime
    deposit.model.created = created.replace(tzinfo=None)
    depid = deposit['_p']['id']
    pid = PersistentIdentifier.create(
        pid_type='depid',
        pid_value=str(depid),
        object_type='rec',
        object_uuid=str(deposit.id),
        status=PIDStatus.REGISTERED
    )
    if RecordIdentifier.query.get(int(depid)) is None:
        RecordIdentifier.insert(int(depid))
    deposit.commit()
    return deposit, pid
def create_record_and_pid(data):
    """Create the deposit record metadata and persistent identifier.

    :param data: Raw JSON dump of the deposit.
    :type data: dict
    :returns: A deposit object and its pid
    :rtype: (`invenio_records.api.Record`,
             `invenio_pidstore.models.PersistentIdentifier`)
    """
    from invenio_records.api import Record
    from invenio_pidstore.models import PersistentIdentifier, PIDStatus, \
        RecordIdentifier

    deposit = Record.create(data=data)

    created = arrow.get(data['_p']['created']).datetime
    deposit.model.created = created.replace(tzinfo=None)
    depid = deposit['_p']['id']
    pid = PersistentIdentifier.create(
        pid_type='depid',
        pid_value=str(depid),
        object_type='rec',
        object_uuid=str(deposit.id),
        status=PIDStatus.REGISTERED
    )
    if RecordIdentifier.query.get(int(depid)) is None:
        RecordIdentifier.insert(int(depid))
    deposit.commit()
    return deposit, pid
Create the deposit record metadata and persistent identifier.

    :param data: Raw JSON dump of the deposit.
    :type data: dict
    :returns: A deposit object and its pid
    :rtype: (`invenio_records.api.Record`,
             `invenio_pidstore.models.PersistentIdentifier`)