Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » multiple packages problem
multiple packages problem [message #710118] Thu, 04 August 2011 14:14 Go to next message
Atif Javed is currently offline Atif Javed
Messages: 21
Registered: March 2010
Junior Member
Hello Friends,
I'm using ACCELEO for model-to-text transformation. But, I'm facing problem which is in fact due to selection of main package (I have an Ecore model which has multiple packages and is hierarchically organized as tree of packages and classes). Does ACCELEO support transformation of models with multiple hierarchical packages? I'm really stuck with this problem and would be very thankful for any hints, suggestions or comments.
Regards,
Atif/
Re: multiple packages problem [message #710194 is a reply to message #710118] Thu, 04 August 2011 14:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3844
Registered: July 2009
Senior Member
Hi

Acceleo's root match is typically for all instances of some type, so if
your type is EPackage it will match on all packages, so you have no problem.

The real problem is usually the converse, you want to match only at the
root of a hierarchy. You can solve this by a containment guard on the
root template.

Regards

Ed Willink

On 04/08/2011 19:14, Muhammad Atif Javed wrote:
> Hello Friends,
> I'm using ACCELEO for model-to-text transformation. But, I'm facing
> problem which is in fact due to selection of main package (I have an
> Ecore model which has multiple packages and is hierarchically
> organized as tree of packages and classes). Does ACCELEO support
> transformation of models with multiple hierarchical packages? I'm
> really stuck with this problem and would be very thankful for any
> hints, suggestions or comments.
> Regards,
> Atif/
>
Re: multiple packages problem [message #710601 is a reply to message #710194] Fri, 05 August 2011 03:52 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1609
Registered: July 2009
Senior Member
Hi,

Having subpackages under a hierarchy is not recommended by EMF, but we should be able to handle them anyway. Without any further information, that is unfortunately all I can really say.

"I'm facing problem which is in fact due to selection of main package" what problem, what symptoms?

Laurent Goubet
Obeo
Re: multiple packages problem [message #711498 is a reply to message #710601] Sat, 06 August 2011 04:00 Go to previous messageGo to next message
Atif Javed is currently offline Atif Javed
Messages: 21
Registered: March 2010
Junior Member
Hey Laurent, Edward
Thanks you very much for reply. Actually, I have an EMF model, which is organized as a set of packages as tree. I'm using ECORE model for generating text; model looks similar like:

http://img220.imageshack.us/img220/2739/modelhierarchy.jpg
Each Epackage in model have NSURI which looks alike: http:///schemas/sampleuri/_PfAJsMe6Ed-7etIj5eTw0Q/19. Meta-model URI's (NSURI's of main-package as well as sub-packages is available at meta-model list after clicking Runtime Version checkbox during creation of new ACCELEO project). Moreover, I'm able to select corresponding classes from Type drop down list. ACCELEO template also did not provide any kind of error and I'm able to select attributes. Everything works fine until that point.
I have written following lines of code in registerpackages method for registration of meta-model (main package).
if (!isInWorkspace(it.unipd.chess.chessmlprofile.chessmlprofilePackage.class)) {
resourceSet.getPackageRegistry().put(epackageMyprofile.eINSTANCE.getNsURI(),epackageMyprofile.eINSTANCE);
}
Moreover, following line in written in register resource factories method:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", epackageMyprofile.eINSTANCE);

But, problems occurred, when I select ACCELEO Model-to-text -> Generate option by right click at either .uml or .di (Papyrus) model. So, problem occurs upon running a simple template which is using my EMF model (generation of model-to-text fails and errors listed below are printed on my console).
...................................................... Console Errors + Transformation Failed .....................................................
!ENTRY org.eclipse.acceleo.module.sample.ui 4 0 2011-08-06 09:07:25.153
!MESSAGE
!STACK 0
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
at org.eclipse.ui.internal.progress.ProgressManager$5.run(ProgressManager.java:960)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:995)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:970)
at org.eclipse.ui.internal.progress.ProgressManager.run(ProgressManager.java:1166)
at org.eclipse.acceleo.module.sample.ui.popupMenus.AcceleoGenerateSampleAction.run(AcceleoGenerateSampleAction.java:91)
at org.eclipse.ui.actions.ActionDelegate.runWithEvent(ActionDelegate.java:70)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: org.eclipse.acceleo.engine.AcceleoEvaluationException: The type of the first parameter of the main template named 'generateElement' is a proxy.
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate(AcceleoService.java:507)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:175)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.doGenerate(AbstractAcceleoGenerator.java:154)
at org.eclipse.acceleo.module.sample.main.Generate.doGenerate(Generate.java:193)
at org.eclipse.acceleo.module.sample.ui.common.GenerateAll.doGenerate(GenerateAll.java:94)
at org.eclipse.acceleo.module.sample.ui.popupMenus.AcceleoGenerateSampleAction$1.run(AcceleoGenerateSampleAction.java:76)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
Root exception:
org.eclipse.acceleo.engine.AcceleoEvaluationException: The type of the first parameter of the main template named 'generateElement' is a proxy.
at org.eclipse.acceleo.engine.service.AcceleoService.doGenerate(AcceleoService.java:507)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.generate(AbstractAcceleoGenerator.java:175)
at org.eclipse.acceleo.engine.service.AbstractAcceleoGenerator.doGenerate(AbstractAcceleoGenerator.java:154)
at org.eclipse.acceleo.module.sample.main.Generate.doGenerate(Generate.java:193)
at org.eclipse.acceleo.module.sample.ui.common.GenerateAll.doGenerate(GenerateAll.java:94)
at org.eclipse.acceleo.module.sample.ui.popupMenus.AcceleoGenerateSampleAction$1.run(AcceleoGenerateSampleAction.java:76)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

..................................................................... End Console ......................................................................................

Some errors printed on console are probably due to root exception. Hierarchy of EMF model into multiple packages is important for us in our system (even though EMF doesn't recommend that). Is there any way to generate code from this kind of EMF model? (I am currently selecting main package URI as meta-model; I think now I briefly described my problem. Will wait for your answer or suggestions for removing errors.

Regards,
Atif/
Re: multiple packages problem [message #711665 is a reply to message #711498] Sat, 06 August 2011 08:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3844
Registered: July 2009
Senior Member
Hi

This seems to be absolutely nothing to do with multiple packages.
> The type of the first parameter of the main template named
> 'generateElement' is a proxy.
This message is a recent improvement In Acceleo, unfortunately it still
doesn't tell you what the unresolved
proxy is, so you have many more opportunities for stupid mistakes to
explore.

Use the debugger on a Java launch to inspect the first parameter of the
main template in the launch so
that you know what is unresolved.

Then add registrations to make the problem go away.

Then investigate why that registration was not provided automatically.
About half my transformations need
manual assistance, which from a purely user perspective is inexcusable.
If the editor knows where the models
are, why should a downstream artefact have so much trouble finding them?

Regards

Ed Willink
Re: multiple packages problem [message #713170 is a reply to message #711665] Mon, 08 August 2011 03:16 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1609
Registered: July 2009
Senior Member
Hi Atif,

You will have more than one "strange" problem with these registration. Your EPackage is properly registered, but the resource factory will prevent any ecore file to be loaded.

-----
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", epackageMyprofile.eINSTANCE);
-----

First things first, never change someone else's resource factory. "ecore" is not your extension (or if it is, you should change it), and changing its resource factory will make not only your tool fail, but a number of others along with it. Furthermore, what you should register here is not a package (epackageMyprofile.eINSTANCE), but rather a resource factory (new XYZResourceFactoryImpl()).

The line should look like

-----
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(myExtension, resourceFactory);
-----

However, if you do not have a custom Resource for your model (you haven't selected the "resource type" in the genmodel), you do not even need to add a single line to the "registerResourceFactories" method.

Laurent Goubet
Obeo
Previous Topic:[Acceleo] JMerge default compiler compliance level
Next Topic:JET Transformation fails when EMF model editor plugin installed
Goto Forum:
  


Current Time: Fri Apr 18 12:01:05 EDT 2014

Powered by FUDForum. Page generated in 0.01936 seconds