Book a Demo

Author Topic: API: Class Stereotype  (Read 9208 times)

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
API: Class Stereotype
« on: November 14, 2012, 01:30:02 am »
Hello,

I ran into the very weird problem. I'm trying to get ElementID and it's stereotype using API or SQL and I'm getting it, but it's not what I'm waiting for. For example the diagram was copied couple times and some existed class objects were added. When I've selected the diagram and I'm going through all diagram objects asking for it's stereotype and id,the API is bring to me the 'original' elements with some stereotypes that are different from what I see on the diagram. How can I "retrieve" classes I see on diagram?

Thank you in advance.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: API: Class Stereotype
« Reply #1 on: November 14, 2012, 03:07:50 am »
What? Can you illustrate that?

q.

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #2 on: November 14, 2012, 05:18:05 pm »
EA.Element curElement;
EA.Repository rep;

foreach(EA.DiagramObject curObject in selectedDiagram.DiagramObjects)
{
     curElement = rep.GetElementByID(curObject.ElementID);    
     //and now I'm trying to get let say stereotype of the current element
     string stereotype = CurElement.Stereotype;

}

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #3 on: November 14, 2012, 05:24:26 pm »
The stereotype is nothing: empty string, but on the diagram the stereotype of this current element has some value "My Stereotype". But again all this story is coming from copying diagrams, objects and so on... I mean, I have some class "MyClass" and I've copied it 5 times, put on different diagrams and copied diagrams also and this story has started. SQL brings me the same results. Your opinion?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: API: Class Stereotype
« Reply #4 on: November 14, 2012, 06:22:24 pm »
I guess there might be a difference between what you see in EA (partially cached in memory) and what is in fact in the database.
Try reloading the model and see if you still have those weird differences.

Geert

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #5 on: November 14, 2012, 06:49:18 pm »
I did it many times and nothing changed. I queried sql and found all my copies of the "MyClass" class. For example I have 5 copies with different stereotypes. But when I loop by DiagramObjects in some diagram it brings to me "original first time created" class. It sounds like fantasia, but ID, stereotype and all other properties are from this "original" one and not I see actually on the diagram. I can assume that current "MyClass" points to the "original" one and makes all this mess.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: API: Class Stereotype
« Reply #6 on: November 14, 2012, 07:11:45 pm »
I think you should have a really good look at what you are doing and how it looks now, bot in the database as in EA.
There's no such thing as magic in EA, and usually there's a logical explanation to everything you see.

Geert

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #7 on: November 14, 2012, 07:34:27 pm »
You are right, no magic in EA for 1000%, but try to play with it and you'll see something wrong with it.

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #8 on: November 14, 2012, 08:24:30 pm »
Did you already check the contents of CurElement.StereotypeEx?

Otherwise I would recommend you to (pre-)check EA API object properties with LieberLieber's free EnarSpy tool (http://blog.lieberlieber.com/2011/03/01/free-tool-enar-spy-for-enterprise-architect/). BTW I have done s.th. similar that might give useful insights for AddIn programming (https://github.com/makulik/EA-Explorer).

HTH
Günther

zalbina

  • EA User
  • **
  • Posts: 149
  • Karma: +0/-0
    • View Profile
Re: API: Class Stereotype
« Reply #9 on: November 14, 2012, 09:15:27 pm »
Günther YOU ARE RIGHT!!!! This is a table which holds all this references to the stereotype. I was looking for it and even paid attention on this table, but did find anything related to my problem on a first look.

Thanks a lot.