martin-fleck / momot

Marrying Search-based Optimization and Model Transformation Technology
http://martin-fleck.github.io/momot/
17 stars 6 forks source link

Henshin rules not applying #14

Closed LiBobb closed 7 years ago

LiBobb commented 7 years ago

Hello, I just followed the video of Class Diagram Reconstruction with exactly all the instructions step by step, and everything seems to work on well except for the search procedure. No rules seems to be applied and the search terminated quickly, returning the source model as result. However, I can run the example ICMT project correctly. And when I open the .henshin_diagram file, I found there are many errors and "null" patterns as below. issue Has anyone met the same problem? I'm using the Eclipse Oxygen(4.7.0), is it related to the version difference? And which version should it be? I found nowhere else to ask for help about the momot problem, so I'm issuing this problem. I'd be really appreciated if anyone can give me any suggestions. Thanks.

martin-fleck-at commented 7 years ago

Hi,

Just from your screenshot it seems that Henshin does not know about the metamodel (*.ecore file). What error messages are you seeing in Henshin (I think you can hover over the error symbols)? If you open the Henshin Diagram editor can you see the 'architecture' palette on the right [1]?

If you do not start a new Eclipse instance which has the defined metamodel registered via an extension point (automatically generated via the genmodel), but instead want to use the Henshin editor in your running development Eclipse instance directly, you need to dynamically register the metamodel into the regisry. To dynamically register an Ecore file you can install, for instance, the 'EPackage registrationFeature' from Kermeta [2], then right click on the Ecore file and select 'EPackages registration' > 'Register EPackages into repository'. After re-opening the diagram file, the errors should be gone. Nevertheless, this is just so that you can open the diagram file without issues, but may not solve the problem of rules not being correctly applied.

Another problem may be relative paths in the Henshin file. At least I know that there was an issue some time ago. So please make sure that the Henshin file uses the URI under which you register the metamodel for references, e.g., the Henshin file should contain references like 'http://momot.big.tuwien.ac.at/examples/icmt/architecture/1.0#//Class' and not '../architecture.ecore#...', cf. [3].

Please see if any of these changes fixes your problem.

Best wishes, Martin

[1] https://youtu.be/BQDz6OmxABE?t=163 [2] http://www.kermeta.org/k2/update [3] https://github.com/martin-fleck/momot/blob/98bbd2ceea3686b9060cb4d8866bfb622e5cc4e0/examples/at.ac.tuwien.big.momot.examples.cra/transformations/architecture.henshin

LiBobb commented 7 years ago

Martin: Thank you very much for your support. Once I open the .henshin_diagram file, I got the following error message:

error

And the hovering-tips are:

msg

Also, in the right panel, no "architecture" column but one "null" column with no content. I've checked all the .henshin file and the .ecore file, both seem to be identical with the one in the github repo, including the prefix. In fact, what confuses me most is not the error message from importing example project (since it can somehow runs correctly), but the fact that the project I manually build with no error message cannot behave normally. Based on the two facts, I guess if the version diffenrence (of eclipse/henshin/ecore) is to blame. Could you please offer me your eclipse, ecore, henshin version (and I guess it is the same with the one in the video)? Thanks

LiBobb commented 7 years ago

Dear Martin: After reviewing my newly created project's .henshin file, I found the hrefs were all like '../architecture.ecore#...'. Then I replaced them with 'http://momot.big.tuwien.ac.at/examples/icmt/architecture/1.0#//Class' using text editor's "Find and Replace" function, and the project worked well. But the henshin diagram becomes like the first screenshot I issued, with many "null" patterns. Why is it like this? And is there any methods I can make the href correct without using "Find and Replace" ? Thank you very much, since the problem is nearly fixed.

martin-fleck-at commented 7 years ago

Hi,

Sorry for not being able tor reply earlier.

As far as I remember, the Henshin editor replaces the namespace URI path (http://momot....) with a relative file URI (../architecture.ecore) if you perform any changes in the model and hit save. Unfortunately, this means that you have to replace the hrefs manually once you save the model through the editor. Maybe this is not the case anymore, but I am not sure. For now I would stick with the 'Find and Replace' approach if the rules are not changing too much.

The Henshin Diagram editor showing 'null' is probably related to the problem I mentioned in my first post. The editor is displaying 'null' because it cannot properly resolve the hrefs you have changed, because there is no EPackage under the given namespace URI. The namespace URI you are specifying (http://...) is the one under which the EPackage of your model needs to be registered in EMF's global package registry (EPackage.Registry.INSTANCE). When a model instance is loaded from its serialized form, this registry may be consulted in order to obtain the correct metamodel that is to be instantiated. The registration of the EPackage under the respective namespace URI is automatically generated for you in the plugin.xml through the GenModel file. You can see this in the extension point 'org.eclipse.emf.ecore.generated_package'.

So in order for the Henshin (Diagram) editor to find the EPackage under the namespace URI you manually changed, the package must be in the registry. This is done by either (1) starting a new Eclipse instance from your current instance, which will parse the extension point and add the entry into the registry or (2) dynamically registering the EPackage into the currently running Eclipse. That is the option I would prefer in your case.

To dynamically register an Ecore file you can install, for instance, the 'EPackage registrationFeature' from Kermeta [1]. Just go to Help > Install New Software... and enter the Kermeta Update URL 'http://www.kermeta.org/k2/update/' into the 'Work with:' field. From the items shown below, select 'EPackage registrationFeature' and continue the installation. After the installation you need to restart your Eclipse. After the restart you should have the option to right click on an ecore file and select 'EPackages registration' > 'Register EPackages into repository'. This adds the EPackage to the registry and should allow the Henshin Diagram editor to find it without issues. You may need to close and reopen the diagram file for the editor to reload the resource.

Please let me know if this solves the 'null' issue for you.

LiBobb commented 7 years ago

Dear Martin: It's sooo kind of you to offer me help all the way. After register the URI, everything works perfectly! So to summarize, the problem comes from henshin URI path, which should not be an ecore file, and should be a URI supposed to be registered in some way. Thank you again! And hope this could help other people coming up with the same peoblem.

martin-fleck-at commented 7 years ago

No worries, glad I could help you and everything is running now on your end ;) I will close this issue, but people will still be able to access it.