Beispiel #1
0
def delete_all_by_registry_id(registry_id):
    """Delete all OaiRecord of a registry

    Args:
        registry_id: The registry id.

    """
    OaiRecord.delete_all_by_registry_id(registry_id)
Beispiel #2
0
def get_all():
    """Return all OaiRecord.

    Returns: List of OaiRecord.

    """
    return OaiRecord.get_all()
Beispiel #3
0
def transform_dict_record_to_oai_record(data, registry_all_sets=[]):
    """ Transforms a dict to a list of OaiRecord object.

    Args:
        data: Data to transform.
        registry_all_sets: List of all sets.

    Returns:
        List of OaiRecord instances.

    """
    list_records = []
    for obj in data:
        oai_record = OaiRecord()
        oai_record.identifier = obj['identifier']
        oai_record.last_modification_date = UTCdatetime.\
            utc_datetime_iso8601_to_datetime(obj['datestamp'])
        oai_record.deleted = obj['deleted']
        oai_record.harvester_sets = [
            x for x in registry_all_sets if x.set_spec in obj['sets']
        ]
        oai_record.xml_content = str(
            obj['metadata']) if obj['metadata'] is not None else None

        list_records.append(oai_record)

    return list_records
Beispiel #4
0
def aggregate(pipeline, user):
    """Execute an aggregate on the OaiRecord collection.

    Args:
        pipeline:

    Returns:

    """
    return OaiRecord.aggregate(pipeline)
def get_by_id(oai_record_id):
    """Get an OaiRecord by its id.

    Args:
        oai_record_id: Id of the OaiRecord.

    Returns: The OaiRecord instance.

    """
    return OaiRecord.get_by_id(oai_record_id)
Beispiel #6
0
def execute_full_text_query(text, list_metadata_format_id, user):
    """Execute full text query on OaiRecord data collection.

    Args:
        text: Keywords.
        list_metadata_format_id: List of metadata format id to search on.

    Returns: List of OaiRecord.

    """
    return OaiRecord.execute_full_text_query(text, list_metadata_format_id)
Beispiel #7
0
def get_count_by_registry_id(registry_id, user):
    """Return the number of OaiRecord by registry id.

    Args:
        registry_id: The registry id.

    Returns:
        Number of OaiRecord (int).

    """
    return OaiRecord.get_count_by_registry_id(registry_id)
Beispiel #8
0
def get_by_id(oai_record_id, user):
    """Get an OaiRecord by its id.

    Args:
        oai_record_id: Id of the OaiRecord.
        user: user retrieving the ID

    Returns: The OaiRecord instance.

    """
    return OaiRecord.get_by_id(oai_record_id)
def _create_oai_record():
    """Get an OaiRecord object.

    Returns:
        OaiRecord instance.

    """
    oai_record = OaiRecord()
    _set_oai_record_fields(oai_record)

    return oai_record
def execute_query(query):
    """Executes a query on the OaiRecord collection.

    Args:
        query: Query to execute.

    Returns:
        Results of the query.

    """
    return OaiRecord.execute_query(query)
Beispiel #11
0
def get_by_identifier_and_metadata_format(identifier, harvester_metadata_format):
    """Get an OaiRecord by its identifier and metadata format.

    Args:
        identifier: Identifier of the OaiRecord.
        harvester_metadata_format: harvester_metadata_format of the OaiRecord.

    Returns: The OaiRecord instance.

    """
    return OaiRecord.get_by_identifier_and_metadata_format(identifier, harvester_metadata_format)
Beispiel #12
0
def get_all_by_registry_id(registry_id, order_by_field=DATA_SORTING_FIELDS):
    """Return a list of OaiRecord by registry id. Possibility to order_by the list.

    Args:
        registry_id: The registry id.
        order_by_field: Order field.

    Returns:
        List of OaiRecord.

    """
    return OaiRecord.get_all_by_registry_id(registry_id, order_by_field)
Beispiel #13
0
def execute_query(query, user, order_by_field=DATA_SORTING_FIELDS):
    """Executes a query on the OaiRecord collection.

    Args:
        query: Query to execute.
        user: User executing the query
        order_by_field: Order by Data field

    Returns:
        Results of the query.

    """
    return OaiRecord.execute_query(query, order_by_field)