|
|
|
|
|
|
|
|
|
Re: Adding references to BPMN2 models from xText DSL [message #1853593 is a reply to message #1852313] |
Sun, 10 July 2022 10:44 |
Toñi Reina 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:
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 #1853599 is a reply to message #1853597] |
Sun, 10 July 2022 19:24 |
|
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 #1853690 is a reply to message #1853630] |
Wed, 13 July 2022 16:18 |
Toñi Reina 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;
}
Thanks in advance.
|
|
|
|
|
|
|
Re: Adding references to BPMN2 models from xText DSL [message #1853721 is a reply to message #1853719] |
Thu, 14 July 2022 19:37 |
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.07791 seconds