Book a Demo

Author Topic: Model Search scripts - how to pass 'search term'?  (Read 7001 times)

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Model Search scripts - how to pass 'search term'?
« on: April 20, 2013, 12:47:20 am »
Hi. I've created two Model Search scripts: one under group 'Search', another one under the group 'Find in Project'.

Q1: in the 'Find in Project' dialog (Edit->Find in Project) I only see the script under the 'Search' group. The one under the 'Find in Project' group can't be found in that list of predefined searches. Based on the group name, I assumed I should be able to find it there. Where this search is available? From the Context menu? (similar to 'Element', 'Connector' and other search types?) If so, what element should I right click on to see that search?

Q2: for the 'Search' group script that I see in the dialog, is it possible to pass 'Search Term' to the script? I tried to add parameter to the OnSearchScript function (ie, 'function OnSearchScript(searchTerm)'), but when i try to printout this value from within the screen, I see that it is 'undefined'.

Thanks,

Vlad

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model Search scripts - how to pass 'search ter
« Reply #1 on: April 22, 2013, 04:52:20 pm »
Vlad,

I think that is not how it is supposed to work.
There are two examples of search scripts here:
C:\Program Files (x86)\Sparx Systems\EA\Scripts\JScript
and it looks to me like they are only using the search window to show the result of the search.

I think that you need a real add-in to be able to add searches that use code.

PS. Are you sure you need code to do the search for you? Until now I've been able to define all the searches I needed using SQL.

rayt

  • EA User
  • **
  • Posts: 28
  • Karma: +1/-0
    • View Profile
Re: Model Search scripts - how to pass 'search ter
« Reply #2 on: April 25, 2013, 07:09:25 pm »
Hi
I wrote to support about a year ago, they wrote search term access for search scripts will be added in a later version.

Paulrus suggested a workaround (in this thread) using a keyword entry dialog that I used .

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Model Search scripts - how to pass 'search ter
« Reply #3 on: May 01, 2013, 12:23:18 am »
Thanks for the responses. Using the Input dialog is the only option I found as well. I thought there might be some hidden object made available in the global context...

RE: the need to use the scripts, the answer is yes - I need to traverse the model to the arbitrary depth - most searches are recursive. It's probable that you can write the same thing in SQL, but I think the statement will be over a page long :) and completely unmaintainable. Plus I'm using JS to compliment EA sparx functionality where it's missing (for autogeneration of the connectors, etc).

On the same note, does anyone use JavaScript extensively within EA Sparx? Any 'gotchas' with memory management etc when traversing a complex model? Does anyone have a set of utility / helper classes they use to simplify major tasks? (I've 'imported' an XML and SQL builder so far to make creating queries and generating XML easier).

Vlad

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model Search scripts - how to pass 'search ter
« Reply #4 on: May 02, 2013, 04:18:13 pm »
Vlad,

Have you considered using C# or the likes and create a real add-in/program to do what you need.

I have an open source C# library to deal with EA:
Enterprise Architect Add-in Framework
Which depens on
UML Tooling Framework

My add-in EA Navigator uses this framework. You can find its code in the Enterprise Architect Toolpack

Geert

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Model Search scripts - how to pass 'search ter
« Reply #5 on: May 07, 2013, 05:41:52 am »
My C# is not very good to say the least :) . Also, from my past experience, JavaScript is generally a bit faster to develop with than any 'enterprise' level languages, but your mileage can vary. If I could write add-ins in Java, I would. But from what I understand, Java API is 'read-only' and can't be used to modify the model.

Vlad

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Model Search scripts - how to pass 'search ter
« Reply #6 on: May 07, 2013, 06:19:25 pm »
Vlad,

If you can write Java then you can write C# too.
I often refer to C# as the Microsoft knockoff of Java ;D

The Java api is not readonly, but you can't develop add-ins using Java.

I'm pretty sure using C# i.s.o. Javascript won't be too much overhead, and in the long run using C# would most certainly be more time efficient.

Try it, you might be surprised: Tutorial: Create your first C# Enterprise Architect addin in 10 minutes

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Model Search scripts - how to pass 'search ter
« Reply #7 on: May 08, 2013, 08:31:23 am »
Quote
But from what I understand, Java API is 'read-only' and can't be used to modify the model.
Not true. You can modify the model, but the Java API wrapper only allows EA functions to be called from Java. It does not allow EA to call Java code, which means that you can't have a Java add-in as it couldn't get any broadcasts.

volenin

  • EA User
  • **
  • Posts: 37
  • Karma: +0/-0
    • View Profile
Re: Model Search scripts - how to pass 'search ter
« Reply #8 on: May 14, 2013, 04:59:09 am »
Well, yes. I do need it to work as an 'add-in' (ie, from within Sparx, rather than standalone app)...

Re: the trick with 'input' dialog box, I just realized there might be no way to do that in JavaScript, only in VBScript. Is that true? Or am I missing the way to display a popup with a textfield input through JavaScript?

Thx. Vlad