def export_entry_links_json()

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


def export_entry_links_json(entries: List[Dict[str, Any]], relationships_data: Dict[str, List[Dict[str, Any]]], output_json: str):
    """
    Export the entry links JSON data for synonyms and related terms.
    """
    with ThreadPoolExecutor(max_workers=MAX_WORKERS) as executor:
        futures = {executor.submit(build_entry_links, entry, relationships_data): entry for entry in entries}
        
        unique_entry_links = {}
        filtered_links = []

        # For entry links within glossary, same entry link will be present in relationships data of two entries
        # so we have to remove entrylinks with same name
        for future in as_completed(futures):
            result = future.result()
            if result:
                for link in result:
                    link_name = link["name"]
                    if link_name not in unique_entry_links:
                        unique_entry_links[link_name] = link
                        filtered_links.append(link)  # Store the unique link in a list

    with open(output_json, mode="w", encoding="utf-8") as outputfile:
        for link in filtered_links:
            outputfile.write(json.dumps(link) + "\n")