Invoking Flock programmatically [message #1725584] |
Fri, 04 March 2016 14:57 |
Vlad Acretoaie Messages: 95 Registered: April 2014 |
Member |
|
|
Hi,
I am trying to invoke Flock from a standalone Java application (although I eventually want to integrate it into an existing Eclipse plugin). To get started, I am working with the models from the Petri net migration example.
To run Flock, I am calling the execute(IModel original, IModel migrated) method from the FlockModule class. This means that I need to first get two IModel instances. I currently do so using the following method (inspired by the EOL standalone Java example):
protected EmfModel createEmfModel(String name, URI model, URI metamodel, boolean readOnLoad, boolean storeOnDisposal)
throws EolModelLoadingException, URISyntaxException {
EmfModel emfModel = new EmfModel();
StringProperties properties = new StringProperties();
properties.put(EmfModel.PROPERTY_NAME, name);
properties.put(EmfModel.PROPERTY_FILE_BASED_METAMODEL_URI, metamodel.toString());
properties.put(EmfModel.PROPERTY_MODEL_URI, model.toString());
properties.put(EmfModel.PROPERTY_READONLOAD, readOnLoad + "");
properties.put(EmfModel.PROPERTY_STOREONDISPOSAL, storeOnDisposal + "");
emfModel.load(properties, null);
return emfModel;
}
So, my invocation of Flocks looks like this:
IModel originalEMF = this.createEmfModel(original, originalURI, originalMetamodelURI, true, true);
IModel evolvedEMF = this.createEmfModel(evolved, evolvedURI, evolvedMetamodelURI, false, true);
module.execute(originalEMF, evolvedEMF);
However, the evolved model does not yet exist in the file system (which is to be expected). This causes the following exception when calling the execute(IModel original, IModel migrated) method.
Exception encountered while executing EOL block.
Type 'Evolved!PTArc' not found
at (C:\Users\rvacr\Workspaces\ModelMigrationTests\FlockPetrinetsJava\model\Petrinets.mig@3:16-3:29)
at (C:\Users\rvacr\Workspaces\ModelMigrationTests\FlockPetrinetsJava\model\Petrinets.mig@3:12-3:29)
at (C:\Users\rvacr\Workspaces\ModelMigrationTests\FlockPetrinetsJava\model\Petrinets.mig@3:2-3:30)
at (C:\Users\rvacr\Workspaces\ModelMigrationTests\FlockPetrinetsJava\model\Petrinets.mig@2:1-7:2)
at org.eclipse.epsilon.flock.execution.EolExecutor.executeBlock(EolExecutor.java:50)
at org.eclipse.epsilon.flock.model.domain.rules.Body.applyTo(Body.java:31)
at org.eclipse.epsilon.flock.execution.MigrateRuleContext.execute(MigrateRuleContext.java:56)
at org.eclipse.epsilon.flock.model.domain.rules.MigrateRule.applyTo(MigrateRule.java:63)
at org.eclipse.epsilon.flock.model.domain.rules.MigrateRules.applyTo(MigrateRules.java:50)
at org.eclipse.epsilon.flock.model.domain.MigrationStrategy.applyRulesTo(MigrationStrategy.java:83)
at org.eclipse.epsilon.flock.equivalences.Equivalences.applyRules(Equivalences.java:65)
at org.eclipse.epsilon.flock.MigrationStrategyRunner.applyRules(MigrationStrategyRunner.java:53)
at org.eclipse.epsilon.flock.MigrationStrategyRunner.run(MigrationStrategyRunner.java:37)
at org.eclipse.epsilon.flock.FlockExecution.run(FlockExecution.java:34)
at org.eclipse.epsilon.flock.FlockContext.execute(FlockContext.java:85)
at org.eclipse.epsilon.flock.FlockModule.execute(FlockModule.java:81)
at org.eclipse.epsilon.flock.FlockModule.execute(FlockModule.java:72)
at petrinetsjava.Migrator.migrate(Migrator.java:41)
at petrinetsjava.Main.main(Main.java:10)
The missing element (Evolved!PTArc) only appears in the evolved metamodel. Am I doing something wrong when creating the EmfModel instance of the evolved model, or should I use another method to invoke Flock?
Thanks in advance!
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04169 seconds