Author Topic: How are the operation param types handled by EA ?  (Read 3649 times)

Stephane B

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
How are the operation param types handled by EA ?
« on: May 06, 2013, 08:05:54 pm »
How are the operation parameter types handled by EA ?

I'm writing model transformation templates and I'd like to have :
    myOperation(param1:myClass1)
transformed into
    myTransformedOperation(param1:myTransformedClass1)

Problem is, I can't figure out how to get a handle on the param type. There doesn't seem to be a connector involved.
As far as I know, the param type is just described as
Parameter {
      ...
      type="myTransformedClass1"
      ...
}
in the Intermediary Language.
If I generate my transformed model like this, I can then check in the UI to understand what happens :
EA seems to be looking for a class named myTransformedClass1 anywhere in the project (goes upward in the model tree and stops at the first one it finds named accordingly).
How can I define precisely the parameter type, so as to have EA to point to the right class ? Is there a hidden Connector or a Classifier ?

Thanks in advance.

Stéphane

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13404
  • Karma: +567/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How are the operation param types handled by E
« Reply #1 on: May 06, 2013, 08:38:38 pm »
Stéphane,

Normally (=>if you have selected the type of the parameter and not just typed in something) there is a hard link between the parameter and the type.

I don't know anything about transformation templates, but I can show how it's implemented in my EA Add-in Framework.
From the ParameterWrapper.cs
Code: [Select]
   public override UML.Classes.Kernel.Type type {
      get {
        // for some strange reason the classifierid of the parameter is a
        // string, where all other id the the EA API are integers.
        int ClassifierID;
        UML.Classes.Kernel.Type type = null;
        if (int.TryParse(this.wrappedParameter.ClassifierID,out ClassifierID))
        {
                 type = this.model.getElementWrapperByID(ClassifierID) as UML.Classes.Kernel.Type;
        }
        // check if the type is defined as an element in the model.
        if( type == null ) {
          // no element, create primitive type based on the name of the type
          type = this.model.factory.createPrimitiveType
            ( this.wrappedParameter.Type );
        }
        return type;
      }
      set { throw new NotImplementedException(); }
    }

Geert

Stephane B

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: How are the operation param types handled by E
« Reply #2 on: May 07, 2013, 12:13:00 am »
Ok, thanks Geert,

Don't know yet if that'll help. I have to let it mature a bit ;-)

Indeed I was pretty sure that there was a hard link. It seems to be a Classifier.

In my template maybe it'll go like this :
Code: [Select]
Operation {
    name = "myTransformedOperation"
    Parameter {
        name = "param1"
        type = "myTransformedClass1"
        Classifier {
            namespace="<the transformation that gave myTransformedClass1>"
            name="<the template that gave myTransformedClass1>"
            source="<someGUID...don't have a clue>"
        }
    }
}

Anyone knowing if I'm getting close ?

Stephane
« Last Edit: May 07, 2013, 12:15:17 am by StephaneB »

Stephane B

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: How are the operation param types handled by E
« Reply #3 on: May 07, 2013, 01:25:59 am »
Seems to work with :

source=%qt%%paramClassifierGUID%%qt%

Now let's get a handle on the return type !

Stephane B

  • EA User
  • **
  • Posts: 31
  • Karma: +0/-0
    • View Profile
Re: How are the operation param types handled by E
« Reply #4 on: May 07, 2013, 01:40:25 am »
Now for the full answer :

Code: [Select]
Operation {

    name = "myTransformedOperation"
    type = "MyTransformedReturnType"

    Classifier {
            
        namespace="<the transformation that gave MyTransformedReturnType>"
        name="<the template that gave MyTransformedReturnType>"
        source=%qt%%opReturnClassifierGUID%%qt%
    }

    Parameter {

        name = "param1"
        type = "MyTransformedClass1"
        Classifier {
            namespace="<the transformation that gave MyTransformedClass1>"
            name="<the template that gave MyTransformedClass1>"
            source=%qt%%paramClassifierGUID%%qt%
        }
    }
}