Author Topic: Accessing Sparx API from the "outside"  (Read 99 times)

Viking

  • EA User
  • **
  • Posts: 199
  • Karma: +1/-2
    • View Profile
Accessing Sparx API from the "outside"
« on: July 12, 2017, 05:05:08 pm »
Hello together,

I am looking for possibilities to access the Sparx API from "outside". I want to run "scripts" in Java, Visual Basic or something else (that works) and manipulate content in EA via the Sparx API. So to say I want to run a script which also could be excecuted inside EA. Most welcome would be Java inside Eclipse as container.

The database for our EA environment is MSSQL-server. I saw a lot of possiblities to access EA (e.g. Scripting Enterprise Architect, from there I used the subject-title). But these possibilities are EAP-based and sometimes I have the impression, that they are outdated (e.g. I did not find a complete example using Java API).

Are there any summaries available?

Many thanks in advance, V.



qwerty

  • EA Guru
  • *****
  • Posts: 8621
  • Karma: +126/-113
  • I'm no guru at all
    • View Profile
Re: Accessing Sparx API from the "outside"
« Reply #1 on: July 12, 2017, 06:12:55 pm »
As I mentioned in my book, these are just samples. I definitely can not list all existing programming languages (though I'm fluent in quite a number of them). My experience in Java is limited and at the first time writing, Java had not been supported at all for EA. But there has been an addition that shows a sample for Java too. So, what are you looking for?

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7531
  • Karma: +143/-20
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Accessing Sparx API from the "outside"
« Reply #2 on: July 12, 2017, 07:22:00 pm »
You can. Look for examples at the VBA code in the Excel importer or the Java samples available in the installation directory.

Geert

DarrenDickens

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Accessing Sparx API from the "outside"
« Reply #3 on: July 17, 2017, 11:37:38 pm »
I use VBA running from within Excel.

I started using that because I knew VBA/Excel rather than VBScript, JScript or JavaScript. These 3 "unknown to me" languages would have meant that I could run my scripts inside or outside EA.

However, I felt getting started with EA in VBA (a familiar environment) was more useful to me. I liked VBA's use of typing such as "Dim oAttribute As EA.Attribute" which would stop me writing stupid code trying to assign a parameter to the attribute (should have assigned it to an EA.Method). I would get a VBA compilation error rather than in VBScript (which doesn't have types) everything is a Variant and so stupid coding mistakes get hidden and pop up during testing instead. I felt I needed the hand-holding of the type system.

I have looked at Geert's examples on his website and other forums and found them very useful. Thanks Geert.

Any other language, e.g Java inside Eclipse, would not be executable inside EA. You would need to convert it to JavaScript later, much like I would have to convert VBA to VBScript. I have seen some benefits of running scripts inside EA and some outside EA. It all depends on what you want to do.

Hope that helps.

@ any guru - If I have said anything that is wrong please feel free to correct me; I'm open to being educated.

Darren

Viking

  • EA User
  • **
  • Posts: 199
  • Karma: +1/-2
    • View Profile
Re: Accessing Sparx API from the "outside"
« Reply #4 on: July 20, 2017, 01:17:04 am »
Thank you, DarrenDickens. Good points.

Java and JavaScript are not similar.