Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes
[TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes [message #1727119] Sat, 19 March 2016 11:26 Go to next message
Mr Cur is currently offline Mr CurFriend
Messages: 31
Registered: September 2014
Member
Dear all,

I use Texo to generate a JPA-based implementation based on an Ecore class diagram. Additionally, I use the annotation facility as part of Texo to influence the generation process.

Now, I want to develop a simple web/form based application to manage the JPA instances.
For a limited subset of my JPA class hierarchy, I developed a prototype using Vaadin. This works reasonably well but the implementation is not straightforward.

Therefore, the plan is the develop an web/form application generation using Acceleo.
Acceleo seems to well suited to generate code based on an Ecore class diagram. However, the code generation should follow the same 'generation' decision as Texo does (e.g. with respect to handling bi-directional relationships and decision on the ownership of such relations in JPA).

Therefore, the Acceleo generator needs to use both the Ecore class diagram and the Texo annotations model.

I have two questions:

1) How to work with the annotations model of Texo in Acceleo?
Acceleo can deal with different meta models, and while creating an Acceleo translator, the annotations model of Texo seems to be recognized.
However, if I develop a simple translator using Acceleo, I get the following error:

Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.ClassNotFoundException: Class 'EPackageModelGenAnnotation' is not found or is abstract.

At https://wiki.eclipse.org/Acceleo/FAQ#My_generation_fails_with_a_.27package_not_found.27_exception it suggest that can be solved easily.
I did the following:

In the method registerPackages (of the by Acceleo generated generate.java):

if (!isInWorkspace(
org.eclipse.emf.texo.annotations.annotationsmodel.AnnotationsmodelPackage.class)) {
resourceSet.getPackageRegistry().put(
org.eclipse.emf.texo.annotations.annotationsmodel.AnnotationsmodelPackage.eINSTANCE.getNsURI(),
org.eclipse.emf.texo.annotations.annotationsmodel.AnnotationsmodelPackage.eINSTANCE);
}
if (!isInWorkspace(
org.eclipse.emf.texo.modelgenerator.modelannotations.ModelcodegeneratorPackage.class)) {
resourceSet.getPackageRegistry().put(
org.eclipse.emf.texo.modelgenerator.modelannotations.ModelcodegeneratorPackage.eINSTANCE.getNsURI(),
org.eclipse.emf.texo.modelgenerator.modelannotations.ModelcodegeneratorPackage.eINSTANCE);
}
resourceSet.getPackageRegistry().put(
"http://www.eclipse.org/emf/texo/modelgenerator/modelannotations",
org.eclipse.emf.texo.annotations.annotationsmodel.AnnotationsmodelPackage.eINSTANCE);

Apparenty, the above is not complete, hence the Exception.
Please a suggestion what I have to add.

2. Rules that Texo uses, specifically to handle bi-directional relationships.
Is there an overview that explains how Texo generates bi-directional relationships, specificly with respect to ownership of relationships?
A suggestion where to look in the source code of Texo to find these rules would also be appreciated.

Thanks.

Cur.
Re: [TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes [message #1727220 is a reply to message #1727119] Mon, 21 March 2016 12:03 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Cur,
Interesting development, it is/was also in my plans to go this direction but didn't get to it. So if you want any help/discussion let me know. I also checked Acceleo also for code generation instead of xtend.

Here is the code which generates jpa annotations for the EReference, I think it gives a good insight for you second question:
http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/generator/org.eclipse.emf.texo.orm/src/org/eclipse/emf/texo/orm/annotator/EReferenceORMAnnotator.java

For your first question, I guess it is a class loading issue with this class. This class is in the org.eclipse.emf.texo.modelgenerator plugin, is that one included in the classpath?

gr. Martin

Re: [TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes [message #1727304 is a reply to message #1727119] Mon, 21 March 2016 22:57 Go to previous messageGo to next message
Mr Cur is currently offline Mr CurFriend
Messages: 31
Registered: September 2014
Member
Hi Martin,

I have the following in MANIFEST.MF wrt Texo
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.emf.texo.modelgenerator,
org.eclipse.emf.texo.orm,
...

I read somewhere that I also need to register the filename extention (.annotations ?).

Something like
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);

But is is unclear to me if this needed for Texo, and if so, how to do it.

Best,

Cur.
Re: [TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes [message #1727701 is a reply to message #1727304] Fri, 25 March 2016 12:33 Go to previous messageGo to next message
Mr Cur is currently offline Mr CurFriend
Messages: 31
Registered: September 2014
Member
Hi Martin,

I can now read a texo annotation model in Acceleo. However, it seems that Acceleo has difficulties to work with two model instances.

Therefore a more promising approach seems to be to retrieve all annotations in the generated code and to deal in an appropriate way with it.
The code generator itself can then use the ecore specification as input (so one model only for Acceleo) .

Best,

-- Cur
Re: [TEXO][ACCELEO] Web-form Vaadin editor for Texo JPA classes [message #1746137 is a reply to message #1727701] Sun, 23 October 2016 09:23 Go to previous message
Isaac Sousa is currently offline Isaac SousaFriend
Messages: 2
Registered: May 2016
Junior Member
Hi Cur,

I'm trying to do something similar to what you are describing. Meaning I want to use Texo model annotations in Acceleo.
From what I understood you tried to use the annotated model as your input both for model structure and to access all annotations, right?

I was wondering if you could share a little more about your conclusions so far on following that approach.

Thanks
Previous Topic:[EMF Forms] Tree Master Detail Recursion
Next Topic:[EMF Forms] What happened to the JavaFX renderer between version 1.7.2 and 1.8.0?
Goto Forum:
  


Current Time: Fri Jan 19 00:09:45 GMT 2018

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

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