Author Topic: [SOLVED] Import rtf template via AddIn  (Read 4909 times)

jan.izyk

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
[SOLVED] Import rtf template via AddIn
« on: November 04, 2015, 08:04:34 pm »
Dear all,

first, hello to all this is my first post in this forum.

second, in parallel I have asked this question to the support of sparx systems. But they said, that they have to investigate my problem. So maybe some one of you has allready solved this problem.

So what I want to do:
I want to set the default behaviour of document generation in EA via an AddIn written in C#.

For this I am creating a virtual document with 1 master-document, several model-documents for each kind of document which shall be generated.

This step is done and works.

Each model-document will be connected with the packages, which shall be documented with this template.

This step is also done and works.

The next step is to import the created rtf-templates into the document generator and connect the templates with the model-documents.

And here is my problem.

First Problem:
I have found that via the command
Code: [Select]
repository.CreateDocumentGenerator()I can have access to the document generator. But I can't find the
method to import a rtf-file (e.g. from the local harddrive) as a new template.

Second Problem:
In EA12 I can connect the rtf-template with a model-document by right clicking on the model-document->Properties->Tags->RTFTemplate and choose there one rtf-template.
But when I have a look on the sql-database of this project, I can't find this link between the rtf-template and the model-document.

I hope this long explanation clarrifies where currently my problems are  ;).
« Last Edit: November 05, 2015, 08:32:37 pm by jan.izyk »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13282
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Import rtf template via AddIn
« Reply #1 on: November 04, 2015, 09:42:34 pm »
The link from the model document to the template is name based.
Just set the value of the tagged value to the name of the template and it will work.

In order to import templates I would look into either MDG technology or the import/export reference data feature.

Geert

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Import rtf template via AddIn
« Reply #2 on: November 05, 2015, 12:22:46 am »
Hello Jan, and welcome to the forum!


Your first problem has no solution. There is no way in the API to import a file from disk into an RTF template.

You could construct a workaround, but I agree with Geert that you're better off using an MDG Technology (EA's name for a packaged set of adaptations, which includes RTF templates).

Your second problem has a solution. In EA, elements (like your model document) are stored in the t_object table, while tagged values (which in this case hold the RTF template reference) are stored in a separate table called t_objectproperties.
The following SQL snippet will retrieve them:
select * from t_objectproperties where t_objectproperties.Object_ID = ...

The RTF templates themselves are stored in t_document. As Geert notes, this link is based on the template's name, not a numeric identifier. You should also note that if you use an MDG Technology to hold your RTF templates, you won't find them in this table. MDG Technologies are held in-memory by the EA client and can't be accessed any way I know.

But assuming you're using a model document with an RTF template that's stored in the same EA project (not in an MDG Technology), this query will show you the link:
Code: [Select]
select t_object.ea_guid as CLASSGUID, t_object.Object_Type as CLASSTYPE,
t_object.Name as ElementName, t_objectproperties.Value as RtfTemplate, t_document.DocID
from t_object, t_objectproperties, t_document
where t_objectproperties.Object_ID = t_object.Object_ID
and t_document.DocName = t_objectproperties.Value
and t_object.Name = 'Uffes way cool model document'
Note that there isn't a lot of useful information you can pull out of t_document, but the above shows you the reference structure anyways.

Cheers,


/Uffe
My theories are always correct, just apply them to the right reality.

jan.izyk

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Import rtf template via AddIn
« Reply #3 on: November 05, 2015, 08:31:50 pm »
Thanks for your fast replies.

OK then in case that the templates will change or a new document will be add to the list of documents, then I have to import them manually.
But because of that every other steps can be done automatically, this is a solution with which I can live.

Thanks again