Search in sources :

Example 1 with Decisions

use of org.benchmarx.examples.familiestopersons.testsuite.Decisions in project benchmarx by eMoflon.

the class FunnyQTFamiliesToPerson method initiateSynchronisationDialogue.

@Override
public void initiateSynchronisationDialogue() {
    srcModel = new XMIResourceImpl();
    trgModel = new XMIResourceImpl();
    FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
    srcModel.getContents().add(familiesRoot);
    setConfigurator(new Configurator<Decisions>().makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true).makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
    transform(RIGHT);
}
Also used : FamilyRegister(Families.FamilyRegister) Decisions(org.benchmarx.examples.familiestopersons.testsuite.Decisions) XMIResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)

Example 2 with Decisions

use of org.benchmarx.examples.familiestopersons.testsuite.Decisions in project benchmarx by eMoflon.

the class UbtXtendFamiliesToPersons method initiateSynchronisationDialogue.

/**
	 * Initiates a synchronization between a source and a target model. The BXtend Transformation is
	 * initialized and empty source, target and correspondence models are created.
	 * Finally a FamilyRegister is added to the source model and an initial forward transformation is issued
	 * to create a corresponding PersonRegister.
	 */
@Override
public void initiateSynchronisationDialogue() {
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>().makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true).makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("family", new XMIResourceFactoryImpl());
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("person", new XMIResourceFactoryImpl());
    set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("corr", new XMIResourceFactoryImpl());
    source = set.createResource(URI.createURI("sourceModel.family"));
    target = set.createResource(URI.createURI("targetModel.person"));
    corr = set.createResource(URI.createURI("corrModel.corr"));
    FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
    source.getContents().add(familiesRoot);
    f2pt = new Family2PersonTransformation(source, target, corr);
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>().makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true).makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
    // perform batch to establish consistent starting state
    f2pt.Family2Person();
}
Also used : Family2PersonTransformation(bitrafo.eval.familyperson.rules.Family2PersonTransformation) FamilyRegister(Families.FamilyRegister) Decisions(org.benchmarx.examples.familiestopersons.testsuite.Decisions) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl)

Example 3 with Decisions

use of org.benchmarx.examples.familiestopersons.testsuite.Decisions in project benchmarx by eMoflon.

the class MediniQVTFamiliesToPersonsConfig method initiateSynchronisationDialogue.

/**
	 * Initiates a synchronization between a source and a target model. The medini QVT engine is initialized,
	 * the required metamodels are registered and empty source, target and configuration models are created.
	 * Finally a FamilyRegister is added to the source model and an initial forward transformation is issued
	 * to create a corresponding PersonRegister.
	 */
@Override
public void initiateSynchronisationDialogue() {
    // delete content of traces folder
    File tracesFolder = new File("./src/org/benchmarx/examples/familiestopersons/implementations/medini/base/traces");
    final File[] files = tracesFolder.listFiles();
    if (files != null) {
        for (File f : files) {
            if (f != null)
                f.delete();
        }
    }
    // in case, no configuration is set, switch to default
    checkConfiguration();
    // Initialise resource set of models
    this.resourceSet = new ResourceSetImpl();
    this.resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
    // Collect all necessary packages from the metamodel(s)
    Collection<EPackage> metaPackages = new ArrayList<EPackage>();
    this.collectMetaModels(metaPackages);
    // Make these packages known to the QVT engine
    init(metaPackages);
    // Create resources for models
    source = resourceSet.createResource(URI.createURI(RESULTPATH + "/source.xmi"));
    config = resourceSet.createResource(URI.createURI(RESULTPATH + "/config.xmi"));
    target = resourceSet.createResource(URI.createURI(RESULTPATH + "/target.xmi"));
    // Collect the models, which should participate in the transformation.
    // You can provide a list of models for each direction.
    // The models must be added in the same order as defined in your transformation!
    Collection<Collection<Resource>> modelResources = new ArrayList<Collection<Resource>>();
    Collection<Resource> firstSetOfModels = new ArrayList<Resource>();
    Collection<Resource> secondSetOfModels = new ArrayList<Resource>();
    Collection<Resource> thirdSetOfModels = new ArrayList<Resource>();
    modelResources.add(firstSetOfModels);
    modelResources.add(secondSetOfModels);
    modelResources.add(thirdSetOfModels);
    firstSetOfModels.add(source);
    secondSetOfModels.add(config);
    thirdSetOfModels.add(target);
    URI directory = URI.createFileURI(basePath + "traces");
    this.preExecution(modelResources, directory);
    // Call setConfigurator, which will initialize the configurator with default decisions
    setConfigurator(new Configurator<Decisions>());
    source.getContents().add(FamiliesFactory.eINSTANCE.createFamilyRegister());
    config.getContents().add(ConfigFactory.eINSTANCE.createConfiguration());
    launchFWD();
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) XMIResourceFactoryImpl(org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl) ArrayList(java.util.ArrayList) Resource(org.eclipse.emf.ecore.resource.Resource) Decisions(org.benchmarx.examples.familiestopersons.testsuite.Decisions) URI(org.eclipse.emf.common.util.URI) EPackage(org.eclipse.emf.ecore.EPackage) Collection(java.util.Collection) File(java.io.File)

Example 4 with Decisions

use of org.benchmarx.examples.familiestopersons.testsuite.Decisions in project benchmarx by eMoflon.

the class EMoflonFamiliesToPersons method initiateSynchronisationDialogue.

@Override
public void initiateSynchronisationDialogue() {
    BasicConfigurator.configure();
    helper = new F2PSyncHelper();
    Resource r = helper.getResourceSet().createResource(URI.createURI("sourceModel"));
    FamilyRegister familiesRoot = FamiliesFactory.eINSTANCE.createFamilyRegister();
    r.getContents().add(familiesRoot);
    // Fix default preferences (which can be overwritten)
    setConfigurator(new Configurator<Decisions>().makeDecision(Decisions.PREFER_CREATING_PARENT_TO_CHILD, true).makeDecision(Decisions.PREFER_EXISTING_FAMILY_TO_NEW, true));
    // perform batch to establish consistent starting state
    helper.setSrc(familiesRoot);
    helper.integrateForward();
    helper.setMute(true);
}
Also used : FamilyRegister(Families.FamilyRegister) Resource(org.eclipse.emf.ecore.resource.Resource) Decisions(org.benchmarx.examples.familiestopersons.testsuite.Decisions)

Aggregations

Decisions (org.benchmarx.examples.familiestopersons.testsuite.Decisions)4 FamilyRegister (Families.FamilyRegister)3 Resource (org.eclipse.emf.ecore.resource.Resource)2 XMIResourceFactoryImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl)2 Family2PersonTransformation (bitrafo.eval.familyperson.rules.Family2PersonTransformation)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 URI (org.eclipse.emf.common.util.URI)1 EPackage (org.eclipse.emf.ecore.EPackage)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 XMIResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl)1