Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370705

Summary: New ModelGenerator
Product: [Modeling] EMFStore Reporter: Missing name <stephan>
Component: CommonAssignee: Project Inbox <emfstore.common-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dlitvinov, emueller, eneufeld, philip.achenbach
Version: unspecified   
Target Milestone: backlog   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
The Modelmutator package with test and testModel
none
Fix for model element deletion
none
Implementation of additional functions and the fix for model element deletion
none
Fix for ConcurrentModificationException
none
The last version none

Description Missing name CLA 2012-02-06 06:51:55 EST
The ModelGenerator does not generate models the correct way. Especially the ModelChanger does not work as expected.

See attached a new ModelMutator that has been tested to do it correctly.
Comment 1 Missing name CLA 2012-02-06 06:52:29 EST
Created attachment 210570 [details]
The Modelmutator package with test and testModel
Comment 2 Dmitry Litvinov CLA 2012-04-04 03:55:47 EDT
Created attachment 213547 [details]
Fix for model element deletion

The new ModelGenerator doesn't delete model elements from the model. To delete model elements it uses DeleteCommand from package org.eclipse.emf.edit, which for some reason does not perform the task. The testing was done with org.eclipse.emf.edit_2.7.0.v20110606-0949.jar (version from the current target platform)

To reproduce the problem:
1. Set a breakpoint in function AbstractModelMutator.deleteEObjects on invokation of ModelMuatorUtil.removeFullPerCommand (line 264) and launch ModelMutator.changeModel in the debug mode
2. Look at the number of process elements in the project (argument  parentEObject of function deleteEObjects) before and after performing removeFullPerCommand

Attached patch resolves the problem by using EcoreUtil.delete instead of DeleteCommand
Comment 3 Dmitry Litvinov CLA 2012-04-11 04:00:57 EDT
Created attachment 213835 [details]
Implementation of additional functions and the fix for model element deletion

Warning: Previous patch file contains wrong raw numbers and cannot be automatically applied, so the current patch contains also the previous one.

The current patch contains many improvements:
1) implementation of additional functions for performing specific model changes will limited maximal number of changes:
	void changeAttributes(int maxNumber)
	void createEObjects(int maxNumber)
	void deleteEObjects(int maxNumber)
	void changeContainmentReferences(int maxNumber)
	void changeCrossReferences(int maxNumber)
Function changeContainmentReferences was implemented from scratch, because this type of transformation (moving children from one parent object to another), wasn't done before.
2) API of the ModelMutator is changed:
 - classes ModelGenerator and ModelChanger removed
 - ModelMutator was made the only subclass of AbstractModelMutator. It makes only basic functions of the superclass available for use by external packages
3) some performance optimizations made, for example:
 - LinkedList changed to ArrayList because ArrayList consumes 2-3 time less memory and works almost always (in our case always) faster
 - if only one random array element is required, there is no need to shuffle the array and to take the first element, instead a random element index has to be generated

The following refactoring can be performed later:
 - function setContaintments (part of AbstractModelMutator.mutate) could be modified to use the newly implemented functions instead of the old code (for code reuse). Function changeContainmentReferences also can be added there
 - ModelMutator could be merged with AbstractModelMutator
Comment 4 Dmitry Litvinov CLA 2012-04-11 04:57:34 EDT
Created attachment 213836 [details]
Fix for ConcurrentModificationException

When commit is performed after function createEObjects, the folowing ConcurrentModificationException occurs. This patch fixes the problem

org.eclipse.emf.common.util.WrappedException: An exception was ignored during command execution
...

Caused by: java.util.ConcurrentModificationException
	at org.eclipse.emf.common.util.AbstractEList$EIterator.checkModCount(AbstractEList.java:762)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.doNext(AbstractEList.java:710)
	at org.eclipse.emf.common.util.AbstractEList$EIterator.next(AbstractEList.java:696)
	at org.eclipse.emf.emfstore.client.model.impl.ProjectSpaceBase.cleanCutElements(ProjectSpaceBase.java:275)
	at org.eclipse.emf.emfstore.client.model.controller.CommitController.commit(CommitController.java:49)
	at org.eclipse.emf.emfstore.client.model.controller.CommitController.run(CommitController.java:36)
	at org.eclipse.emf.emfstore.client.model.controller.CommitController.run(CommitController.java:1)
	at org.eclipse.emf.emfstore.client.model.connectionmanager.ServerCall.run(ServerCall.java:163)
	at org.eclipse.emf.emfstore.client.model.connectionmanager.SessionManager.executeCall(SessionManager.java:85)
	at org.eclipse.emf.emfstore.client.model.connectionmanager.SessionManager.execute(SessionManager.java:40)
	at org.eclipse.emf.emfstore.client.model.connectionmanager.ServerCall.execute(ServerCall.java:169)
	at org.eclipse.emf.emfstore.client.model.impl.ProjectSpaceBase.commit(ProjectSpaceBase.java:290)
...
Comment 5 Dmitry Litvinov CLA 2012-04-20 05:05:55 EDT
Created attachment 214295 [details]
The last version

Namespace of the packages is changed to org.eclipse.emf.emfstore.modelmutator...
The archive contains the last version with all patches applied
Comment 6 Philip Achenbach CLA 2012-05-15 14:46:11 EDT
The following comment is due to the Eclipse IP process.

I hereby confirm:
1.  I authored 100% of the content I'm contributing
2.  I have the rights to contribute the content to Eclipse
3.  I contribute the content under the EPL

Have fun,
Philip
Comment 7 Missing name CLA 2012-05-15 15:45:06 EDT
The following comment is due to the Eclipse IP process.

I hereby confirm:
1.  I authored 100% of the content I'm contributing
2.  I have the rights to contribute the content to Eclipse
3.  I contribute the content under the EPL
Comment 8 Dmitry Litvinov CLA 2012-05-16 04:54:28 EDT
I hereby confirm:
1. I authored 100% of the content I'm contributing
2. I have the rights to contribute the content to Eclipse
3. I contribute the content under the EPL

Dmitry Litvinov
Comment 9 Edgar Mueller CLA 2012-07-06 05:31:28 EDT
ModelMutator has been approved by the foundation and is now located in the emfstore.core git repo.