Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enterprise Architect Model Search XML Format

I have written a few Add-Ins for Enterprise Architect in C#. I want to add a complex model search now in a similar manner. I have no issue running my add-in search. I believe my issue is with the XML Model Search Format. The only documentation that I can find is here.

I tried to use the example JScript and VB Script files in EA "JScript - Model Search (Attributes) Example". I cannot get that to give me output when I run it in EA. That has to be user error, I believe. I am using that code as an example to try to properly output my search results from a C# add-in.

I can't figure out what the value for <ReportViewData UID=\"MySearchID\" > should be? It seems like it should be the UID of the search. How does one find that? It is missing from the JScript example, as far as I can tell.

Does anyone have a properly formatted XML Search Format file I can test? Just modifying a known working file by hand to match an element in my repo and importing the results would be a huge help. I can't find any documentation other than what I have linked above.

like image 351
MrSnrub Avatar asked Nov 16 '25 19:11

MrSnrub


1 Answers

Repository.RunModelSearch does not return any results. It just runs the model search (Ctrl-F) as if the user had selected it and passed a search term. You can add your own XML which the model search window will display (so it's formatted correctly). There are other ways to retrieve data from the model. Use either Repository.SQLSearch or Repository.GetElementSet.

Assume you have the following SQL search named "test":

SELECT  ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name FROM t_object
WHERE Name LIKE '*<Search Term>*' 

And your XML looks like this:

<ReportViewData UID="MySearchID" >
 <Fields>
         <Field name="CLASSGUID"/>
         <Field name="CLASSTYPE"/>
 </Fields>

 <Rows>
         <Row>
                 <Field name="CLASSGUID" value="{99660FA1-6927-41bf-9676-521A6C852884}"/>
                 <Field name="CLASSTYPE" value="Class"/>
         </Row>
 </Rows>
</ReportViewData>

If you run Repository.RunModelSearch ("test", "Class1", "", xml) it will append the class with the supplied guid irrespective to what else has been found. It will even display the class as object if you change the CLASSTYPE to Object.

As fas as I understood ReportViewData UID="MySearchID" is used to preserve search settings (column widths etc.) and is of less importance.

Honestly I can hardly imagine a use case for this method ;-)

P.S.: I asked Sparx about this and here is the reply:

public object MyAddinSearch(EA.Repository Repository, String SearchText, out String XMLResults)

The XMLResults parameter needs to be passed by reference. The XML results generated by this function need to be assigned to this parameter for further processing by EA. The return value for this method simply requires a non-empty result to indicate that results should be displayed in EA. For example, simply returning a boolean true value is sufficient.

like image 124
qwerty_so Avatar answered Nov 19 '25 10:11

qwerty_so