Author Topic: Get the list of tags of a connector  (Read 296 times)

tzafrir

  • EA User
  • **
  • Posts: 127
  • Karma: +0/-0
    • View Profile
Get the list of tags of a connector
« on: September 13, 2019, 06:07:01 am »
Hi,
I am trying to get the list of tags that are associated with a ST, that is associated to a connector.

I found an API that gets the tag from the connector:
EA.Collection tagCollection = connector.TaggedValues;

but trying to run over them with simple loop:
for(short i = 0;i< tagCollection.Count; i++)
{
  EA.TaggedValue tag = (EA.TaggedValue)tagCollection.GetAt(i);
  tagName = tag.Name;
}

I get exception that casting cannot be done, and can not do this conversion.

Can someone tell me how can I overcome it? or other way to get the tags of the connector?

Thanks



qwerty

  • EA Guru
  • *****
  • Posts: 10625
  • Karma: +233/-194
  • I'm no guru at all
    • View Profile
Re: Get the list of tags of a connector
« Reply #1 on: September 13, 2019, 06:08:40 am »
Not sure about that Java stuff, but try a long instead of the short. Pretty sure the tagCollection.Count returns a long that can't be casted to short.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 9537
  • Karma: +274/-27
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Get the list of tags of a connector
« Reply #2 on: September 13, 2019, 06:11:48 am »
try casting to EA.ConnectorTag

It helps to read the manual you know: https://sparxsystems.com/enterprise_architect_user_guide/15.0/automation/connector.html

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6841
  • Karma: +66/-7
    • View Profile
Re: Get the list of tags of a connector
« Reply #3 on: September 13, 2019, 08:46:05 am »
try casting to EA.ConnectorTag
This would be the problem.

Not sure about that Java stuff, but try a long instead of the short. Pretty sure the tagCollection.Count returns a long that can't be casted to short.
I believe short is correct and Java will complain if you pass GetAt a long or int.
Eve

support@sparxsystems.com

qwerty

  • EA Guru
  • *****
  • Posts: 10625
  • Karma: +233/-194
  • I'm no guru at all
    • View Profile
Re: Get the list of tags of a connector
« Reply #4 on: September 13, 2019, 09:20:30 am »
So as we are at guessing: what I do in such cases is to comment things stepwise to find the culprit.

q.

tzafrir

  • EA User
  • **
  • Posts: 127
  • Karma: +0/-0
    • View Profile
Re: Get the list of tags of a connector
« Reply #5 on: September 15, 2019, 03:43:34 pm »
Thanks for the help,
casting to EA.ConnectorTag solved the issue.