Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [acceleo]static uml profile registration(static uml profile registration)
[acceleo]static uml profile registration [message #803624] Tue, 21 February 2012 10:42 Go to next message
saadia dhouib is currently offline saadia dhouib
Messages: 36
Registered: April 2010
Member
Hi all,
I want to make code generation from a uml model with a static profile applied to it.
I have developed a first acceleo generator, but I have this error:
The generation fail to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates.
The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator.



I guess that the problem comes from the registration of the static profile.
Does someone know how to register it via the registerPackages method?

Thanks
Re: [acceleo]static uml profile registration [message #804306 is a reply to message #803624] Wed, 22 February 2012 08:03 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane Begaudeau
Messages: 406
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

You should edit the generated Java launcher and add something like this after the call to initialize(...).

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo



Re: [acceleo]static uml profile registration [message #836435 is a reply to message #804306] Wed, 04 April 2012 09:39 Go to previous message
saadia dhouib is currently offline saadia dhouib
Messages: 36
Registered: April 2010
Member
Hi Stephane,
I have tried to modify registerPackages method as you mentioned but I still have the error:
!ENTRY org.eclipse.acceleo.engine 2 0 2012-04-04 15:10:36.410
!MESSAGE The generation fail to generate any file because there are no model elements that matches at least the type of the first parameter of one of your main templates.
The problem may be caused by a problem with the registration of your metamodel, please see the method named "registerPackages" in the Java launcher of your generator.

Here is my code:
public static final String PROFILES_PATHMAP = "pathmap://Toto_PROFILES/"; //$NON-NLS-1$


public static final String Toto_PROFILE_URI = PROFILES_PATHMAP + "TotoProfile.profile.uml"; //$NON-NLS-1$

public void registerPackages(ResourceSet resourceSet) {

super.registerPackages(resourceSet);

//
EPackage.Registry packageRegistry = resourceSet.getPackageRegistry();
Resource.Factory.Registry factoryRegistry = resourceSet.getResourceFactoryRegistry();
//Map<URI, URI> uriMap = resourceSet.getURIConverter().getURIMap();

//
if(!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
factoryRegistry.getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
}
URI uri = URI.createURI(Toto_PROFILE_URI);
// TODO If you need additional package registrations, do them here. The following line is an example for UML.
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);

resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
resourceSet.getPackageRegistry().put(TotoPackage.eINSTANCE.getNsURI(), TotoPackage.eINSTANCE);
System.err.println("uri : " + uri);
Map uriMap = resourceSet.getURIConverter().getURIMap();
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri);
}
Previous Topic:[Acceleo/Xtext] Can I use files for concrete models created with xtext2 in acceleo?
Next Topic:Migration OAW4 to OAW5
Goto Forum:
  


Current Time: Wed Apr 16 06:53:11 EDT 2014

Powered by FUDForum. Page generated in 0.01749 seconds