Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestions about implementing Domain class relationships & constraints in Grails
    text
    copied!<p>Using ArgoUML, I very quickly created this trivial representation of a few Domain classes (Person, Store, Product) and their relationships. <a href="http://img411.imageshack.us/img411/715/soquestion.png" rel="nofollow noreferrer">UML Model http://img411.imageshack.us/img411/715/soquestion.png</a> </p> <p>I'm struggling with the implementation of the relationships. Below was my initial approach for the Person domain, but it seems that I am missing something important. </p> <pre><code>class PersonToPerson { Person from Person to String relation static constraints = { relation(inList:["Friend to", "Enemy of", "Likes", "Hates"]) } static belongsTo = [ Person ] } class Person { String firstName String secondName . . . static hasMany= [ personToPerson:PersonToPerson, personToStore:PersonToStore ] } </code></pre> <p><strong>Edit: updated question for clarity</strong></p> <hr> <p>After thinking on the problem I think I have a better way to ask the question(s). In the implementation of PersonToPerson above I have the relation as a simple string. I want the user to be able to select from a list of unique relations, which are defined in the constraints, for the string value for PersonToPerson. So this leads to the questions...</p> <ol> <li>Should personToPerson and personToStore be consolidated into one list of type Relationship? Or should they stay independent lists as shown?</li> <li>What is the mechanism to allow the user to add new values to the relation constraint?</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload