Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Invoking Flock programmatically
Invoking Flock programmatically [message #1725584] Fri, 04 March 2016 14:57 Go to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
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!
Re: Invoking Flock programmatically [message #1725603 is a reply to message #1725584] Fri, 04 March 2016 18:52 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Vlad,

Off the top of my head, you should also add the two models to the module's model repository i.e. module.getContext().getModelRepository().add(...).

If this doesn't work, could you please provide a minimal example [1] I can use to reproduce this?

Cheers,
Dimitris

[1] https://www.eclipse.org/epsilon/doc/articles/minimal-examples/
Re: Invoking Flock programmatically [message #1725741 is a reply to message #1725603] Mon, 07 March 2016 11:37 Go to previous messageGo to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
Hi Dimitris,

It looks like your suggestion did the trick, thank you very much Smile

There is one other thing I'd like to ask you (let me know if I should start a new thread). The models I am planning to migrate are rather large (can get to around 10 MB), and I noticed that a few years ago a user posted a message regarding migration performance for large models (here is the thread: https://www.eclipse.org/forums/index.php/m/1039454/?srch=flock#msg_1039454).

Do you know if the performance issues have been addressed since then, or if it was something specific to that user?

Cheers,
Vlad
Re: Invoking Flock programmatically [message #1725742 is a reply to message #1725741] Mon, 07 March 2016 11:50 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Vlad,

The performance of Epsilon languages has improved a lot over the last few years so it'd be very interesting to see how Flock performs in your use case.

Cheers,
Dimitris
Re: Invoking Flock programmatically [message #1725875 is a reply to message #1725742] Tue, 08 March 2016 08:54 Go to previous messageGo to next message
Vlad Acretoaie is currently offline Vlad AcretoaieFriend
Messages: 95
Registered: April 2014
Member
Hi Dimitris,

Thank you for the help. So far it's looking good, but I have yet to test the real migration (I have to specify it first). I'll report back regarding performance.

Cheers,
Vlad
Re: Invoking Flock programmatically [message #1725876 is a reply to message #1725875] Tue, 08 March 2016 08:55 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2154
Registered: July 2009
Location: York, UK
Senior Member

Hi Vlad,

You're welcome. Looking forward to your findings!

Cheers,
Dimitris
Previous Topic:Guidelines to avoid using lazy rules
Next Topic:EOL: How to modify an element of a sequence to another value?
Goto Forum:
  


Current Time: Fri Mar 29 11:21:25 GMT 2024

Powered by FUDForum. Page generated in 0.02601 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top