Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » EMF-IncQuery » Using Incquery as EVM for notifying UML papyrus changes(Using Incquery as EVM for notifying UML papyrus changes)
Using Incquery as EVM for notifying UML papyrus changes [message #1702586] Thu, 23 July 2015 12:16 Go to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Hi everyone,

I'm using IncQuery for incremental evaluation when model changes.
I have a model listened by IncQueryEngine, my model is UML created by papyrus. I want each time the model changed by Papyrus editor, the incquery should evaluate queries incrementally and notify me the results.
How can I do it? I tried to use ExecutionSchema but it only works if I change my model by Java code not by the Papyrus editor. Say like:

val clz = UMLFactory.eINSTANCE.createClass => [name = "ABC"]
umlModel.packagedElements += clz

This code snippets work and IncQuery notifies me the results but not does by IncQuery? Does Incquery re-evaluate models if they are changed in any manner?

Thanks
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702588 is a reply to message #1702586] Thu, 23 July 2015 12:27 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 197
Registered: September 2015
Senior Member
At first, I have a very basic question:
* When you use Papyrus, do you initialize the engine on the same resource set that the Papyrus editor uses, or a different one (e.g. by creating another resource set and loading the editor input file)?

If you don't know how to access the Papyrus editor resource set, tell us how you are initializing your code (e.g. menu action in editor, model explorer local menu, Papyrus service).

Cheers!
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702591 is a reply to message #1702586] Thu, 23 July 2015 12:34 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

Quote:
This code snippets work and IncQuery notifies me the results but not does by IncQuery? Does Incquery re-evaluate models if they are changed in any manner?

I guess, one of the IncQuery occurences in the first version should be Papyrus; in the remainder I would go on that basis. If it is incorrect, feel free to ask for clarification.

The change notification in EMF-IncQuery works by registering an IncQueryEngine instance as change listener to EMF models (more specifically, Resource/ResourceSets), and then sends further notifications when match sets are changed. E.g., you can verify this in the Query Explorer view from the IncQuery SDK: load your queries and the instance model (from a Papyrus editor), and you can check that the display reacts to model changes automatically.

Behind the scenes, for EMF-IncQuery to work with the changes of the edited model, you have to make sure to initialize the IncQueryEngine on the ResourceSet used by Papyrus, instead of simply opening the model again programmatically (that would result in having a separate in-memory representation of the same model; but the two are not connected in any way). For this to work, you have to write some integration code, e.g. check the current selection of the editor, and find the corresponding resource, or (if I recall correctly), the Papyrus editor implements the IEditingDomainProvider interface, that can also be used to access the editors ResourceSet.

Cheers,
Zoltán
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702609 is a reply to message #1702591] Thu, 23 July 2015 13:48 Go to previous messageGo to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Hi,

What I'm doing is as followings:
-create Junit test.
-create queries and rules for processing it
-create UML model with papyrus, save it in a folder of my project
-loading resourceset from the created papyrus uml model and attach it to a incquery engine
-I programmatically create a class and add to uml model (programmatically as well) => notifications are ok
-Directly modify the uml model in papyrus editor, notifications are not caught by IncQuery.

As you suggested, It may be in different temporary resources.
Do you have any example that programmatically listen to changes when I modify models by Papyrus?

Thanks
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702630 is a reply to message #1702609] Thu, 23 July 2015 15:33 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

the fact that you try to combine JUnit tests and Papyrus integration strongly suggests to me that you have two different models loaded (and I am not even sure they are in the same JVM! JUnit test execute in a different JVM than your Eclipse instance).

If you want EMF-IncQuery to listen to changes in an Eclipse editor, you have to
1. Write an Eclipse plug-in, that initializes the IncQuery Engine to the resourceset of Papyrus. This can be triggered by a menu command, or you could use internal Papyrus services.
2. The registered engine will receive notifications, and you can use it any way, you want; but you have to make sure to reuse this engine instance.

We don't have any example for accessing models from an editor, but maybe the model connector implementation we use in Query Explorer might help: http://git.eclipse.org/c/incquery/org.eclipse.incquery.git/tree/plugins/org.eclipse.incquery.tooling.ui/src/org/eclipse/incquery/tooling/ui/queryexplorer/adapters/EMFModelConnector.java#n99 This class is instantiated with a reference to an Eclipse editor; and at a later point, the getNotifier method is called that returns the Resource/ResourceSet of the editor that can be used to initialize the IncQueryEngine with.

Cheers,
Zoltán
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702842 is a reply to message #1702630] Sat, 25 July 2015 17:09 Go to previous messageGo to next message
Van Cam PHAM is currently offline Van Cam PHAMFriend
Messages: 13
Registered: July 2015
Junior Member
Hi,

As the problem is resolved, I have another thing that I want to transform from a UML model to another UML model incrementally. Each time a change on papyrus editor is propagated to the target model.

To detect these changes (Add, remove or update), I use a traceability model that connects the two models. I put the target and traceability in the resourceset of the papyrus source model. I can catch changes but cannot edit in anyway on the target or traceability. It throws an error of "Cannot modify resource set without a write transaction".

After that, I change to get the editting domain of the resource set and put the change actions to target and trace model but it still gets errors.

Do you have any example about this?

Thanks
Re: Using Incquery as EVM for notifying UML papyrus changes [message #1702843 is a reply to message #1702842] Sat, 25 July 2015 17:21 Go to previous message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
Senior Member
Hi,

this behavior is related to the fact that the Papyrus editor uses EMF Transactions in the background, that (among other things) allows undo/redo for the model modifications, however, it requires that all model modification be wrapped into EMF Edit commands.

Basically, you could do one of the following things:

1. You can use RecordingCommands to wrap your custom code into commands.
2. You can write your model modifications using commands.

Finally, we have developed a model transformation API (including model modifications) in the VIATRA project, that allows changing from plain EMF operations to EMF.Edit commands without changing the transformation rules (see https://wiki.eclipse.org/VIATRA/Transformation_API#Model_Manipulation_Primitives for details).

I hope, this explanation is clear.

Cheers,
Zoltán
Previous Topic:Query on Papyrus UML models with applied profiles
Next Topic:Find the feature of changed elements
Goto Forum:
  


Current Time: Sat Mar 30 08:54:38 GMT 2024

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

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

Back to the top