Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Tehila1 on March 09, 2014, 07:34:49 pm
-
Hello!
How can I check programmatically if an EA template is exist already in a model, by template name?
Thanks in advance!
-
You can try queries.
If 'tis a document generation template, user defined templates are in t_document (select * from t_document) table.
or if 'tis a code gen / transformation template, user defined changes / new templates are in t_template(select * from t_template)
-
Thanks a lot!
For other's sake- here is the complete way to check if a document template is exist in current model:
string squery = @"SELECT t_document.DocID FROM t_document WHERE t_document.DocName LIKE 'YourTemplateName' ";
XmlDocument result = Repository.SelectStatement(squery);
XmlNodeList template = result.SelectNodes("//DocID");
if (template.Count <= 0) // The template is missing
-
Where do I find help about parsing the XML results of SQL query (XML is really new to me...) so that bit of code when I checked the EA Help file came up empty?
-
Which language do you use?
q.
-
Right now vbscript but I am flexible :)
-
BTW I had Inside EA, now today I picked up your other three! :)
Have to print them out and start reading!
[email protected]
-
Try this VB Sample code in
Dim XmlData As String
Dim Notes, Script, ScriptLanguage, ScriptName As String
Dim root, noteX As XElement
XmlData = Repository.SQLQuery("SELECT Notes FROM t_script)
root = XElement.Parse(XmlData)
If root.Elements("Dataset_0").Any() Then
Notes = root.<Dataset_0>.<Data>.<Row>.<Notes>.Value().ToString()
noteX = XElement.Parse(Notes)
ScriptName = noteX.FirstAttribute.Value
ScriptLanguage = noteX.LastAttribute.Value
End If
-
BTW I had Inside EA, now today I picked up your other three! :)
Have to print them out and start reading!
[email protected]
Thanks :-) Hope you enjoy them. If you have any questions or remarks please contact me via mail.
q.