Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » [EOL] Call operation from inside an operation
[EOL] Call operation from inside an operation [message #1386986] Mon, 23 June 2014 12:12 Go to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi,

is it possible to call an operation from inside an operation when calling the code from a Java program?

I use a Java program to execute an operation.

I call the method calculateACD from the Java program.

There are no parsing errors.

The error message is:
Method 'calculateDeps' not found for: Sequence {....

What am I doing wrong?

Thanks for help
Greetings, Mario

InMemoryEmfModel emfModel = new InMemoryEmfModel(model.getResources().get(0));
emfModel.setName("daten");
String acd = Util.loadFile(new File("src/eol/acd.eol"));
IEolExecutableModule module = new EolModule();
Util.log("Load acd: " + module.parse(acd));
module.getContext().getModelRepository().addModel(emfModel);

EolOperations declaredOperations = module.getDeclaredOperations();
EolOperation operation = declaredOperations.getOperation("calculateACD");
ArrayList<Object> parameters = new ArrayList<Object>();
Object result = operation.execute(null, parameters, module.getContext());



The EOL query (acd.eol)

operation calculateACD () : Real {
	
	var alletypen = daten!ConcreteClassifier.all();
	var anonyme = daten!AnonymousClass.all();
	alletypen.addAll(anonyme);
	alletypen = alletypen.select(iterator | iterator.eResource().getURI().toString().startsWith('file:/'));	
	
	var deps = alletypen.calculateDeps();
	return deps.size();
}



operation Sequence calculateDeps () : Sequence {
	var methodCallType = MethodCall.createInstance().type;
	return self.getChildrenByEType(methodCallType);
}	

Re: [EOL] Call operation from inside an operation [message #1386988 is a reply to message #1386986] Mon, 23 June 2014 12:16 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi,

This should work. Does it make a difference if you change the context type of calculateDeps from Sequence to Any?

Cheers,
Dimitris
Re: [EOL] Call operation from inside an operation [message #1386989 is a reply to message #1386988] Mon, 23 June 2014 12:18 Go to previous messageGo to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Thanks for the reply.

I changed it, but the same error occured.

Is there another way to do this?
Re: [EOL] Call operation from inside an operation [message #1387040 is a reply to message #1386989] Mon, 23 June 2014 16:30 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Mario,

Adding the line below to your Java code should do the trick.

module.getContext().setModule(module);

Cheers,
Dimitris
Re: [EOL] Call operation from inside an operation [message #1387057 is a reply to message #1387040] Mon, 23 June 2014 19:28 Go to previous messageGo to next message
Mario Bauer is currently offline Mario BauerFriend
Messages: 21
Registered: May 2014
Junior Member
Hi Dimitris,

thanks a lot, now it works.

Was this trick documented somewhere?

Greetings, Mario
Re: [EOL] Call operation from inside an operation [message #1387073 is a reply to message #1387057] Mon, 23 June 2014 21:49 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2165
Registered: July 2009
Location: York, UK
Senior Member

Hi Mario,

Great! I don't think this is documented anywhere at the moment but I've added a note in my to-do list to start an article about such tips and tricks.

Cheers,
Dimitris
Previous Topic:[ETL] Why do I get dynamicEObjects?
Next Topic:[EPL] Execution semantics
Goto Forum:
  


Current Time: Sat Apr 27 01:42:42 GMT 2024

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

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

Back to the top