diff --git a/api/utils.py b/api/utils.py index e7ac83f..5e82ff9 100644 --- a/api/utils.py +++ b/api/utils.py @@ -9,7 +9,6 @@ import requests import sys import urllib -import json from urllib.parse import urljoin @@ -437,73 +436,6 @@ def check_metadata_terms_with_values(metadata, terms): return df_access -def is_unique_id(item_id): - """Returns True if the given identifier is unique. Otherwise, False. - - Parameters - ---------- - item_id : str - Digital Object identifier, which can be a generic one (DOI, PID ...), or an internal (e.g. an - identifier from the repo) - Returns - ------- - boolean - True if the item id is a persistent identifier. False if not - """ - is_unique = False - if idutils.is_doi(item_id): - is_unique = True - if idutils.is_handle(item_id): - is_unique = True - if is_uuid(item_id): - is_unique = True - - return is_unique - - -def check_metadata_terms_with_values(metadata, terms): - """Checks if provided terms are found in the metadata. - - Parameters - ---------- - metadata: pd.DataFrame with metadata from repository - terms: pd.DataFrame with terms to search in the metadata - - Returns - ------- - DataFrame with the matching elements found in the metadata. - """ - term_dfs = [] - for index, row in terms.iterrows(): - _element = row["element"] - _qualifier = row["qualifier"] - # Select matching metadata row - _df = metadata.loc[ - (metadata["element"] == _element) - & (metadata["qualifier"].apply(lambda x: x in [None, _qualifier])) - & (metadata["text_value"] != "") - ] - if _df.empty: - logging.warning( - "Element (and qualifier) not found in metadata: %s (qualifier: %s)" - % (_element, _qualifier) - ) - else: - term_dfs.append(_df) - logging.debug( - "Found matching <%s> element in metadata: %s" - % (_element, _df.to_json()) - ) - df_access = pd.DataFrame() - if term_dfs: - df_access = pd.concat(term_dfs) - logging.debug( - "DataFrame produced with matching metadata elements: \n%s" % df_access - ) - - return df_access - - def oai_check_record_url(oai_base, metadata_prefix, pid): endpoint_root = urllib.parse.urlparse(oai_base).netloc try: