Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Failed to load Papyrus model with MARTE Stereotypes in standalone application
Failed to load Papyrus model with MARTE Stereotypes in standalone application [message #899662] Wed, 01 August 2012 17:36 Go to next message
Alfredo Motta is currently offline Alfredo MottaFriend
Messages: 41
Registered: June 2012
Member
Hello everybody,

I have a standalone application that is trying to use UML2 library to load a Papyrus model with MARTE stereotypes. I am working on this since a couple of days, hope someone could help Sad
The model is a toy model, with one class and one stereotype applied to it. It's already a couple of days that I am trying to solve the problem without success, wondering if you could help me.

The model is the one attacched containing one class with one MARTE stereotype applied. Here is the code I am using to load the model in the standalone app.

public static Model getModel(String pathToModel){
//A collection of related persistent documents.
ResourceSet set = new ResourceSetImpl();
		
//Register the UML Package
set.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
		set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		
//Register the MARTE package
set.getPackageRegistry().put(org.eclipse.papyrus.MARTE.MARTE_Foundations.Time.TimePackage.eNS_URI, org.eclipse.papyrus.MARTE.MARTE_Foundations.Time.TimePackage.eINSTANCE);
set.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.PROFILE_FILE_EXTENSION, UMLResource.Factory.INSTANCE);
		
//Define Location for marte
set.getURIConverter().getURIMap().put(URI.createURI("pathmap://Papyrus_PROFILES/MARTE.profile.uml"), URI.createFileURI(new File("input/MARTE.profile.uml").getAbsolutePath()));

//Add the model file to the resource set
URI uri = URI.createFileURI(pathToModel);
set.createResource(uri);
Resource r = set.getResource(uri, true);
		
LOGGER.info("Printing the content of the model resouce");
for(EObject o: r.getContents()){
  LOGGER.info(o);
  EcoreUtil.resolveAll(o);
}
		
Model m=(Model)EcoreUtil.getObjectByType(r.getContents(), UMLPackage.eINSTANCE.getModel());
return m;
}


and this is the code printing the stereotypes applied to the elements. I would expect the retrieve the MARTE ClockType stereotype from the class, but this is not the case.

LOGGER.info("Load the model");
Model m=ModelDecorator.getModel(model_file);
		
LOGGER.info("Printing applied profiles");
LOGGER.info(m.getAppliedProfiles());		
		
LOGGER.info("Printing stereotypes");
for(Element e: m.allOwnedElements()){
	LOGGER.info("Element " + e + " has the following stereotypes");
	LOGGER.info(e.getAppliedStereotypes());
}


This is the corresponding output

Printing the content of the model resouce
org.eclipse.uml2.uml.internal.impl.ModelImpl@7215fb38 (name: model, visibility: <unset>) (URI: null) (viewpoint: <unset>)
org.eclipse.papyrus.MARTE.MARTE_Foundations.Time.impl.ClockTypeImpl@664310d0 (nature: discrete, isLogical: false)

Printing applied profiles
[org.eclipse.uml2.uml.internal.impl.ProfileImpl@395d601f (name: Time, visibility: <unset>) (URI: null)]

Printing model element stereotypes
Element org.eclipse.uml2.uml.internal.impl.ClassImpl@154e45b3 (name: RadarClock, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false) has the following stereotypes
[] --> this should have the ClockType Stereotype according to the model
Element org.eclipse.uml2.uml.internal.impl.ProfileApplicationImpl@75d252d (isStrict: false) has the following stereotypes
[]


Attached the model the and the MARTE profiles.
In order to get this work I changed in the MARTE profile the UML2 version from this xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" to this xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML". Otherwise the types were not recognized correctly.

Thank you so much for your help

[Updated on: Wed, 01 August 2012 17:38]

Report message to a moderator

Re: Failed to load Papyrus model with MARTE Stereotypes in standalone application [message #904352 is a reply to message #899662] Tue, 28 August 2012 09:50 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 126
Registered: September 2011
Senior Member
Quote:
In order to get this work I changed in the MARTE profile the UML2 version from this xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" to this xmlns:uml="http://www.eclipse.org/uml2/4.0.0/UML". Otherwise the types were not recognized correctly.

Maybe that is the problem. Maybe you created your model using the UML2.3 specification while using the UML2.4 specification in your standalone application.
Possible solutions: Either migrate your model to UML2.4 (Papyrus 0.9.x (Juno)) or downgrade the UML2 library that you are using in the standalone application.

[Updated on: Tue, 28 August 2012 09:52]

Report message to a moderator

Re: Failed to load Papyrus model with MARTE Stereotypes in standalone application [message #904356 is a reply to message #904352] Tue, 28 August 2012 10:02 Go to previous messageGo to next message
Simon Schwichtenberg is currently offline Simon SchwichtenbergFriend
Messages: 126
Registered: September 2011
Senior Member
I could imagine, that you can easily read the model into memory with the help of the EMF-API. I am not sure, but maybe it dissolves the dependecies (i.e. the MARTE profile) automatically. Take a look at the loadContent method here:
http://eclipsesource.com/blogs/2011/03/31/what-every-eclipse-developer-should-know-about-emf-%E2%80%93-part-2/
Re: Failed to load Papyrus model with MARTE Stereotypes in standalone application [message #987194 is a reply to message #904356] Sat, 24 November 2012 11:09 Go to previous message
Alfredo Motta is currently offline Alfredo MottaFriend
Messages: 41
Registered: June 2012
Member
Quote:
Maybe that is the problem. Maybe you created your model using the UML2.3 specification while using the UML2.4 specification in your standalone application.
Possible solutions: Either migrate your model to UML2.4 (Papyrus 0.9.x (Juno)) or downgrade the UML2 library that you are using in the standalone application.


Thank you, I solved my problem by upgrading the library
Previous Topic:Inconsistencies between ".di"file and ".uml"file
Next Topic:Repeated Errors After Update
Goto Forum:
  


Current Time: Mon Dec 22 12:59:14 GMT 2014

Powered by FUDForum. Page generated in 0.01658 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software