Book a Demo

Author Topic: Subtypes  (Read 20438 times)

Lilleberg

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Subtypes
« on: February 19, 2009, 01:32:36 am »
Hi!

I have an EA.Element of Type "InteractionFragment". I can get the index of the subtype by doing this:

EA.Element element = (EA.Element)m_Repository.GetElementByID(ID);
int subType = element.Subtype;


My first question is: How can I get the name of the subtype? As you can see in the picture below my InteractionFragment have subtype "alt". But by using the code above I can only get the index. Not the name.

My second question is: Is the index of InteractionFragments always the same? I mean is the index of subtype "alt" always 0 and so on...





Thanks!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Subtypes
« Reply #1 on: February 19, 2009, 03:32:31 am »
AFAIK...

To the second question, no there is no reliable way to obtain the name from the API. EA uses the SubType attribute to mean different things for different element types. Many of these are (to date) undocumented. While they are probably quite stable, there is no promise that they will remain the same in future.

With the above caveat, you can be pretty sure that commonly seen element types will stay pretty much the same, at least for the current version of EA. Otherwise many legacy applications would break, due to the same issues you are experiencing.

For now you will have to translate these 'manually' in your applications.

As to the first question, the return value from the SubType field is not (necessarily) the index into the drop-down. The reason for this disconnection has the same root cause as I mention earlier, that the attribute means different things for different elements. Not all elements have SubTypes that are consecutive from 0 or 1, so these are difficult to use as an index. Some do, but there is no guarantee.

You will have to play with the API a bit, but you should be able to find the ones you need, then create a data structure (or whatever) to handle the conversion for your applications.

HTH, David
No, you can't have it!

priombiswas89

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Subtypes
« Reply #2 on: March 18, 2021, 10:38:17 pm »
Hi!

I have an EA.Element of Type "InteractionFragment". I can get the index of the subtype by doing this:

EA.Element element = (EA.Element)m_Repository.GetElementByID(ID);
int subType = element.Subtype;


My first question is: How can I get the name of the subtype? As you can see in the picture below my InteractionFragment have subtype "alt". But by using the code above I can only get the index. Not the name.

My second question is: Is the index of InteractionFragments always the same? I mean is the index of subtype "alt" always 0 and so on...





Thanks!

I am also having the same problem and couldn't find any solution yet. If you have found any solution, it would be very helpful if you share it here.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Subtypes
« Reply #3 on: March 18, 2021, 10:54:44 pm »
Wow, blast from the past! :o

The Subtype is not an "index" but simply a numerical representation.

I don't know the actual values, but it will be something like

1 = alt
2 = opt
3 = loop
etc...

these values will not change. If "1" translates to "alt" now, then it will always mean "alt"

Geert

priombiswas89

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Subtypes
« Reply #4 on: March 19, 2021, 08:45:51 pm »
Wow, blast from the past! :o

The Subtype is not an "index" but simply a numerical representation.

I don't know the actual values, but it will be something like

1 = alt
2 = opt
3 = loop
etc...

these values will not change. If "1" translates to "alt" now, then it will always mean "alt"

Geert

After my api investigation, it seems like that's the only way to get the names of combined fragment type. I have another question regarding the fragments. Following is my sequence diagram:
https://ibb.co/GQ2MV6H

Here you can see, inside loop fragment there are two transitions. Is there any way I can get this relation from api? Here relation means, Fragment loop has two transitions/connectors.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Subtypes
« Reply #5 on: March 19, 2021, 09:10:06 pm »
Those messages are simple connectors you find in the Connectors collection of the lifeline elements. (At least I would guess so)

q.

priombiswas89

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Subtypes
« Reply #6 on: March 19, 2021, 09:12:04 pm »
Those messages are simple connectors you find in the Connectors collection of the lifeline elements. (At least I would guess so)

q.

I am getting the messages from connectors, what I need to get from the api is the relationship between the interaction fragment and the message inside the fragment.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Subtypes
« Reply #7 on: March 19, 2021, 10:36:57 pm »
I am getting the messages from connectors, what I need to get from the api is the relationship between the interaction fragment and the message inside the fragment.
[/quote]
You'll have to figure that out based on the coordinates of the diagramObject (for the fragment) and diagramLinks (for the messages)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Subtypes
« Reply #8 on: March 19, 2021, 11:31:33 pm »
Find them in the accorrding list of objects (type=InteractionFragment) and locate their position in the diagram.

q.

priombiswas89

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Subtypes
« Reply #9 on: March 20, 2021, 12:12:09 am »
Find them in the accorrding list of objects (type=InteractionFragment) and locate their position in the diagram.

q.

I am getting the coordinates, for example, for InteractionFragment:

Code: [Select]
if (element.MetaType.Equals("InteractionFragment"))
                {
                    top = diagramObj.top;
                    bottom = diagramObj.bottom;
                    left = diagramObj.left;
                    right = diagramObj.right;
                }
                GetAllConnectors(rep, sequenceDiagramObj, element); // to get the connectors/transitions

to find the connectors

Code: [Select]
private void GetAllConnectors(Repository rep, SequenceDiagram sequenceDiagramObj, EA.Element element)
        {
            foreach (EA.Connector primitiveItem in element.Connectors)
            {
               Primitive primitiveObj = new Primitive();
                int startX, startY, endX, endY = 0;
                startX = primitiveItem.StartPointX;
                startY = primitiveItem.StartPointY;
                endX = primitiveItem.EndPointX;
                endY = primitiveItem.EndPointY;

                foreach (var item in sequenceDiagramObj.primitives)
                {
                    sequenceDiagramObj.primitives.Add(primitiveObj);
                }
            }
        }

The problem is, MetaType = "InteractionFragment" doesn't have any associated connectors, only  MetaType = "Sequence" have associated connectors. How can I associate and group them according to coordinates?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Subtypes
« Reply #10 on: March 20, 2021, 05:41:47 am »
Look at the coordinates of the DiagramLinks of the message connectors and compare those to the DiagramObject of your of your interactionfragment.

I don't see any diagramLinks in your code.

Geert

priombiswas89

  • EA User
  • **
  • Posts: 47
  • Karma: +0/-0
    • View Profile
Re: Subtypes
« Reply #11 on: March 21, 2021, 10:46:23 pm »
Look at the coordinates of the DiagramLinks of the message connectors and compare those to the DiagramObject of your of your interactionfragment.

I don't see any diagramLinks in your code.

Geert

I have modified the code as below:

Code: [Select]
foreach (EA.DiagramLink link in diag.DiagramLinks)
            {
                EA.Connector connector = rep.GetConnectorByID(link.ConnectorID);
                startX = connector.StartPointX;
                startY = connector.StartPointY;
                endX = connector.EndPointX;
                endY = connector.EndPointY;
            }
            foreach (DiagramObject diagramObj in diag.DiagramObjects)
            {
                int elementId = diagramObj.ElementID;
                EA.Element element = rep.GetElementByID(elementId);
               
                if (element.MetaType.Equals("InteractionFragment"))
                {
                    top = diagramObj.top;
                    bottom = diagramObj.bottom;
                    left = diagramObj.left;
                    right = diagramObj.right;
                    GetTypeName(element);
                }
            }

I am confused about how to compare startX, startY, endX, endY to top, bottom, left and right.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Subtypes
« Reply #12 on: March 22, 2021, 03:04:28 am »
What is your confusion about? Comparison? This is a simple plain with two coordinates. To find what you are looking for you need something called geometry.

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: Subtypes
« Reply #13 on: March 22, 2021, 05:03:35 am »
Diagrams operate in a field with two axes X (horizontal) and Y (vertical)
The top left of a diagram is 0,0

100 pixels to the right, and 100 pixels down translates to 100,-100 (Y axis counts down negative)

A diagram link starts inside a fragment if

- startPointX between left and right
- startpointY between top and bottom

Geert