javascript - 使用 javascript 在 Enterprise Architecture 中批量创建标签

标签 javascript enterprise-architect requirements

我创建了一个 EA 项目,其中包含大量需求,需要将其导入到 Redmine 中。我们不想用手来做,而是想使用工具 这个工具需要使用一些特定的标签来同步数据,所以我需要为每个需求创建五个标签,而且我根本无法为每个需求都这样做,因为我有数百个标签。

我开始检查 javascript 脚本,并且在一个示例中注意到了这样的函数:

/**
 * Sets the specified TaggedValue on the provided element. If the provided element does not already
 * contain a TaggedValue with the specified name, a new TaggedValue is created with the requested
 * name and value. If a TaggedValue already exists with the specified name then action to take is
 * determined by the replaceExisting variable. If replaceExisting is set to true, the existing value
 * is replaced with the specified value, if not, a new TaggedValue is created with the new value.
 *
 * @param[in] theElement (EA.Element) The element to set the TaggedValue value on
 * @param[in] taggedValueName (String) The name of the TaggedValue to set
 * @param[in] taggedValueValue (variant) The value of the TaggedValue to set
 * @param[in] replaceExisting (boolean) If a TaggedValue of the same name already exists, specifies 
 * whether to replace it, or create a new TaggedValue.
 */
function TVSetElementTaggedValue( theElement /* : EA.Element */, taggedValueName /* : String */, taggedValueValue /* : variant */, replaceExisting /* : boolean */ ) /* : void */
{
    if ( theElement != null && taggedValueName.length > 0 )
    {
        var taggedValue as EA.TaggedValue;
        taggedValue = null;

        // If replace existing was specified then attempt to get a tagged value from the element
        // with the provided name
        if ( replaceExisting )
            taggedValue = theElement.TaggedValues.GetByName( taggedValueName );

        if ( taggedValue == null )
        {
            taggedValue = theElement.TaggedValues.AddNew( taggedValueName, taggedValueValue );
        }
        else
        {
            taggedValue.Value = taggedValueValue;
        }

        taggedValue.Update();
    }
}

我需要做的是如何检索存储在特定包中的需求列表,以及如何循环它们以应用此功能。

如有任何帮助,我们将不胜感激。

最佳答案

基本上:

for e in myPackage.elements:
    if e.type == 9: #code for Requirement
        print(e.name)
        for t in e.taggedValues:
            print(t.name, t.value, t.notes)

将列出包的元素及其所有标记值。

这是Python,但翻译成任何其他语言并不困难。

关于javascript - 使用 javascript 在 Enterprise Architecture 中批量创建标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58344997/

相关文章:

javascript - Mongoose find() 使用锁存器在 for 循环内调用

validation - 软件测试与软件评估

c - 要求低且二进制大小至少为 2MB 的开源 C 程序

javascript - jquery加载简单数据

javascript - 为什么绝对定位的父项中的百分比宽度子项在 IE 中不起作用?

javascript - JavaScript 中的 while(true) - 它是如何工作的

command-line - 如何在 Enterprise Architect 中自动生成 HTML 输出

enterprise-architect - 模型中的 Clon EA 元素

java - java 中的企业架构师脚本 : how to change the way of a connector?

python - environment.yml中的pip包如何使用.condarc中提供的代理?