Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: MartinHe on September 21, 2018, 06:35:10 pm

Title: Usage of an "Add-in Search" in the "Model Views" window
Post by: MartinHe on September 21, 2018, 06:35:10 pm
Hello together,

I would like to use an add-in search in the model views window. When I execute the search in the "Find in Project" window, the expected results are shown. But the model views window shows "Search Found No Items".

I specified the following simple SQL query as search where the editor type is "SQL Editor":

        SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name, Package_ID FROM t_object WHERE Object_Type = 'Interface'

I deployed the search together with the model views search folder as part of a MDG technology. It works as expected.

Now I implemented the search in C# as part of an add-in:

        public virtual bool SearchInterfaces(Repository repository, string searchText, ref string xmlResults)
        {
            string sql = "SELECT ea_guid AS CLASSGUID, Object_Type AS CLASSTYPE, Name, Package_ID FROM t_object WHERE Object_Type = 'Interface'";
            string xml = repository.SQLQuery(sql);
            XDocument document = XDocument.Parse(xml);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("<ReportViewData UID=\"{6F9943C6-44A4-4150-B1CF-16EE74E3F04D}\">");
            sb.AppendLine("<Fields>");
            sb.AppendLine("<Field name=\"CLASSGUID\" />");
            sb.AppendLine("<Field name=\"CLASSTYPE\" />");
            sb.AppendLine("<Field name=\"Name\" />");
            sb.AppendLine("</Fields>");
            sb.AppendLine("<Rows>");
            foreach (XElement row in document.Descendants("Row"))
            {
                sb.AppendLine("<Row>");
                sb.AppendLine("<Field name=\"CLASSGUID\" value=\"" + row.Element("CLASSGUID").Value + "\" />");
                sb.AppendLine("<Field name=\"CLASSTYPE\" value=\"" + row.Element("CLASSTYPE").Value + "\" />");
                sb.AppendLine("<Field name=\"Name\" value=\"" + row.Element("Name").Value + "\" />");
                sb.AppendLine("</Row>");
            }
            sb.AppendLine("</Rows>");
            sb.AppendLine("</ReportViewData>");
            xmlResults = sb.ToString();
            return true;
        }

The UID "{6F9943C6-44A4-4150-B1CF-16EE74E3F04D}" is the UID of the search (with Editor Type "Add-In Search") as specified in the MDG technology.

As mentioned above, the search shows the expected results in the "Find in Project" window, but not int the "Model Views" window. I tried EA 14.1 (1427) and EA 13.5 (1354).

Can anybody tell me where the defect is?

Thank you very much!

Best regards,

Martin
Title: Re: Usage of an "Add-in Search" in the "Model Views" window
Post by: Geert Bellekens on September 21, 2018, 06:41:27 pm
I think you better contact support.
It is possible that add-in searches don't work in model views.

Geert
Title: Re: Usage of an "Add-in Search" in the "Model Views" window
Post by: MartinHe on September 26, 2018, 04:05:51 pm
Indeed, add-in searches are not supported in the model views window according to the support.