def process_entry()

in dataplex-quickstart-labs/00-resources/scripts/python/business-glossary-import/bg_import/business_glossary_export_v2.py [0:0]


def process_entry(entry: Dict[str, Any],
                      parent_mapping: Dict[str, str],
                      map_entry_id_to_entry_type: Dict[str, str],
                      ) -> Dict[str, Any]:
    """
    Process a single entry (only glossary_term or glossary_category) and produce the export JSON.
    - Extract the entry id (the portion after "/entries/") for constructing new resource names.
    - The export "name" is: export_base + "/" + new resource.
    - The parentEntry is always the glossary resource (export_base + "/" + glossary export).
    - The ancestors array is built using the entry ids.
    """
    entry_type = entry.get("entryType", "")
    if entry_type not in ["glossary_term", "glossary_category"]:
        return None

    display_name = entry.get("displayName", "").strip()
    core_aspects = entry.get("coreAspects", {})
    business_context = core_aspects.get("business_context", {}).get("jsonContent", {})
    description = business_context.get("description", "")
    contacts_list = business_context.get("contacts", [])
    child_id = get_entry_id(entry["name"])
    
    glossary_resource = get_export_resource_by_id(child_id, entry_type)
    entry_name = f"{DATAPLEX_ENTRY_GROUP}/entries/{glossary_resource}"
    glossary_entry_id = f"projects/{PROJECT}/locations/{LOCATION}/glossaries/{GLOSSARY}"
    parent_entry_name = f"{DATAPLEX_ENTRY_GROUP}/entries/{glossary_entry_id}"
    parent_entry_name = get_entry_name(glossary_entry_id, "glossary")

    ancestors = compute_ancestors(child_id, parent_mapping, map_entry_id_to_entry_type)
    
    glossary_resource_aspect = "glossary-term-aspect" if entry_type == "glossary_term" else "glossary-category-aspect"
    aspects = {
            f"{PROJECT_NUMBER}.global.{glossary_resource_aspect}": {"data": {}},
            f"{PROJECT_NUMBER}.global.overview": {"data": {"content": f"<p>{description}</p>"}},
            f"{PROJECT_NUMBER}.global.contacts": {"data": {"identities": [{"name": c} for c in contacts_list]}}
        }
    entry_type_name = get_entry_type_name(entry_type)   
    entry_source = {
        "resource": glossary_resource,
        "displayName": display_name,
        "description": "",
        "ancestors": ancestors
    }

    return {
        "entry": {
            "name": entry_name,
            "entryType": entry_type_name,
            "aspects": aspects,
            "parentEntry": parent_entry_name,
            "entrySource": entry_source
        }
    }