@records.command()<EOL>@click.argument('<STR_LIT:source>', type=click.File('<STR_LIT:r>'), default=sys.stdin)<EOL>@click.option('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', multiple=True)<EOL>@click.option('<STR_LIT>', is_flag=True, default=False)<EOL>@option_pid_minter<EOL>@with_appcontext<EOL>def create(source, ids, force, pid_minter=None):
records_deprecation_warning()<EOL>from .api import Record<EOL>from .models import RecordMetadata<EOL>pid_minter = [process_minter(minter) for minter in pid_minter or []]<EOL>data = json.load(source)<EOL>if isinstance(data, dict):<EOL><INDENT>data = [data]<EOL><DEDENT>if ids:<EOL><INDENT>assert len(ids) == len(data), '<STR_LIT>'<EOL><DEDENT>for record, id_ in zip_longest(data, ids):<EOL><INDENT>id_ = id_ or uuid.uuid4()<EOL>try:<EOL><INDENT>for minter in pid_minter:<EOL><INDENT>minter(id_, record)<EOL><DEDENT>click.echo(Record.create(record, id_=id_).id)<EOL><DEDENT>except exc.IntegrityError:<EOL><INDENT>if force:<EOL><INDENT>current_app.logger.warning(<EOL>"<STR_LIT>".format(id_))<EOL>vm = current_app.extensions['<STR_LIT>'].versioning_manager<EOL>uow = vm.unit_of_work(db.session)<EOL>uow.create_transaction(db.session)<EOL>model = RecordMetadata.query.get(id_)<EOL>rec = Record(record, model=model).commit()<EOL>current_app.logger.info("<STR_LIT>".format(<EOL>rec.revision_id))<EOL>click.echo(rec.id)<EOL><DEDENT>else:<EOL><INDENT>raise click.BadParameter(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(id_),<EOL>param_hint='<STR_LIT>',<EOL>)<EOL><DEDENT><DEDENT>db.session.flush()<EOL><DEDENT>db.session.commit()<EOL>
Create new bibliographic record(s).