如何使用Jscript检索由依赖类型的连接器实现的所有信息流的集合?
答案 0 :(得分:1)
第一种选择是使用API。
循环连接器并检查EA.Connector.ConveyedItems
但除了一个微不足道的模型之外,任何事情都会非常缓慢。
所以唯一合理的方法是使用EA.Repository.SQLQuery(string SQL)
获取connectorID的列表,然后使用EA.Repository.GetConnectorByID(int ID)
来获取连接器对象。
您需要的SQL查询具有
的性质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上有一个操作来从依赖项中获取信息流。
/// <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后,此代码会获得传送的内容
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;
}
}