title: EMF: How to set values for attributes of a Class?
body: <p>I'm working on a project in <em>EMF</em>, where I have created a simple order system. A part of the system is presented on the picture below:</p>
  <p><a href="https://i.stack.imgur.com/XfLEv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XfLEv.png" alt="enter image description here" /></a></p>
  <p>So an <code>OrderItem</code> object will have a reference to only one product and its price will be calculated by the <code>quantity</code> of <code>OrderItem</code> times the <code>price</code> of the <code>Product</code>. The attribute <code>isValid</code> must be set whenever <code>OrderItem.quantity</code> changes, e.g. if <code>Product.quantity &lt; OrderItem.quantity</code> then set <code>isValid=false</code> else <code>true</code>.</p>
  <p>My question is how can I achieve this, so when I am creating an instance of the model using the Editor or changing some instance variable, dependent variables are updated automatically? (Should I rewrite the generated code? Should I override the <code>set()</code> method using <code>Annotation</code>? Should I use <em>AQL</em> or <em>Services</em>?) Thank you!</p>