Esempio n. 1
0
def create_record_factory(
    record_type, data=None, with_pid=True, with_indexing=False, with_validation=False
):
    control_number = random.randint(1, 2_147_483_647)
    if with_validation:
        data = faker.record(record_type, data)
    record = RecordMetadataFactory(
        record_type=record_type, data=data, control_number=control_number
    )

    if with_pid:
        record._persistent_identifier = PersistentIdentifierFactory(
            object_uuid=record.id,
            pid_type=record_type,
            pid_value=record.json["control_number"],
        )

    if with_indexing:
        index = current_app.config["PID_TYPE_TO_INDEX"][record_type]
        record._index = current_search.client.index(
            index=get_index_alias(index), id=str(record.id), body=record.json, params={}
        )

        current_search.flush_and_refresh(index)
    return record
Esempio n. 2
0
    def _create_record_factory(
        record_type,
        data=None,
        with_pid=True,
        with_indexing=False,
        with_validation=False,
    ):
        control_number = random.randint(1, 2_147_483_647)
        if with_validation:
            data = faker.record(record_type, data)
        record = RecordMetadataFactory(record_type=record_type,
                                       data=data,
                                       control_number=control_number)

        if with_pid:
            record._persistent_identifier = PersistentIdentifierFactory(
                object_uuid=record.id,
                pid_type=record_type,
                pid_value=record.json["control_number"],
            )

        if with_indexing:
            index = base_app.config["PID_TYPE_TO_INDEX"][record_type]
            record._index = es_clear.index(
                index=index,
                id=str(record.id),
                doc_type=index.split("-")[-1],
                body=record.json,
                params={},
            )
            es_clear.indices.refresh(index)
        return record
Esempio n. 3
0
def create_pidstore(object_uuid, pid_type, pid_value):
    return PersistentIdentifierFactory(
        object_uuid=object_uuid, pid_type=pid_type, pid_value=pid_value
    )