General (#1) - Apply Profiles and Stereotypes to output model (#3) - Message List

Apply Profiles and Stereotypes to output model
 unsolved

Hello,

I like to do a plain UML2 to UML2 Modeltransformation. For this, I generated an EMF UML2 2.0 Model with MagicDraw and importet it as the First Model in the Launch Editor.

The Target-Model should be EMF UML2 2.0 too, with the same (as the source model) and additional profiles.

So, I'm wondering, if there is a way to specify a specialized Profile for the Target-Model in medini QVT.

Next, the elements in the Target-Model should apply to a Stereotype - or at least maintain the same Stereotype (from the UML Standard Profile) as in the Source-Model.

I've tried to use c2.applyStereotype(c1.getAppliedStereotype('UML Standard Profile::entity)); for example (with c1 and c2 as domains) in the where clause, but this has no effect. (BTW: The Target-Model doesn't has the UML Standard Profile referenced! Maybe this is the preceding fault?)

Can you please give me a hint?

Thanks a lot in advance.

Regards, Robert

  • Message #2

    Hi Robert,

    A mediniQVT user had a similar problem and he solved it by defining two input models: The UML2 model and the Stereotyp defining model. Note that you have to use a current mediniQVT version (field "First Model" now is named "First Set of Models"). With the following QVT code, the user succuessfully tested on existence of a stereotype in a UML Class instance:

       top relation QoSCharacteristic2Component {
             QoSChar : uml::Stereotype;
                 checkonly domain source stereotype : uml::Class {
           };
                 enforce domain target ccmComponent : CCMModel::ComponentDef {
           };
                when {
               not stereotype.getValue(QoSChar(),'isInvariant').oclIsUndefined();
               stereotype.getValue(QoSChar(),'isInvariant').oclAsType(Boolean) = true;
           }
                where {
               name2identifier(stereotype, ccmComponent);
           }
             }
       query QoSChar () : uml::Stereotype {
           uml::Stereotype.allInstances()->select(x : uml::Stereotype | x.name = 'QoSCharacteristic')->asSequence()->first()
       }
    

    So you should try to use setValue(..) instead of getValue(..) to actually set the stereotype.

    However as I just experience, you cannot call setValue() since it returns "void" and the QVT engine expects an boolean type for where-expressions. So please wait until we have a workaround to this problem. We will inform you.

    Regards, Jörg Kiegeland

    • Message #3

      Thanks, Jörg, for your answer.

      As I see, the Stereotype 'QoSCharacteristic' contains Tagged Values, and the user checks a specific value in that Stereotype. Ok.

      But what, if the Stereotype is just like a "marker" and does not contain any Tagged Values? In this case, I'm also unable to use the setValue() operation.

      BTW: How do I part several models in "First set of models"? Can I specify the referenced UML-Profiles there? For example: "platform:myModel.uml, profile:umlstandard.uml" ??? So could I use this also for "Second set of models" to specify, which UML-Profiles are referenced in the Target model?

      Well, christmas-time brings much time to play and test a little bit...

      Thanks in advance, Regards, Robert Herschke

      • Message #4

        Hi Robert,

        to interrogate whether a stereotype is applied you should use (but not tested by me):

        stereotype.isStereotypeApplied(QoSChar());

        To the other question: You do not need to connect several model URIs by yourself - it is done by the Browse.. wizard already. Just click the Browse button and then choose several models by e.g. the "Browse Workspace" button- the models are connected by a space. You then can put into this set the model defining the stereotype (uml::Stereotype.allInstances() then retrieves all instances of all defined models of type uml::Stereotype).

        A target model can reference model elements from any other models - you do not need to include these other models in "Second set of models". Cross-references to other EMF resources is natively supported by EMF.

        Remember that you still cannot call a method returning "void" in a where-clause - we work on a solution to this.

        Regards Jörg Kiegeland

        • Message #17

          Hi Jörg,

          where does the method "isStereotypeApplied" come from ?

          Regards, Siegfried

  • Message #5

    Hi,

    i successfully applied Stereotypes by providing the profile as EMF-Metamodel to QVT. When doing this I could for instance write the following to apply a Stereotype "Entity" to a Class:

    enforce domain entity : myprofile::Entity{
      base_class = someClass
    }
    

    (Note that the property base_class follows a naming convention defined by the profile-to-CMOF-mapping defined in the Profiles-chapter of UML superstructure)

    However, the way how I provided the profile as EMF model to QVT was quite weird: I called "define" on the profile and copied the generated elements afterward into a separate ecore file. This I registered then in the MediniQVT preferences. I recently read some posts about "static profiles" in Eclipse and I think, with them this can be done in a more obvious way the I did.

    Regards, stefan.

Attachments

No attachments created.