Book a Demo

Author Topic: Tagged values based on stereotype for method in addin  (Read 4093 times)

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Tagged values based on stereotype for method in addin
« on: May 03, 2019, 12:29:25 am »
I have an MDG file with a profile with stereotypes inside, all of it is a part of an add-in. When I create a method with the appropriate stereotype, no tags are added. When I do a similar task with a class, it works fine. What's more, when I do it manually from the GUI as a user, it works correctly (both for a method and for a class). Am I missing something?

Code for adding a method:

Code: [Select]
       private static EA.Method CreateRestApiResourceOperation(EA.Element ResourceElement, OpenApiOperation Operation)
        {
            EA.Method result = ResourceElement.Methods.AddNew(Operation.OperationId, "");
            result.Stereotype = RestApiOperationMetaclass;
            result.Notes = Operation.Summary + "\n" + Operation.Description;
            result.Update();
            return result;
        }

Similar code for a class:
Code: [Select]
        private static EA.Element CreateResourceClass(string Name, OpenApiPathItem PathItem, EA.Package Parent)
        {
            EA.Element result = Parent.Elements.AddNew(Name, RestApiResourceMetaclass);
            result.Notes = PathItem.Summary + "\n" + PathItem.Description;
            result.Update();
            Parent.Update();
            return result;
        }

The profile in MDG file is pretty simple.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Tagged values based on stereotype for method in addin
« Reply #1 on: May 03, 2019, 01:03:40 am »
I just tried to assign to SterotypeEx and that worked.

q.

P.S. But Stereotype also worked. So: wich version (I'm on 13.5)

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: Tagged values based on stereotype for method in addin
« Reply #2 on: May 03, 2019, 01:11:39 am »
My version is 14.1 build 1429.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Tagged values based on stereotype for method in addin
« Reply #3 on: May 03, 2019, 01:41:11 am »
I just tried to assign to SterotypeEx and that worked.

q.

P.S. But Stereotype also worked. So: wich version (I'm on 13.5)
I agree, stereotypeEx, with a fully qualified stereotype is the way to go.
Using Stereotype might fail if you have another stereotype defined somewhere (model, MDG, ...) with the same name.

Geert

Slávek Rydval

  • EA User
  • **
  • Posts: 40
  • Karma: +2/-0
    • View Profile
    • homepage
Re: Tagged values based on stereotype for method in addin
« Reply #4 on: May 03, 2019, 02:15:21 am »
Well, I found it.

There were two problems:
  • As you mentioned, StereotypeEx is the proper way.
  • There cannot be _metatype attribute for a stereotype that extends an operation metaclass in a profile.