You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Enterprise Architect片段表格项中获取链接文档实际内容?

在Enterprise Architect片段中获取元素备注及链接文档内容的解决思路

问题概述

需要在指定Enterprise Architect片段中同时展示元素的备注及关联的链接文档内容,现有SQL查询仅能获取链接文档的DocID,无法拿到实际内容。

可行性结论

完全可行,通过调整SQL查询语句并利用EA数据库内置字段即可实现。

解决步骤

  • 修正SQL查询,获取文档内容字段
    EA的t_document表中,Content字段存储了ModelDocument类型的实际内容。修改原查询中的字段选择,并优化连接逻辑避免重复结果:

    select 
        obj2.Name, 
        obj2.stereotype, 
        obj2.note as [notes-Formatted], 
        doc.Content as LinkedDocumentContent
    from 
        t_connector conn 
        inner join t_object obj on (obj.object_id = conn.start_object_id or obj.object_id = conn.end_object_id)
        inner join t_object obj2 on (obj2.object_id = conn.start_object_id or obj2.object_id = conn.end_object_id)
        inner join t_document doc on (obj2.ea_guid = doc.ElementID)
    where 
        conn.stereotype = 'something' 
        and obj.object_id = #OBJECTID# 
        and obj2.stereotype = 'block' 
        and doc.DocType = 'ModelDocument'
        and obj.object_id != obj2.object_id -- 排除当前对象,避免重复匹配
    
  • 处理内容格式
    Content字段存储的是RTF或HTML格式内容:

    • 若使用EA内置片段展示,EA会自动解析格式并正常显示;
    • 若用于外部工具,需根据实际需求解析格式标签,提取纯文本或保留格式样式。
  • 兼容无链接文档的场景
    原查询使用inner join会过滤掉无关联文档的元素,改用left join可保留这些元素,并通过case语句处理空值:

    select 
        obj2.Name, 
        obj2.stereotype, 
        obj2.note as [notes-Formatted], 
        case when doc.Content is not null then doc.Content else '无关联文档' end as LinkedDocumentContent
    from 
        t_connector conn 
        inner join t_object obj on (obj.object_id = conn.start_object_id or obj.object_id = conn.end_object_id)
        inner join t_object obj2 on (obj2.object_id = conn.start_object_id or obj2.object_id = conn.end_object_id)
        left join t_document doc on (obj2.ea_guid = doc.ElementID and doc.DocType = 'ModelDocument')
    where 
        conn.stereotype = 'something' 
        and obj.object_id = #OBJECTID# 
        and obj2.stereotype = 'block'
        and obj.object_id != obj2.object_id
    

内容的提问来源于stack exchange,提问作者vascobnunes

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 08:43:28