Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Adding references to BPMN2 models from xText DSL (Adding references to BPMN2 models from xText DSL)
Adding references to BPMN2 models from xText DSL [message #1852313] Tue, 10 May 2022 11:53 Go to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
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 #1852315 is a reply to message #1852313] Tue, 10 May 2022 12:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
how does the xml look like?
also you ususally just use

language = StandardLanguage {
referencedResource = "platform:/resource/xxxx/model/yyyy.genmodel"

in xtext workflow


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Tue, 10 May 2022 12:48]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1852340 is a reply to message #1852315] Wed, 11 May 2022 10:11 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Hi Christian,

the genmodel file is the one included in the bmpn2 eclipse plugin.

I have installed the bpmn2 Eclipse modeler (https://www.eclipse.org/bpmn2-modeler/). As a consequence, the bmpn2 metamodel has been added to my Eclipse installation. I have attached the genmodel file included in org.eclipse.bpmn2_1.5.1.Final-v20200903-1545.jar (the jar file installed in my Eclipse).

Regarding
<code>
language = StandardLanguage {
referencedResource = "platform:/resource/xxxx/model/yyyy.genmodel"
</code>

do you mean that I should include a StandardLanguage clause?

I was just trying to follow the examples shown in https://dietrich-it.de/xtext/2011/07/17/xtext-2.0-and-uml/ and https://blogs.itemis.com/en/how-to-reference-uml-elements-from-xtext-dsls
Re: Adding references to BPMN2 models from xText DSL [message #1852345 is a reply to message #1852340] Wed, 11 May 2022 11:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
where do you add the workflow snippet above?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1852357 is a reply to message #1852345] Wed, 11 May 2022 15:28 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
To the mwe2 workflow file that runs when generating the xText stuff. I have attached the mwe2 file
Re: Adding references to BPMN2 models from xText DSL [message #1852358 is a reply to message #1852357] Wed, 11 May 2022 15:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
if you have standardlang the register stuff should go to the standardlangaue section as referencedResource

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1852397 is a reply to message #1852358] Fri, 13 May 2022 17:56 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
I have tested two different things, however, the error remains the same
1)Add a referenceResource to the StandardLanguage section of my DSL
		language = StandardLanguage {
			name = "security.bpmn.ucon.xtext.Bpucondsl"
			fileExtensions = "bpucon"
			...

			referencedResource = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
		}


and
2) Add a second StandardLanguage section with the bpmn2 configuration
		language = StandardLanguage {
			name = "org.eclipse.bmpn2.BPMN20"
			fileExtensions = "bpmn"
			referencedResource = "platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
		}


Re: Adding references to BPMN2 models from xText DSL [message #1852402 is a reply to message #1852397] Fri, 13 May 2022 19:39 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
i get the same error when opening the genmodel with genmodel editor.
so the genmodel file seems to be broken.
you should contact the bpmn team
index.php/fa/42063/0/


this is the bad commit
https://git.eclipse.org/c/bpmn2/org.eclipse.bpmn2.git/commit/org.eclipse.bpmn2/model/BPMN20.genmodel?id=7f93282cd3cc31a795a7d9dec149fe1fe99503f8

patch would look like
https://git.eclipse.org/r/c/bpmn2/org.eclipse.bpmn2/+/193347

i assume you can import plugin as source and patch locally to continue


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Fri, 13 May 2022 20:20]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1852418 is a reply to message #1852402] Sun, 15 May 2022 19:20 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Thanks a lot, Christian, that was exactly the problem.
I downloaded the genmodel you have fixed, and incorporated into the jar org.eclipse.bpmn2_1.5.1.Final-v20200903-1545, and it works.

I was going crazy :-)
Re: Adding references to BPMN2 models from xText DSL [message #1853593 is a reply to message #1852313] Sun, 10 July 2022 10:44 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
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:


  • org.eclipse.bpmn2


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:53
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"
}


Re: Adding references to BPMN2 models from xText DSL [message #1853595 is a reply to message #1853593] Sun, 10 July 2022 15:16 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
I am not sure if I can follow you
If you want to reference you need an iresourceserviceprovider
https://blogs.itemis.com/en/how-to-reference-uml-elements-from-xtext-dsls?hs_amp=true

Can you provide the code you have implemented for that


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853597 is a reply to message #1853595] Sun, 10 July 2022 17:37 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Sure.
I have simplified my DSL to maintain it as simple as possible. With this simplification I have the same problem than with the original dsl.

I have uploaded two files:


  • security.xtext.bmpn.simple.zip: It contains all the projects related to the DSL.
  • security.xtext.bmpn.simple.sample.zip: It contains the example I have been using for testing the DSL.

Re: Adding references to BPMN2 models from xText DSL [message #1853599 is a reply to message #1853597] Sun, 10 July 2022 19:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
the workflow runs fine if you use the normal referenced resource thing

{code}
var rootPath = ".."

Workflow {
component = XtextGenerator {
configuration = {
project = StandardProjectConfig {
baseName = "security.xtext.bmpn.simple"
rootPath = rootPath
runtimeTest = {
enabled = true
}
eclipsePlugin = {
enabled = true
}
eclipsePluginTest = {
enabled = true
}
createEclipseMetaData = true
}
code = {
encoding = "windows-1252"
lineDelimiter = "\r\n"
fileHeader = "/*\n * generated by Xtext \${version}\n */"
preferXtendStubs = false
}
}
language = StandardLanguage {
name = "security.xtext.bmpn.simple.BPSecDsl"
referencedResource="platform:/resource/org.eclipse.bpmn2/model/BPMN20.genmodel"
fileExtensions = "bpsec"

serializer = {
generateStub = false
}
validator = {
// composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
// Generates checks for @Deprecated grammar annotations, an IssueProvider and a corresponding PropertyPage
generateDeprecationValidation = true
}
generator = {
generateXtendStub = true
}
junitSupport = {
junitVersion = "5"
}
}
}
}
{code}

i cannot find a resource service provider in the code you have shared

just this

<extension
point="org.eclipse.xtext.extension_resourceServiceProvider">
<resourceServiceProvider
class="org.example.domainmodel.ui.UMLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider"
uriExtension="uml">
</resourceServiceProvider>

neither the executableextensionfactory nor the class name nor the file extension make sense.
the code also should go to separate plugin


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853600 is a reply to message #1853599] Sun, 10 July 2022 20:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
No Message Body

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853601 is a reply to message #1853600] Sun, 10 July 2022 20:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
there are also some more problems how names are built in bpmn (free txt with spaces vs id)
and how the resources are loaded
(xtext resource set needs patch)



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853602 is a reply to message #1853599] Sun, 10 July 2022 20:55 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Christian Dietrich wrote on Sun, 10 July 2022 19:24
the workflow runs fine if you use the normal referenced resource thing

Do you mean that I should remove from the workflow file all the lines added to run the example?

Christian Dietrich wrote on Sun, 10 July 2022 19:24

i cannot find a resource service provider in the code you have shared

just this

<extension
point="org.eclipse.xtext.extension_resourceServiceProvider">
<resourceServiceProvider
class="org.example.domainmodel.ui.UMLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.generic.EmfResourceUIServiceProvider"
uriExtension="uml">
</resourceServiceProvider>


That peace of xml code it is placed in the plugin.xml that is in the security.xtext.bmpn.simple.ui project. That is what I understood from the blog post. Should I move it to somewhere else?

Quote:
neither the executableextensionfactory nor the class name nor the file extension make sense.
I do not understand well this comment. Please, could you elaborate it a bit more? That is, do you refer to the BPMN2ExecutableExtensionFactory? The name
BPMN2ExecutableExtensionFactory is what do not make sense? The extension of this file? or do you refer to the BPMN2RuntimeModule class and the methods
getFileExtensions and getLanguageName?

Quote:

the code also should go to separate plugin
Which code should go to separate plugin? The code I have added?

Thanks for your answers
Re: Adding references to BPMN2 models from xText DSL [message #1853603 is a reply to message #1853601] Sun, 10 July 2022 21:23 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
With this zip I understand now what you mean with "the code also should go to separate plugin".

Is it suppose that the code you included in the zip works?

I have tested and I still have the same results. With Ctrl + Space, I have no access to the bpmn2 elements. I have changed the versions of the org.eclipse.bpmn2, org.eclipse.xtext, org.eclipse.xtext.ui, org.eclipse.xtext.ui.shared and org.apache.log4j, because I have older versions of this plugins installed, but I suppose this should not be a problem.

Thanks for all the work, I thought it was as easy as following the post, but it has more difficulties than expected.
Re: Adding references to BPMN2 models from xText DSL [message #1853604 is a reply to message #1853603] Mon, 11 July 2022 04:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
for me it does work for processes
how do you exactly test it.
did you do a clean build
do you have build automatically on?

did you debug the code
are there any error messages in log


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Mon, 11 July 2022 04:10]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1853624 is a reply to message #1853604] Mon, 11 July 2022 17:35 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Thanks, I've tested in a clean workspace, and now it works!!!
It must have been a mixture with my complete project

Thanks a lot for your help, without it, I wouldn't have solve the problem.

I'm going to document the process and put it in a github project, in case it could help somebody else. I will post the github reference as soon as is ready.
Re: Adding references to BPMN2 models from xText DSL [message #1853625 is a reply to message #1853624] Mon, 11 July 2022 18:04 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
I suppose that in order to add activities the only thing I have to do is to add a new public QualifiedName qualifiedName(org.eclipse.bpmn2.Activity ele) to BpmnQualifiedNameProvider, am I right?
Re: Adding references to BPMN2 models from xText DSL [message #1853626 is a reply to message #1853625] Mon, 11 July 2022 18:41 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Toñi Reina wrote on Mon, 11 July 2022 18:04
I suppose that in order to add activities the only thing I have to do is to add a new public QualifiedName qualifiedName(org.eclipse.bpmn2.Activity ele) to BpmnQualifiedNameProvider, am I right?


I have test it and it seems it works.
When pressing Ctrl+Space a list with all tasks in the bpmn model appear.
However, what I need is that only the tasks that belong to the process that acts as a container appear.

My question is to get this done, should I extend the DefaultEObjectHoverProvider, as in https://dietrich-it.de/xtext/2011/07/16/hover-support-in-xtext-2.0-tutorial/?

Thanks again for your support

Re: Adding references to BPMN2 models from xText DSL [message #1853630 is a reply to message #1853626] Mon, 11 July 2022 19:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
You need to implement nameprovider in the resource service providers and scoping in the dsl
For

> However, what I need is that only the tasks that belong to the process that acts as a container appear.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Mon, 11 July 2022 19:23]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1853690 is a reply to message #1853630] Wed, 13 July 2022 16:18 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
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;
	}

index.php/fa/42300/0/

Thanks in advance.
Re: Adding references to BPMN2 models from xText DSL [message #1853691 is a reply to message #1853690] Wed, 13 July 2022 16:51 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
you have to acutally call things on the process to get it resolved,
e.g. call getName() or getId() etc


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853716 is a reply to message #1853691] Thu, 14 July 2022 15:12 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
No Message Body
Re: Adding references to BPMN2 models from xText DSL [message #1853718 is a reply to message #1853716] Thu, 14 July 2022 17:46 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
You mean that writing something like this the whole process will be loaded in memory?
		org.eclipse.bpmn2.Process processRef = ((Process)context.eContainer()).getRefProcess();
		System.out.println("Process  name" + processRef.getName());
		System.out.println("process contents " + processRef.eContents());

When I tested it,the result is the following one:
Process name null
process contents []


This make me suppose that the object that represents a Process in my DSL is loaded, however, the object that represents a BPMN2 Process is not loaded.
I've been looking for similar problems in the forum, and as far as I understood the problem is related to cross references . Should I create a resourceSet and load the objects from the bpmn2 file? or Xtext loaded them somehow?
Re: Adding references to BPMN2 models from xText DSL [message #1853719 is a reply to message #1853718] Thu, 14 July 2022 19:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
The process cannot be resolved. I thought you had this runnin. Is the reference to the process not marked as error????
did you triple check the bpmn stuff is properly indexed?
(navigate -> open model element dialog)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Thu, 14 July 2022 19:12]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1853721 is a reply to message #1853719] Thu, 14 July 2022 19:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
btw this scope provider works fine for me with the code i shared before
(during build)

public class BPSecDslScopeProvider extends AbstractBPSecDslScopeProvider {
	
	@Override
	public IScope getScope(EObject context, EReference reference) {
		if (reference == BPSecDslPackage.Literals.TASK__REF_TASK) {
			security.xtext.bmpn.simple.bPSecDsl.Process p = EcoreUtil2.getContainerOfType(context, security.xtext.bmpn.simple.bPSecDsl.Process.class);
			List<Activity> tasks = new ArrayList<>();
			for (EObject o : p.getRefProcess().eContents()) {
				if (o instanceof Activity) {
					tasks.add((Activity) o);
				}
			}
			return Scopes.scopeFor(tasks, (Activity e)-> {
				String id = e.getId();
				return QualifiedName.create(id);
			}, IScope.NULLSCOPE);
		}
		return super.getScope(context, reference);
	}

}


maybe the problem is that the bpmn2 file you shared has errors
maybe there is something wromg how bpmn2 internally resolves proxies, but there you have to ask them see e.g. org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObjectByID(String)


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com

[Updated on: Thu, 14 July 2022 20:29]

Report message to a moderator

Re: Adding references to BPMN2 models from xText DSL [message #1853723 is a reply to message #1853721] Thu, 14 July 2022 20:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14735
Registered: July 2009
Senior Member
it also seems to be required to add

public class BPSecDslRuntimeModule extends AbstractBPSecDslRuntimeModule {

public Class<? extends XtextResourceSet> bindXtextResourceSet() {
return BpmnPatchedSynchronizedXtextResourceSet.class;
}
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Adding references to BPMN2 models from xText DSL [message #1853751 is a reply to message #1853723] Sat, 16 July 2022 17:38 Go to previous messageGo to next message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
Thanks, Christian, now it works!!
Without your help would have been impossible.
Re: Adding references to BPMN2 models from xText DSL [message #1854153 is a reply to message #1853751] Wed, 03 August 2022 16:40 Go to previous message
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 20
Registered: May 2022
Junior Member
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.
Previous Topic:Xtext 2.28.0.M2 is out
Next Topic:can we invoke IFormatter2 through context menu?
Goto Forum:
  


Current Time: Sun Dec 01 20:44:32 GMT 2024

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

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

Back to the top