Book a Demo

Author Topic: Location of User Defined searches  (Read 3949 times)

Ian E Mitchell

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Location of User Defined searches
« on: February 01, 2012, 04:52:03 am »
Does anyone know where to find the details of user-defined searches? The EA Help says cryptically that they are in the Program Files folder, but I can't see my searches anywhere...Am I just being thick?
eaDocX - Document Generator for EA -  http://www.eadocx.com

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Location of User Defined searches
« Reply #1 on: February 01, 2012, 08:43:13 am »
I guess %appdata%\Sparx Systems\EA\Search Data

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Location of User Defined searches
« Reply #2 on: February 01, 2012, 08:35:58 pm »
Ian,

This code snippet is where we read the user defined searches and create our own EAModelSearch objects:
Code: [Select]
/// <summary>
        /// reads name, customsearch and sql statement from XML document, created by EA
        /// </summary>
        public List<UMLModelSearch> ModelSearches
        {
            get
            {
                string appData = System.Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                string path = Path.Combine(appData, @"Sparx Systems\EA\Search Data");
                string filename = System.IO.Path.Combine(path, "EA_Search.xml");
                List<UMLModelSearch> searchQuery = new List<UMLModelSearch>();

                
                using (XmlTextReader reader = new XmlTextReader(filename))
                {
                    EAModelSearch modelSearch = null;
                    while (reader.Read())
                    {
                        string elementName = reader.Name;
                        if (elementName == "Search")
                        {
                            
                            
                            //name given to the query and used by the EA user to select the query to execute
                            modelSearch = new EAModelSearch(reader.GetAttribute("Name"), "", UML.UMLSearchType.UserDefined);
                            if (string.IsNullOrEmpty(modelSearch.Name))
                                continue;
                            //customSearch defines if statement is built-in(0)
                            //or customMade(1) by the EA user
                            
                            
                        }
                        else if (elementName == "RootTable")
                        {
                            if (modelSearch == null)
                                continue;
                            //filter contains SQL statement from xml document
                            modelSearch.Filter = reader.GetAttribute("Filter");
                            searchQuery.Add(modelSearch);
                            modelSearch = null;
                        }
                    }
                }
                searchQuery.AddRange(modelSearchTranslation);
                return searchQuery;
            }
        }

Geert

Ian E Mitchell

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Location of User Defined searches
« Reply #3 on: February 04, 2012, 12:52:03 am »
Thanks everyone.
Just for the record, in a Windows 7, 32 bit machine, with user account 'Ian', the search was located in :
 c:\Users\Ian\AppData\Roaming\Sparx Sstems\EA\Search Data\EA_Search.xml
Note AppData is, by default, a hidden folder.
All I have to do now, to get a list of the user-defined searches (so I can run one of them from the Automation interface) is parse this XML file.
Any chance Sparx might give us a 'GetListOfSearches' API call ?
eaDocX - Document Generator for EA -  http://www.eadocx.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Location of User Defined searches
« Reply #4 on: February 04, 2012, 01:22:30 am »
Would be a nice addition.
Do you register the feature request?

Geert