Book a Demo

Author Topic: Creation of stereotyped ports at an element  (Read 3779 times)

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Creation of stereotyped ports at an element
« on: August 26, 2015, 10:45:31 am »
Hi guys,

I am constantly getting the "Invalid Type" error when trying to add a stereotyped port to an element programmatically. The stereotype is defined in a profile and has the _metatype attribute set correctly. Whether I use the Elements or EmbeddedElements collection doesn't matter, the error is the same.

Code: [Select]
IDualCollection instanceElements = newElementInstance.EmbeddedElements;
IDualElement newPort = (IDualElement)instanceElements.AddNew(currPort.Name, profileName + "::" + currPort.Stereotype);

Any ideas?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creation of stereotyped ports at an element
« Reply #1 on: August 26, 2015, 06:24:17 pm »
I guess the stereotype is invalid. Have you tried to use just "Port" for a test?

q.

McMannus

  • EA User
  • **
  • Posts: 108
  • Karma: +4/-1
    • View Profile
Re: Creation of stereotyped ports at an element
« Reply #2 on: August 26, 2015, 06:27:26 pm »
Good morning,

since both collections Element.Elements and Element.EmbeddedElements are readonly, this does not mean, that you cannot invoke methods like AddNew on them. The funny thing is that it works if I use the EA type "Port" instead of the qualified classifier, however the stereotype is then omitted. Setting it afterwards works (but only with Element.StereotypeEx), but I was just curious why directly providing the stereotype does not work only with stereotypes extending Part or Port, while this works with all other meta-class stereotypes, I am using.
« Last Edit: August 26, 2015, 06:28:40 pm by McMannus »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Creation of stereotyped ports at an element
« Reply #3 on: August 26, 2015, 07:19:57 pm »
IF you re-read my post you see I found it was a wrong shot ;)

I'll see whether I can try with a stereotyped port later.

q.

P.S. The following snippet worked with no issue:
Code: [Select]
my $e1 = $rep->GetElementByGUID("{0FF00F45-BF2D-4d25-8E38-BFB02D36BD58}");
my $p = $e1->EmbeddedElements->AddNew("test", "SoaML::requestPoint");
$p->Update();
« Last Edit: August 26, 2015, 07:32:43 pm by qwerty »