195 lines
4.7 KiB
Java
195 lines
4.7 KiB
Java
/**
|
|
*/
|
|
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;
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* An implementation of the model object '<em><b>Random Mutate Model</b></em>'.
|
|
* <!-- end-user-doc -->
|
|
* <p>
|
|
* The following features are implemented:
|
|
* </p>
|
|
* <ul>
|
|
* <li>{@link mutator.impl.RandomMutateModelImpl#getModelSlot <em>Model Slot</em>}</li>
|
|
* </ul>
|
|
*
|
|
* @generated
|
|
*/
|
|
public class RandomMutateModelImpl extends WorkflowComponentImpl implements RandomMutateModel {
|
|
/**
|
|
* The default value of the '{@link #getModelSlot() <em>Model Slot</em>}' attribute.
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @see #getModelSlot()
|
|
* @generated
|
|
* @ordered
|
|
*/
|
|
protected static final String MODEL_SLOT_EDEFAULT = null;
|
|
|
|
/**
|
|
* The cached value of the '{@link #getModelSlot() <em>Model Slot</em>}' attribute.
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @see #getModelSlot()
|
|
* @generated
|
|
* @ordered
|
|
*/
|
|
protected String modelSlot = MODEL_SLOT_EDEFAULT;
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @generated
|
|
*/
|
|
protected RandomMutateModelImpl() {
|
|
super();
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @generated
|
|
*/
|
|
@Override
|
|
protected EClass eStaticClass() {
|
|
return MutatorPackage.Literals.RANDOM_MUTATE_MODEL;
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @generated
|
|
*/
|
|
@Override
|
|
public String getModelSlot() {
|
|
return modelSlot;
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @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));
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @generated
|
|
*/
|
|
@Override
|
|
public void eUnset(int featureID) {
|
|
switch (featureID) {
|
|
case MutatorPackage.RANDOM_MUTATE_MODEL__MODEL_SLOT:
|
|
setModelSlot(MODEL_SLOT_EDEFAULT);
|
|
return;
|
|
}
|
|
super.eUnset(featureID);
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @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);
|
|
}
|
|
|
|
/**
|
|
* <!-- begin-user-doc -->
|
|
* <!-- end-user-doc -->
|
|
* @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<EObject> contents = model.getContents();
|
|
|
|
SiteOfLossGenerator gen = new SiteOfLossGenerator(3);
|
|
gen.generateSiteOfLoss(contents);
|
|
|
|
subMonitor.done();
|
|
context.getLogger().addInfo("Done.", this);
|
|
}
|
|
} //RandomMutateModelImpl
|