=UTF-8
diff --git a/fr.tpt.mem4csd.loss.modelMutation/META-INF/MANIFEST.MF b/fr.tpt.mem4csd.loss.modelMutation/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..bd3c053
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/META-INF/MANIFEST.MF
@@ -0,0 +1,17 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: fr.tpt.mem4csd.loss.modelMutation;singleton:=true
+Automatic-Module-Name: fr.tpt.mem4csd.loss.modelMutation
+Bundle-Version: 0.1.0.qualifier
+Bundle-ClassPath: .
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Bundle-RequiredExecutionEnvironment: JavaSE-17
+Export-Package: mutator,
+ mutator.impl,
+ mutator.util
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.emf.ecore;visibility:=reexport,
+ de.mdelab.workflow;visibility:=reexport
+Bundle-ActivationPolicy: lazy
diff --git a/fr.tpt.mem4csd.loss.modelMutation/build.properties b/fr.tpt.mem4csd.loss.modelMutation/build.properties
new file mode 100644
index 0000000..4465407
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/build.properties
@@ -0,0 +1,10 @@
+#
+
+bin.includes = .,\
+ model/,\
+ META-INF/,\
+ plugin.xml,\
+ plugin.properties
+jars.compile.order = .
+source.. = src/
+output.. = bin/
diff --git a/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.ecore b/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.ecore
new file mode 100644
index 0000000..b6a5d17
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.ecore
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.genmodel b/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.genmodel
new file mode 100644
index 0000000..eb9048a
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/model/Mutator.genmodel
@@ -0,0 +1,16 @@
+
+
+ Mutator.ecore
+
+
+
+
+
+
diff --git a/fr.tpt.mem4csd.loss.modelMutation/plugin.properties b/fr.tpt.mem4csd.loss.modelMutation/plugin.properties
new file mode 100644
index 0000000..8eb9194
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/plugin.properties
@@ -0,0 +1,4 @@
+#
+
+pluginName = fr.tpt.mem4csd.loss.modelMutation
+providerName = www.example.org
diff --git a/fr.tpt.mem4csd.loss.modelMutation/plugin.xml b/fr.tpt.mem4csd.loss.modelMutation/plugin.xml
new file mode 100644
index 0000000..7ea4929
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/plugin.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorFactory.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorFactory.java
new file mode 100644
index 0000000..edd1fd0
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorFactory.java
@@ -0,0 +1,42 @@
+/**
+ */
+package mutator;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ *
+ * The Factory for the model.
+ * It provides a create method for each non-abstract class of the model.
+ *
+ * @see mutator.MutatorPackage
+ * @generated
+ */
+public interface MutatorFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ *
+ *
+ * @generated
+ */
+ MutatorFactory eINSTANCE = mutator.impl.MutatorFactoryImpl.init();
+
+ /**
+ * Returns a new object of class 'Random Mutate Model'.
+ *
+ *
+ * @return a new object of class 'Random Mutate Model'.
+ * @generated
+ */
+ RandomMutateModel createRandomMutateModel();
+
+ /**
+ * Returns the package supported by this factory.
+ *
+ *
+ * @return the package supported by this factory.
+ * @generated
+ */
+ MutatorPackage getMutatorPackage();
+
+} //MutatorFactory
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorPackage.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorPackage.java
new file mode 100644
index 0000000..a65145a
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/MutatorPackage.java
@@ -0,0 +1,227 @@
+/**
+ */
+package mutator;
+
+import de.mdelab.workflow.components.ComponentsPackage;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+
+/**
+ *
+ * The Package for the model.
+ * It contains accessors for the meta objects to represent
+ *
+ * - each class,
+ * - each feature of each class,
+ * - each operation of each class,
+ * - each enum,
+ * - and each data type
+ *
+ *
+ * @see mutator.MutatorFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface MutatorPackage extends EPackage {
+ /**
+ * The package name.
+ *
+ *
+ * @generated
+ */
+ String eNAME = "mutator";
+
+ /**
+ * The package namespace URI.
+ *
+ *
+ * @generated
+ */
+ String eNS_URI = "http://mem4csd.telecom-paris.fr/loss/mutator";
+
+ /**
+ * The package namespace name.
+ *
+ *
+ * @generated
+ */
+ String eNS_PREFIX = "mutator";
+
+ /**
+ * The singleton instance of the package.
+ *
+ *
+ * @generated
+ */
+ MutatorPackage eINSTANCE = mutator.impl.MutatorPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link mutator.impl.RandomMutateModelImpl Random Mutate Model}' class.
+ *
+ *
+ * @see mutator.impl.RandomMutateModelImpl
+ * @see mutator.impl.MutatorPackageImpl#getRandomMutateModel()
+ * @generated
+ */
+ int RANDOM_MUTATE_MODEL = 0;
+
+ /**
+ * The feature id for the 'Name' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL__NAME = ComponentsPackage.WORKFLOW_COMPONENT__NAME;
+
+ /**
+ * The feature id for the 'Description' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL__DESCRIPTION = ComponentsPackage.WORKFLOW_COMPONENT__DESCRIPTION;
+
+ /**
+ * The feature id for the 'Enabled' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL__ENABLED = ComponentsPackage.WORKFLOW_COMPONENT__ENABLED;
+
+ /**
+ * The feature id for the 'Model Slot' attribute.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL__MODEL_SLOT = ComponentsPackage.WORKFLOW_COMPONENT_FEATURE_COUNT + 0;
+
+ /**
+ * The number of structural features of the 'Random Mutate Model' class.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL_FEATURE_COUNT = ComponentsPackage.WORKFLOW_COMPONENT_FEATURE_COUNT + 1;
+
+ /**
+ * The operation id for the 'Check Configuration' operation.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL___CHECK_CONFIGURATION__WORKFLOWEXECUTIONCONTEXT = ComponentsPackage.WORKFLOW_COMPONENT___CHECK_CONFIGURATION__WORKFLOWEXECUTIONCONTEXT;
+
+ /**
+ * The operation id for the 'Execute' operation.
+ *
+ *
+ * @deprecated See {@link de.mdelab.workflow.components.WorkflowComponent#execute(de.mdelab.workflow.WorkflowExecutionContext) model documentation} for details.
+ * @generated
+ * @ordered
+ */
+ @Deprecated
+ int RANDOM_MUTATE_MODEL___EXECUTE__WORKFLOWEXECUTIONCONTEXT = ComponentsPackage.WORKFLOW_COMPONENT___EXECUTE__WORKFLOWEXECUTIONCONTEXT;
+
+ /**
+ * The operation id for the 'Execute' operation.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL___EXECUTE__WORKFLOWEXECUTIONCONTEXT_IPROGRESSMONITOR = ComponentsPackage.WORKFLOW_COMPONENT___EXECUTE__WORKFLOWEXECUTIONCONTEXT_IPROGRESSMONITOR;
+
+ /**
+ * The operation id for the 'Check Canceled' operation.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL___CHECK_CANCELED__IPROGRESSMONITOR = ComponentsPackage.WORKFLOW_COMPONENT___CHECK_CANCELED__IPROGRESSMONITOR;
+
+ /**
+ * The number of operations of the 'Random Mutate Model' class.
+ *
+ *
+ * @generated
+ * @ordered
+ */
+ int RANDOM_MUTATE_MODEL_OPERATION_COUNT = ComponentsPackage.WORKFLOW_COMPONENT_OPERATION_COUNT + 0;
+
+
+ /**
+ * Returns the meta object for class '{@link mutator.RandomMutateModel Random Mutate Model}'.
+ *
+ *
+ * @return the meta object for class 'Random Mutate Model'.
+ * @see mutator.RandomMutateModel
+ * @generated
+ */
+ EClass getRandomMutateModel();
+
+ /**
+ * Returns the meta object for the attribute '{@link mutator.RandomMutateModel#getModelSlot Model Slot}'.
+ *
+ *
+ * @return the meta object for the attribute 'Model Slot'.
+ * @see mutator.RandomMutateModel#getModelSlot()
+ * @see #getRandomMutateModel()
+ * @generated
+ */
+ EAttribute getRandomMutateModel_ModelSlot();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ *
+ *
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ MutatorFactory getMutatorFactory();
+
+ /**
+ *
+ * Defines literals for the meta objects that represent
+ *
+ * - each class,
+ * - each feature of each class,
+ * - each operation of each class,
+ * - each enum,
+ * - and each data type
+ *
+ *
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link mutator.impl.RandomMutateModelImpl Random Mutate Model}' class.
+ *
+ *
+ * @see mutator.impl.RandomMutateModelImpl
+ * @see mutator.impl.MutatorPackageImpl#getRandomMutateModel()
+ * @generated
+ */
+ EClass RANDOM_MUTATE_MODEL = eINSTANCE.getRandomMutateModel();
+
+ /**
+ * The meta object literal for the 'Model Slot' attribute feature.
+ *
+ *
+ * @generated
+ */
+ EAttribute RANDOM_MUTATE_MODEL__MODEL_SLOT = eINSTANCE.getRandomMutateModel_ModelSlot();
+
+ }
+
+} //MutatorPackage
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/RandomMutateModel.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/RandomMutateModel.java
new file mode 100644
index 0000000..bd8c556
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/RandomMutateModel.java
@@ -0,0 +1,46 @@
+/**
+ */
+package mutator;
+
+import de.mdelab.workflow.components.WorkflowComponent;
+
+/**
+ *
+ * A representation of the model object 'Random Mutate Model'.
+ *
+ *
+ *
+ * The following features are supported:
+ *
+ *
+ * - {@link mutator.RandomMutateModel#getModelSlot Model Slot}
+ *
+ *
+ * @see mutator.MutatorPackage#getRandomMutateModel()
+ * @model
+ * @generated
+ */
+public interface RandomMutateModel extends WorkflowComponent {
+ /**
+ * Returns the value of the 'Model Slot' attribute.
+ *
+ *
+ * @return the value of the 'Model Slot' attribute.
+ * @see #setModelSlot(String)
+ * @see mutator.MutatorPackage#getRandomMutateModel_ModelSlot()
+ * @model required="true"
+ * @generated
+ */
+ String getModelSlot();
+
+ /**
+ * Sets the value of the '{@link mutator.RandomMutateModel#getModelSlot Model Slot}' attribute.
+ *
+ *
+ * @param value the new value of the 'Model Slot' attribute.
+ * @see #getModelSlot()
+ * @generated
+ */
+ void setModelSlot(String value);
+
+} // RandomMutateModel
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorFactoryImpl.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorFactoryImpl.java
new file mode 100644
index 0000000..d31ec3d
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorFactoryImpl.java
@@ -0,0 +1,97 @@
+/**
+ */
+package mutator.impl;
+
+import mutator.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ *
+ * An implementation of the model Factory.
+ *
+ * @generated
+ */
+public class MutatorFactoryImpl extends EFactoryImpl implements MutatorFactory {
+ /**
+ * Creates the default factory implementation.
+ *
+ *
+ * @generated
+ */
+ public static MutatorFactory init() {
+ try {
+ MutatorFactory theMutatorFactory = (MutatorFactory)EPackage.Registry.INSTANCE.getEFactory(MutatorPackage.eNS_URI);
+ if (theMutatorFactory != null) {
+ return theMutatorFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new MutatorFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ *
+ *
+ * @generated
+ */
+ public MutatorFactoryImpl() {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL: return createRandomMutateModel();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public RandomMutateModel createRandomMutateModel() {
+ RandomMutateModelImpl randomMutateModel = new RandomMutateModelImpl();
+ return randomMutateModel;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public MutatorPackage getMutatorPackage() {
+ return (MutatorPackage)getEPackage();
+ }
+
+ /**
+ *
+ *
+ * @deprecated
+ * @generated
+ */
+ @Deprecated
+ public static MutatorPackage getPackage() {
+ return MutatorPackage.eINSTANCE;
+ }
+
+} //MutatorFactoryImpl
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorPackageImpl.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorPackageImpl.java
new file mode 100644
index 0000000..9a7e26c
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/MutatorPackageImpl.java
@@ -0,0 +1,194 @@
+/**
+ */
+package mutator.impl;
+
+import de.mdelab.workflow.WorkflowPackage;
+
+import de.mdelab.workflow.components.ComponentsPackage;
+
+import de.mdelab.workflow.helpers.HelpersPackage;
+
+import mutator.MutatorFactory;
+import mutator.MutatorPackage;
+import mutator.RandomMutateModel;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ *
+ * An implementation of the model Package.
+ *
+ * @generated
+ */
+public class MutatorPackageImpl extends EPackageImpl implements MutatorPackage {
+ /**
+ *
+ *
+ * @generated
+ */
+ private EClass randomMutateModelEClass = null;
+
+ /**
+ * Creates an instance of the model Package, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ *
+ *
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see mutator.MutatorPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private MutatorPackageImpl() {
+ super(eNS_URI, MutatorFactory.eINSTANCE);
+ }
+ /**
+ *
+ *
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the Package for this model, and for any others upon which it depends.
+ *
+ *
This method is used to initialize {@link MutatorPackage#eINSTANCE} when that field is accessed.
+ * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
+ *
+ *
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static MutatorPackage init() {
+ if (isInited) return (MutatorPackage)EPackage.Registry.INSTANCE.getEPackage(MutatorPackage.eNS_URI);
+
+ // Obtain or create and register package
+ Object registeredMutatorPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
+ MutatorPackageImpl theMutatorPackage = registeredMutatorPackage instanceof MutatorPackageImpl ? (MutatorPackageImpl)registeredMutatorPackage : new MutatorPackageImpl();
+
+ isInited = true;
+
+ // Initialize simple dependencies
+ WorkflowPackage.eINSTANCE.eClass();
+ HelpersPackage.eINSTANCE.eClass();
+ ComponentsPackage.eINSTANCE.eClass();
+
+ // Create package meta-data objects
+ theMutatorPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theMutatorPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theMutatorPackage.freeze();
+
+ // Update the registry and return the package
+ EPackage.Registry.INSTANCE.put(MutatorPackage.eNS_URI, theMutatorPackage);
+ return theMutatorPackage;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public EClass getRandomMutateModel() {
+ return randomMutateModelEClass;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public EAttribute getRandomMutateModel_ModelSlot() {
+ return (EAttribute)randomMutateModelEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public MutatorFactory getMutatorFactory() {
+ return (MutatorFactory)getEFactoryInstance();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ *
+ *
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ randomMutateModelEClass = createEClass(RANDOM_MUTATE_MODEL);
+ createEAttribute(randomMutateModelEClass, RANDOM_MUTATE_MODEL__MODEL_SLOT);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ *
+ *
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Obtain other dependent packages
+ ComponentsPackage theComponentsPackage = (ComponentsPackage)EPackage.Registry.INSTANCE.getEPackage(ComponentsPackage.eNS_URI);
+
+ // Create type parameters
+
+ // Set bounds for type parameters
+
+ // Add supertypes to classes
+ randomMutateModelEClass.getESuperTypes().add(theComponentsPackage.getWorkflowComponent());
+
+ // Initialize classes, features, and operations; add parameters
+ initEClass(randomMutateModelEClass, RandomMutateModel.class, "RandomMutateModel", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getRandomMutateModel_ModelSlot(), ecorePackage.getEString(), "modelSlot", null, 1, 1, RandomMutateModel.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //MutatorPackageImpl
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/RandomMutateModelImpl.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/RandomMutateModelImpl.java
new file mode 100644
index 0000000..96afaf5
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/impl/RandomMutateModelImpl.java
@@ -0,0 +1,194 @@
+/**
+ */
+package mutator.impl;
+
+import de.mdelab.workflow.WorkflowExecutionContext;
+import de.mdelab.workflow.components.impl.WorkflowComponentImpl;
+import de.mdelab.workflow.impl.WorkflowExecutionException;
+import fr.tpt.mem4csd.loss.modelMutationUtils.SiteOfLossGenerator;
+import mutator.MutatorPackage;
+import mutator.RandomMutateModel;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.EMap;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+
+/**
+ *
+ * An implementation of the model object 'Random Mutate Model'.
+ *
+ *
+ * The following features are implemented:
+ *
+ *
+ * - {@link mutator.impl.RandomMutateModelImpl#getModelSlot Model Slot}
+ *
+ *
+ * @generated
+ */
+public class RandomMutateModelImpl extends WorkflowComponentImpl implements RandomMutateModel {
+ /**
+ * The default value of the '{@link #getModelSlot() Model Slot}' attribute.
+ *
+ *
+ * @see #getModelSlot()
+ * @generated
+ * @ordered
+ */
+ protected static final String MODEL_SLOT_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getModelSlot() Model Slot}' attribute.
+ *
+ *
+ * @see #getModelSlot()
+ * @generated
+ * @ordered
+ */
+ protected String modelSlot = MODEL_SLOT_EDEFAULT;
+
+ /**
+ *
+ *
+ * @generated
+ */
+ protected RandomMutateModelImpl() {
+ super();
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ protected EClass eStaticClass() {
+ return MutatorPackage.Literals.RANDOM_MUTATE_MODEL;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String getModelSlot() {
+ return modelSlot;
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void setModelSlot(String newModelSlot) {
+ String oldModelSlot = modelSlot;
+ modelSlot = newModelSlot;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT, oldModelSlot, modelSlot));
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
+ return getModelSlot();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
+ setModelSlot((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
+ setModelSlot(MODEL_SLOT_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
+ return MODEL_SLOT_EDEFAULT == null ? modelSlot != null : !MODEL_SLOT_EDEFAULT.equals(modelSlot);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ *
+ *
+ * @generated
+ */
+ @Override
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuilder result = new StringBuilder(super.toString());
+ result.append(" (modelSlot: ");
+ result.append(modelSlot);
+ result.append(')');
+ return result.toString();
+ }
+
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public void execute(final WorkflowExecutionContext context, final IProgressMonitor monitor)
+ throws WorkflowExecutionException, IOException {
+ final SubMonitor subMonitor = SubMonitor.convert(monitor, 2);
+
+ context.getLogger().addInfo("Modifying a slot.", this);
+ subMonitor.setTaskName("RandomMutation");
+
+ Resource model = getModelResource(context, modelSlot, "temp", true);
+
+ EList contents = model.getContents();
+
+ SiteOfLossGenerator gen = new SiteOfLossGenerator(3);
+ gen.generateSiteOfLoss(contents);
+
+ subMonitor.done();
+ context.getLogger().addInfo("Done.", this);
+ }
+} //RandomMutateModelImpl
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorAdapterFactory.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorAdapterFactory.java
new file mode 100644
index 0000000..0b3ac8d
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorAdapterFactory.java
@@ -0,0 +1,160 @@
+/**
+ */
+package mutator.util;
+
+import de.mdelab.workflow.NamedComponent;
+
+import de.mdelab.workflow.components.WorkflowComponent;
+
+import mutator.*;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ *
+ * The Adapter Factory for the model.
+ * It provides an adapter createXXX method for each class of the model.
+ *
+ * @see mutator.MutatorPackage
+ * @generated
+ */
+public class MutatorAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * The cached model package.
+ *
+ *
+ * @generated
+ */
+ protected static MutatorPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ *
+ *
+ * @generated
+ */
+ public MutatorAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = MutatorPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ *
+ * This implementation returns true if the object is either the model's package or is an instance object of the model.
+ *
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ @Override
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch that delegates to the createXXX methods.
+ *
+ *
+ * @generated
+ */
+ protected MutatorSwitch modelSwitch =
+ new MutatorSwitch() {
+ @Override
+ public Adapter caseRandomMutateModel(RandomMutateModel object) {
+ return createRandomMutateModelAdapter();
+ }
+ @Override
+ public Adapter caseNamedComponent(NamedComponent object) {
+ return createNamedComponentAdapter();
+ }
+ @Override
+ public Adapter caseWorkflowComponent(WorkflowComponent object) {
+ return createWorkflowComponentAdapter();
+ }
+ @Override
+ public Adapter defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the target.
+ *
+ *
+ * @param target the object to adapt.
+ * @return the adapter for the target.
+ * @generated
+ */
+ @Override
+ public Adapter createAdapter(Notifier target) {
+ return modelSwitch.doSwitch((EObject)target);
+ }
+
+
+ /**
+ * Creates a new adapter for an object of class '{@link mutator.RandomMutateModel Random Mutate Model}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see mutator.RandomMutateModel
+ * @generated
+ */
+ public Adapter createRandomMutateModelAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link de.mdelab.workflow.NamedComponent Named Component}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see de.mdelab.workflow.NamedComponent
+ * @generated
+ */
+ public Adapter createNamedComponentAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link de.mdelab.workflow.components.WorkflowComponent Workflow Component}'.
+ *
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ *
+ * @return the new adapter.
+ * @see de.mdelab.workflow.components.WorkflowComponent
+ * @generated
+ */
+ public Adapter createWorkflowComponentAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ *
+ * This default implementation returns null.
+ *
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //MutatorAdapterFactory
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorSwitch.java b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorSwitch.java
new file mode 100644
index 0000000..df4a558
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src-gen/mutator/util/MutatorSwitch.java
@@ -0,0 +1,146 @@
+/**
+ */
+package mutator.util;
+
+import de.mdelab.workflow.NamedComponent;
+
+import de.mdelab.workflow.components.WorkflowComponent;
+
+import mutator.*;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.util.Switch;
+
+/**
+ *
+ * The Switch for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the caseXXX method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ *
+ * @see mutator.MutatorPackage
+ * @generated
+ */
+public class MutatorSwitch extends Switch {
+ /**
+ * The cached model package
+ *
+ *
+ * @generated
+ */
+ protected static MutatorPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ *
+ *
+ * @generated
+ */
+ public MutatorSwitch() {
+ if (modelPackage == null) {
+ modelPackage = MutatorPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Checks whether this is a switch for the given package.
+ *
+ *
+ * @param ePackage the package in question.
+ * @return whether this is a switch for the given package.
+ * @generated
+ */
+ @Override
+ protected boolean isSwitchFor(EPackage ePackage) {
+ return ePackage == modelPackage;
+ }
+
+ /**
+ * Calls caseXXX for each class of the model until one returns a non null result; it yields that result.
+ *
+ *
+ * @return the first non-null result returned by a caseXXX call.
+ * @generated
+ */
+ @Override
+ protected T doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case MutatorPackage.RANDOM_MUTATE_MODEL: {
+ RandomMutateModel randomMutateModel = (RandomMutateModel)theEObject;
+ T result = caseRandomMutateModel(randomMutateModel);
+ if (result == null) result = caseWorkflowComponent(randomMutateModel);
+ if (result == null) result = caseNamedComponent(randomMutateModel);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Random Mutate Model'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Random Mutate Model'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseRandomMutateModel(RandomMutateModel object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Named Component'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Named Component'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseNamedComponent(NamedComponent object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'Workflow Component'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'Workflow Component'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public T caseWorkflowComponent(WorkflowComponent object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpreting the object as an instance of 'EObject'.
+ *
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ *
+ * @param object the target of the switch.
+ * @return the result of interpreting the object as an instance of 'EObject'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ @Override
+ public T defaultCase(EObject object) {
+ return null;
+ }
+
+} //MutatorSwitch
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/BaseMutations.java b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/BaseMutations.java
new file mode 100644
index 0000000..91ee396
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/BaseMutations.java
@@ -0,0 +1,115 @@
+package fr.tpt.mem4csd.loss.modelMutationUtils;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.management.RuntimeErrorException;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.*;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+public class BaseMutations {
+
+ public BaseMutations() {
+ }
+
+ protected EObject doCreate(Resource res, EClass clazz) {
+ EObject obj = EcoreUtil.create(clazz);
+ res.getContents().add(obj);
+ return obj;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ protected EObject addComplex(EObject container, EReference reference, EClass clazz, String name) {
+ EObject obj = EcoreUtil.create(clazz);
+ obj.eSet(clazz.getEStructuralFeature("name"), name);
+ if (reference.isMany()) {
+ ((EList) container.eGet(reference)).add(obj);
+ if (!reference.isContainment()) {
+ // ECore will add containment if contained.
+ // Otherwise the object needs to be manually added to the resource.
+ container.eResource().getContents().add(obj);
+ }
+ } else {
+ container.eSet(reference, obj);
+ if (!reference.isContainment()) {
+ // ECore will add containment if contained.
+ // Otherwise the object needs to be manually added to the resource.
+ container.eResource().getContents().add(obj);
+ }
+ assert container.eIsSet(reference);
+ }
+ return obj;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ protected EObject addPrimitive(EObject container, EAttribute attribute, EDataType dataType) {
+ EObject data = (EObject)dataType.getDefaultValue();
+ if (attribute.isMany()) {
+ ((EList) container.eGet(attribute)).add(data);
+ } else {
+ container.eSet(attribute, data);
+ }
+ return data;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ protected void doAdd(EObject container, EStructuralFeature reference, Collection extends Object> elements) {
+ ((EList) container.eGet(reference)).addAll(elements);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ protected void doAdd(EObject container, EStructuralFeature reference, Object what, int index) {
+ ((EList) container.eGet(reference)).add(index, what);
+ }
+
+ protected void doSet(EObject container, EStructuralFeature feature, Object value) {
+ if (value == null) {
+ container.eUnset(feature);
+ } else {
+ container.eSet(feature, value);
+ }
+ }
+
+ protected void doRemove(EObject object) {
+ EcoreUtil.remove(object);
+ }
+
+ protected void doRemove(EObject container, EStructuralFeature reference) {
+ List> list = (List>) container.eGet(reference);
+ list.clear();
+ }
+
+ protected void doRemove(EObject container, EStructuralFeature feature, Object element) {
+ ((EList>) container.eGet(feature)).remove(element);
+ }
+
+ protected void doRemove(EObject container, EStructuralFeature feature, int index) {
+ ((EList>) container.eGet(feature)).remove(index);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+
+ protected void doMoveTo(EObject what, EObject newContainer, EReference reference, int index) {
+ if (reference.isMany()) {
+ ((EList) newContainer.eGet(reference)).add(index, what);
+ } else {
+ newContainer.eSet(reference, what);
+ }
+ }
+
+ protected void doMoveTo(EObject what, Resource newContainer, int index) {
+ newContainer.getContents().add(index, what);
+ }
+
+ protected void doChangeIndex(EObject container, EStructuralFeature feature, int oldIndex, int newIndex) {
+ EList> featureValue = (EList>) container.eGet(feature);
+ featureValue.move(newIndex, oldIndex);
+ }
+}
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/LimitedAdditionExtractor.java b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/LimitedAdditionExtractor.java
new file mode 100644
index 0000000..4409628
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/LimitedAdditionExtractor.java
@@ -0,0 +1,96 @@
+package fr.tpt.mem4csd.loss.modelMutationUtils;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Queue;
+import java.util.Set;
+import java.util.LinkedList;
+import java.util.HashSet;
+import java.util.ArrayList;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.common.util.EList;
+
+public class LimitedAdditionExtractor implements MutationExtractor {
+
+ @Override
+ public List extract(Collection rootObjects) {
+ List mutations = new ArrayList<>();
+
+ Queue toVisit = new LinkedList();
+ Set visited = new HashSet<>();
+
+ toVisit.addAll(rootObjects);
+
+ while (!toVisit.isEmpty()) {
+ EObject element = toVisit.poll();
+
+ if (element == null || visited.contains(element)) {
+ continue;
+ }
+
+ visited.add(element);
+ EClass eclass = element.eClass();
+ List features = eclass.getEStructuralFeatures();
+
+ for (EStructuralFeature feature : features) {
+
+ int lowerBound = feature.getLowerBound();
+ int upperBound = feature.getUpperBound();
+
+ boolean isContainmentRef = feature instanceof EReference;
+
+ // Check how many elements exist already.
+ int existingElements = 0;
+ Object objExistingFeatures = element.eGet(feature);
+ if (feature.isMany()) {
+ // EList
+ existingElements = ((EList>)objExistingFeatures).size();
+ if (isContainmentRef) {
+ @SuppressWarnings("unchecked")
+ EList contents = (EList)objExistingFeatures;
+ toVisit.addAll(contents);
+ }
+ } else {
+ // EObject
+ existingElements = ((objExistingFeatures == null) ? 0 : 1);
+ if (isContainmentRef) {
+ toVisit.add((ENamedElement)objExistingFeatures);
+ }
+ }
+
+ // Primitive Validation. Existing Model must be valid.
+ assert (existingElements >= lowerBound);
+
+ if (upperBound < 0) {
+ upperBound = maxCardinality;
+ }
+
+ assert (existingElements <= upperBound);
+
+ int countToCreate = Integer.min(upperBound, maxCardinality) - existingElements;
+
+ for (int i = 0; i < countToCreate; i++) {
+ mutations.add(new Mutation(Mutation.Type.eCreate, element, feature));
+ }
+ }
+ }
+
+ return mutations;
+ }
+
+ public int getMaxCardinality() {
+ return maxCardinality;
+ }
+
+ public LimitedAdditionExtractor(int maxCardinality) {
+ super();
+ this.maxCardinality = maxCardinality;
+ }
+
+ private int maxCardinality;
+}
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/Mutation.java b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/Mutation.java
new file mode 100644
index 0000000..485507d
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/Mutation.java
@@ -0,0 +1,77 @@
+package fr.tpt.mem4csd.loss.modelMutationUtils;
+
+import java.util.Objects;
+
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public class Mutation {
+ public enum Type {
+ eCreate,
+ eUpdate,
+ eDestroy
+ }
+
+ public Mutation(Type mutationType, EObject targetElement, EStructuralFeature targetLink) {
+ super();
+ this.mutationType = mutationType;
+ this.targetElement = targetElement;
+ this.targetLink = targetLink;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mutationType, targetElement, targetLink);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Mutation other = (Mutation) obj;
+ return mutationType == other.mutationType && Objects.equals(targetElement, other.targetElement)
+ && Objects.equals(targetLink, other.targetLink);
+ }
+
+ @Override
+ public String toString() {
+ String name = "";
+ if (targetElement instanceof ENamedElement) {
+ name = ((ENamedElement)targetElement).getName();
+ }
+ else
+ {
+ EClass clzz = targetElement.eClass();
+ if (clzz != null) {
+ EList features = clzz.getEAllStructuralFeatures();
+ for (EStructuralFeature feature : features) {
+ if (feature.getName().equals("name")) {
+ name = (String)targetElement.eGet(feature);
+ }
+ }
+ }
+ }
+ return "Mutation [" + mutationType + " " + targetLink.getName() + " on " + name + "]";
+ }
+
+ private Type mutationType;
+ private EObject targetElement;
+ private EStructuralFeature targetLink;
+
+ public Type getMutationType() {
+ return mutationType;
+ }
+ public EObject getTargetElement() {
+ return targetElement;
+ }
+ public EStructuralFeature getTargetLink() {
+ return targetLink;
+ }
+}
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/MutationExtractor.java b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/MutationExtractor.java
new file mode 100644
index 0000000..756a751
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/MutationExtractor.java
@@ -0,0 +1,10 @@
+package fr.tpt.mem4csd.loss.modelMutationUtils;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EObject;
+
+public interface MutationExtractor {
+ List extract(Collection rootObjects);
+}
diff --git a/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/SiteOfLossGenerator.java b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/SiteOfLossGenerator.java
new file mode 100644
index 0000000..085d526
--- /dev/null
+++ b/fr.tpt.mem4csd.loss.modelMutation/src/fr/tpt/mem4csd/loss/modelMutationUtils/SiteOfLossGenerator.java
@@ -0,0 +1,80 @@
+package fr.tpt.mem4csd.loss.modelMutationUtils;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.ENamedElement;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+public class SiteOfLossGenerator {
+
+ public void generateSiteOfLoss(Collection root) {
+ List mutations = extractor.extract(root);
+ for (Mutation mutation : mutations) {
+ applyMutation(mutation);
+ }
+ }
+
+ private EClass findConcreteClass(EClass clazz) {
+ if (!clazz.isAbstract()) {
+ return clazz;
+ }
+
+ TreeIterator treeIter = clazz.getEPackage().eAllContents();
+ while (treeIter.hasNext()) {
+ EObject element = treeIter.next();
+ if (element instanceof EClass) {
+ EClass currentClass = (EClass) element;
+
+ if (!currentClass.isAbstract() && !currentClass.getName().contains("Abstract") && currentClass.getEAllSuperTypes().contains(clazz)) {
+ return (EClass) element;
+ }
+ }
+ };
+
+ return null;
+ }
+
+ private int idCounter = 0;
+
+ private String generateName(EObject parent, EStructuralFeature feature) {
+ // The EObjects are definitely NamedElements, but can't be casted due to difference in Equinox modules.
+ String parentName = parent.eGet(parent.eClass().getEStructuralFeature("name")).toString();
+ return "GEN_" + parentName + "_" + feature.getName() + "_" + idCounter++;
+ }
+
+ private void applyMutation(Mutation mutation) {
+ if (mutation.getMutationType() == Mutation.Type.eCreate) {
+ EStructuralFeature feature = mutation.getTargetLink();
+ EObject element = mutation.getTargetElement();
+ if (feature instanceof EReference) {
+ EReference reference = (EReference)feature;
+ EClass featureType = findConcreteClass(reference.getEReferenceType());
+ if (featureType == null) {
+ return;
+ }
+ mutator.addComplex(element, reference, featureType, generateName(element, reference));
+ } else if (feature instanceof EAttribute) {
+ EAttribute attribute = (EAttribute)feature;
+ EDataType dataType = attribute.getEAttributeType();
+ mutator.addPrimitive(element, attribute, dataType);
+ }
+ }
+ }
+
+ public SiteOfLossGenerator(int maxCardinality) {
+ this.maxCardinality = maxCardinality;
+ extractor = new LimitedAdditionExtractor(maxCardinality);
+ mutator = new BaseMutations();
+ }
+
+ BaseMutations mutator;
+ MutationExtractor extractor;
+ int maxCardinality;
+}