[blueprints-emf] Question about generating models for blueprint and Jboss Errai [message #1626808] |
Sat, 21 February 2015 01:11  |
Eclipse User |
|
|
|
I am using Blueprint-EMF - and am really impressed with it!
My question is this - can I generate models that I can use in Jboss Errai and blueprint-emf?
To elaborate - Errai, being a model-driven GWT based framework, expects Pojos that are annotated, like so - note the @Portable annotation:
@Portable
public class Person {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
Do I have to generate two models - one POJO, with annotation, and another EObject based?
If so, is there any convenient way to map between the two?
Or can I customize the generated models to include this annotation, and if yes, how?
Thanks and regards
|
|
|
Re: [blueprints-emf] Question about generating models for blueprint and Jboss Errai [message #1626869 is a reply to message #1626808] |
Sat, 21 February 2015 02:02   |
Eclipse User |
|
|
|
Hi Anton,
Texo generates true java pojos from an ecore model:
https://wiki.eclipse.org/Texo
and you can convert between these pojos and EMF EObjects:
https://wiki.eclipse.org/Texo/Convert_to_EMF
Texo does not generate the Portable annotation but there is a way to specify these in the model and then they are placed
in the java code:
https://wiki.eclipse.org/Texo/Direct_Java_Annotations
gr. Martin
On 21-02-15 07:11, Anton Hughes wrote:
> I am using https://github.com/ghillairet/blueprints-emf - and am really impressed with it!
>
> My question is this - can I generate models that I can use in Jboss Errai and blueprint-emf?
>
> To elaborate - Errai, being a model-driven GWT based framework, expects Pojos that are annotated, like so - note the
> @Portable annotation:
>
> @Portable
> public class Person {
>
> private String name;
> private int age;
>
> public String getName() {
> return name;
> }
> public void setName(String name) {
> this.name = name;
> }
> public int getAge() {
> return age;
> }
> public void setAge(int age) {
> this.age = age;
> }
>
> }
>
>
> Do I have to generate two models - one POJO, with annotation, and another EObject based?
> If so, is there any convenient way to map between the two?
> Or can I customize the generated models to include this annotation, and if yes, how?
>
> Thanks and regards
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [blueprints-emf] Question about generating models for blueprint and Jboss Errai [message #1627020 is a reply to message #1626912] |
Sat, 21 February 2015 04:03   |
Eclipse User |
|
|
|
Hi Anton,
Hope that Ed sees this question, afaik there is no standard way to define a java annotation in an EAnnotation (but I
could be wrong).
But EMF allows you to customize templates:
https://wiki.eclipse.org/EMF/ExtendingCodeGeneration#Dynamic_Templates_.26_Generator_Adapter
So there you can also solve this.
gr. Martin
On 21-02-15 08:38, Anton Hughes wrote:
> Thanks Martin
>
> Yes I am aware - and really impressed - with your work.
> And I may well go with your suggestion.
>
> However, partly out of interest, and also to reduce dependencies/complexity, is it possible to add a class annotation
> using EAnnotation?
>
> I have read elsewhere on this forum that it is really easy to customize the generated code, and have seen people write
> of using Annotations to do this - but cannot find any documentation or tutorials for this.
> I would imagine annotating a class or method must be a common use-case. So I'm sure this would be easy to do with
> ecore/emf?
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [blueprints-emf] Question about generating models for blueprint and Jboss Errai [message #1629563 is a reply to message #1628912] |
Sun, 22 February 2015 14:36  |
Eclipse User |
|
|
|
Hi Anton,
Texo throws an exception if the generated source is not valid java. In this case somehow the interface StrategyRule gets
a toString implementation (that's the underlying error). Not sure how/why this happens.
Can you send me the ecore/xcore to try it out?
gr. Martin
On 22-02-15 11:55, Anton Hughes wrote:
> Hi Martin
>
> I'm trying Texo - as this looks like a really flexible solution.
> However, I am running into an error.
>
> My xcore file validates fine. Could this be simply a case of not enough memory?
>
> The error is:
>
> java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException
> at org.eclipse.emf.texo.eclipse.popup.actions.BaseGenerateAction.run(BaseGenerateAction.java:86)
> at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:253)
> at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
> at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
> at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
> at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4454)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3799)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3409)
> at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
> at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
> at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:606)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
> Caused by: java.lang.reflect.InvocationTargetException
> at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:423)
> at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:527)
> at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:284)
> at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:983)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
> at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:1018)
> at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:993)
> at org.eclipse.ui.internal.progress.ProgressManager.run(ProgressManager.java:1194)
> at org.eclipse.emf.texo.eclipse.popup.actions.BaseGenerateAction.run(BaseGenerateAction.java:79)
> ... 31 more
> Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Throwable caught for current source for
> /home/anton/workspaces/magick/magick.models.ecore/src-gen/magick/models/domain/StrategyRule.java :/**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> 25: Abstract methods do not specify a body
> location 3 old source package magick.models.domain;
>
> import javax.persistence.Entity;
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract class StrategyRule
> extends TradeItem
> {
>
>
>
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> }
> new source /**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> at org.eclipse.emf.texo.eclipse.popup.actions.GenerateCode.generateFromModelFile(GenerateCode.java:101)
> at org.eclipse.emf.texo.eclipse.popup.actions.GenerateCode.generateFromModelFiles(GenerateCode.java:60)
> at org.eclipse.emf.texo.orm.annotator.GenerateModelJPACode.generateFromModelFiles(GenerateModelJPACode.java:38)
> at org.eclipse.emf.texo.orm.annotator.GenerateModelJPADaoCode.generateFromModelFiles(GenerateModelJPADaoCode.java:38)
> at org.eclipse.emf.texo.eclipse.popup.actions.BaseGenerateAction.generate(BaseGenerateAction.java:127)
> at org.eclipse.emf.texo.eclipse.popup.actions.BaseGenerateAction.generate(BaseGenerateAction.java:107)
> at org.eclipse.emf.texo.eclipse.popup.actions.BaseGenerateAction$1.execute(BaseGenerateAction.java:75)
> at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
> at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
> at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
> at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
> Caused by: java.lang.IllegalStateException: Throwable caught for current source for
> /home/anton/workspaces/magick/magick.models.ecore/src-gen/magick/models/domain/StrategyRule.java :/**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> 25: Abstract methods do not specify a body
> location 3 old source package magick.models.domain;
>
> import javax.persistence.Entity;
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract class StrategyRule
> extends TradeItem
> {
>
>
>
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> }
> new source /**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> at org.eclipse.emf.texo.generator.ArtifactGenerator.run(ArtifactGenerator.java:146)
> at org.eclipse.emf.texo.eclipse.popup.actions.GenerateCode.generateFromModelFile(GenerateCode.java:99)
> ... 10 more
> Caused by: java.lang.IllegalStateException: Throwable caught for current source for
> /home/anton/workspaces/magick/magick.models.ecore/src-gen/magick/models/domain/StrategyRule.java :/**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> 25: Abstract methods do not specify a body
> location 3 old source package magick.models.domain;
>
> import javax.persistence.Entity;
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract class StrategyRule
> extends TradeItem
> {
>
>
>
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> }
> new source /**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> at org.eclipse.emf.texo.generator.SourceMerger.mergeImportAndFormat(SourceMerger.java:136)
> at org.eclipse.emf.texo.generator.SourceMerger.merge(SourceMerger.java:70)
> at org.eclipse.emf.texo.generator.MergingOutputHandler.beforeWriteAndClose(MergingOutputHandler.java:63)
> at org.eclipse.xpand2.output.Outlet.beforeWriteAndClose(Outlet.java:98)
> at org.eclipse.xpand2.output.FileHandleImpl.writeAndClose(FileHandleImpl.java:135)
> at org.eclipse.xpand2.output.OutputImpl.closeFile(OutputImpl.java:171)
> at org.eclipse.emf.texo.generator.ArtifactGenerator.run(ArtifactGenerator.java:99)
> ... 11 more
> Caused by: java.lang.IllegalStateException: /**
> */
> package magick.models.domain;
>
> import javax.persistence.Entity;
>
>
> /**
> * A representation of the model object '<em><b>StrategyRule</b></em>'.
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Strategy Rule</b></em>'.
> * <!-- end-user-doc -->
> * @generated
> */
> @Entity(name="domain_StrategyRule")
> public abstract interface StrategyRule {
>
> /**
> * A toString method which prints the values of all EAttributes of this instance.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @generated
> */
> @Override
> public String toString() {
> return "StrategyRule "
> + "{extends: " + super.toString() + "} "
> ;
> }
> } // StrategyRule
>
> 25: Abstract methods do not specify a body
>
> at org.eclipse.emf.texo.generator.ImportResolver.setSource(ImportResolver.java:494)
> at org.eclipse.emf.texo.generator.SourceMerger.organizeImports(SourceMerger.java:147)
> at org.eclipse.emf.texo.generator.SourceMerger.mergeImportAndFormat(SourceMerger.java:119)
> ... 17 more
>
>
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.04633 seconds