Book a Demo

Author Topic: Sparx Java/,net API  (Read 9540 times)

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Sparx Java/,net API
« on: February 02, 2012, 08:02:02 pm »
Hi,

How can I access sparx Java/.net api which can be called from any external tool by importing api. I want to develop a tool over sparx which needs to fetch requirement from sparx. How can I access Sparx SDK for the same ?

Thanks
-Riddhi Shah

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #2 on: February 02, 2012, 09:51:54 pm »
Hi Geert,

Thank you so much for quick reply.

I was trying to refer .jar & .dll file from C:\Program Files\Sparx Systems\EA Trial\Java API. But here I found a note that in readme.txt that "Limitations and known issues:

1. You cannot currently use this API to write plug-ins for EA. It is only suitable for accessing the automation server API.
"

Is it okay to use this jar & dll for accessing information ? I basically want to fetch information regarding Requirements through my java application.

I appreciate your help.

Thanks.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sparx Java/,net API
« Reply #3 on: February 02, 2012, 10:43:32 pm »
Yes should be ok.
You'll just have to execute your code from a separate exe iso as an add-in in EA.

Geert

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #4 on: February 03, 2012, 01:16:16 am »
Thanks Geert. That was really helpful.

Is there a way in api to create requirement with tagged values ? I could not find the method for the same.

- Riddhi

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sparx Java/,net API
« Reply #5 on: February 03, 2012, 01:19:38 am »
Package.Elements.AddNew()

Geert
« Last Edit: February 03, 2012, 01:19:57 am by Geert.Bellekens »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Sparx Java/,net API
« Reply #6 on: February 03, 2012, 02:35:29 am »
+ Element.TaggedValues.Addnew()

q.

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #7 on: February 07, 2012, 12:33:31 am »
Hi,

I am trying to open package and get list of elements from package. The issue I am facing is , On package get it loads package on sparx interface , and my package object is still null. I am doing following:

 Repository r = new Repository();
              boolean flag = r.OpenFile("C:\\Project.eap");
            
              Package pkg = r.GetPackageByGuid("293016A6-0D38-427d-90E4-3EE5925DB438");
              org.sparx.Collection<Element> coll = pkg.GetElements();

on pkg.getElements() it gives null pointer exception.

Thanks,

Riddhi

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sparx Java/,net API
« Reply #8 on: February 07, 2012, 01:09:39 am »
That's because your GUID is not in the correct format.

Geert

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #9 on: February 07, 2012, 11:55:01 pm »
Hi Geert,

Thank you so much for your reply. It was really helpfull.

I am still struglling with Create/Update/Get Requirements through java api. I need api to list all requirements of given package/reposirtory. Also I need apis to create/update requiorements in given package. As per previous reports, I tried to add element in following way :

Repository r = new Repository();
boolean flag = r.OpenFile("C:\\TestProject.eap");
Package pkg = r.GetPackageByGuid("{293016A6-0D38-427d-90E4-3EE5925DB438}");
org.sparx.Collection<Element> coll = pkg.GetElements();
coll.AddNew("Requirement","test");

Here, it does not give any error. But I can not see any requirement created under package ( having guid {293016A6-0D38-427d-90E4-3EE5925DB438} ).

Also, I was looking at the documentation pdf called enterprise_architect_sdk.pdf. Where there is listing of various classes/ methods. I was looking at Requirement class, but I did not get how to load requirement object.

Is it advisable to use java api or is it better to create .net project ?

Thank you so much once again.

Thanks,
 
Riddhi Shah

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sparx Java/,net API
« Reply #10 on: February 08, 2012, 12:26:56 am »
Riddhi,

- Make sure you always reload the model before checking if something has appeared in EA. The GUI tends to cache a whole lot of stuff, and it might not have notice that something new has been created in the database.
- Make sure you always call update() after each change.
- Sometimes a refresh() on a collection also is necessary sometimes after adding/removing elements from the collection.
- Make sure you call update() on the new element returned by AddNew()

Geert

PS. It should not matter if you choose Java or .Net, but for .Net there are more examples available.

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #11 on: February 08, 2012, 12:49:04 am »
Hi,

Thank you so much for the reply.

Even after calling following it is not showing requirements on reload of model :

Element e = coll.AddNew("Requirement","test");
              e.Update();
              e.Refresh();
              coll.Refresh();

Is mercurial api user interactive ? I notice that If we are running on trial license , it asks to continue trial license on

Repository r = new Repository();
              boolean flag = r.OpenFile("D:\Trail.eap");

Till will do not click continue, api does not respond.

Also, I want to create requirement with all the properties set like priority, status , title , description and custom tags. What is the way of doing it ?


Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #12 on: February 08, 2012, 12:52:13 am »
* I mean to ask , Is this ( sparx ) api user interactive ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Sparx Java/,net API
« Reply #13 on: February 08, 2012, 12:57:43 am »
I'm sorry, this is as far as I go.
I'm willing to get you started, but from a certain point on you will have to do it on your own.

Good luck

Geert

Test12345

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Sparx Java/,net API
« Reply #14 on: February 08, 2012, 01:11:17 am »
Thanks Geert.