| Summary: | New ModelGenerator | ||
|---|---|---|---|
| Product: | [Modeling] EMFStore | Reporter: | Missing name <stephan> |
| Component: | Common | Assignee: | 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
Missing name
Created attachment 210570 [details]
The Modelmutator package with test and testModel
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
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
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)
...
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
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 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 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 ModelMutator has been approved by the foundation and is now located in the emfstore.core git repo. |