by
dcooper@jade.co.nz >> Wed, 22 Dec 2004 13:53:39 GMT
If you're using JADE 6, you can use a conditional relationship to implement this.
For a thorough discussion of conditions and using them as constraints in conditional relationships, have a look at this white paper on the web site:
www.jadeworld.com/downloads/jade6/conditions.pdf
I'm assuming you have a single Letter class, or perhaps a single Letter abstract class with a subclass per letter. In either case, add a condition to the Letter class (Methods menu, New Condition) called isConsonant. If you implemented an abstract Letter class with subclasses, I'd still add the condition to the top-level Letter class as conditions are not polymorphic.
A condition is like a restricted method that always returns a Boolean. A condition is marked in the browser window with a question mark icon. One of the main uses of conditions is to put constraints on inverse references, so they have a number of restrictions to guarantee that they always produce the same result without side effects. The only statements they can contain are 'if' and 'return' statements. They can contain constant definitions but no variable definitions. They can contain constant parameters (but not input, output or io parameters). They can only reference parameters, properties of self, or other conditions. They cannot reference any environmental objects (such as app or global) as these may not be available in all contexts in which a condition is evaluated (eg: database reorg). Methods may not be invoked from a condition except for a small number of RootSchema methods (eg: Date::month), deemed to be conditionSafe (look for this in the method signature), that are guaranteed to produce the same result in any context.
Having defined your isConsonant condition to do what you want, you need to have an inverse relationship to manage your letters (conditions can only be used to constrain inverse relationships). I'll assume your Letter class has a myLetterMaster reference and that you have two inverse collections to this (allMaxLettersByName and allMinLettersByName) on LetterMaster. Select the allMinLettersByName property (the one you want to constrain) and bring up the Define Reference dialog for it (ie: select to change the property). You'll see a Constraint combo box under the allMinLettersByName property. Your isConsonant condition will appear in the combo for you to use as a constraint. Select it and ok the dialog (you'll probably get told that you need a reorg).
The effect of this is that letters will be added to allMinLettersByName only when they satisfy the constraint (ie: when your isConsonant condition returns true for the member object).
Cheers,
Dean.