|<Xtend> How to delete a UseCase from a list [message #533387]
||Thu, 13 May 2010 11:58
Registered: April 2010
I am trying to delete actor from the list with following xtend code,
uml::Model root(uml::Model model):
let actorList = model.eAllContents.typeSelect(Actor).collect(e|e):
// find Actor
List[uml::Actor] findActor(List[uml::Actor] ac, String name):
ac.select(e|e.name == name);
// delete Actor
Boolean deleteActor(List[uml::Actor] ac1):
workflow executed but actor remains there.
Any one can point where I am wrong or I m missing some thing.
|Re: <Xtend> How to delete a UseCase from a list [message #533470 is a reply to message #533387]
||Fri, 14 May 2010 03:32
| Karsten Thoms
Registered: July 2009
there are several misconceptions in your code here:
1) .collect(e|e) does not do anything
2) I think you use forAll(), but indeed should use collect(). Although forAll does loop through the collection as well as collect(), forAll will return a boolean when checking that all elements in the collection meet the condition inside. That's not what you are intending here.
3) actorList is a new collection, it is no reference to the set of actors in the model, it just contains them. Calling the deleteActor function will actually remove the actor from actorList, but not from the model.
I think what you really want to achieve is to delete the actor "User" really from the model. To do so you would have to use org.eclipse.emf.ecore.util.EcoreUtil#delete(), which must be called through a Java extension.
Void delete (emf::EObject): org.eclipse.emf.ecore.util.EcoreUtil.delete(org.eclipse.emf.ecore.EObject);
Call this fuction by searching the model for your actor:
Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Powered by FUDForum
. Page generated in 0.01595 seconds