Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » retreive every package and subpackage from model
retreive every package and subpackage from model [message #1065907] Fri, 28 June 2013 08:42 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hello, I trying to retrieve every folder (Package) whose are located in a specific package.

  helper context UML!Package def : getSubFolders() : Sequence(UML!Package) = 
	self.ownedElement->select(e | e.oclIsKindOf('Package')).oclIsTypeOf('Package');

 helper context UML!Package def : getPackages() : Sequence(UML!Package) = 
	self.ownedElement->select(e | e.oclIsKindOf('Package')).oclIsTypeOf('Package')
	->union(self.getSubFolders());
Re: retreive every package and subpackage from model [message #1065934 is a reply to message #1065907] Fri, 28 June 2013 11:49 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

As you can probably have sub-packages, I think you need to define a recursive helper to be able to navigate through all of them.
Another point, the select operation is returning a collection and not a single element: you have to use the "->" operator (and not a ".") as well as relevant operations on it.


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: retreive every package and subpackage from model [message #1066430 is a reply to message #1065934] Tue, 02 July 2013 15:53 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Do not consider this reply, it's an error

[Updated on: Tue, 02 July 2013 17:12]

Report message to a moderator

Re: retreive every package and subpackage from model [message #1066440 is a reply to message #1066430] Tue, 02 July 2013 16:34 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Have you tried something like this:
helper context UML!Package def : getPackages() : OrderedSet(UML!Package) = 
	self.nestedPackage->iterate(sp; subpack: OrderedSet(UML!Package) = OrderedSet{} |
		if not sp.nestedPackage->oclIsUndefined() then 
			subpack->append(sp)->union(sp.getPackages())
		else
			subpack->append(sp)
		endif
	));


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: retreive every package and subpackage from model [message #1066450 is a reply to message #1065934] Tue, 02 July 2013 17:09 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Thank for your advice, but the recursive helper I wrote doesn't retrieve what I want.
Actually, the problem is coming when I would like to get all a specific sub-packages I want. Here is the code

 helper context UML!Package def : getSubFolders() : Sequence(UML!Package) = 
	self.ownedElement->select(e | e.oclIsTypeOf('Package'));

 helper context UML!Package def : getPackages() : Sequence(UML!Package) = 
	self.nestedPackage.first().nestedPackage->iterate(sp; subpack: Sequence(UML!Package) = 
		self.nestedPackage.first().debug() |
		if sp.getNeededPackages() then 
			subpack.union(sp)
		else
			subpack.getPackages() and (not sp.oclIsUndefined())
		endif
	);


And this is what was printed in the console:

IN!Logical View
IN!PNAV
IN!picNAVstructure
IN!blackbox
IN!sharedData_interface
IN!produced
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: IN!TacticalTime.and(java.lang.Boolean)
	at getPackages#19(Lib4SomMM.atl[31:4-31:55])
		local variables: self=IN!blackbox, subpack=IN!sharedData_interface, sp=IN!produced
	at getPackages#15(Lib4SomMM.atl[31:4-31:25])
		local variables: self=IN!picNAVstructure, subpack=IN!blackbox, sp=IN!sharedData_interface
	at getPackages#15(Lib4SomMM.atl[31:4-31:25])
		local variables: self=IN!PNAV, subpack=IN!picNAVstructure, sp=IN!blackbox
	at getPackages#15(Lib4SomMM.atl[31:4-31:25])
		local variables: self=IN!Logical View, subpack=IN!PNAV, sp=IN!picNAVstructure
	at getPackages#15(Lib4SomMM.atl[31:4-31:25])
		local variables: self=IN!Rose model, subpack=IN!Logical View, sp=IN!PNAV
	at __applyDocumentRoot#31(uml2allsom.atl[24:16-24:31])
		local variables: self=uml2allsom : ASMModule, link=TransientLink {rule = DocumentRoot, sourceElements = {m = org.eclipse.uml2.uml.internal.impl.ModelImpl@19adbe4 (name: Rose model, visibility: <unset>) (URI: null) (viewpoint: <unset>)}, targetElements = {mt = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1708622 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1b8c02f (name: ModelType) (instanceClassName: null) (abstract: false, interface: false)), dr = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@766284 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@6f85ca (name: DocumentRoot) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, m=IN!Rose model, dr=OUT!<unnamed>, mt=OUT!<unnamed>
	at __exec__#8(uml2allsom.atl)
		local variables: self=uml2allsom : ASMModule, e=TransientLink {rule = DocumentRoot, sourceElements = {m = org.eclipse.uml2.uml.internal.impl.ModelImpl@19adbe4 (name: Rose model, visibility: <unset>) (URI: null) (viewpoint: <unset>)}, targetElements = {mt = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1708622 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1b8c02f (name: ModelType) (instanceClassName: null) (abstract: false, interface: false)), dr = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@766284 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@6f85ca (name: DocumentRoot) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
	at main#24(uml2allsom.atl)
		local variables: self=uml2allsom : ASMModule

Re: retreive every package and subpackage from model [message #1066454 is a reply to message #1066450] Tue, 02 July 2013 17:23 Go to previous message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Thank you @Hugo Bruneliere, its works perfectly.

That's cool.
Previous Topic:EMFTVM - Matched rules do not match cross referenced model elements
Next Topic:Problem with ATL compiling
Goto Forum:
  


Current Time: Sat Apr 20 01:42:59 GMT 2024

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

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

Back to the top