state machine and UML2

Talking about the metafacades infrastructure

state machine and UML2

Postby erik.post » Wed 17. Jan 2007, 16:47

I'm running into a new problem with state machines and my cartridge. My cartridge has an UML 1.4 metamodel in which the common StateMachineFacade is extended by my custom Facade class. In the metafacades.xml, this is mapped with a simple <mapping class="MyStateMachineFacade" />. This cartridge works with UML 1.4 models saved by MagicDraw 9.5.



The problem is when I use an exported UML2 model. The model itself contains the same elements as my UML1.4 model. When processing the model with the cartridge, I get the following error:



Code: Select all
org.andromda.core.metafacade.MetafacadeMappingsException: No mapping class could be found for MyStateMachineFacadeLogicImpl'




(package name left-out for brevity)



Do I have to change some things to have my cartridge work with UML2?
erik.post
 
Posts: 26
Joined: Tue 10. Oct 2006, 15:15

Postby wouter.zoons » Wed 17. Jan 2007, 17:26

hmm .. the cartridge should not behave differently if the repository changes, unless you have references to uml1.4 metaclasses in your cartridge descriptors (the XML files in META-INF/andromda)



side note: I'm assuming you are familiar with the fact that activity graphs in UML1.4 are represented using state machines in UML2.0 ?
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium

Postby erik.post » Wed 17. Jan 2007, 22:43

Thanks for your reply. I'm not at my work computer atm, but afaik the cartridge does not reference any uml1.4 metaclass in the xml files. All mappings are inferred from super facades extended in the metafacade model, plus some facades that use properties for the mapping.



I tried adding an extra mapping of my StateMachineFacade to org.eclipse.uml2.impl.StateMachineImpl, but generation fails for a UML1.4 model (ie, metafacades are not instantiated correctly anymore, leading to null values in the templates).



Both the UML1.4 and UML2 models only use (very simple) state machine diagrams. No activity diagrams are involved.
erik.post
 
Posts: 26
Joined: Tue 10. Oct 2006, 15:15

Postby wouter.zoons » Thu 18. Jan 2007, 01:02

in that case it should definitely work, can you post the relevant part(s) from your metafacades.xml ?
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium

Postby erik.post » Thu 18. Jan 2007, 17:46

I have the following in my metafacades.xml:

Code: Select all
<metafacade class="nl.eid.andromda.cartridges.metafacades.ProcessFacadeLogicImpl">
    <mapping>
        <stereotype>PROCESS</stereotype>
    </mapping>
</metafacade>
<metafacade class="nl.eid.andromda.cartridges.metafacades.CustomStateFacadeLogicImpl">
    <mapping>
        <property name="containedInProcess" />
    </mapping>
</metafacade>
<metafacade class="nl.eid.andromda.cartridges.metafacades.CustomTransitionFacadeLogicImpl">
    <mapping>
        <property name="containedInProcess" />
   </mapping>
</metafacade>
<metafacade class="nl.eid.andromda.cartridges.metafacades.CustomTriggerFacadeLogicImpl">
    <mapping>
        <property name="containedInProcess" />
    </mapping>
</metafacade>
<metafacade class="nl.eid.andromda.cartridges.metafacades.CustomStateMachineFacadeLogicImpl" />

The metafacade model contains the CustomStateMachineFacade class, stereotyped as metafacade, and the class extends (generalization) StateMachineFacade (from the andromda meta profile). The CustomStateMachineFacade has associations to CustomTriggerFacade (which extends EventFacade) and CustomTransitionFacade (which extends TransitionFacade). And finally, the metamodel contains CustomStateVertexFacade (extending StateVertexFacade) and CustomStateFacade (extending StateFacade).

The containedInProcess property returns true if the class associated with the state machine is a ProcessFacade (this is the case when a class in the model has a Process stereotype).

The exception log shows as main exception:
Code: Select all
Failed to construct a meta facade of type 'null' with mappingObject of type --> 'class org.eclipse.uml2.impl.PackageImpl'

The Root exception is different:
Code: Select all
org.andromda.core.metafacade.MetafacadeMappingsException: No mapping class could be found for 'nl.eid.andromda.cartridges.metafacades.CustomStateMachineFacadeLogicImpl'




Btw, can the metamodel also be a UML2 model, or does it have to be a UML1.4 model? My current metamodel is UML1.4.
erik.post
 
Posts: 26
Joined: Tue 10. Oct 2006, 15:15

Postby erik.post » Tue 23. Jan 2007, 17:08

I fixed the exception by adding the following to my metafacades.xml:

Code: Select all
<metafacade class="org.andromda.metafacades.emf.uml2.StateMachineFacadeLogicImpl">
    <mapping class="org.eclipse.uml2.impl.StateMachineImpl" />
</metafacade>


Debugging through MetafacadeUtils#getInheritedMappingClassName showed that org.andromda.metafacades.emf.uml2.StateMachineFacadeLogicImpl was not mapped to anything. Only org.andromda.metafacades.emf.uml2.ActivityGraphFacadeLogicImpl was mapped to org.eclipse.uml2.impl.StateMachineImpl, so I added the StateMachineFacadeLogicImpl to the mapping.
erik.post
 
Posts: 26
Joined: Tue 10. Oct 2006, 15:15

Postby wouter.zoons » Wed 24. Jan 2007, 13:56

wow great you found this, excellent job!

I'll apply this update to the CVS so the next build will have it, if you are working with the 3.3-SNAPSHOT you can remove it once the artifacts have been uploaded to our maven repository (I'll post a message here)
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium

Postby wouter.zoons » Wed 24. Jan 2007, 14:18

I went ahead and committed this change to andromda-all/metafacades/uml/emf/uml2/src/main/resources/META-INF/andromda/metafacades.xml



see my commit here (line #134): http://andromda.cvs.sourceforge.net/and ... =V3_x_HEAD



Chad, I was unable to get the build working because of an earlier problem, I'll rollback my change if I see CruiseControl failing on my commit (since I'm unable for the moment to verify I'm not breaking anything)
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium

Postby wouter.zoons » Wed 24. Jan 2007, 15:19

alright, the build was successful



Erik, try removing the mapping on your local system and see if it works .. it should work if you're using the 3.3-SNAPSHOT, let me know what happens
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium

Postby erik.post » Wed 24. Jan 2007, 15:28

Ok, thanks for applying the fix. I will test it, and let you know if it works!
erik.post
 
Posts: 26
Joined: Tue 10. Oct 2006, 15:15

Postby wouter.zoons » Wed 24. Jan 2007, 15:39

okay, I had to pull this update from CVS, it's not a good idea to map several facades on the same meta-class because AndroMDA won't be able to select the proper one at runtime (it can't know)



I discussed with Chad and he suggested you'ld do something like this:

Code: Select all
<metafacade class="nl.eid.andromda.cartridges.metafacades.CustomStateMachineFacadeLogicImpl">
    <mapping class="org.eclipse.uml2.impl.StateMachineImpl" />
</metafacade>




this will definitely work but is not so nice because it makes your cartridge depend on EMF-UML2 (at least a meta-class from it)



we're looking into a more generic solution where the desired facade type is discovered through a tagged value or something, we didn't find any elegant solution right away though
Wouter Zoons - wouter [at] andromda [dot] org

http://www.andromda.org/ - http://draftdog.blogspot.com/
wouter.zoons
AndroMDA Admin
 
Posts: 4137
Joined: Fri 6. May 2005, 19:29
Location: Brussels, Belgium


Return to Metafacades

Who is online

Users browsing this forum: No registered users and 0 guests