Enterprise Architect version 14.0

download
purchase

enzh-CNcsnlfrdehiiditkoplptruskessv

My Profile

Social Media Channels

facebook  twitter  youtube   linkedin

Lubos

Lubos

Lubomír Markovič

HomeCredit a.s. (Business Analyst)
 
Experience in companies developing large banking systems as designer, analyst and methodologist. Responsible for Sparx Enterprise Architect integration into company's environment and processes.
Monday, 21 December 2009 14:20

"General" Search Profile -- using SQL

There are many situations where some specific search profile could be useful. But it's not good to create many search profiles because their list tends to be cluttered.

There is some "general" search profile that uses the power of the repository.GetElementSet function below.

When you create the following Addin-search and add the search profile to use this addin-function you can use searches using direct SQL queries like:

select Object_ID from t_object where name like 'a%'

The SQL has to return the list of object_id (see help for repository.GetElementSet)

 

Search profile (Plugin COM object is called EAPlugins)

<Search Name="Find By SQL" GUID="{371E2601-771A-4d70-9030-918A0167AAD1}" PkgGUID="-1" Type="0" LnksToObj="0" CustomSearch="1" AddinAndMethodName="EAPlugins.findBySQL"><SrchOn/><LnksTo/></Search>

Plugin code (C#):

public  Boolean findBySQL(EA.Repository rep, String searchString, out String XML)
{

            XML = @"<ReportViewData>  
       <Fields>

              <Field name=""CLASSGUID""/>
              <Field name=""CLASSTYPE""/>
               <Field name=""Name""/>            
       </Fields>
       <Rows>
";
            EA.Collection col=null;
           
            try
            {
               
                col= CommonUtils.repository.GetElementSet(searchString, 2);
                if ((col.Count == 1) && (col.GetAt(0) == null)) { }   //this temporarily solves the bug in EA where an empty Set gives Count 1
                else
                {
                    foreach (EA.Element elem in col)
                    {
                        
                        XML = XML + "<Row>\n";
                        XML = XML + "<Field name=\"CLASSGUID\" value=\"" + elem.ElementGUID + "\"/>\n";
                        XML = XML + "<Field name=\"CLASSTYPE\" value=\"" + elem.Type + "\"/>\n";
                        XML = XML + "<Field name=\"Name\" value=\"" + elem.Name + "\"/>\n";
                        XML = XML + "</Row>\n";
                    }
                }
            }
            catch (Exception) { }
            finally {
                if (col!=null)
                  System.Runtime.InteropServices.Marshal.ReleaseComObject(col);
                col = null;
            }
            ;

            XML = XML + @"</Rows>
</ReportViewData>";

            return true;
        }

Friday, 18 December 2009 09:09

Create a "hyperlink" for EA elements II.

This is a reaction for this resource http://community.sparxsystems.com/resources/community/scripts/create-hyperlink-ea-elements

where the same functionality is solved by script. I believe that using the search profile is more appropriate for the problem.

The search profile below can find any package, object, attribute, operation, diagram by given ea_GUID.

It can be given by the {261AEBEE-a0f0-4ba9-B60A-A26D663DBAFB} form or by BKM_261AEBEE_a0f0_4ba9_B60A_A26D663DBAFB form (it is used in RTF documents)

The given search string can be the whole sentence just including the GUID (you don't have to extract guid from the sentence) -- it is useful when you use messages produced e.g. by some script where you can copy only the whole line from the output view..

The search profile is for MSSQL (it can be enhanced by using #WC#  wildcard) :

select o.ea_guid AS CLASSGUID,o.name as 'NAME'
from t_package o  where o.ea_guid LIKE replace(replace(replace(SUBSTRING('%<Search Term>%',PATINDEX('%{%','%<Search Term>%'),PATINDEX('%}%','%<Search Term>%')-PATINDEX('%{%','%<Search Term>%')+1),'BKM_',''),'#',''),'_','-')
UNION
select o.ea_guid AS CLASSGUID,o.name as 'NAME'
from t_object o  where o.ea_guid LIKE replace(replace(replace(SUBSTRING('%<Search Term>%',PATINDEX('%{%','%<Search Term>%'),PATINDEX('%}%','%<Search Term>%')-PATINDEX('%{%','%<Search Term>%')+1),'BKM_',''),'#',''),'_','-')
UNION
select o.ea_guid AS CLASSGUID,o.name as 'NAME'
from t_attribute o  where o.ea_guid LIKE replace(replace(replace(SUBSTRING('%<Search Term>%',PATINDEX('%{%','%<Search Term>%'),PATINDEX('%}%','%<Search Term>%')-PATINDEX('%{%','%<Search Term>%')+1),'BKM_',''),'#',''),'_','-')
UNION
select o.ea_guid AS CLASSGUID,o.name as 'NAME'
from t_operation o  where o.ea_guid LIKE replace(replace(replace(SUBSTRING('%<Search Term>%',PATINDEX('%{%','%<Search Term>%'),PATINDEX('%}%','%<Search Term>%')-PATINDEX('%{%','%<Search Term>%')+1),'BKM_',''),'#',''),'_','-')
UNION
select o.ea_guid AS CLASSGUID,o.name as 'NAME'
from t_diagram o  where o.ea_guid LIKE replace(replace(replace(SUBSTRING('%<Search Term>%',PATINDEX('%{%','%<Search Term>%'),PATINDEX('%}%','%<Search Term>%')-PATINDEX('%{%','%<Search Term>%')+1),'BKM_',''),'#',''),'_','-')