Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: skrauss on September 01, 2011, 12:47:20 am
-
Is there a way to set automatically project constants for the document generator via EA script or addin?
My problem is a follows:
In a project I have several packages which reflects documents (for example SRS, SDD, etc)
Each document has its own number and release number but it shall use the same template, so it should be updated before generating.
For eaxample, I have 10 SRS for 10 projects which share the same SRS template. I have a lot of projects in a server based repository, so defining a project constant for each document is not possible.
SRS = SW Requirements Specification
SDD = SW Design Description
-
I'm sorry, I really don't understand your requirement.
What exactly are you trying to achieve?
Geert
-
Thank you Geert for your answer.
I want to put the document number and release on top of each page.
I have defined project constants like document_number and document_release, but I have to change them manually for each document before document generating.
-
I don't really see it in the api documentation, so you might have to figure out where in the database it is stored and update it there.
Geert
-
For anybody who wants to know where this information is stored in the database:
It is in table "t_rtf" where dataset field Type is "ProjectOpts" and
field "Template" contains project constants in Format CONSTANT_1=VALUE_1;
Don't like to update the database directly.
Perhaps a filename constant could be a workaround.
-
I can understand your reluctance to edit the database directly, but after a while I'm afraid you're going to give up. :(
There's just too much that is not properly exposed in the API...
As a consolation, if you use the undocumented operation Repository.Execute(SQLUpdateString) then you don't have to mess around with your own database connections and stuff like that.
Geert
-
okay, I managed to do it!
Here's the script variant:
CWAT_SRS is my template name
IDENTNR is project constant name for identification number, which is placed as project constant on each page header.
...
' Code for when a package is selected
dim thePackage as EA.Package
set thePackage = Repository.GetTreeSelectedPackage()
Dim prj as EA.Project
set prj = Repository.GetProjectInterface()
Dim sql
sql = "UPDATE t_rtf SET Template='IDENTNR=" & thePackage.Name & ";' WHERE Type='ProjectOpts'"
Repository.Execute sql
prj.RunReport thePackage.PackageGUID, "CWAT_SRS", "X:\" & thePackage.Name & ".rtf"
-
That's a nice thing.
Does it change the Constant as permanent?
Little ideas for that:
Let your script search and use the latest baseline for your package.
This may help you to handle correct revision and changedates.
Edit: Some ideas for SQl without any test of funcion:
Dim Variable As Mysql_query = "SELECT Version
FROM `t_document`
WHERE `DocType` = 'Baseline'
AND DocName LIKE 'thepackage.Name'
ORDER BY `t_document`.`DocDate` DESC
LIMIT 0 , 1 "
Maybe you two could correct it and integrate it to your script? It would be much nicer to get the revision-Number into your documents footer.
BTW: How do you make sure not to overwrite other project constants?
-
Is it possible to use the Package.Version or a Package.TaggedValue at the selected Package therefore?
It is only an idea. I have no experience with RTF documentation.
-
Very good idea.
But to spin this around i got this:
Dim statement1
Dim statement2
statement1 = Repository.SQLQuery("select Template from t_rtf where Type='ProjectOpts'")
statement2 = statement1 & "Requirement_Specification_Filename=" & thePackage.Version & ";"
Session.Output( "Statement2: " & statement2 )
' Repository.Execute ("UPDATE t_rtf SET Template='" & statement2 & "' WHERE Type='ProjectOpts'")
' prj.RunReport thePackage.PackageGUID, "Requirement_Specification", "Z:\" & thePackage.Name & ".rtf"
My output is as expected:
Statement2: <?xml version="1.0"?>
<EADATA version="1.0" exporter="Enterprise Architect">
<Dataset_0><Data><Row><Template>000_item=000_Sperritem;Projectmanager=Someone;Projectname=Project0815;Projectnr=0815;Requirement_Specification_Filename=0815_Requirements_Specification_AE12;</Template></Row></Data></Dataset_0></EADATA>
Requirement_Specification_Filename=AE09;
That is what i expected, but i want to get rid of the xml tags to write it back to the t_rtf
How can i do that?
-
So you are trying to parse and xml string hé :o
Maybe, just maybe you are not the first to try need this, and maybe, just maybe there's already some feature in your programming language libraries that takes care of all that fancy xml stuff.... 8-)
Geert