Adding references to BPMN2 models from xText DSL [message #1852313] |
Tue, 10 May 2022 07:53  |
Eclipse User |
|
|
|
Hi all,
I'm trying to reproduce the strategy mentioned in https at blogs.itemis.com/en/how-to-reference-uml-elements-from-xtext-dsls?success=true and https at dietrich-it.de/xtext/2011/07/17/xtext-2.0-and-uml/
to add references to bpmn2 elements instead of uml2 elements, but I'm having problems with the addons to GenerateDomainmodel.mwe2.
This is what I have added
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
uriMap = {
from = "platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.genmodel"
to = "platform:/resource/org.eclipse.emf.codegen.ecore/model/GenModel.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel"
to = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.bpmn2/model/BPMN20.genmodel"
to = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.ecore"
to = "platform:/resource/org.eclipse.emf.codegen.ecore/model/GenModel.ecore"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
to = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore"
}
uriMap = {
from = "platform:/plugin/org.eclipse.bmpn2/model/BPMN20.ecore"
to = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.ecore"
}
registerGeneratedEPackage = "org.eclipse.emf.ecore.EcorePackage"
registerGeneratedEPackage = "org.eclipse.bpmn2.Bpmn2Package"
registerGeneratedEPackage = "org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage"
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
registerGenModelFile = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
}
However, when I run the workflow it seems that the genmodel is not handled properly. This is the error I have
Caused by: org.xml.sax.SAXParseExceptionpublicId: platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel; systemId: platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel; lineNumber: 3; columnNumber: 1; Element type "genmodel:GenModel" must be followed by either attribute specifications, ">" or "/>".
at java.xml/com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:204)
What can I be doing wrong?
Thanks in advance
|
|
|
|
|
|
|
|
|
|
|
Re: Adding references to BPMN2 models from xText DSL [message #1853593 is a reply to message #1852313] |
Sun, 10 July 2022 06:44   |
Eclipse User |
|
|
|
Hi again,
I'm still trying to add references to BPMN2 models from an xText DSL. I have followed all the steps specified in this post https://blogs.itemis.com/en/how-to-reference-uml-elements-from-xtext-dsls. However, when I press Ctrl + Space in the place I want to use a bpmn2 element, nothing happens.
I'm redoing the process from the beginning to check if I missed something, and I have found out in the original post two plugins are added to re Require-Bundle section in the MANIFEST.MF file:
- org.eclipse.uml2.uml
- org.eclipse.uml2.codegen.ecore
However, in my case, I have added only one:
I've been looking for a plugin similar to org.eclipse.uml2.codegen.ecore in the bmpn2 context, but I haven't found any. Do I need a similar plugin to run my example (I have included what I have added to the workflow file in a previous post).
Another question is related to debugging, I've used the debugger and the typical strategy of writing printlns in some places, but I cannot found where the problem is. Could I use something to find out why is not working my example as expected?
Thanks a lot.
Toñi Reina wrote on Tue, 10 May 2022 11:53Hi all,
I'm trying to reproduce the strategy mentioned in https at blogs.itemis.com/en/how-to-reference-uml-elements-from-xtext-dsls?success=true and https at dietrich-it.de/xtext/2011/07/17/xtext-2.0-and-uml/
to add references to bpmn2 elements instead of uml2 elements, but I'm having problems with the addons to GenerateDomainmodel.mwe2.
This is what I have added
bean = StandaloneSetup {
scanClassPath = true
platformUri = "${runtimeProject}/.."
uriMap = {
from = "platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.genmodel"
to = "platform:/resource/org.eclipse.emf.codegen.ecore/model/GenModel.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.genmodel"
to = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.bpmn2/model/BPMN20.genmodel"
to = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.codegen.ecore/model/GenModel.ecore"
to = "platform:/resource/org.eclipse.emf.codegen.ecore/model/GenModel.ecore"
}
uriMap = {
from = "platform:/plugin/org.eclipse.emf.ecore/model/Ecore.ecore"
to = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore"
}
uriMap = {
from = "platform:/plugin/org.eclipse.bmpn2/model/BPMN20.ecore"
to = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.ecore"
}
registerGeneratedEPackage = "org.eclipse.emf.ecore.EcorePackage"
registerGeneratedEPackage = "org.eclipse.bpmn2.Bpmn2Package"
registerGeneratedEPackage = "org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage"
registerGenModelFile = "platform:/resource/org.eclipse.emf.ecore/model/Ecore.genmodel"
registerGenModelFile = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Adding references to BPMN2 models from xText DSL [message #1853690 is a reply to message #1853630] |
Wed, 13 July 2022 12:18   |
Eclipse User |
|
|
|
Hi Christian,
I'm trying to understand how scoping is working, and I'm doing some tests. I arrive at the conclusion that I can use the predefined FilteringScope, and create a Predicate to filter only the tasks that belong to the surrounding process. Thay is, when I press Ctrl + Enter only the tasks that belong to Process_1 should appear:
policy Policy1
declarations:
proces P1 mapsTo Process_1{
task T1 mapsTo Task_4
}
To do so, I pretend to obtain a referece to Process_1 (in the following code this reference is stored in the processRef variable), and chek if the Task referenced by the IEObjectDescription has as containter Process_1. However, when I debug the code, I realize that processRef and t refer to objects whose most of the properties are null. I have included a screenshot where you can see all these null properties.
My question is if the EObjects that refer to the bpmn2 metamodel are not fully loaded for memory reasons. And if they are not fully loaded, how can I loaded to access, for example, to the taskRef container
public class BPSecDslScopeProvider extends AbstractBPSecDslScopeProvider {
public IScope getScope(EObject context, EReference reference) {
IScope res =null;
if (context instanceof Task
&& reference == BPSecDslPackage.Literals.TASK__REF_TASK) {
//processRef contains the reference to the process that is stored in the bpmn2 file
org.eclipse.bpmn2.Process processRef = ((Process)context.eContainer()).getRefProcess();
//Obtain the current IScope
res = super.getScope(context, reference);
//This for is for validation purposes, I'm trying to understand the behaviour of IEObjectDescription
for (IEObjectDescription iod: res.getAllElements()) {
org.eclipse.bpmn2.Task t = (org.eclipse.bpmn2.Task) iod.getEObjectOrProxy();
System.out.println("Get container " + t.eContainer());
}
Predicate<IEObjectDescription> pred = ??;
res =new FilteringScope(res, pred);
}else {
res = super.getScope(context, reference);
}
return res;
}

Thanks in advance.
|
|
|
|
|
|
|
|
|
|
Re: Adding references to BPMN2 models from xText DSL [message #1854153 is a reply to message #1853751] |
Wed, 03 August 2022 12:40  |
Eclipse User |
|
|
|
Hi,
promised is debt. I have created a github repository here: https://github.com/reinaqu/bpmnFromXtextDSL. The repository contains the full project and I have documented the process in the README file, just in case is useful for someone else.
Finally, I have found out that some of the problems reported in this thread may be related to a bug similar to the one introduced in this post. The problem seems to be related to loading properly the bpmn2 resources. By closing the file that contains the DSL instance (the one with bpsec extension) and opening it again the problem seems to disappear.
|
|
|