Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCORE] How to refer to a particular attribute
[XCORE] How to refer to a particular attribute [message #1268406] Mon, 10 March 2014 13:15 Go to next message
Simone Di Cola is currently offline Simone Di ColaFriend
Messages: 60
Registered: February 2014
Member
Hi all,
having the model below, I'd like to know if there is a way to refer from the class ComputationUnit to the array of elements defined in the abstract class Component.

abstract class Component{
String name
contains Comment comment
contains Contract contract
contains DataElement[0..*] dataElements
contains Service[1..*] services
}

class AtomicComponent extends Component{
contains ComputationUnit computationUnit
}

class ComputationUnit{
contains Method[1..*] methods
}

Basically, what I would like to do is to have a method lie getDataElement() inside the class ComputationUnit.

Thanks
Simone
Re: [XCORE] How to refer to a particular attribute [message #1268565 is a reply to message #1268406] Mon, 10 March 2014 17:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Simone,

Comments below.

On 10/03/2014 2:15 PM, Simone Di Cola wrote:
> Hi all, having the model below, I'd like to know if there is a way to
> refer from the class ComputationUnit to the array of elements defined
> in the abstract class Component.
>
> abstract class Component{
> String name
> contains Comment comment
> contains Contract contract
> contains DataElement[0..*] dataElements
> contains Service[1..*] services
> }
>
> class AtomicComponent extends Component{
> contains ComputationUnit computationUnit
> }
>
> class ComputationUnit{
> contains Method[1..*] methods
> }
>
> Basically, what I would like to do is to have a method lie
> getDataElement() inside the class ComputationUnit.
Yes, in general you can define operations with bodies (that use Xbase
syntax) and those bodies can refer to things in the model. In this
case, you've not defined an inverse reference for
AtomicComponent.computationUnit so you'd have to navigate from the
CompilationUnit to its container via EObject.eContainer() and cast it.
Probably nicer is to define a "container" reference in CompilationUnit
to access the containing AtomicComponent and from that you can of course
access all the features of a Component...
>
> Thanks
> Simone


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Storing standalone validation preferences
Next Topic:Loading a model from XMI into an already existing object
Goto Forum:
  


Current Time: Fri Apr 19 20:09:15 GMT 2024

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

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

Back to the top