如何将列从公共表添加到企业架构中的新表
How to add columns from a Common Table to New Table in Enterprise Architect
我正在使用Enterprise Architect 10工具为SQL数据库设计模式。
每当一个新表被添加到EA Schema(比如列'Name'和'Description')时,公共列(UserId, Status, Role, 15个这样的列)必须被添加到新表中。
目的表列=源表列+公共表列。
Destination表应该包含Name、Description、UserId、Status和Role列。
我有超过100个表,不能手动添加所有的公共列到每个表。
当我添加新表并执行脚本时,是否有任何规定或脚本(javascript或vbscript)可以执行此操作?
—在尝试后添加了此代码…
!INC Local Scripts.EAConstants-JScript
/**脚本名称:*作者:*的目的:*日期:*/
函数main (){//在这里输入脚本代码!//显示脚本输出窗口存储库。EnsureOutputVisible("Script");
// Get the currently selected element in the tree to work on
var theElement as EA.Element;
var theDestElement as EA.Element;
theElement = Repository.GetTreeSelectedObject();
//theDestElement = Repository.GetTreeSelectedObject();
//theDestElement.Name='Newtable1';
if( theElement != null && theElement.ObjectType == otElement)
{
Session.Output( "Working on element '" + theElement.Name + "' (Type=" + theElement.Type +
", ID=" + theElement.ElementID + ")" );
var srcAttributes as EA.Collection;
srcAttributes = theElement.Attributes;
theDestElement = Repository.
Session.Output(theDestElement);
theDestElement.Name='NewTable1';
var dstAttributes as EA.Collection;
dstAttributes = theDestElement.Attributes;
newAttribute = null;
// List attributes
for ( var i = 0 ; i < srcAttributes.Count ; i++ )
{
var currentAttribute as EA.Attribute;
currentAttribute = srcAttributes.GetAt( i );
dstAttributes.AddNew(currentAttribute.,currentAttribute);
//theDestElement
Session.Output( "Attribute: " + currentAttribute.Name );
}
Session.Output( "Done!" );
}
else
{
// No item selected in the tree, or the item selected was not an element
Session.Prompt( "This script requires an element be selected in the Project Browser.'n" +
"Please select an element in the Project Browser and try again.", promptOK );
}
}
main (),
我可以使用
选择一个表的所有属性theElement = Repository.GetTreeSelectedObject();
但是我不清楚要复制所有属性的目标表。
请帮助。
谢谢你,兰姆
首先,您可以使用模板包,其中放置了带有列的公共表。
要回顾性地完成它,您可以使用内部脚本支持来实现它。在EA中转到工具->脚本,寻找"VBScript -属性生命周期示例"或"JScript -属性生命周期示例",查看如何从元素中添加/删除属性。
相关文章:
- 使用ajax发送rowID并将选定的行附加到新表中
- 使用Jquery收集数组中的行ID,然后为新表查询这些值
- 在新表单上使用JavaScript创建多个共享点项目,但将下一页加载延迟到全部创建
- 点击按钮,用javascript生成新表单
- 添加新表单时,如何保持表单的焦点
- 使用可能的字段编辑器打开新表中的引导程序表行
- 我想创建一个添加新表单的按钮
- 如何为新表制作下一个代码滑块
- AJAX / JQuery - 在新表行上打印每个嵌套的子项
- 将 html 表换成新表
- 无法在 Web SQL 数据库中创建新表
- 如何获取新表行仅当先前输入的一行不为空时才单击
- 如何使用 Javascript 将文本从文本区域移动到新表中
- 正在附加表,而不是创建新表
- 为什么在我的HTML文件中创建新表而不是刷新同一个表
- 新表单-嵌入表单集合-Symfony2
- 我想动态地创建新表,并使用jquery通过相同的按钮删除它
- 按下提交按钮后,用相同的颜色框打开一个新表单
- 附加一个新表单,并在输入文本时提交
- 如何将列从公共表添加到企业架构中的新表