首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >实现的Sparx EA Jscript信息流

实现的Sparx EA Jscript信息流
EN

Stack Overflow用户
提问于 2017-11-15 18:43:25
回答 1查看 445关注 0票数 1

如何使用Jscript检索依赖类型的连接器实现的所有信息流的集合?

EN

回答 1

Stack Overflow用户

发布于 2017-11-15 23:04:40

第一个选项是使用API。

循环连接器并检查EA.Connector.ConveyedItems

但是,如果不是简单的模型,这将是非常缓慢的。

因此,唯一合理的方法是使用EA.Repository.SQLQuery(string SQL)获取connectorID的列表,然后使用EA.Repository.GetConnectorByID(int ID)获取连接器对象。

您需要的SQL查询的性质是

代码语言:javascript
复制
select * 
from ((((t_connector c
inner join t_xref x on (x.Client = c.ea_guid
                    and x.Name = 'MOFProps'
                    and x.Type = 'connector property'
                    and x.Behavior = 'abstraction'))
inner join t_connector cf on x.Description like '%' + cf.ea_guid + '%')
inner join t_xref xf on (xf.Client = cf.ea_guid
                    and xf.Name = 'MOFProps'
                    and xf.Type = 'connector property'
                    and xf.Behavior = 'conveyed'))
inner join t_object o on o.ea_guid like xf.Description)
where c.Connector_Type = 'Dependency'

如果您正在处理.eap (MS-Access)文件,请将%替换为*

我也有一个C#实现。在类ConnectorWrapper上,有这个操作来从依赖项中获取信息流。

代码语言:javascript
复制
/// <summary>
/// convenience method to return the information flows that realize this Relationship
/// </summary>
/// <returns>the information flows that realize this Relationship</returns>
public virtual HashSet<UML.InfomationFlows.InformationFlow> getInformationFlows()
{
    HashSet<UML.InfomationFlows.InformationFlow> informationFlows = new HashSet<UML.InfomationFlows.InformationFlow>();
    string sqlGetInformationFlowIDs = @"select x.description
        from (t_connector c
        inner join t_xref x on (x.client = c.ea_guid and x.Name = 'MOFProps'))
        where c.ea_guid = '" + this.guid + "'";
    var queryResult = this.model.SQLQuery(sqlGetInformationFlowIDs);
    var descriptionNode = queryResult.SelectSingleNode(this.model.formatXPath("//description"));
    if (descriptionNode != null)
    {
        foreach (string ifGUID in descriptionNode.InnerText.Split(','))
        {
            var informationFlow = this.model.getRelationByGUID(ifGUID) as UML.InfomationFlows.InformationFlow;
            if (informationFlow != null )
            {
                informationFlows.Add(informationFlow);
            }
        }
    }
    return informationFlows;
}

一旦你有了InformationFlow,这个代码就会得到所传送的物品

代码语言:javascript
复制
public HashSet<UML.Classes.Kernel.Classifier> conveyed 
{
    get 
    {
        if (_conveyed == null)
        {
            string getXrefDescription = @"select x.Description from t_xref x 
                                        where x.Name = 'MOFProps'
                                        and x.Behavior = 'conveyed'
                                        and x.client = '" + this.guid + "'";
            //xrefdescription contains the GUID's of the conveyed elements comma separated
            var xrefDescription = this.model.SQLQuery(getXrefDescription).SelectSingleNode(this.model.formatXPath("//Description"));
            if (xrefDescription != null)
            {
                foreach (string conveyedGUID in xrefDescription.InnerText.Split(','))
                {
                    var conveyedElement = this.model.getElementWrapperByGUID(conveyedGUID) as UML.Classes.Kernel.Classifier;
                    if (conveyedElement != null)
                    {
                        //initialize if needed
                        if (_conveyed == null)
                        {
                            _conveyed = new HashSet<UML.Classes.Kernel.Classifier>();
                        }
                        //add the element
                        _conveyed.Add(conveyedElement);
                    }
                }
            }
        }
        //nothing found, return empty list.
        if (_conveyed == null)
        {
            _conveyed = new HashSet<UML.Classes.Kernel.Classifier>();
        }
        return _conveyed;
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47305307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档